Documentation
¶
Index ¶
- Variables
- func ParseADTSHeader(data []byte) (sampleRate uint32, channels uint8, frameLength uint16, err error)
- type ADTSReader
- type Decoder
- type M4AReader
- func (m *M4AReader) Channels() uint8
- func (m *M4AReader) Close() error
- func (m *M4AReader) Duration() time.Duration
- func (m *M4AReader) Metadata() Metadata
- func (m *M4AReader) Position() time.Duration
- func (m *M4AReader) Read(pcm []int16) (int, error)
- func (m *M4AReader) SampleRate() uint32
- func (m *M4AReader) Seek(position time.Duration) error
- type Metadata
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidADTS is returned when the ADTS stream is invalid. ErrInvalidADTS = errors.New("faad2: invalid ADTS stream") // ErrADTSSyncNotFound is returned when no ADTS sync word is found. ErrADTSSyncNotFound = errors.New("faad2: ADTS sync word not found") )
var ( // ErrInvalidConfig is returned when the AAC codec configuration is invalid. ErrInvalidConfig = errors.New("faad2: invalid codec configuration") // ErrDecodeFailed is returned when AAC frame decoding fails. ErrDecodeFailed = errors.New("faad2: decode failed") // ErrOutOfMemory is returned when WASM memory allocation fails. ErrOutOfMemory = errors.New("faad2: out of memory") // ErrNotInitialized is returned when trying to decode without initialization. ErrNotInitialized = errors.New("faad2: decoder not initialized") // ErrNotM4A is returned when the input is not a valid M4A/MP4 file. ErrNotM4A = errors.New("faad2: not an M4A/MP4 file") // ErrNoAudioTrack is returned when no AAC audio track is found. ErrNoAudioTrack = errors.New("faad2: no AAC audio track found") // ErrUnsupportedCodec is returned when the audio codec is not AAC. ErrUnsupportedCodec = errors.New("faad2: unsupported audio codec (not AAC)") )
Functions ¶
Types ¶
type ADTSReader ¶
type ADTSReader struct {
// contains filtered or unexported fields
}
ADTSReader reads and decodes audio from ADTS streams (raw AAC).
func OpenADTS ¶
func OpenADTS(r io.Reader) (*ADTSReader, error)
OpenADTS opens an ADTS stream for audio decoding.
func (*ADTSReader) Channels ¶
func (ar *ADTSReader) Channels() uint8
Channels returns the number of audio channels.
func (*ADTSReader) FramesRead ¶
func (ar *ADTSReader) FramesRead() int64
FramesRead returns the number of AAC frames decoded so far.
func (*ADTSReader) Read ¶
func (ar *ADTSReader) Read(pcm []int16) (int, error)
Read reads decoded PCM samples into the buffer. Returns the number of samples read.
func (*ADTSReader) SampleRate ¶
func (ar *ADTSReader) SampleRate() uint32
SampleRate returns the audio sample rate.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder represents an AAC decoder instance.
func (*Decoder) Init ¶
Init initializes the decoder with AAC codec configuration (typically from MP4 esds box or ADTS header).
func (*Decoder) SampleRate ¶
SampleRate returns the sample rate after initialization.
type M4AReader ¶
type M4AReader struct {
// contains filtered or unexported fields
}
M4AReader reads and decodes audio from M4A/MP4 files.
func OpenM4A ¶
func OpenM4A(r io.ReadSeeker) (*M4AReader, error)
OpenM4A opens an M4A/MP4 file for audio decoding.
func (*M4AReader) Read ¶
Read reads decoded PCM samples into the buffer. Returns number of samples read, or io.EOF when done.
func (*M4AReader) SampleRate ¶
SampleRate returns the audio sample rate.