arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
G729Encoder Class Reference

G.729 encoder using the bcg729 library. More...

#include <CodecG729.h>

Inheritance diagram for G729Encoder:
AudioEncoder AudioWriter MimeSource AudioInfoSupport

Public Member Functions

 G729Encoder (bool is_vad_enabled=false)
 
AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 
bool begin () override
 
virtual bool begin (AudioInfo info)
 
void end () override
 
virtual uint32_t frameDurationUs ()
 Optional rtsp function: provide the frame duration in microseconds.
 
virtual int frameSize ()
 
const char * mime () override
 Provides the mime type of the encoded result.
 
 operator bool () override
 
virtual uint16_t samplesPerFrame ()
 Optional rtsp function: provide samples per the frame.
 
void setAudioInfo (AudioInfo info) override
 Defines the sample rate, number of channels and bits per sample.
 
void setOutput (Print &out_stream) override
 Default output assignment (encoders may override to store Print reference)
 
void setVADEnabled (bool enabled)
 
size_t write (const uint8_t *data, size_t len) override
 

Protected Member Functions

void processByte (uint8_t byte)
 
void writeBlocking (Print *out, uint8_t *data, size_t len)
 

Protected Attributes

size_t buffer_pos = 0
 
bcg729EncoderChannelContextStruct * encoder_ctx = nullptr
 
AudioInfo info
 
Vector< uint8_t > input_buffer
 
bool is_active = false
 
Printp_print = nullptr
 
Vector< uint8_t > result_buffer
 
bool vad_enabled = false
 

Detailed Description

G.729 encoder using the bcg729 library.

Accepts 16-bit PCM samples at 8 000 Hz (mono) and writes compressed G.729 frames to the configured output. Frames are produced every 80 input samples (10 ms):

VAD (Voice Activity Detection) is enabled by default; pass false to the constructor to disable it and always produce 10-byte speech frames.

Input must be exactly 8 000 Hz / mono / 16-bit PCM. Passing any other AudioInfo via setAudioInfo() logs an error and the fixed format is enforced.

Bitrate: 8 kbps (10 bytes × 8 bits/byte ÷ 0.01 s) which gives 1 kbytes/s Compression ratio: 16:1 (w/o SID frame)

Note
Requires https://github.com/pschatzmann/codec-bcg729
Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ G729Encoder()

G729Encoder ( bool  is_vad_enabled = false)
inline

Member Function Documentation

◆ audioInfo()

AudioInfo audioInfo ( )
inlineoverridevirtualinherited

provides the actual input AudioInfo

Implements AudioInfoSupport.

Reimplemented in CodecNOP, MP3EncoderShine, BinaryContainerEncoder, and MP3ParserEncoder.

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ begin() [1/2]

bool begin ( )
inlineoverridevirtual

Implements AudioWriter.

◆ begin() [2/2]

virtual bool begin ( AudioInfo  info)
inlinevirtualinherited

◆ end()

void end ( )
inlineoverridevirtual

Implements AudioWriter.

◆ frameDurationUs()

virtual uint32_t frameDurationUs ( )
inlinevirtualinherited

Optional rtsp function: provide the frame duration in microseconds.

Reimplemented in ADPCMEncoder, MP3EncoderShine, OpusOggEncoder, MP3ParserEncoder, and MetaDataFilterEncoder.

◆ frameSize()

virtual int frameSize ( )
inlinevirtualinherited

Optional rtsp function: provide the encoded size (in bytes) of one frame, once known (e.g. after the encoder has seen real data). Lets an RTSPFormat size its RTP fragments to match one frame instead of a fixed guess, so throughput actually tracks frameDurationUs() - a fragment size covering several frames' worth of bytes sent at one-frame timing overruns real-time bandwidth and, over UDP (no flow control), causes packet loss. Returns 0 if not yet known/not applicable (fixed-frame-size codecs have no need to override this).

Reimplemented in ADPCMEncoder, EncoderALAC, AMRNBEncoder, AMRWBEncoder, and MP3ParserEncoder.

◆ mime()

const char * mime ( )
inlineoverridevirtual

Provides the mime type of the encoded result.

Implements AudioEncoder.

◆ operator bool()

operator bool ( )
inlineoverridevirtual

Implements AudioWriter.

◆ processByte()

void processByte ( uint8_t  byte)
inlineprotected

◆ samplesPerFrame()

virtual uint16_t samplesPerFrame ( )
inlinevirtualinherited

Optional rtsp function: provide samples per the frame.

Reimplemented in OpusAudioEncoder, OpusMultiStreamAudioEncoder, MP3EncoderShine, MP3ParserEncoder, and MetaDataFilterEncoder.

◆ setAudioInfo()

void setAudioInfo ( AudioInfo  from)
inlineoverridevirtual

Defines the sample rate, number of channels and bits per sample.

Reimplemented from AudioEncoder.

◆ setOutput()

void setOutput ( Print out_stream)
inlineoverridevirtual

Default output assignment (encoders may override to store Print reference)

Reimplemented from AudioEncoder.

◆ setVADEnabled()

void setVADEnabled ( bool  enabled)
inline

◆ write()

size_t write ( const uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

Implements AudioWriter.

◆ writeBlocking()

void writeBlocking ( Print out,
uint8_t *  data,
size_t  len 
)
inlineprotectedinherited

Member Data Documentation

◆ buffer_pos

size_t buffer_pos = 0
protected

◆ encoder_ctx

bcg729EncoderChannelContextStruct* encoder_ctx = nullptr
protected

◆ info

AudioInfo info
protectedinherited

◆ input_buffer

Vector<uint8_t> input_buffer
protected

◆ is_active

bool is_active = false
protected

◆ p_print

Print* p_print = nullptr
protected

◆ result_buffer

Vector<uint8_t> result_buffer
protected

◆ vad_enabled

bool vad_enabled = false
protected

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