|
arduino-audio-tools
|
Manages multiple Demuxers with automatic container-format detection - the container-side counterpart of MultiVideoDecoder (Video/MultiVideoDecoder.h), which does the same job one layer down for the video elementary stream's own codec. No demuxers are registered by default and this header has no container-parser dependency of its own (it only needs the Demuxer interface, ContainerCommon.h) - register whichever concrete demuxers (DemuxerAVI/DemuxerMP4/DemuxerMPG) your content actually needs via addDemuxer(). More...
#include <MultiVideoDemuxer.h>
Public Member Functions | |
| void | addDemuxer (Demuxer &demuxer) |
| virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
| Adds target to be notified about audio changes. | |
| AudioInfo | audioInfo () override |
| provides the actual input AudioInfo | |
| virtual AudioInfo | audioInfoOut () |
| 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 | isNotifyActive () |
| Checks if the automatic AudioInfo update is active. | |
| virtual bool | isValid (const uint8_t *data, size_t len) |
| const char * | mime () override |
| const char * | mimeVideo () override |
| operator bool () override | |
| virtual bool | removeNotifyAudioChange (AudioInfoSupport &bi) |
| Removes a target in order not to be notified about audio changes. | |
| Demuxer * | selectedDemuxer () const |
| 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 | 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. | |
| void | setOutput (Print &out) override |
| void | setOutputAudio (Print &out) override |
| void | setOutputVideo (Print &out) override |
| void | setOutputVideo (VideoOutput &out) override |
| void | setSendWavHeader (bool flag) override |
| Forwarded to every registered demuxer eagerly (see class comment). | |
| VideoInfo | videoInfo () override |
| 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 | notifyAudioChange (AudioInfo info) |
| void | select (Demuxer *demuxer) |
| void | writeBlocking (Print *out, uint8_t *data, size_t len) |
Protected Attributes | |
| Vector< Demuxer * > | demuxers {0} |
| AudioInfo | info |
| bool | is_first = true |
| bool | is_notify_active = true |
| Vector< AudioInfoSupport * > | notify_vector |
| Print * | p_print = nullptr |
| Demuxer * | p_selected = nullptr |
Manages multiple Demuxers with automatic container-format detection - the container-side counterpart of MultiVideoDecoder (Video/MultiVideoDecoder.h), which does the same job one layer down for the video elementary stream's own codec. No demuxers are registered by default and this header has no container-parser dependency of its own (it only needs the Demuxer interface, ContainerCommon.h) - register whichever concrete demuxers (DemuxerAVI/DemuxerMP4/DemuxerMPG) your content actually needs via addDemuxer().
Drop it in wherever a plain Demuxer& is expected - VideoPlayer in fact uses one internally as its own built-in demuxer, with addDemuxer() registering against it - or feed it via write() directly, and it self-selects the right registered demuxer from the stream's own container signature instead of the caller having to know the file format up front.
Detection runs once, on the very first write() call: each registered demuxer's own Demuxer::isValid() (content-sniffing - a virtual method with a default-false implementation, so a demuxer only takes part if it actually overrides it; DemuxerAVI/DemuxerMP4/DemuxerMPG all do - see their own class comments) is tried, in registration order, against that first call's bytes. Reliable in practice since every real container signature (AVI's "RIFF"/"AVI ", MP4's "ftyp" box, MPG's pack start_code) falls within the first dozen bytes of the file, comfortably inside any realistic first read/write() chunk. Every subsequent write() call, plus every other Demuxer method, is forwarded to that same demuxer for the rest of the stream - never re-detected.
setOutputAudio()/setOutputVideo()/setSendWavHeader() are applied to every registered demuxer eagerly (cheap - just stores pointers/a flag, no allocation) - call addDemuxer() for all of them before these, so whichever one gets selected on the first write() is already wired. Only the actually-selected demuxer's begin() is called (on selection, from inside write()) - matching MultiVideoDecoder's own memory-efficient lazy-init rationale.
|
inline |
Registers a demuxer under its own Demuxer::mimeVideo() - see the class comment for when/how it's later selected (content-sniffing via its own Demuxer::isValid()). Call before the first write() reaches this object.
Replaces, rather than adds to, any demuxer already registered under the same mimeVideo() - at most one entry per container format, for the same reason MultiVideoDecoder::addDecoder() does: a stale second entry for the same format would otherwise be permanently unreachable dead weight, never actually selected.
|
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, ResampleStreamT< TInterpolator >, and SupportedRatesStream.
|
inlineoverridevirtual |
Defers actual demuxer init to the first write() (see class comment)
Reimplemented from AudioDecoder.
|
inlineoverridevirtualinherited |
Reimplemented from AudioWriter.
Reimplemented in DecoderBasic, and OggContainerDecoder.
|
inlinevirtualinherited |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlineoverridevirtual |
Reimplemented from AudioDecoder.
|
inlineoverridevirtual |
Common audio info of the currently selected demuxer - an empty AudioInfoFormat before the first write()/if none matched.
Implements Demuxer.
|
inlineinherited |
|
inlineoverridevirtual |
|
inlineinherited |
Checks if the automatic AudioInfo update is active.
|
inlinevirtualinherited |
True if data (the start of the stream, as handed to the first write()) looks like this demuxer's own container format - content-sniffing, not a guarantee (see the concrete class for exactly what's checked). Used by MultiVideoDemuxer to auto-select a registered demuxer (MultiVideoDemuxer.h); not otherwise part of the write()/parse path. Default false, matching VideoDecoder::isValid()'s own default - a demuxer not meant to be auto-detected this way simply never overrides it.
Reimplemented in DemuxerAVI, DemuxerMP4, and DemuxerMPG.
|
inlineoverridevirtual |
The audio MIME type of the currently selected demuxer's audio track
Implements Demuxer.
|
inlineoverridevirtual |
|
inlineprotectedinherited |
|
inlineoverridevirtual |
Implements AudioWriter.
|
inlinevirtualinherited |
Removes a target in order not to be notified about audio changes.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlineprotected |
|
inline |
The demuxer detection picked for the current stream - nullptr before the first write(), or if none matched.
|
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.
|
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 - delegates to setOutputAudio(), matching every concrete Demuxer's own convention.
Reimplemented from AudioDecoder.
|
inlineoverridevirtual |
Defines the audio output stream - forwarded to every registered demuxer eagerly (see class comment).
Implements Demuxer.
|
inlineoverridevirtual |
Defines the video output - forwarded to every registered demuxer eagerly (see class comment).
Implements Demuxer.
|
inlineoverridevirtual |
See Demuxer::setOutputVideo(VideoOutput&) - forwarded to every registered demuxer eagerly (same rationale as the Print& overload above).
Implements Demuxer.
|
inlineoverridevirtual |
Forwarded to every registered demuxer eagerly (see class comment).
Implements Demuxer.
|
inlineoverridevirtualinherited |
Fulfills VideoInfoSource::videoInfo(), so any Demuxer can be passed directly to e.g. OutputOpenCV::setVideoInfoSource() - note the reported 'format' is the container's codec (e.g. H264), not necessarily what ends up written to a raw-picture VideoOutput/Print (that depends on whatever decoder sits between the demuxer and the output); consumers that care about the decoded format should still set it explicitly and rely on this only for width/height.
Implements VideoInfoSource.
|
inlineoverridevirtual |
Implements AudioWriter.
|
inlineprotectedinherited |
|
inherited |
custom id to be used by application
|
protectedinherited |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protected |