23#include <libavutil/audio_fifo.h>
32 std::function<
void(std::shared_ptr<AudioFrame>&&)>
cb)
83 cb_(std::move(
frame));
102 if (cb_ &&
nb_samples == 0 &&
f->nb_samples == frameSize_) {
103 nextOutputPts_ =
frame->pointer()->pts + frameSize_;
104 cb_(std::move(
frame));
109 hasVoice_ =
frame->has_voice;
114 throw std::runtime_error(
"Failed to add audio to frame resizer");
117 if (nextOutputPts_ == 0)
122 cb_(std::move(
frame));
125std::shared_ptr<AudioFrame>
131 auto frame = std::make_shared<AudioFrame>(format_, frameSize_);
134 reinterpret_cast<void**
>(
frame->pointer()->data),
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)