Skip to content
Snippets Groups Projects
Commit a4ce78b7 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

rtp session: write to ringbuffer directly

Change-Id: I0de9d73d38e865f736e64c6a1adb1139d96cd641
parent ef9d7bf2
No related branches found
No related tags found
No related merge requests found
......@@ -92,14 +92,11 @@ AudioReceiveThread::setup()
void
AudioReceiveThread::process()
{
AudioFormat mainBuffFormat = Manager::instance().getRingBufferPool().getInternalAudioFormat();
auto decodedFrame = std::make_unique<AudioFrame>();
auto sharedFrame = std::make_shared<AudioFrame>();
auto decodedFrame = std::make_shared<AudioFrame>();
switch (audioDecoder_->decode(*decodedFrame)) {
case MediaDecoder::Status::FrameFinished:
sharedFrame->copyFrom(*decodedFrame);
audioDecoder_->writeToRingBuffer(std::move(decodedFrame), *ringbuffer_, mainBuffFormat);
notify(std::static_pointer_cast<MediaFrame>(sharedFrame));
notify(std::static_pointer_cast<MediaFrame>(decodedFrame));
ringbuffer_->put(std::move(decodedFrame));
return;
case MediaDecoder::Status::DecodeError:
RING_WARN("decoding failure, trying to reset decoder...");
......
......@@ -466,21 +466,6 @@ MediaDecoder::getTimeBase() const
int MediaDecoder::getPixelFormat() const
{ return decoderCtx_->pix_fmt; }
void
MediaDecoder::writeToRingBuffer(std::unique_ptr<AudioFrame>&& decodedFrame,
RingBuffer& rb, const AudioFormat outFormat)
{
AudioFormat format (decoderCtx_->sample_rate, decoderCtx_->channels, decoderCtx_->sample_fmt);
if (format != outFormat) {
if (not resampler_) {
RING_DBG("Creating audio resampler");
resampler_.reset(new Resampler);
}
decodedFrame = resampler_->resample(std::move(decodedFrame), outFormat);
}
rb.put(std::move(decodedFrame));
}
int
MediaDecoder::correctPixFmt(int input_pix_fmt) {
......
......@@ -90,7 +90,6 @@ class MediaDecoder {
int setupFromAudioData();
Status decode(AudioFrame&);
void writeToRingBuffer(std::unique_ptr<AudioFrame>&& decodedFrame, RingBuffer&, const AudioFormat);
int getWidth() const;
int getHeight() const;
......@@ -115,7 +114,6 @@ class MediaDecoder {
AVCodecContext *decoderCtx_ = nullptr;
AVFormatContext *inputCtx_ = nullptr;
AVStream *avStream_ = nullptr;
std::unique_ptr<Resampler> resampler_;
int streamIndex_ = -1;
bool emulateRate_ = false;
int64_t startTime_;
......@@ -123,10 +121,6 @@ class MediaDecoder {
DeviceParams inputParams_;
AudioBuffer decBuff_;
AudioBuffer resamplingBuff_;
void extract(const std::map<std::string, std::string>& map, const std::string& key);
int correctPixFmt(int input_pix_fmt);
int setupStream(AVMediaType mediaType);
int selectStream(AVMediaType type);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment