22#include <libavutil/frame.h>
25#include <libavutil/audio_fifo.h>
35 std::function<
void(std::shared_ptr<AudioFrame>&&)>
cb)
86 cb_(std::move(
frame));
97 auto*
f =
frame->pointer();
105 if (cb_ &&
nb_samples == 0 &&
f->nb_samples == frameSize_) {
106 nextOutputPts_ =
frame->pointer()->pts + frameSize_;
107 cb_(std::move(
frame));
112 hasVoice_ =
frame->has_voice;
117 throw std::runtime_error(
"Failed to add audio to frame resizer");
120 if (nextOutputPts_ == 0)
125 cb_(std::move(
frame));
128std::shared_ptr<AudioFrame>
134 auto frame = std::make_shared<AudioFrame>(format_, frameSize_);
140 frame->pointer()->pts = nextOutputPts_;
141 frame->has_voice = hasVoice_;
142 nextOutputPts_ += frameSize_;
void setFrameSize(int frameSize)
void setFormat(const AudioFormat &format, int frameSize)
AudioFrameResizer(const AudioFormat &format, int frameSize, std::function< void(std::shared_ptr< AudioFrame > &&)> cb={})
int frameSize() const
Gets the number of samples per output frame.
int samples() const
Gets the numbers of samples available for reading.
void enqueue(std::shared_ptr< AudioFrame > &&frame)
Write @frame's data to the queue.
std::shared_ptr< AudioFrame > dequeue()
Notifies owner of a new frame.
AudioFormat format() const
Gets the format used by @queue_, input frames must match this format or enqueuing will fail.
#define JAMI_WARNING(formatstr,...)
std::string getError(int err)
void emitSignal(Args... args)