MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::IO::AudioStreamContext Class Reference

RAII owner of one audio stream's codec and resampler state. More...

#include <AudioStreamContext.hpp>

+ Collaboration diagram for MayaFlux::IO::AudioStreamContext:

Public Member Functions

 AudioStreamContext ()=default
 
 ~AudioStreamContext ()
 
 AudioStreamContext (const AudioStreamContext &)=delete
 
AudioStreamContextoperator= (const AudioStreamContext &)=delete
 
 AudioStreamContext (AudioStreamContext &&)=delete
 
AudioStreamContextoperator= (AudioStreamContext &&)=delete
 
bool open (const FFmpegDemuxContext &demux, bool planar_output=false, uint32_t target_rate=0)
 Open the audio stream from an already-probed demux context.
 
void close ()
 Release codec and resampler resources.
 
bool is_valid () const
 True if the codec and resampler are ready for decoding.
 
void flush_codec ()
 Flush codec internal buffers (call after a seek).
 
void drain_resampler_init ()
 Drain any samples buffered inside the resampler.
 
void extract_stream_metadata (const FFmpegDemuxContext &demux, FileMetadata &out) const
 Populate stream-specific fields into an existing FileMetadata.
 
std::vector< FileRegionextract_cue_regions (const FFmpegDemuxContext &demux) const
 Extract cue/marker regions from stream metadata tags.
 
const std::string & last_error () const
 

Public Attributes

AVCodecContext * codec_context = nullptr
 Owned; freed in destructor.
 
SwrContext * swr_context = nullptr
 Owned; freed in destructor.
 
int stream_index = -1
 
uint64_t total_frames = 0
 
uint32_t sample_rate = 0
 
uint32_t channels = 0
 

Private Member Functions

bool setup_resampler (bool planar_output, uint32_t target_rate)
 

Private Attributes

std::string m_last_error
 

Detailed Description

RAII owner of one audio stream's codec and resampler state.

Encapsulates all audio-stream-specific FFmpeg objects:

  • AVCodecContext for the selected audio stream
  • SwrContext for sample-format conversion and optional resampling
  • Cached audio parameters: sample_rate, channel count, total_frames

Does NOT own AVFormatContext — that belongs to FFmpegDemuxContext. Packet reading is always delegated to the demuxer's format_context; this context only decodes and converts packets it receives.

Destruction order (enforced in destructor): swr_context → codec_context The associated FFmpegDemuxContext must outlive this object.

Definition at line 29 of file AudioStreamContext.hpp.


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