Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jami::AudioFrameResizer Class Reference

Buffers extra samples. More...

#include <audio_frame_resizer.h>

Collaboration diagram for jami::AudioFrameResizer:
Collaboration graph

Public Member Functions

 AudioFrameResizer (const AudioFormat &format, int frameSize, std::function< void(std::shared_ptr< AudioFrame > &&)> cb={})
 
std::shared_ptr< AudioFramedequeue ()
 Notifies owner of a new frame.
 
void enqueue (std::shared_ptr< AudioFrame > &&frame)
 Write @frame's data to the queue.
 
AudioFormat format () const
 Gets the format used by @queue_, input frames must match this format or enqueuing will fail.
 
int frameSize () const
 Gets the number of samples per output frame.
 
int samples () const
 Gets the numbers of samples available for reading.
 
void setFormat (const AudioFormat &format, int frameSize)
 
void setFrameSize (int frameSize)
 
 ~AudioFrameResizer ()
 

Detailed Description

Buffers extra samples.

This is in case an input's frame size (number of samples in a frame) and the output's frame size don't match. The queue will store the extra samples until a frame can be read. Will call passed in callback once a frame is output.

Works at frame-level instead of sample- or byte-level like FFmpeg's FIFO buffers.

Definition at line 38 of file audio_frame_resizer.h.

Constructor & Destructor Documentation

◆ AudioFrameResizer()

jami::AudioFrameResizer::AudioFrameResizer ( const AudioFormat format,
int  frameSize,
std::function< void(std::shared_ptr< AudioFrame > &&)>  cb = {} 
)

Definition at line 30 of file audio_frame_resizer.cpp.

◆ ~AudioFrameResizer()

jami::AudioFrameResizer::~AudioFrameResizer ( )

Definition at line 39 of file audio_frame_resizer.cpp.

References jami::emitSignal().

Here is the call graph for this function:

Member Function Documentation

◆ dequeue()

std::shared_ptr< AudioFrame > jami::AudioFrameResizer::dequeue ( )

◆ enqueue()

void jami::AudioFrameResizer::enqueue ( std::shared_ptr< AudioFrame > &&  frame)

Write @frame's data to the queue.

The internal buffer will be reallocated if there's not enough space for @frame's samples.

Returns the number of samples written, or negative on error.

NOTE @frame's format must match @format_, or this will fail.

Definition at line 88 of file audio_frame_resizer.cpp.

References dequeue(), jami::emitSignal(), format(), jami::libav_utils::getError(), JAMI_ERR, JAMI_WARNING, samples(), setFormat(), and jami::AudioFormat::toString().

Referenced by jami::RingBuffer::put().

Here is the call graph for this function:

◆ format()

AudioFormat jami::AudioFrameResizer::format ( ) const

Gets the format used by @queue_, input frames must match this format or enqueuing will fail.

Returned frames are in this format.

Definition at line 57 of file audio_frame_resizer.cpp.

Referenced by enqueue(), and setFormat().

◆ frameSize()

int jami::AudioFrameResizer::frameSize ( ) const

Gets the number of samples per output frame.

Definition at line 51 of file audio_frame_resizer.cpp.

Referenced by setFrameSize(), and jami::AudioProcessor::tidyQueues().

◆ samples()

int jami::AudioFrameResizer::samples ( ) const

Gets the numbers of samples available for reading.

Definition at line 45 of file audio_frame_resizer.cpp.

References jami::emitSignal().

Referenced by dequeue(), enqueue(), jami::WebRTCAudioProcessor::getProcessed(), setFormat(), and jami::AudioProcessor::tidyQueues().

Here is the call graph for this function:

◆ setFormat()

void jami::AudioFrameResizer::setFormat ( const AudioFormat format,
int  frameSize 
)

Definition at line 63 of file audio_frame_resizer.cpp.

References jami::emitSignal(), format(), JAMI_WARN, jami::AudioFormat::nb_channels, jami::AudioFormat::sampleFormat, samples(), and setFrameSize().

Referenced by enqueue(), and jami::RingBuffer::setFormat().

Here is the call graph for this function:

◆ setFrameSize()

void jami::AudioFrameResizer::setFrameSize ( int  frameSize)

Definition at line 77 of file audio_frame_resizer.cpp.

References dequeue(), jami::emitSignal(), and frameSize().

Referenced by setFormat(), and jami::RingBuffer::setFrameSize().

Here is the call graph for this function:

The documentation for this class was generated from the following files: