Files
MuditaOS/module-audio/Audio/transcode/InputTranscodeProxy.hpp
Marcin Smoczyński ece6a51e5b [EGD-6800] Enable voice transcoding
Add voice transcoding during phone call with two basic transforms:
 - sample rate downscaling by a factor of 2 with a decimator
 - sample rate upscaling by a factor of 2 with an interpolator (no
low-pass filter)

Signed-off-by: Marcin Smoczyński <smoczynski.marcin@gmail.com>
2021-05-21 18:12:57 +02:00

44 lines
1.2 KiB
C++

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
#include <Audio/StreamProxy.hpp>
#include "Transform.hpp"
#include <memory>
namespace audio::transcode
{
/**
* @brief An input transcoding proxy for an AbstractStream.
*/
class InputTranscodeProxy : public audio::StreamProxy
{
public:
/**
* @brief Construct a new Input Transcode Proxy object
*
* @param wrappedStream
* @param transform to apply on the input
*/
explicit InputTranscodeProxy(std::shared_ptr<AbstractStream> wrappedStream,
std::shared_ptr<Transform> transform) noexcept;
bool push(const Span &span) override;
void commit() override;
bool reserve(Span &span) override;
[[nodiscard]] auto getInputTraits() const noexcept -> Traits override;
private:
std::shared_ptr<Transform> transform;
Span reservedSpan;
std::size_t transcodingSpaceSize;
std::unique_ptr<std::uint8_t[]> transcodingSpace;
Span transcodingSpaceSpan;
bool isReserved = false;
};
}; // namespace audio::transcode