|
arduino-audio-tools
|
AVI Container Decoder which can be fed with small chunks of data. The minimum length must be bigger then the header size! The file structure is documented at https://learn.microsoft.com/en-us/windows/win32/directshow/avi-riff-file-reference. More...
#include <ContainerAVI.h>
Public Member Functions | |
| DemuxerAVI (int bufferSize=1024) | |
| virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
| Adds target to be notified about audio changes. | |
| AudioInfo | audioInfo () override |
| provides the actual input AudioInfo | |
| virtual AudioInfo | audioInfoOut () |
| WAVFormatX | aviAudioInfo () |
| Provides the audio information. | |
| AVIMainHeader | aviMainHeader () |
| Provides the information from the main header chunk. | |
| AVIStreamHeader | aviStreamHeader (int idx) |
| Provides the information from the stream header chunks. | |
| const char * | aviVideoFormat () |
| BitmapInfoHeader | aviVideoInfo () |
| Provides the video information. | |
| bool | begin () override |
| virtual bool | begin (AudioInfo info) override |
| virtual void | clearNotifyAudioChange () |
| Deletes all change notify subscriptions. | |
| void | end () override |
| AudioInfoFormat | getAudioInfo () override |
| Print * | getOutput () |
| VideoInfo | getVideoInfo () override |
| bool | isMetadataReady () |
| Returns true if all metadata has been parsed and is available. | |
| bool | isNotifyActive () |
| Checks if the automatic AudioInfo update is active. | |
| const char * | mime () override |
| The container's MIME type (e.g. "video/avi", "video/mp4"). | |
| operator bool () override | |
| virtual bool | removeNotifyAudioChange (AudioInfoSupport &bi) |
| Removes a target in order not to be notified about audio changes. | |
| void | setAudioInfo (AudioInfo from) override |
| for most decoders this is not needed | |
| virtual bool | setCodecConfig (const uint8_t *data, size_t len) |
| Some decoders need e.g. a magic cookie to provide the relevant info for decoding. | |
| void | setMute (bool mute) |
| void | setNotifyActive (bool flag) |
| Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
| virtual void | setOutput (AudioOutput &out_stream) |
| Defines where the decoded result is written to. | |
| virtual void | setOutput (AudioStream &out_stream) |
| Defines where the decoded result is written to. | |
| virtual void | setOutput (Print &out_stream) override |
| void | setOutputAudio (Print &out_stream) override |
| virtual void | setOutputVideo (Print &out_stream) override |
| void | setOutputVideo (VideoOutput &out_stream) |
| void | setSendWavHeader (bool flag) override |
| void | setValidationCallback (bool(*cb)(DemuxerAVI &avi)) |
| void | setVideoAudioSync (VideoAudioSync *yourSync) |
| Replace the synchronization logic with your implementation. | |
| int | videoSeconds () |
| Provide the length of the video in seconds. | |
| virtual size_t | write (const uint8_t *data, size_t len) override |
Public Attributes | |
| int | id |
| custom id to be used by application | |
Protected Member Functions | |
| void | cleanupStack () |
| void | consume (int len) |
| We remove the processed bytes from the beginning of the buffer. | |
| uint32_t | getInt (int offset) |
| Provides the int32 at the indicated byte offset. | |
| StrView & | getStr (int offset, int len) |
| Provides the string at the indicated byte offset with the indicated length. | |
| bool | isCurrentStreamAudio () |
| bool | isCurrentStreamVideo () |
| void | notifyAudioChange (AudioInfo info) |
| bool | parse () |
| ParseObject | parseAVIStreamData () |
| ParseObject | parseChunk (const char *id) |
| We load the indicated chunk from the current data. | |
| bool | parseHeader () |
| ParseObject | parseList (const char *id) |
| We load the indicated list from the current data. | |
| void | processStack (ParseObject &result) |
| void | sendWavHeader () |
| void | setupAudioInfo () |
| void | setupVideoInfo () |
| ParseObject | tryParseChunk () |
| ParseObject | tryParseChunk (const char *id) |
| ParseObject | tryParseList () |
| We try to parse the actual state for any list. | |
| ParseObject | tryParseList (const char *id) |
| void | writeBlocking (Print *out, uint8_t *data, size_t len) |
| void | writeData () |
Static Protected Member Functions | |
| static VideoFormat | toVideoFormat (uint32_t biCompression, uint16_t biBitCount) |
AVI Container Decoder which can be fed with small chunks of data. The minimum length must be bigger then the header size! The file structure is documented at https://learn.microsoft.com/en-us/windows/win32/directshow/avi-riff-file-reference.
|
inline |
| bufferSize | internal parse buffer size. |
This class only demuxes - it does not decode audio itself. Point setOutputAudio() at an EncodedAudioStream (wrapping whatever AudioDecoder matches the AVI's audio format) if you need the audio track decoded; the raw payload is written through as-is otherwise. Point setOutputVideo() at a Print (e.g. a VideoOutput) to receive the demuxed video track; leave unset to ignore video.
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, CodecChain, MP3DecoderHelix, MP3DecoderMAD, OggContainerDecoder, RTSPClient< TcpClient, UdpSocket >, Pipeline, and Pipeline::ModifyingStreamAdapter.
|
inlineoverridevirtualinherited |
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in CodecNOP, DecoderBasic, DSFDecoder, MP3DecoderHelix, MP3DecoderMAD, OpusAudioDecoder, OpusMultiStreamAudioDecoder, VorbisDecoder, WAVDecoder, WavIMADecoder, OggContainerDecoder, and VorbisDecoder.
|
inlinevirtualinherited |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in MP3EncoderShine, PureDataStream, PWMAudioOutput< PWMDriverT >, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, Pipeline, ResampleStream, and ResampleStreamT< TInterpolator >.
|
inline |
Provides the audio information.
|
inline |
Provides the information from the main header chunk.
|
inline |
Provides the information from the stream header chunks.
|
inline |
|
inline |
Provides the video information.
|
inlineoverridevirtual |
Reimplemented from AudioDecoder.
|
inlineoverridevirtualinherited |
Reimplemented from AudioWriter.
Reimplemented in DecoderBasic, and OggContainerDecoder.
|
inlineprotected |
|
inlinevirtualinherited |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlineprotected |
We remove the processed bytes from the beginning of the buffer.
|
inlineoverridevirtual |
Reimplemented from AudioDecoder.
|
inlineoverridevirtual |
Common audio info (sample_rate/channels/bits_per_sample), extended with the parsed 'strf' format tag - the same AudioInfoFormat type is also provided by DemuxerMP4. Named getAudioInfo() rather than audioInfo() because AudioDecoder already declares a virtual AudioInfo audioInfo() (returning the plain, unextended type by value) - by-value virtual returns can't be covariantly widened in C++, so reusing that name for a subclass-returning version isn't possible (it would be a hard "invalid covariant return type" error, not silent hiding).
Implements Demuxer.
|
inlineprotected |
Provides the int32 at the indicated byte offset.
|
inlineinherited |
|
inlineprotected |
Provides the string at the indicated byte offset with the indicated length.
|
inlineoverridevirtual |
Common video info (width/height/format/frame_size/total_file_size), analogous to audioInfo() - the same VideoInfo type is also provided by DemuxerMP4. format is decoded from the 'strf' biCompression field (the authoritative codec id; more reliable than the 'strh' handler text for third-party files, available separately via videoFormat()); VideoFormat::UNKNOWN for any codec not covered by the enum.
Implements Demuxer.
|
inlineprotected |
|
inlineprotected |
|
inline |
Returns true if all metadata has been parsed and is available.
|
inlineinherited |
Checks if the automatic AudioInfo update is active.
|
inlineoverridevirtual |
The container's MIME type (e.g. "video/avi", "video/mp4").
Implements Demuxer.
|
inlineprotectedinherited |
|
inlineoverridevirtual |
Implements AudioWriter.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
We load the indicated chunk from the current data.
|
inlineprotected |
|
inlineprotected |
We load the indicated list from the current data.
|
inlineprotected |
|
inlinevirtualinherited |
Removes a target in order not to be notified about audio changes.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlineprotected |
Synthesizes a valid WAV header (via the shared WAVHeader writer - also correctly handles ADPCM's extra 'fmt ' extension + 'fact' chunk) from the parsed 'strf' audio_info and sends it to p_output_audio, once, before any real audio payload - so a WAVDecoder-based output can bootstrap itself from it. Length is written as streamed/unknown, since the AVI's audio track length is not known upfront while demuxing.
|
inlineoverridevirtualinherited |
for most decoders this is not needed
Implements AudioWriter.
Reimplemented in DecoderALAC, CodecChain, DSFDecoder, DecoderL8, OpusAudioDecoder, OpusMultiStreamAudioDecoder, CodecNOP, G729Decoder, and G7xxDecoder.
|
inlinevirtualinherited |
Some decoders need e.g. a magic cookie to provide the relevant info for decoding.
Reimplemented in DecoderALAC, and MultiDecoder.
|
inline |
|
inlineinherited |
Deactivate/Reactivate automatic AudioInfo updates: (default is active)
|
inlinevirtualinherited |
Defines where the decoded result is written to.
Reimplemented in ADTSDecoder, CodecChain, MTSDecoder, MTSDecoderTSDemux, and MetaDataFilterDecoder.
|
inlinevirtualinherited |
Defines where the decoded result is written to.
Reimplemented in ADTSDecoder, CodecChain, MTSDecoder, MTSDecoderTSDemux, and MetaDataFilterDecoder.
|
inlineoverridevirtual |
Satisfies the AudioWriter/AudioDecoder interface - needed so EncodedAudioOutput/EncodedAudioStream's polymorphic AudioDecoder* wiring (which calls setOutput() through that base class pointer) still reaches the audio output correctly; delegates to setOutputAudio().
Reimplemented from AudioDecoder.
|
inlineoverridevirtual |
Defines the audio output stream - e.g. an EncodedAudioStream wrapping an AudioDecoder that matches the AVI's audio format, or any other Print if you want the raw payload as-is.
Implements Demuxer.
|
inlineoverridevirtual |
Defines the video output - e.g. a VideoOutput implementation, or any other Print if you want the raw payload as-is.
Implements Demuxer.
|
inline |
|
inlineoverridevirtual |
Overrides the automatic decision of whether a synthetic WAV header (matching the parsed 'strf' audio format) is sent to the audio output before any audio payload. By default this is decided automatically from the parsed format: on whenever isWavFormat() of the parsed 'strf' format is true (PCM/ADPCM, i.e. audio that needs to go through a WAVDecoder), off otherwise (e.g. compressed formats with their own decoder that don't expect a WAV header). Call this to force it either way instead.
Implements Demuxer.
|
inlineprotected |
|
inlineprotected |
|
inline |
Register a validation callback which is called after parsing just before playing the audio
|
inline |
Replace the synchronization logic with your implementation.
|
inlinestaticprotected |
Maps a 'strf' biCompression value (+ biBitCount, to disambiguate BI_BITFIELDS) to the corresponding VideoFormat. Covers what MuxerAVI writes plus a few common real-world FOURCC aliases seen in third-party AVI files.
|
inlineprotected |
We parse a chunk and provide the FOURCC id and size: No content data is stored
|
inlineprotected |
We try to parse the indicated chunk and determine the size: No content data is stored
|
inlineprotected |
We try to parse the actual state for any list.
|
inlineprotected |
|
inline |
Provide the length of the video in seconds.
|
inlineoverridevirtual |
Implements AudioWriter.
|
inlineprotectedinherited |
|
inlineprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
inherited |
custom id to be used by application
|
protectedinherited |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
Total file size (bytes) declared by the RIFF header, normalized from its chunk_size (= file_size - 8) field; 0 if not yet parsed or the declared size looks like an unbounded/streamed placeholder.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |