14
14
namespace audio_tools {
15
15
16
16
/* *
17
- * PMT Program Element Stream Type
17
+ * @brief PMT Program Element Stream Types
18
+ * @ingroup basic
18
19
*/
19
20
enum class MTSStreamType {
20
21
VIDEO = 0x01 ,
@@ -75,9 +76,8 @@ enum class MTSStreamType {
75
76
76
77
/* *
77
78
* @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
81
81
*
82
82
* @ingroup codecs
83
83
* @ingroup decoder
@@ -87,9 +87,11 @@ enum class MTSStreamType {
87
87
88
88
class MTSDecoder : public AudioDecoder {
89
89
public:
90
+ // / Default constructor
90
91
MTSDecoder () = default ;
92
+ // / Provide the AAC decoder (or MP3 Decoder) to receive the extracted content
91
93
MTSDecoder (AudioDecoder &dec) { p_dec = &dec; };
92
-
94
+ // / Start the prcessor
93
95
bool begin () override {
94
96
TRACED ();
95
97
if (p_dec) p_dec->begin ();
@@ -113,7 +115,7 @@ class MTSDecoder : public AudioDecoder {
113
115
is_active = true ;
114
116
return true ;
115
117
}
116
-
118
+ // / Stops the processing
117
119
void end () override {
118
120
TRACED ();
119
121
if (p_dec) p_dec->end ();
@@ -122,6 +124,7 @@ class MTSDecoder : public AudioDecoder {
122
124
123
125
virtual operator bool () override { return is_active; }
124
126
127
+ // / Provides the mime type: "video/MP2T";
125
128
const char *mime () { return " video/MP2T" ; }
126
129
127
130
size_t write (const uint8_t *data, size_t len) override {
@@ -143,21 +146,22 @@ class MTSDecoder : public AudioDecoder {
143
146
return result;
144
147
}
145
148
146
- void flush () {}
147
-
148
149
// / Set a new write buffer size (default is 2000)
149
150
void resizeBuffer (int size) { buffer.resize (size); }
150
151
152
+ // / Clears the stream type filter
151
153
void clearStreamTypes () {
152
154
TRACED ();
153
155
stream_types.clear ();
154
156
}
155
157
158
+ // / Defines the stream type that should be extracted
156
159
void addStreamType (MTSStreamType type) {
157
160
TRACED ();
158
161
stream_types.push_back (type);
159
162
}
160
163
164
+ // / Checks if the stream type is active
161
165
bool isStreamTypeActive (MTSStreamType type) {
162
166
for (int j = 0 ; j < stream_types.size (); j++) {
163
167
if (stream_types[j] == type) return true ;
@@ -269,7 +273,8 @@ class MTSDecoder : public AudioDecoder {
269
273
TRACEI ();
270
274
bool payloadUnitStartIndicator = false ;
271
275
272
- int payloadStart = getPayloadStart (packet, false , payloadUnitStartIndicator);
276
+ int payloadStart =
277
+ getPayloadStart (packet, false , payloadUnitStartIndicator);
273
278
int len = TS_PACKET_SIZE - payloadStart;
274
279
275
280
// if we are at the beginning we start with a pat
@@ -287,7 +292,8 @@ class MTSDecoder : public AudioDecoder {
287
292
}
288
293
}
289
294
290
- int getPayloadStart (uint8_t *packet, bool isPES, bool &payloadUnitStartIndicator) {
295
+ int getPayloadStart (uint8_t *packet, bool isPES,
296
+ bool &payloadUnitStartIndicator) {
291
297
uint8_t adaptionField = (packet[3 ] & 0x30 ) >> 4 ;
292
298
int adaptationSize = 0 ;
293
299
int offset = 4 ; // Start after TS header (4 bytes)
@@ -434,7 +440,8 @@ class MTSDecoder : public AudioDecoder {
434
440
assert (result == pesDataSize);
435
441
}
436
442
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);
438
445
assert (result == pesDataSize);
439
446
}
440
447
}
0 commit comments