1414namespace audio_tools {
1515
1616/* *
17- * PMT Program Element Stream Type
17+ * @brief PMT Program Element Stream Types
18+ * @ingroup basic
1819 */
1920enum class MTSStreamType {
2021 VIDEO = 0x01 ,
@@ -75,9 +76,8 @@ enum class MTSStreamType {
7576
7677/* *
7778 * @brief MPEG-TS (MTS) decoder. Extracts (demuxes) the AAC audio data from a
78- *MPEG-TS (MTS) data stream. You can define the relevant stream types via the
79- *API: For details see https://tsduck.io/download/docs/mpegts-introduction.pdf
80- *
79+ * MPEG-TS (MTS) data stream. You can define the relevant stream types via the
80+ * API: For details see https://tsduck.io/download/docs/mpegts-introduction.pdf
8181 *
8282 * @ingroup codecs
8383 * @ingroup decoder
@@ -87,9 +87,11 @@ enum class MTSStreamType {
8787
8888class MTSDecoder : public AudioDecoder {
8989 public:
90+ // / Default constructor
9091 MTSDecoder () = default ;
92+ // / Provide the AAC decoder (or MP3 Decoder) to receive the extracted content
9193 MTSDecoder (AudioDecoder &dec) { p_dec = &dec; };
92-
94+ // / Start the prcessor
9395 bool begin () override {
9496 TRACED ();
9597 if (p_dec) p_dec->begin ();
@@ -113,7 +115,7 @@ class MTSDecoder : public AudioDecoder {
113115 is_active = true ;
114116 return true ;
115117 }
116-
118+ // / Stops the processing
117119 void end () override {
118120 TRACED ();
119121 if (p_dec) p_dec->end ();
@@ -122,6 +124,7 @@ class MTSDecoder : public AudioDecoder {
122124
123125 virtual operator bool () override { return is_active; }
124126
127+ // / Provides the mime type: "video/MP2T";
125128 const char *mime () { return " video/MP2T" ; }
126129
127130 size_t write (const uint8_t *data, size_t len) override {
@@ -143,21 +146,22 @@ class MTSDecoder : public AudioDecoder {
143146 return result;
144147 }
145148
146- void flush () {}
147-
148149 // / Set a new write buffer size (default is 2000)
149150 void resizeBuffer (int size) { buffer.resize (size); }
150151
152+ // / Clears the stream type filter
151153 void clearStreamTypes () {
152154 TRACED ();
153155 stream_types.clear ();
154156 }
155157
158+ // / Defines the stream type that should be extracted
156159 void addStreamType (MTSStreamType type) {
157160 TRACED ();
158161 stream_types.push_back (type);
159162 }
160163
164+ // / Checks if the stream type is active
161165 bool isStreamTypeActive (MTSStreamType type) {
162166 for (int j = 0 ; j < stream_types.size (); j++) {
163167 if (stream_types[j] == type) return true ;
@@ -269,7 +273,8 @@ class MTSDecoder : public AudioDecoder {
269273 TRACEI ();
270274 bool payloadUnitStartIndicator = false ;
271275
272- int payloadStart = getPayloadStart (packet, false , payloadUnitStartIndicator);
276+ int payloadStart =
277+ getPayloadStart (packet, false , payloadUnitStartIndicator);
273278 int len = TS_PACKET_SIZE - payloadStart;
274279
275280 // if we are at the beginning we start with a pat
@@ -287,7 +292,8 @@ class MTSDecoder : public AudioDecoder {
287292 }
288293 }
289294
290- int getPayloadStart (uint8_t *packet, bool isPES, bool &payloadUnitStartIndicator) {
295+ int getPayloadStart (uint8_t *packet, bool isPES,
296+ bool &payloadUnitStartIndicator) {
291297 uint8_t adaptionField = (packet[3 ] & 0x30 ) >> 4 ;
292298 int adaptationSize = 0 ;
293299 int offset = 4 ; // Start after TS header (4 bytes)
@@ -434,7 +440,8 @@ class MTSDecoder : public AudioDecoder {
434440 assert (result == pesDataSize);
435441 }
436442 if (p_dec) {
437- size_t result = writeDataT<uint8_t , AudioDecoder>(p_dec, pesData, pesDataSize);
443+ size_t result =
444+ writeDataT<uint8_t , AudioDecoder>(p_dec, pesData, pesDataSize);
438445 assert (result == pesDataSize);
439446 }
440447 }
0 commit comments