|
arduino-audio-tools
|
ISO/IEC 13818-1 MPEG Transport Stream Demuxer: parses the fixed 188-byte TS packet framing, follows PAT -> PMT to discover the video and (optional) audio elementary stream PIDs and their codec (stream_type), reassembles each PES packet's payload from the TS packets between one payload_unit_start_indicator and the next, and forwards the raw elementary-stream bytes to setOutputVideo()/setOutputAudio() - same scope and design as DemuxerMPG (ContainerMPG.h): no decoding happens here, point the outputs at whatever decoder understands the codec. More...
#include <ContainerMTS.h>


Public Member Functions | |
| DemuxerMTS (int bufferSize=8 *MTS_PACKET_SIZE) | |
| 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. | |
| bool | isValid (const uint8_t *data, size_t len) override |
| const char * | mime () override |
| const char * | mimeVideo () 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 | 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 |
| Defines where the decoded result is written to. | |
| void | setOutputAudio (Print &out) override |
| void | setOutputVideo (Print &out) override |
| void | setOutputVideo (VideoOutput &out) override |
| void | setSendWavHeader (bool flag) override |
| 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 | appendToAudio (const uint8_t *data, size_t len) |
| void | appendToUnit (bool isVideo, const uint8_t *data, size_t len) |
| void | appendToVideo (const uint8_t *data, size_t len) |
| void | flushAudioUnit () |
| void | flushUnit (bool isVideo) |
| void | flushVideoUnit () |
| void | handlePesPayload (bool isVideo, const uint8_t *payload, size_t len, bool pusi) |
| void | notifyAudioChange (AudioInfo info) |
| bool | parse () |
| void | parsePacket (const uint8_t *pkt) |
| void | parsePat (const uint8_t *data, size_t len, bool pusi) |
| void | parsePmt (const uint8_t *data, size_t len, bool pusi) |
| void | probeAudioHeader (const uint8_t *data, size_t len) |
| void | writeBlocking (Print *out, uint8_t *data, size_t len) |
Protected Attributes | |
| uint8_t | audio_channels = 0 |
| bool | audio_frame_open = false |
| bool | audio_header_parsed = false |
| uint16_t | audio_pid = 0xFFFF |
| Vector< uint8_t > | audio_probe |
| uint32_t | audio_sample_rate = 0 |
| uint8_t | audio_stream_type = 0 |
| Vector< uint8_t > | audio_unit_buffer |
| size_t | audio_unit_len = 0 |
| AudioInfo | info |
| bool | is_notify_active = true |
| bool | is_parsing_active = false |
| Vector< AudioInfoSupport * > | notify_vector |
| Print * | p_output_audio = nullptr |
| Print * | p_output_video = nullptr |
| VideoOutput * | p_output_video_video = nullptr |
| Print * | p_print = nullptr |
| MTSParseBuffer | parse_buffer |
| uint16_t | pmt_pid = 0xFFFF |
| uint32_t | total_bytes = 0 |
| bool | video_frame_open = false |
| uint16_t | video_pid = 0xFFFF |
| uint8_t | video_stream_type = 0 |
| Vector< uint8_t > | video_unit_buffer |
| size_t | video_unit_len = 0 |
ISO/IEC 13818-1 MPEG Transport Stream Demuxer: parses the fixed 188-byte TS packet framing, follows PAT -> PMT to discover the video and (optional) audio elementary stream PIDs and their codec (stream_type), reassembles each PES packet's payload from the TS packets between one payload_unit_start_indicator and the next, and forwards the raw elementary-stream bytes to setOutputVideo()/setOutputAudio() - same scope and design as DemuxerMPG (ContainerMPG.h): no decoding happens here, point the outputs at whatever decoder understands the codec.
PES packet boundaries (marked by payload_unit_start_indicator) are used directly as access-unit boundaries - i.e. every new PES packet on the video/audio PID flushes the previous one as one complete write() call to the corresponding output, mirroring how a real TS muxer (including MuxerMTS itself) packetizes one access unit per PES packet. This is simpler than DemuxerMPG's own PES-length/start-code-driven framing, because TS's own PID demultiplexing already separates the elementary streams apart - no need to hunt for start codes in a mixed byte stream.
|
inline |
| bufferSize | internal parse buffer size - must be able to hold at least one full 188-byte TS packet; a few packets' worth (the default) keeps write() from truncating a typical caller-sized chunk. |
|
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.
Appends to video_unit_buffer with amortized (doubling) growth, same rationale as ContainerMPG.h's own appendToVideo/appendToAudio.
|
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 |
Reimplemented from AudioDecoder.
Reimplemented from AudioWriter.
Reimplemented in DecoderBasic, and OggContainerDecoder.
|
inlinevirtualinherited |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlineoverridevirtual |
Reimplemented from AudioDecoder.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineoverridevirtual |
Common audio info, parsed from the audio ES's own ADTS/MPEG-audio frame header once seen - falls back to 44100/stereo if not yet available.
Implements Demuxer.
|
inlineinherited |
|
inlineoverridevirtual |
Common video info - format is the PMT-reported codec once the PMT has been parsed (VideoFormat::UNKNOWN before then, or if the stream_type isn't one this container recognizes); width/height/fps are not parsed (see class comment) and stay 0.
Implements Demuxer.
|
inlineprotected |
Reassembles one PES packet's payload per PID from the TS packets between one payload_unit_start_indicator and the next - see class comment for why a PUSI boundary is used directly as the access-unit boundary instead of tracking PES_packet_length.
True if data starts with the TS sync byte (0x47), confirmed by a second sync byte 188 bytes later when enough data is available - see Demuxer::isValid().
Reimplemented from Demuxer.
|
inlineoverridevirtual |
Provides the audio mime, derived from the PMT's audio stream_type once parsed - "audio/aac" (the common case for .ts/HLS content) before that.
Implements Demuxer.
|
inlineoverridevirtual |
The container's MIME type (e.g. "video/avi", "video/mp4").
Implements Demuxer.
|
inlineprotectedinherited |
|
inlineoverridevirtual |
Implements AudioWriter.
|
inlineprotected |
Consumes one 188-byte packet (resyncing on the sync byte first, if needed) and parses it. Returns true if progress was made (call again
|
inlineprotected |
Parses the Program Association Section, picking the PID of the PMT for the first program listed (program_number != 0).
Parses the (single-section) Program Map, picking out the PID/ stream_type of the first video and first audio elementary stream.
Inspects the first bytes of the audio ES for an ADTS (AAC) or MPEG audio frame header - whichever matches audio_stream_type - to determine sample_rate/channels. Same approach as ContainerMPG.h's probeAudioHeader(), adapted for ADTS's layout.
|
inlinevirtualinherited |
Removes a target in order not to be notified about audio changes.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlineoverridevirtualinherited |
for most decoders this is not needed
Implements AudioWriter.
Reimplemented in DecoderALAC, CodecChain, DSFDecoder, DecoderL8, OpusAudioDecoder, OpusMultiStreamAudioDecoder, CodecNOP, G729Decoder, and G7xxDecoder.
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 |
Defines where the decoded result is written to.
Reimplemented from AudioDecoder.
|
inlineoverridevirtual |
Defines the audio output stream - e.g. an EncodedAudioStream wrapping an AudioDecoder that matches the track's codec, 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.
|
inlineoverridevirtual |
Defines the video output - the VideoOutput-specific counterpart of setOutputVideo(Print&), for a target like PacedVideoOutput/ OutputTinyGPU/OutputOpenCV that implements VideoOutput but not Print (the two are unrelated types - see VideoFrameMeter's own comment). Part of the base interface (unlike other concrete-class-specific extras) so code holding only a Demuxer& (e.g. VideoPlayer) can wire it to an arbitrary VideoOutput& without knowing the concrete container format - every current demuxer already implemented this identically before it was pulled up into the interface.
Implements Demuxer.
|
inlineoverridevirtual |
|
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.
Implements AudioWriter.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
inherited |
custom id to be used by application
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |