diff --git a/_codec_m_t_s_8h_source.html b/_codec_m_t_s_8h_source.html index 67fb1df816..77afad2c13 100644 --- a/_codec_m_t_s_8h_source.html +++ b/_codec_m_t_s_8h_source.html @@ -106,909 +106,909 @@
35  }
36 };
37 
-
47 class MTSDecoder : public AudioDecoder {
-
48  public:
-
49  MTSDecoder() {
-
50  self = this;
-
51  };
-
52 
-
53  void begin() override {
-
54  TRACED();
-
55  // automatically close when called multiple times
-
56  if (is_active) {
-
57  end();
-
58  }
-
59 
-
60  is_active = true;
-
61 
-
62  // create the pids we plan on printing
-
63  memset(print_pids, 0, sizeof(print_pids));
-
64 
-
65  // set default values onto the context.
-
66  if (tsd_context_init(&ctx)!=TSD_OK){
-
67  TRACEE();
-
68  is_active = false;
-
69  }
-
70 
-
71  // log memory allocations ?
-
72  //if (is_alloc_active){
-
73  ctx.malloc = log_malloc;
-
74  ctx.realloc = log_realloc;
-
75  ctx.calloc = log_calloc;
-
76  ctx.free = log_free;
-
77  //}
-
78 
-
79  // default supported stream types
-
80  if (stream_types.empty()){
-
81  addStreamType(TSD_PMT_STREAM_TYPE_PES_METADATA);
-
82  addStreamType(TSD_PMT_STREAM_TYPE_AUDIO_AAC);
-
83  }
-
84 
-
85  // add a callback.
-
86  // the callback is used to determine which PIDs contain the data we want
-
87  // to demux. We also receive PES data for any PIDs that we register later
-
88  // on.
-
89  if (tsd_set_event_callback(&ctx, event_cb)!=TSD_OK){
-
90  TRACEE();
-
91  is_active = false;
-
92  }
-
93 
-
94  }
-
95 
-
96  void end() override {
-
97  TRACED();
-
98  // finally end the demux process which will flush any remaining PES data.
-
99  tsd_demux_end(&ctx);
-
100 
-
101  // destroy context
-
102  tsd_context_destroy(&ctx);
-
103 
-
104  is_active = false;
-
105  }
-
106 
-
107  virtual operator bool() override { return is_active; }
-
108 
-
109  const char *mime() { return "video/MP2T"; }
-
110 
-
111  size_t write(const void *in_ptr, size_t in_size) override {
-
112  if (!is_active) return 0;
-
113  LOGD("MTSDecoder::write: %d", (int)in_size);
-
114  size_t result = buffer.writeArray((uint8_t*)in_ptr, in_size);
-
115  // demux
-
116  demux(underflowLimit);
-
117  return result;
-
118  }
-
119 
-
120  void flush(){
-
121  demux(0);
-
122  }
-
123 
-
124  void clearStreamTypes(){
-
125  TRACED();
-
126  stream_types.clear();
-
127  }
-
128 
-
129  void addStreamType(TSDPMTStreamType type){
-
130  TRACED();
-
131  stream_types.push_back(type);
-
132  }
-
133 
-
134  bool isStreamTypeActive(TSDPMTStreamType type){
-
135  for (int j=0;j<stream_types.size();j++){
-
136  if (stream_types[j]==type) return true;
-
137  }
-
138  return false;
-
139  }
-
140 
-
142  void resizeBuffer(int size){
-
143  buffer.resize(size);
-
144  }
-
145 
-
147  void setMemoryAllocationLogging(bool flag){
-
148  is_alloc_active = flag;
-
149  }
-
150 
-
151  protected:
-
152  static MTSDecoder *self;
-
153  int underflowLimit = MTS_UNDERFLOW_LIMIT;
-
154  bool is_active = false;
-
155  bool is_write_active = false;
-
156  bool is_alloc_active = false;
-
157  TSDemuxContext ctx;
-
158  uint16_t print_pids[MTS_PRINT_PIDS_LEN] = {0};
-
159  SingleBuffer<uint8_t> buffer{MTS_WRITE_BUFFER_SIZE};
-
160  Vector<TSDPMTStreamType> stream_types;
-
161  Vector<AllocSize> alloc_vector;
-
162 
-
163  void set_write_active(bool flag){
-
164  //LOGD("is_write_active: %s", flag ? "true":"false");
-
165  is_write_active = flag;
-
166  }
-
167 
-
168  void demux(int limit){
-
169  TRACED();
-
170  TSDCode res = TSD_OK;
-
171  int count = 0;
-
172  while (res == TSD_OK && buffer.available() > limit) {
-
173  size_t len = tsd_demux(&ctx, (void *)buffer.data(), buffer.available(), &res);
-
174  // remove processed bytes
-
175  buffer.clearArray(len);
-
176  // get next bytes
-
177  count++;
-
178  if (res != TSD_OK) logResult(res);
-
179  }
-
180  LOGD("Number of demux calls: %d", count);
-
181  }
-
182 
-
183  void logResult(TSDCode code) {
-
184  switch (code) {
-
185  case TSD_OK:
-
186  LOGD("TSD_OK");
-
187  break;
-
188  case TSD_INVALID_SYNC_BYTE:
-
189  LOGW("TSD_INVALID_SYNC_BYTE");
-
190  break;
-
191  case TSD_INVALID_CONTEXT:
-
192  LOGW("TSD_INVALID_CONTEXT");
-
193  break;
-
194  case TSD_INVALID_DATA:
-
195  LOGW("TSD_INVALID_DATA");
-
196  break;
-
197  case TSD_INVALID_DATA_SIZE:
-
198  LOGW("TSD_INVALID_DATA_SIZE");
-
199  break;
-
200  case TSD_INVALID_ARGUMENT:
-
201  LOGW("TSD_INVALID_ARGUMENT");
-
202  break;
-
203  case TSD_INVALID_START_CODE_PREFIX:
-
204  LOGW("TSD_INVALID_START_CODE_PREFIX");
-
205  break;
-
206  case TSD_OUT_OF_MEMORY:
-
207  LOGW("TSD_OUT_OF_MEMORY");
-
208  break;
-
209  case TSD_INCOMPLETE_TABLE:
-
210  LOGW("TSD_INCOMPLETE_TABLE");
-
211  break;
-
212  case TSD_NOT_A_TABLE_PACKET:
-
213  LOGW("TSD_NOT_A_TABLE_PACKET");
-
214  break;
-
215  case TSD_PARSE_ERROR:
-
216  LOGW("TSD_PARSE_ERROR");
-
217  break;
-
218  case TSD_PID_ALREADY_REGISTERED:
-
219  LOGW("TSD_PID_ALREADY_REGISTERED");
-
220  break;
-
221  case TSD_TSD_MAX_PID_REGS_REACHED:
-
222  LOGW("TSD_TSD_MAX_PID_REGS_REACHED");
-
223  break;
-
224  case TSD_PID_NOT_FOUND:
-
225  LOGW("TSD_PID_NOT_FOUND");
-
226  break;
-
227  case TSD_INVALID_POINTER_FIELD:
-
228  LOGW("TSD_INVALID_POINTER_FIELD");
-
229  break;
-
230  }
-
231  }
-
232 
-
233  // event callback
-
234  static void event_cb(TSDemuxContext *ctx, uint16_t pid, TSDEventId event_id,
-
235  void *data) {
-
236  TRACED();
-
237  if (MTSDecoder::self != nullptr) {
-
238  MTSDecoder::self->event_cb_local(ctx, pid, event_id, data);
-
239  }
-
240  }
-
241 
-
242  void event_cb_local(TSDemuxContext *ctx, uint16_t pid, TSDEventId event_id,
-
243  void *data) {
-
244  if (event_id == TSD_EVENT_PAT) {
-
245  set_write_active(false);
-
246  print_pat(ctx, data);
-
247  } else if (event_id == TSD_EVENT_PMT) {
-
248  set_write_active(false);
-
249  print_pmt(ctx, data);
-
250  } else if (event_id == TSD_EVENT_PES) {
-
251  TSDPESPacket *pes = (TSDPESPacket *)data;
-
252  // This is where we write the PES data into our buffer.
-
253  LOGD("====================");
-
254  LOGD("PID %d PES Packet, Size: %ld, stream_id=%u, pts=%lu, dts=%lu", pid,
-
255  pes->data_bytes_length, pes->stream_id, pes->pts, pes->dts);
-
256  // print out the PES Packet data if it's in our print list
-
257  int i;
-
258  AudioLogger logger = AudioLogger::instance();
-
259  for (i = 0; i < MTS_PRINT_PIDS_LEN; ++i) {
-
260  if (print_pids[i] == pid) {
-
261  // log data
-
262  if (logger.isLogging(AudioLogger::Debug)) {
-
263  logger.print(" PES data ");
-
264  logger.print(is_write_active? "active:":"inactive:");
-
265  int j = 0;
-
266  while (j < pes->data_bytes_length) {
-
267  char n = pes->data_bytes[j];
-
268  logger.printCharHex(n);
-
269  ++j;
-
270  }
-
271  logger.printChar('\n');
-
272  }
-
273  // output data
-
274  if (p_print != nullptr) {
-
275  //size_t eff = p_print->write(pes->data_bytes, pes->data_bytes_length);
-
276  size_t eff = writeSamples<uint8_t>(p_print,(uint8_t*) pes->data_bytes, pes->data_bytes_length);
-
277  if(eff!=pes->data_bytes_length){
-
278  // we should not get here
-
279  TRACEE();
-
280  }
-
281  }
-
282  }
-
283  }
-
284 
-
285  } else if (event_id == TSD_EVENT_ADAP_FIELD_PRV_DATA) {
-
286  set_write_active(false);
-
287  // we're only watching for SCTE Adaptions Field Private Data,
-
288  // so we know that we must parse it as a list of descritors.
-
289  TSDAdaptationField *adap_field = (TSDAdaptationField *)data;
-
290  TSDDescriptor *descriptors = NULL;
-
291  size_t descriptors_length = 0;
-
292  tsd_descriptor_extract(ctx, adap_field->private_data_bytes,
-
293  adap_field->transport_private_data_length,
-
294  &descriptors, &descriptors_length);
-
295 
-
296  LOGD("====================");
-
297  LOGD("Descriptors - Adaptation Fields");
-
298  int i = 0;
-
299  for (; i < descriptors_length; ++i) {
-
300  TSDDescriptor *des = &descriptors[i];
-
301  LOGD(" %d) tag: (0x%04X) %s", i, des->tag,
-
302  descriptor_tag_to_str(des->tag));
-
303  LOGD(" length: %d", des->length);
-
304  print_descriptor_info(des);
-
305  }
-
306  }
-
307  }
-
308 
-
309  void print_pat(TSDemuxContext *ctx, void *data) {
-
310  LOGD("====================");
-
311  TSDPATData *pat = (TSDPATData *)data;
-
312  size_t len = pat->length;
-
313  size_t i;
-
314  LOGD("PAT, Length %d", (int)pat->length);
-
315 
-
316  if (len > 1) {
-
317  LOGD("number of progs: %d", (int)len);
-
318  }
-
319  for (i = 0; i < len; ++i) {
-
320  LOGD(" %d) prog num: 0x%X, pid: 0x%X", (int)i, pat->program_number[i],
-
321  pat->pid[i]);
-
322  }
-
323  }
-
324 
-
325  void print_pmt(TSDemuxContext *ctx, void *data) {
-
326  LOGD("====================");
-
327  LOGD("PMT");
-
328  TSDPMTData *pmt = (TSDPMTData *)data;
-
329  LOGD("PCR PID: 0x%04X", pmt->pcr_pid);
-
330  LOGD("program info length: %d", (int)pmt->program_info_length);
-
331  LOGD("descriptors length: %d", (int)pmt->descriptors_length);
-
332  size_t i;
-
333 
-
334  for (i = 0; i < pmt->descriptors_length; ++i) {
-
335  TSDDescriptor *des = &pmt->descriptors[i];
-
336  LOGD(" %d) tag: (0x%04X) %s", (int)i, des->tag,
-
337  descriptor_tag_to_str(des->tag));
-
338  LOGD(" length: %d", des->length);
-
339  print_descriptor_info(des);
-
340  }
-
341 
-
342  LOGD("program elements length: %d", (int)pmt->program_elements_length);
-
343  for (i = 0; i < pmt->program_elements_length; ++i) {
-
344  TSDProgramElement *prog = &pmt->program_elements[i];
-
345  LOGD(" -----Program #%d", (int)i);
-
346  LOGD(" stream type: (0x%04X) %s", prog->stream_type,
-
347  stream_type_to_str((TSDPESStreamId)(prog->stream_type)));
-
348  LOGD(" elementary pid: 0x%04X", prog->elementary_pid);
-
349  LOGD(" es info length: %d", prog->es_info_length);
-
350  LOGD(" descriptors length: %d", (int)prog->descriptors_length);
-
351 
-
352  if (isStreamTypeActive((TSDPMTStreamType)prog->stream_type)){
-
353  set_write_active(true);
-
354  }
-
355 
-
356  // keep track of metadata pids, we'll print the data for these
-
357  for(int j=0;j<stream_types.size();j++){
-
358  add_print_pid(prog, stream_types[j]);
-
359  }
-
360 
-
361  // we'll register to listen to the PES data for this program.
-
362  int reg_types = TSD_REG_PES;
-
363 
-
364  size_t j;
-
365  for (j = 0; j < prog->descriptors_length; ++j) {
-
366  TSDDescriptor *des = &prog->descriptors[j];
-
367  LOGD(" %d) tag: (0x%04X) %s", (int)j, des->tag,
-
368  descriptor_tag_to_str(des->tag));
-
369  LOGD(" length: %d", des->length);
-
370  print_descriptor_info(des);
-
371 
-
372  // if this tag is the SCTE Adaption field private data descriptor,
-
373  // we'll also register for the Adaptation Field Privae Data.
-
374  if (des->tag == 0x97) {
-
375  reg_types |= TSD_REG_ADAPTATION_FIELD;
-
376  }
-
377  }
-
378 
-
379  // register all the PIDs we come across.
-
380  tsd_register_pid(ctx, prog->elementary_pid, reg_types);
-
381  }
-
382  }
-
383 
-
384  void add_print_pid(TSDProgramElement *prog, TSDPMTStreamType type) {
-
385  if (prog->stream_type == type) {
-
386  int k;
-
387  for (k = 0; k < MTS_PRINT_PIDS_LEN; ++k) {
-
388  // find a spare slot in the pids
-
389  if (print_pids[k] == 0) {
-
390  print_pids[k] = prog->elementary_pid;
-
391  break;
-
392  }
-
393  }
-
394  }
-
395  }
-
396 
-
397  const char *stream_type_to_str(TSDPESStreamId stream_id) {
-
398  if (stream_id >= 0x1C && stream_id <= 0x7F && stream_id != 0x24 &&
-
399  stream_id != 0x42) {
-
400  stream_id = (TSDPESStreamId)0x1C;
-
401  } else if (stream_id >= 0x8A && stream_id <= 0x8F) {
-
402  stream_id = (TSDPESStreamId)0x8A;
-
403  } else if (stream_id >= 0x93 && stream_id <= 0x94) {
-
404  stream_id = (TSDPESStreamId)0x93;
-
405  } else if (stream_id >= 0x96 && stream_id <= 0x9F) {
-
406  stream_id = (TSDPESStreamId)0x96;
-
407  } else if (stream_id >= 0xA1 && stream_id <= 0xBF) {
-
408  stream_id = (TSDPESStreamId)0xA1;
-
409  } else if (stream_id >= 0xC4 && stream_id <= 0xE9) {
-
410  stream_id = (TSDPESStreamId)0xC4;
-
411  } else if (stream_id >= 0xEB && stream_id <= 0xFF) {
-
412  stream_id = (TSDPESStreamId)0xEB;
-
413  }
-
414 
-
415  switch (stream_id) {
-
416  case 0x00:
-
417  return "ITU-T | ISO/IEC Reserved";
-
418  case 0x01:
-
419  return "ISO/IEC 11172 Video";
-
420  case 0x02:
-
421  return "ITU-T Rec. H.262 | ISO/IEC 13818-2 Video";
-
422  case 0x03:
-
423  return "ISO/IEC 11172 Audio";
-
424  case 0x04:
-
425  return "ISO/IEC 13818-3 Audio";
-
426  case 0x05:
-
427  return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private sections";
-
428  case 0x06:
-
429  return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing "
-
430  "private data";
-
431  case 0x07:
-
432  return "ISO/IEC 13522 MHEG";
-
433  case 0x08:
-
434  return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 DSM-CC";
-
435  case 0x09:
-
436  return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1/11172-1 auxiliary";
-
437  case 0x0A:
-
438  return "ISO/IEC 13818-6 Multi-protocol Encapsulation";
-
439  case 0x0B:
-
440  return "ISO/IEC 13818-6 DSM-CC U-N Messages";
-
441  case 0x0C:
-
442  return "ISO/IEC 13818-6 Stream Descriptors";
-
443  case 0x0D:
-
444  return "ISO/IEC 13818-6 Sections (any type, including private data)";
-
445  case 0x0E:
-
446  return "ISO/IEC 13818-1 auxiliary";
-
447  case 0x0F:
-
448  return "ISO/IEC 13818-7 Audio (AAC) with ADTS transport";
-
449  case 0x10:
-
450  return "ISO/IEC 14496-2 Visual";
-
451  case 0x11:
-
452  return "ISO/IEC 14496-3 Audio with the LATM transport syntax as "
-
453  "defined in ISO/IEC 14496-3";
-
454  case 0x12:
-
455  return "ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried "
-
456  "in PES packets";
-
457  case 0x13:
-
458  return "ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried "
-
459  "in ISO/IEC 14496_sections";
-
460  case 0x14:
-
461  return "ISO/IEC 13818-6 DSM-CC Synchronized Download Protocol";
-
462  case 0x15:
-
463  return "Metadata carried in PES packets";
-
464  case 0x16:
-
465  return "Metadata carried in metadata_sections";
-
466  case 0x17:
-
467  return "Metadata carried in ISO/IEC 13818-6 Data Carousel";
-
468  case 0x18:
-
469  return "Metadata carried in ISO/IEC 13818-6 Object Carousel";
-
470  case 0x19:
-
471  return "Metadata carried in ISO/IEC 13818-6 Synchronized Download "
-
472  "Protocol";
-
473  case 0x1A:
-
474  return "IPMP stream (defined in ISO/IEC 13818-11, MPEG-2 IPMP)";
-
475  case 0X1B:
-
476  return "AVC video stream as defined in ITU-T Rec. H.264 | ISO/IEC "
-
477  "14496-10 Video";
-
478  case 0x1C:
-
479  return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved";
-
480  case 0x24:
-
481  return "ITU-T Rec. H.265 and ISO/IEC 23008-2 (Ultra HD video) in a "
-
482  "packetized stream";
-
483  case 0x42:
-
484  return "Chinese Video Standard in a packetized stream";
-
485  case 0x80:
-
486  return "DigiCipher® II video | Identical to ITU-T Rec. H.262 | ISO/IEC "
-
487  "13818-2 Video";
-
488  case 0x81:
-
489  return "ATSC A/53 audio [2] | AC-3 audio";
-
490  case 0x82:
-
491  return "SCTE Standard Subtitle";
-
492  case 0x83:
-
493  return "SCTE Isochronous Data | Reserved";
-
494  case 0x84:
-
495  return "ATSC/SCTE reserved";
-
496  case 0x85:
-
497  return "ATSC Program Identifier , SCTE Reserved";
-
498  case 0x86:
-
499  return "SCTE 35 splice_information_table | [Cueing]";
-
500  case 0x87:
-
501  return "E-AC-3";
-
502  case 0x88:
-
503  return "DTS HD Audio";
-
504  case 0x89:
-
505  return "ATSC Reserved";
-
506  case 0x8A:
-
507  return "ATSC Reserved";
-
508  case 0x90:
-
509  return "DVB stream_type value for Time Slicing / MPE-FEC";
-
510  case 0x91:
-
511  return "IETF Unidirectional Link Encapsulation (ULE)";
-
512  case 0x92:
-
513  return "VEI stream_type";
-
514  case 0x93:
-
515  return "ATSC Reserved";
-
516  case 0x95:
-
517  return "ATSC Data Service Table, Network Resources Table";
-
518  case 0x96:
-
519  return "ATSC Reserved";
-
520  case 0xA0:
-
521  return "SCTE [IP Data] | ATSC Reserved";
-
522  case 0xA1:
-
523  return "ATSC Reserved";
-
524  case 0xC0:
-
525  return "DCII (DigiCipher®) Text";
-
526  case 0xC1:
-
527  return "ATSC Reserved";
-
528  case 0xC2:
-
529  return "ATSC synchronous data stream | [Isochronous Data]";
-
530  case 0xC3:
-
531  return "SCTE Asynchronous Data";
-
532  case 0xC4:
-
533  return "ATSC User Private Program Elements";
-
534  case 0xEA:
-
535  return "VC-1 Elementary Stream per RP227";
-
536  case 0xEB:
-
537  return "ATSC User Private Program Elements";
-
538  }
-
539  return "Unknown";
-
540  }
-
541 
-
542  const char *descriptor_tag_to_str(uint8_t tag) {
-
543  if (tag >= 0x24 && tag <= 0x27) {
-
544  tag = 0x24;
-
545  } else if (tag >= 0x29 && tag <= 0x35) {
-
546  tag = 0x29;
-
547  } else if (tag >= 0x3A && tag <= 0x3F) {
-
548  tag = 0x3A;
-
549  } else if (tag >= 0x40 && tag <= 0x51) {
-
550  tag = 0x40;
-
551  } else if (tag >= 0x98 && tag <= 0x9F) {
-
552  tag = 0x98;
-
553  }
-
554 
-
555  switch (tag) {
-
556  case 0x00:
-
557  case 0x01:
-
558  return "ISO/IEC 13818 Reserved";
-
559  case 0x02:
-
560  return "video_stream_descriptor";
-
561  case 0x03:
-
562  return "audio_stream_descriptor";
-
563  case 0x04:
-
564  return "hierarchy_descriptor";
-
565  case 0x05:
-
566  return "registration_descriptor";
-
567  case 0x06:
-
568  return "data_stream_alignment_descriptor";
-
569  case 0x07:
-
570  return "target_background_grid_descriptor";
-
571  case 0x08:
-
572  return "video_window_descriptor";
-
573  case 0x09:
-
574  return "CA_descriptor";
-
575  case 0x0A:
-
576  return "ISO_639_language_descriptor";
-
577  case 0x0B:
-
578  return "system_clock_descriptor";
-
579  case 0x0C:
-
580  return "multiplex_buffer_utilization_descriptor";
-
581  case 0x0D:
-
582  return "copyright_descriptor";
-
583  case 0x0E:
-
584  return "Maximum_bitrate_descriptor";
-
585  case 0x0F:
-
586  return "Private_data_indicator_descriptor";
-
587  case 0x10:
-
588  return "smoothing_buffer_descriptor";
-
589  case 0x11:
-
590  return "STD_descriptor";
-
591  case 0x12:
-
592  return "IBP descriptor";
-
593  case 0x13:
-
594  return "DSM-CC carousel_identifier_descriptor";
-
595  case 0x14:
-
596  return "DSM-CC association_tag_descriptor";
-
597  case 0x15:
-
598  return "DSM-CC deferred_association_tags_descriptor";
-
599  case 0x16:
-
600  return "ISO/IEC 13818-6 reserved";
-
601  case 0x17:
-
602  return "NPT Reference descriptor";
-
603  case 0x18:
-
604  return "NPT Endpoint descriptor";
-
605  case 0x19:
-
606  return "Stream Mode descriptor";
-
607  case 0x1A:
-
608  return "Stream Event descriptor";
-
609  case 0x1B:
-
610  return "MPEG-4_video_descriptor";
-
611  case 0x1C:
-
612  return "MPEG-4_audio_descriptor";
-
613  case 0x1D:
-
614  return "IOD_descriptor";
-
615  case 0x1E:
-
616  return "SL_descriptor";
-
617  case 0x1F:
-
618  return "FMC_descriptor";
-
619  case 0x20:
-
620  return "External_ES_ID_descriptor";
-
621  case 0x21:
-
622  return "MuxCode_descriptor";
-
623  case 0x22:
-
624  return "FmxBufferSize_descriptor";
-
625  case 0x23:
-
626  return "MultiplexBuffer_descriptor";
-
627  case 0x24:
-
628  return "Reserved for ISO/IEC 13818-1 use";
-
629  case 0x28:
-
630  return "AVC_video_descriptor()";
-
631  case 0x29:
-
632  return "Reserved for ISO/IEC 13818-1 use";
-
633  case 0x36:
-
634  return "content_labeling_descriptor";
-
635  case 0x37:
-
636  return "Metadata_location_descriptor";
-
637  case 0x3A:
-
638  return "ISO/IEC 13818 Reserved";
-
639  case 0x40:
-
640  return "User Private";
-
641  case 0x52:
-
642  return "SCTE 35 Stream Identifier Descriptor";
-
643  case 0x60:
-
644  return "ACAP-X Application Descriptor";
-
645  case 0x61:
-
646  return "ACAP-X Application Location Descriptor";
-
647  case 0x62:
-
648  return "ACAP-X Application Boundary Descriptor";
-
649  case 0x80:
-
650  return "Stuffing_descriptor";
-
651  case 0x81:
-
652  return "AC3_audio_descriptor";
-
653  case 0x82:
-
654  return "SCTE Frame_rate_descriptor";
-
655  case 0x83:
-
656  return "SCTE Extended_video_descriptor";
-
657  case 0x84:
-
658  return "SCTE Component_name_descriptor";
-
659  case 0x85:
-
660  return "ATSC program_identifier";
-
661  case 0x86:
-
662  return "Caption_service_descriptor";
-
663  case 0x87:
-
664  return "Content_advisory_descriptor";
-
665  case 0x88:
-
666  return "ATSC CA_descriptor";
-
667  case 0x89:
-
668  return "ATSC Descriptor_tag";
-
669  case 0x8A:
-
670  return "SCTE 35 cue identifier descriptor";
-
671  case 0x8B:
-
672  return "ATSC/SCTE Reserved";
-
673  case 0x8C:
-
674  return "TimeStampDescriptor";
-
675  case 0x8D:
-
676  return "parameterized_service_descriptor() ";
-
677  case 0x8E:
-
678  return "Interactive Services Filtering Criteria descriptor";
-
679  case 0x8F:
-
680  return "Interactive Services NRT Services Summary descriptor";
-
681  case 0x90:
-
682  return "SCTE Frequency_spec_descriptor";
-
683  case 0x91:
-
684  return "SCTE Modulation_params_descriptor";
-
685  case 0x92:
-
686  return "SCTE Transport_stream_id_descriptor";
-
687  case 0x93:
-
688  return "SCTE Revision detection descriptor";
-
689  case 0x94:
-
690  return "SCTE Two part channel number descriptor";
-
691  case 0x95:
-
692  return "SCTE Channel properties descriptor";
-
693  case 0x96:
-
694  return "SCTE Daylight Savings Time Descriptor";
-
695  case 0x97:
-
696  return "SCTE_adaptation_field_data_descriptor()";
-
697  case 0x98:
-
698  return "SCTE Reserved";
-
699  case 0xA0:
-
700  return "extended_channel_name_descriptor";
-
701  case 0xA1:
-
702  return "ATSC service_location_descriptor";
-
703  case 0xA2:
-
704  return "time_shifted_service_descriptor";
-
705  case 0xA3:
-
706  return "component_name_descriptor";
-
707  case 0xA4:
-
708  return "ATSC data_service_descriptor";
-
709  case 0xA5:
-
710  return "ATSC PID Count descriptor";
-
711  case 0xA6:
-
712  return "ATSC Download descriptor";
-
713  case 0xA7:
-
714  return "ATSC Multiprotocol Encapsulation descriptor";
-
715  case 0xA8:
-
716  return "ATSC dcc_departing_request_descriptor";
-
717  case 0xA9:
-
718  return "ATSC dcc_arriving_request_descriptor";
-
719  case 0xAA:
-
720  return "ATSC rc_descriptor";
-
721  case 0xAB:
-
722  return "ATSC Genre descriptor";
-
723  case 0xAC:
-
724  return "SCTE MAC Address List";
-
725  case 0xAD:
-
726  return "ATSC private information descriptor";
-
727  case 0xAE:
-
728  return "ATSC compatibility wrapper descriptor";
-
729  case 0xAF:
-
730  return "ATSC broadcaster policy descriptor";
-
731  case 0xB0:
-
732  return "ATSC service name descriptor";
-
733  case 0xB1:
-
734  return "ATSC URI descriptor";
-
735  case 0xB2:
-
736  return "ATSC enhanced signaling descriptor";
-
737  case 0xB3:
-
738  return "ATSC M/H string mapping descriptor";
-
739  case 0xB4:
-
740  return "ATSC Module Link descriptor";
-
741  case 0xB5:
-
742  return "ATSC CRC32 descriptor";
-
743  case 0xB6:
-
744  return "ATSC Content Identifier Descriptor";
-
745  case 0xB7:
-
746  return "ModuleInfoDescriptor";
-
747  case 0xB8:
-
748  return "ATSC Group Link descriptor";
-
749  case 0xB9:
-
750  return "ATSC Time Stamp descriptor";
-
751  case 0xBA:
-
752  return "ScheduleDescriptor";
-
753  case 0xBB:
-
754  return "Component list descriptor";
-
755  case 0xBC:
-
756  return "ATSC M/H component descriptor";
-
757  case 0xBD:
-
758  return "ATSC M/H rights issuer descriptor";
-
759  case 0xBE:
-
760  return "ATSC M/H current program descriptor";
-
761  case 0xBF:
-
762  return "ATSC M/H original service identification descriptor";
-
763  case 0xC0:
-
764  return "protection_descriptor";
-
765  case 0xC1:
-
766  return "MH_SG_bootstrap_descriptor";
-
767  case 0xC2:
-
768  return "Service ID descriptor";
-
769  case 0xC3:
-
770  return "Protocol Version descriptor";
-
771  case 0xC4:
-
772  return "NRT Service descriptor";
-
773  case 0xC5:
-
774  return "Capabilities descriptor";
-
775  case 0xC6:
-
776  return "Icon descriptor";
-
777  case 0xC7:
-
778  return "Receiver Targeting descriptor";
-
779  case 0xC8:
-
780  return "Time Slot descriptor";
-
781  case 0xC9:
-
782  return "Internet Location Descriptor";
-
783  case 0xCA:
-
784  return "Associated Service descriptor";
-
785  case 0xCB:
-
786  return "Eye Identification Descriptor tag";
-
787  case 0xCC:
-
788  return "E-AC-3 descriptor (A/52 Annex G)";
-
789  case 0xCD:
-
790  return "2D 3D Corresponding Content Descriptor";
-
791  case 0xCE:
-
792  return "Multimedia EPG Linkage Descriptor";
-
793  case 0xE0:
-
794  return "etv_application_information_descriptor()";
-
795  case 0xE1:
-
796  return "etv_media_time_descriptor()";
-
797  case 0xE2:
-
798  return "etv_stream_event_descriptor()";
-
799  case 0xE3:
-
800  return "etv_application_descriptor()";
-
801  case 0xE4:
-
802  return "RBI_signaling_descriptor()";
-
803  case 0xE5:
-
804  return "etv_application_metadata_descriptor()";
-
805  case 0xE6:
-
806  return "etv_bif_platform_descriptor()";
-
807  case 0xE7:
-
808  return "etv_integrated_signaling_descriptor()";
-
809  case 0xE8:
-
810  return "3d_MPEG2_descriptor()";
-
811  case 0XE9:
-
812  return "ebp_descriptor()";
-
813  case 0xEA:
-
814  return "MPEG_AAC_descriptor";
-
815  case 0xEB:
-
816  return "IC3D_event_info_descriptor";
-
817  case 0xEC:
-
818  return "MDTV hybrid stereoscopic service descriptor";
-
819  }
-
820  return "Unknown";
-
821  }
-
822 
-
823  void print_descriptor_info(TSDDescriptor *desc) {
-
824  // print out some interesting descriptor data
-
825  switch (desc->tag) {
-
826  case 0x05: // Registration descriptor
-
827  {
-
828  TSDDescriptorRegistration res;
-
829  if (TSD_OK == tsd_parse_descriptor_registration(
-
830  desc->data, desc->data_length, &res)) {
-
831  LOGD("\n format identififer: 0x%08X", res.format_identifier);
-
832  }
-
833  } break;
-
834  case 0x0A: // ISO 639 Language descriptor
-
835  {
-
836  TSDDescriptorISO639Language res;
-
837  if (TSD_OK == tsd_parse_descriptor_iso639_language(
-
838  desc->data, desc->data_length, &res)) {
-
839  LOGD("\n");
-
840  int i = 0;
-
841  for (; i < res.language_length; ++i) {
-
842  LOGD(" ISO Language Code: 0x%08X, audio type: 0x%02x",
-
843  res.iso_language_code[i], res.audio_type[i]);
-
844  }
-
845  LOGD("\n");
-
846  }
-
847  } break;
-
848  case 0x0E: // Maximum bitrate descriptor
-
849  {
-
850  TSDDescriptorMaxBitrate res;
-
851  if (TSD_OK == tsd_parse_descriptor_max_bitrate(
-
852  desc->data, desc->data_length, &res)) {
-
853  LOGD(" Maximum Bitrate: %d x 50 bytes/second", res.max_bitrate);
-
854  }
-
855  } break;
-
856  default: {
-
857  LOGW(" Unknown Descriptor: 0x%x ", desc->tag);
-
858  } break;
-
859  }
-
860  }
-
861 
-
862  static void* log_malloc (size_t size) {
-
863  void *result = malloc(size);
-
864  LOGI("malloc(%d) -> %p %s\n", (int)size,result, result!=NULL?"OK":"ERROR");
-
865  return result;
-
866  }
-
867 
-
868  static void* log_calloc(size_t num, size_t size){
-
869  void *result = calloc(num, size);
-
870  LOGI("calloc(%d) -> %p %s\n", (int)(num*size),result, result!=NULL?"OK":"ERROR");
-
871  return result;
-
872  }
-
873 
-
874  static void* log_realloc(void *ptr, size_t size){
-
875  void *result = realloc(ptr, size);
-
876  LOGI("realloc(%d) -> %p %s\n", (int)size, result, result!=NULL?"OK":"ERROR");
-
877  return result;
-
878  }
-
879 
-
880  static void log_free (void *mem){
-
881  LOGD("free(%p)\n", mem);
-
882  free(mem);
-
883  }
-
884 
-
885  // // store allocated size in first bytes
-
886  // static void* log_malloc (size_t size) {
-
887  // void *result = malloc(size);
-
888  // memset(result, 0, size);
-
889  // AllocSize entry{result, size};
-
890  // self->alloc_vector.push_back(entry);
-
891  // assert(find_size(result)>=0);
-
892  // LOGI("malloc(%d) -> %p %s\n", (int)size,result, result!=NULL?"OK":"ERROR");
-
893  // return result;
-
894  // }
-
895 
-
896  // static void* log_calloc(size_t num, size_t size){
-
897  // return log_malloc(num*size);
-
898  // }
-
899 
-
900  // static int find_size(void *ptr){
-
901  // for (int j=0;j<self->alloc_vector.size();j++){
-
902  // if (self->alloc_vector[j].data==ptr) return j;
-
903  // }
-
904  // return -1;
-
905  // }
-
906 
-
907  // static void* log_realloc(void *ptr, size_t size){
-
908  // int pos = find_size(ptr);
-
909  // void *result = nullptr;
-
910  // if (pos>=0){
-
911  // result = realloc(ptr, size);
-
912  // // store size in header
-
913  // size_t old_size = self->alloc_vector[pos].size;
-
914  // memset(result+old_size, 0, size-old_size);
-
915  // self->alloc_vector[pos].size = size;
-
916  // } else {
-
917  // LOGE("realloc of unallocatd memory %p", ptr);
-
918  // result = realloc(ptr, size);
-
919  // AllocSize entry{result, size};
-
920  // self->alloc_vector.push_back(entry);
-
921  // assert(find_size(result)>=0);
-
922  // }
-
923 
-
924  // LOGI("realloc(%d) -> %p %s\n", (int)size, result, result!=NULL?"OK":"ERROR");
-
925  // return result;
-
926  // }
-
927 
-
928  // static void log_free (void *mem){
-
929  // LOGD("free(%p)\n", mem);
-
930  // free(mem);
-
931  // int pos = find_size(mem);
-
932  // if (pos>=0){
-
933  // self->alloc_vector.erase(pos);
-
934  // assert(find_size(mem)==-1);
-
935 
-
936  // } else {
-
937  // LOGE("free of unallocatd memory %p", mem);
-
938  // }
-
939  // }
-
940 
+
48 class MTSDecoder : public AudioDecoder {
+
49  public:
+
50  MTSDecoder() {
+
51  self = this;
+
52  };
+
53 
+
54  void begin() override {
+
55  TRACED();
+
56  // automatically close when called multiple times
+
57  if (is_active) {
+
58  end();
+
59  }
+
60 
+
61  is_active = true;
+
62 
+
63  // create the pids we plan on printing
+
64  memset(print_pids, 0, sizeof(print_pids));
+
65 
+
66  // set default values onto the context.
+
67  if (tsd_context_init(&ctx)!=TSD_OK){
+
68  TRACEE();
+
69  is_active = false;
+
70  }
+
71 
+
72  // log memory allocations ?
+
73  //if (is_alloc_active){
+
74  ctx.malloc = log_malloc;
+
75  ctx.realloc = log_realloc;
+
76  ctx.calloc = log_calloc;
+
77  ctx.free = log_free;
+
78  //}
+
79 
+
80  // default supported stream types
+
81  if (stream_types.empty()){
+
82  addStreamType(TSD_PMT_STREAM_TYPE_PES_METADATA);
+
83  addStreamType(TSD_PMT_STREAM_TYPE_AUDIO_AAC);
+
84  }
+
85 
+
86  // add a callback.
+
87  // the callback is used to determine which PIDs contain the data we want
+
88  // to demux. We also receive PES data for any PIDs that we register later
+
89  // on.
+
90  if (tsd_set_event_callback(&ctx, event_cb)!=TSD_OK){
+
91  TRACEE();
+
92  is_active = false;
+
93  }
+
94 
+
95  }
+
96 
+
97  void end() override {
+
98  TRACED();
+
99  // finally end the demux process which will flush any remaining PES data.
+
100  tsd_demux_end(&ctx);
+
101 
+
102  // destroy context
+
103  tsd_context_destroy(&ctx);
+
104 
+
105  is_active = false;
+
106  }
+
107 
+
108  virtual operator bool() override { return is_active; }
+
109 
+
110  const char *mime() { return "video/MP2T"; }
+
111 
+
112  size_t write(const void *in_ptr, size_t in_size) override {
+
113  if (!is_active) return 0;
+
114  LOGD("MTSDecoder::write: %d", (int)in_size);
+
115  size_t result = buffer.writeArray((uint8_t*)in_ptr, in_size);
+
116  // demux
+
117  demux(underflowLimit);
+
118  return result;
+
119  }
+
120 
+
121  void flush(){
+
122  demux(0);
+
123  }
+
124 
+
125  void clearStreamTypes(){
+
126  TRACED();
+
127  stream_types.clear();
+
128  }
+
129 
+
130  void addStreamType(TSDPMTStreamType type){
+
131  TRACED();
+
132  stream_types.push_back(type);
+
133  }
+
134 
+
135  bool isStreamTypeActive(TSDPMTStreamType type){
+
136  for (int j=0;j<stream_types.size();j++){
+
137  if (stream_types[j]==type) return true;
+
138  }
+
139  return false;
+
140  }
+
141 
+
143  void resizeBuffer(int size){
+
144  buffer.resize(size);
+
145  }
+
146 
+
148  void setMemoryAllocationLogging(bool flag){
+
149  is_alloc_active = flag;
+
150  }
+
151 
+
152  protected:
+
153  static MTSDecoder *self;
+
154  int underflowLimit = MTS_UNDERFLOW_LIMIT;
+
155  bool is_active = false;
+
156  bool is_write_active = false;
+
157  bool is_alloc_active = false;
+
158  TSDemuxContext ctx;
+
159  uint16_t print_pids[MTS_PRINT_PIDS_LEN] = {0};
+
160  SingleBuffer<uint8_t> buffer{MTS_WRITE_BUFFER_SIZE};
+
161  Vector<TSDPMTStreamType> stream_types;
+
162  Vector<AllocSize> alloc_vector;
+
163 
+
164  void set_write_active(bool flag){
+
165  //LOGD("is_write_active: %s", flag ? "true":"false");
+
166  is_write_active = flag;
+
167  }
+
168 
+
169  void demux(int limit){
+
170  TRACED();
+
171  TSDCode res = TSD_OK;
+
172  int count = 0;
+
173  while (res == TSD_OK && buffer.available() > limit) {
+
174  size_t len = tsd_demux(&ctx, (void *)buffer.data(), buffer.available(), &res);
+
175  // remove processed bytes
+
176  buffer.clearArray(len);
+
177  // get next bytes
+
178  count++;
+
179  if (res != TSD_OK) logResult(res);
+
180  }
+
181  LOGD("Number of demux calls: %d", count);
+
182  }
+
183 
+
184  void logResult(TSDCode code) {
+
185  switch (code) {
+
186  case TSD_OK:
+
187  LOGD("TSD_OK");
+
188  break;
+
189  case TSD_INVALID_SYNC_BYTE:
+
190  LOGW("TSD_INVALID_SYNC_BYTE");
+
191  break;
+
192  case TSD_INVALID_CONTEXT:
+
193  LOGW("TSD_INVALID_CONTEXT");
+
194  break;
+
195  case TSD_INVALID_DATA:
+
196  LOGW("TSD_INVALID_DATA");
+
197  break;
+
198  case TSD_INVALID_DATA_SIZE:
+
199  LOGW("TSD_INVALID_DATA_SIZE");
+
200  break;
+
201  case TSD_INVALID_ARGUMENT:
+
202  LOGW("TSD_INVALID_ARGUMENT");
+
203  break;
+
204  case TSD_INVALID_START_CODE_PREFIX:
+
205  LOGW("TSD_INVALID_START_CODE_PREFIX");
+
206  break;
+
207  case TSD_OUT_OF_MEMORY:
+
208  LOGW("TSD_OUT_OF_MEMORY");
+
209  break;
+
210  case TSD_INCOMPLETE_TABLE:
+
211  LOGW("TSD_INCOMPLETE_TABLE");
+
212  break;
+
213  case TSD_NOT_A_TABLE_PACKET:
+
214  LOGW("TSD_NOT_A_TABLE_PACKET");
+
215  break;
+
216  case TSD_PARSE_ERROR:
+
217  LOGW("TSD_PARSE_ERROR");
+
218  break;
+
219  case TSD_PID_ALREADY_REGISTERED:
+
220  LOGW("TSD_PID_ALREADY_REGISTERED");
+
221  break;
+
222  case TSD_TSD_MAX_PID_REGS_REACHED:
+
223  LOGW("TSD_TSD_MAX_PID_REGS_REACHED");
+
224  break;
+
225  case TSD_PID_NOT_FOUND:
+
226  LOGW("TSD_PID_NOT_FOUND");
+
227  break;
+
228  case TSD_INVALID_POINTER_FIELD:
+
229  LOGW("TSD_INVALID_POINTER_FIELD");
+
230  break;
+
231  }
+
232  }
+
233 
+
234  // event callback
+
235  static void event_cb(TSDemuxContext *ctx, uint16_t pid, TSDEventId event_id,
+
236  void *data) {
+
237  TRACED();
+
238  if (MTSDecoder::self != nullptr) {
+
239  MTSDecoder::self->event_cb_local(ctx, pid, event_id, data);
+
240  }
+
241  }
+
242 
+
243  void event_cb_local(TSDemuxContext *ctx, uint16_t pid, TSDEventId event_id,
+
244  void *data) {
+
245  if (event_id == TSD_EVENT_PAT) {
+
246  set_write_active(false);
+
247  print_pat(ctx, data);
+
248  } else if (event_id == TSD_EVENT_PMT) {
+
249  set_write_active(false);
+
250  print_pmt(ctx, data);
+
251  } else if (event_id == TSD_EVENT_PES) {
+
252  TSDPESPacket *pes = (TSDPESPacket *)data;
+
253  // This is where we write the PES data into our buffer.
+
254  LOGD("====================");
+
255  LOGD("PID %d PES Packet, Size: %ld, stream_id=%u, pts=%lu, dts=%lu", pid,
+
256  pes->data_bytes_length, pes->stream_id, pes->pts, pes->dts);
+
257  // print out the PES Packet data if it's in our print list
+
258  int i;
+
259  AudioLogger logger = AudioLogger::instance();
+
260  for (i = 0; i < MTS_PRINT_PIDS_LEN; ++i) {
+
261  if (print_pids[i] == pid) {
+
262  // log data
+
263  if (logger.isLogging(AudioLogger::Debug)) {
+
264  logger.print(" PES data ");
+
265  logger.print(is_write_active? "active:":"inactive:");
+
266  int j = 0;
+
267  while (j < pes->data_bytes_length) {
+
268  char n = pes->data_bytes[j];
+
269  logger.printCharHex(n);
+
270  ++j;
+
271  }
+
272  logger.printChar('\n');
+
273  }
+
274  // output data
+
275  if (p_print != nullptr) {
+
276  //size_t eff = p_print->write(pes->data_bytes, pes->data_bytes_length);
+
277  size_t eff = writeSamples<uint8_t>(p_print,(uint8_t*) pes->data_bytes, pes->data_bytes_length);
+
278  if(eff!=pes->data_bytes_length){
+
279  // we should not get here
+
280  TRACEE();
+
281  }
+
282  }
+
283  }
+
284  }
+
285 
+
286  } else if (event_id == TSD_EVENT_ADAP_FIELD_PRV_DATA) {
+
287  set_write_active(false);
+
288  // we're only watching for SCTE Adaptions Field Private Data,
+
289  // so we know that we must parse it as a list of descritors.
+
290  TSDAdaptationField *adap_field = (TSDAdaptationField *)data;
+
291  TSDDescriptor *descriptors = NULL;
+
292  size_t descriptors_length = 0;
+
293  tsd_descriptor_extract(ctx, adap_field->private_data_bytes,
+
294  adap_field->transport_private_data_length,
+
295  &descriptors, &descriptors_length);
+
296 
+
297  LOGD("====================");
+
298  LOGD("Descriptors - Adaptation Fields");
+
299  int i = 0;
+
300  for (; i < descriptors_length; ++i) {
+
301  TSDDescriptor *des = &descriptors[i];
+
302  LOGD(" %d) tag: (0x%04X) %s", i, des->tag,
+
303  descriptor_tag_to_str(des->tag));
+
304  LOGD(" length: %d", des->length);
+
305  print_descriptor_info(des);
+
306  }
+
307  }
+
308  }
+
309 
+
310  void print_pat(TSDemuxContext *ctx, void *data) {
+
311  LOGD("====================");
+
312  TSDPATData *pat = (TSDPATData *)data;
+
313  size_t len = pat->length;
+
314  size_t i;
+
315  LOGD("PAT, Length %d", (int)pat->length);
+
316 
+
317  if (len > 1) {
+
318  LOGD("number of progs: %d", (int)len);
+
319  }
+
320  for (i = 0; i < len; ++i) {
+
321  LOGD(" %d) prog num: 0x%X, pid: 0x%X", (int)i, pat->program_number[i],
+
322  pat->pid[i]);
+
323  }
+
324  }
+
325 
+
326  void print_pmt(TSDemuxContext *ctx, void *data) {
+
327  LOGD("====================");
+
328  LOGD("PMT");
+
329  TSDPMTData *pmt = (TSDPMTData *)data;
+
330  LOGD("PCR PID: 0x%04X", pmt->pcr_pid);
+
331  LOGD("program info length: %d", (int)pmt->program_info_length);
+
332  LOGD("descriptors length: %d", (int)pmt->descriptors_length);
+
333  size_t i;
+
334 
+
335  for (i = 0; i < pmt->descriptors_length; ++i) {
+
336  TSDDescriptor *des = &pmt->descriptors[i];
+
337  LOGD(" %d) tag: (0x%04X) %s", (int)i, des->tag,
+
338  descriptor_tag_to_str(des->tag));
+
339  LOGD(" length: %d", des->length);
+
340  print_descriptor_info(des);
+
341  }
+
342 
+
343  LOGD("program elements length: %d", (int)pmt->program_elements_length);
+
344  for (i = 0; i < pmt->program_elements_length; ++i) {
+
345  TSDProgramElement *prog = &pmt->program_elements[i];
+
346  LOGD(" -----Program #%d", (int)i);
+
347  LOGD(" stream type: (0x%04X) %s", prog->stream_type,
+
348  stream_type_to_str((TSDPESStreamId)(prog->stream_type)));
+
349  LOGD(" elementary pid: 0x%04X", prog->elementary_pid);
+
350  LOGD(" es info length: %d", prog->es_info_length);
+
351  LOGD(" descriptors length: %d", (int)prog->descriptors_length);
+
352 
+
353  if (isStreamTypeActive((TSDPMTStreamType)prog->stream_type)){
+
354  set_write_active(true);
+
355  }
+
356 
+
357  // keep track of metadata pids, we'll print the data for these
+
358  for(int j=0;j<stream_types.size();j++){
+
359  add_print_pid(prog, stream_types[j]);
+
360  }
+
361 
+
362  // we'll register to listen to the PES data for this program.
+
363  int reg_types = TSD_REG_PES;
+
364 
+
365  size_t j;
+
366  for (j = 0; j < prog->descriptors_length; ++j) {
+
367  TSDDescriptor *des = &prog->descriptors[j];
+
368  LOGD(" %d) tag: (0x%04X) %s", (int)j, des->tag,
+
369  descriptor_tag_to_str(des->tag));
+
370  LOGD(" length: %d", des->length);
+
371  print_descriptor_info(des);
+
372 
+
373  // if this tag is the SCTE Adaption field private data descriptor,
+
374  // we'll also register for the Adaptation Field Privae Data.
+
375  if (des->tag == 0x97) {
+
376  reg_types |= TSD_REG_ADAPTATION_FIELD;
+
377  }
+
378  }
+
379 
+
380  // register all the PIDs we come across.
+
381  tsd_register_pid(ctx, prog->elementary_pid, reg_types);
+
382  }
+
383  }
+
384 
+
385  void add_print_pid(TSDProgramElement *prog, TSDPMTStreamType type) {
+
386  if (prog->stream_type == type) {
+
387  int k;
+
388  for (k = 0; k < MTS_PRINT_PIDS_LEN; ++k) {
+
389  // find a spare slot in the pids
+
390  if (print_pids[k] == 0) {
+
391  print_pids[k] = prog->elementary_pid;
+
392  break;
+
393  }
+
394  }
+
395  }
+
396  }
+
397 
+
398  const char *stream_type_to_str(TSDPESStreamId stream_id) {
+
399  if (stream_id >= 0x1C && stream_id <= 0x7F && stream_id != 0x24 &&
+
400  stream_id != 0x42) {
+
401  stream_id = (TSDPESStreamId)0x1C;
+
402  } else if (stream_id >= 0x8A && stream_id <= 0x8F) {
+
403  stream_id = (TSDPESStreamId)0x8A;
+
404  } else if (stream_id >= 0x93 && stream_id <= 0x94) {
+
405  stream_id = (TSDPESStreamId)0x93;
+
406  } else if (stream_id >= 0x96 && stream_id <= 0x9F) {
+
407  stream_id = (TSDPESStreamId)0x96;
+
408  } else if (stream_id >= 0xA1 && stream_id <= 0xBF) {
+
409  stream_id = (TSDPESStreamId)0xA1;
+
410  } else if (stream_id >= 0xC4 && stream_id <= 0xE9) {
+
411  stream_id = (TSDPESStreamId)0xC4;
+
412  } else if (stream_id >= 0xEB && stream_id <= 0xFF) {
+
413  stream_id = (TSDPESStreamId)0xEB;
+
414  }
+
415 
+
416  switch (stream_id) {
+
417  case 0x00:
+
418  return "ITU-T | ISO/IEC Reserved";
+
419  case 0x01:
+
420  return "ISO/IEC 11172 Video";
+
421  case 0x02:
+
422  return "ITU-T Rec. H.262 | ISO/IEC 13818-2 Video";
+
423  case 0x03:
+
424  return "ISO/IEC 11172 Audio";
+
425  case 0x04:
+
426  return "ISO/IEC 13818-3 Audio";
+
427  case 0x05:
+
428  return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private sections";
+
429  case 0x06:
+
430  return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing "
+
431  "private data";
+
432  case 0x07:
+
433  return "ISO/IEC 13522 MHEG";
+
434  case 0x08:
+
435  return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 DSM-CC";
+
436  case 0x09:
+
437  return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1/11172-1 auxiliary";
+
438  case 0x0A:
+
439  return "ISO/IEC 13818-6 Multi-protocol Encapsulation";
+
440  case 0x0B:
+
441  return "ISO/IEC 13818-6 DSM-CC U-N Messages";
+
442  case 0x0C:
+
443  return "ISO/IEC 13818-6 Stream Descriptors";
+
444  case 0x0D:
+
445  return "ISO/IEC 13818-6 Sections (any type, including private data)";
+
446  case 0x0E:
+
447  return "ISO/IEC 13818-1 auxiliary";
+
448  case 0x0F:
+
449  return "ISO/IEC 13818-7 Audio (AAC) with ADTS transport";
+
450  case 0x10:
+
451  return "ISO/IEC 14496-2 Visual";
+
452  case 0x11:
+
453  return "ISO/IEC 14496-3 Audio with the LATM transport syntax as "
+
454  "defined in ISO/IEC 14496-3";
+
455  case 0x12:
+
456  return "ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried "
+
457  "in PES packets";
+
458  case 0x13:
+
459  return "ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried "
+
460  "in ISO/IEC 14496_sections";
+
461  case 0x14:
+
462  return "ISO/IEC 13818-6 DSM-CC Synchronized Download Protocol";
+
463  case 0x15:
+
464  return "Metadata carried in PES packets";
+
465  case 0x16:
+
466  return "Metadata carried in metadata_sections";
+
467  case 0x17:
+
468  return "Metadata carried in ISO/IEC 13818-6 Data Carousel";
+
469  case 0x18:
+
470  return "Metadata carried in ISO/IEC 13818-6 Object Carousel";
+
471  case 0x19:
+
472  return "Metadata carried in ISO/IEC 13818-6 Synchronized Download "
+
473  "Protocol";
+
474  case 0x1A:
+
475  return "IPMP stream (defined in ISO/IEC 13818-11, MPEG-2 IPMP)";
+
476  case 0X1B:
+
477  return "AVC video stream as defined in ITU-T Rec. H.264 | ISO/IEC "
+
478  "14496-10 Video";
+
479  case 0x1C:
+
480  return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved";
+
481  case 0x24:
+
482  return "ITU-T Rec. H.265 and ISO/IEC 23008-2 (Ultra HD video) in a "
+
483  "packetized stream";
+
484  case 0x42:
+
485  return "Chinese Video Standard in a packetized stream";
+
486  case 0x80:
+
487  return "DigiCipher® II video | Identical to ITU-T Rec. H.262 | ISO/IEC "
+
488  "13818-2 Video";
+
489  case 0x81:
+
490  return "ATSC A/53 audio [2] | AC-3 audio";
+
491  case 0x82:
+
492  return "SCTE Standard Subtitle";
+
493  case 0x83:
+
494  return "SCTE Isochronous Data | Reserved";
+
495  case 0x84:
+
496  return "ATSC/SCTE reserved";
+
497  case 0x85:
+
498  return "ATSC Program Identifier , SCTE Reserved";
+
499  case 0x86:
+
500  return "SCTE 35 splice_information_table | [Cueing]";
+
501  case 0x87:
+
502  return "E-AC-3";
+
503  case 0x88:
+
504  return "DTS HD Audio";
+
505  case 0x89:
+
506  return "ATSC Reserved";
+
507  case 0x8A:
+
508  return "ATSC Reserved";
+
509  case 0x90:
+
510  return "DVB stream_type value for Time Slicing / MPE-FEC";
+
511  case 0x91:
+
512  return "IETF Unidirectional Link Encapsulation (ULE)";
+
513  case 0x92:
+
514  return "VEI stream_type";
+
515  case 0x93:
+
516  return "ATSC Reserved";
+
517  case 0x95:
+
518  return "ATSC Data Service Table, Network Resources Table";
+
519  case 0x96:
+
520  return "ATSC Reserved";
+
521  case 0xA0:
+
522  return "SCTE [IP Data] | ATSC Reserved";
+
523  case 0xA1:
+
524  return "ATSC Reserved";
+
525  case 0xC0:
+
526  return "DCII (DigiCipher®) Text";
+
527  case 0xC1:
+
528  return "ATSC Reserved";
+
529  case 0xC2:
+
530  return "ATSC synchronous data stream | [Isochronous Data]";
+
531  case 0xC3:
+
532  return "SCTE Asynchronous Data";
+
533  case 0xC4:
+
534  return "ATSC User Private Program Elements";
+
535  case 0xEA:
+
536  return "VC-1 Elementary Stream per RP227";
+
537  case 0xEB:
+
538  return "ATSC User Private Program Elements";
+
539  }
+
540  return "Unknown";
+
541  }
+
542 
+
543  const char *descriptor_tag_to_str(uint8_t tag) {
+
544  if (tag >= 0x24 && tag <= 0x27) {
+
545  tag = 0x24;
+
546  } else if (tag >= 0x29 && tag <= 0x35) {
+
547  tag = 0x29;
+
548  } else if (tag >= 0x3A && tag <= 0x3F) {
+
549  tag = 0x3A;
+
550  } else if (tag >= 0x40 && tag <= 0x51) {
+
551  tag = 0x40;
+
552  } else if (tag >= 0x98 && tag <= 0x9F) {
+
553  tag = 0x98;
+
554  }
+
555 
+
556  switch (tag) {
+
557  case 0x00:
+
558  case 0x01:
+
559  return "ISO/IEC 13818 Reserved";
+
560  case 0x02:
+
561  return "video_stream_descriptor";
+
562  case 0x03:
+
563  return "audio_stream_descriptor";
+
564  case 0x04:
+
565  return "hierarchy_descriptor";
+
566  case 0x05:
+
567  return "registration_descriptor";
+
568  case 0x06:
+
569  return "data_stream_alignment_descriptor";
+
570  case 0x07:
+
571  return "target_background_grid_descriptor";
+
572  case 0x08:
+
573  return "video_window_descriptor";
+
574  case 0x09:
+
575  return "CA_descriptor";
+
576  case 0x0A:
+
577  return "ISO_639_language_descriptor";
+
578  case 0x0B:
+
579  return "system_clock_descriptor";
+
580  case 0x0C:
+
581  return "multiplex_buffer_utilization_descriptor";
+
582  case 0x0D:
+
583  return "copyright_descriptor";
+
584  case 0x0E:
+
585  return "Maximum_bitrate_descriptor";
+
586  case 0x0F:
+
587  return "Private_data_indicator_descriptor";
+
588  case 0x10:
+
589  return "smoothing_buffer_descriptor";
+
590  case 0x11:
+
591  return "STD_descriptor";
+
592  case 0x12:
+
593  return "IBP descriptor";
+
594  case 0x13:
+
595  return "DSM-CC carousel_identifier_descriptor";
+
596  case 0x14:
+
597  return "DSM-CC association_tag_descriptor";
+
598  case 0x15:
+
599  return "DSM-CC deferred_association_tags_descriptor";
+
600  case 0x16:
+
601  return "ISO/IEC 13818-6 reserved";
+
602  case 0x17:
+
603  return "NPT Reference descriptor";
+
604  case 0x18:
+
605  return "NPT Endpoint descriptor";
+
606  case 0x19:
+
607  return "Stream Mode descriptor";
+
608  case 0x1A:
+
609  return "Stream Event descriptor";
+
610  case 0x1B:
+
611  return "MPEG-4_video_descriptor";
+
612  case 0x1C:
+
613  return "MPEG-4_audio_descriptor";
+
614  case 0x1D:
+
615  return "IOD_descriptor";
+
616  case 0x1E:
+
617  return "SL_descriptor";
+
618  case 0x1F:
+
619  return "FMC_descriptor";
+
620  case 0x20:
+
621  return "External_ES_ID_descriptor";
+
622  case 0x21:
+
623  return "MuxCode_descriptor";
+
624  case 0x22:
+
625  return "FmxBufferSize_descriptor";
+
626  case 0x23:
+
627  return "MultiplexBuffer_descriptor";
+
628  case 0x24:
+
629  return "Reserved for ISO/IEC 13818-1 use";
+
630  case 0x28:
+
631  return "AVC_video_descriptor()";
+
632  case 0x29:
+
633  return "Reserved for ISO/IEC 13818-1 use";
+
634  case 0x36:
+
635  return "content_labeling_descriptor";
+
636  case 0x37:
+
637  return "Metadata_location_descriptor";
+
638  case 0x3A:
+
639  return "ISO/IEC 13818 Reserved";
+
640  case 0x40:
+
641  return "User Private";
+
642  case 0x52:
+
643  return "SCTE 35 Stream Identifier Descriptor";
+
644  case 0x60:
+
645  return "ACAP-X Application Descriptor";
+
646  case 0x61:
+
647  return "ACAP-X Application Location Descriptor";
+
648  case 0x62:
+
649  return "ACAP-X Application Boundary Descriptor";
+
650  case 0x80:
+
651  return "Stuffing_descriptor";
+
652  case 0x81:
+
653  return "AC3_audio_descriptor";
+
654  case 0x82:
+
655  return "SCTE Frame_rate_descriptor";
+
656  case 0x83:
+
657  return "SCTE Extended_video_descriptor";
+
658  case 0x84:
+
659  return "SCTE Component_name_descriptor";
+
660  case 0x85:
+
661  return "ATSC program_identifier";
+
662  case 0x86:
+
663  return "Caption_service_descriptor";
+
664  case 0x87:
+
665  return "Content_advisory_descriptor";
+
666  case 0x88:
+
667  return "ATSC CA_descriptor";
+
668  case 0x89:
+
669  return "ATSC Descriptor_tag";
+
670  case 0x8A:
+
671  return "SCTE 35 cue identifier descriptor";
+
672  case 0x8B:
+
673  return "ATSC/SCTE Reserved";
+
674  case 0x8C:
+
675  return "TimeStampDescriptor";
+
676  case 0x8D:
+
677  return "parameterized_service_descriptor() ";
+
678  case 0x8E:
+
679  return "Interactive Services Filtering Criteria descriptor";
+
680  case 0x8F:
+
681  return "Interactive Services NRT Services Summary descriptor";
+
682  case 0x90:
+
683  return "SCTE Frequency_spec_descriptor";
+
684  case 0x91:
+
685  return "SCTE Modulation_params_descriptor";
+
686  case 0x92:
+
687  return "SCTE Transport_stream_id_descriptor";
+
688  case 0x93:
+
689  return "SCTE Revision detection descriptor";
+
690  case 0x94:
+
691  return "SCTE Two part channel number descriptor";
+
692  case 0x95:
+
693  return "SCTE Channel properties descriptor";
+
694  case 0x96:
+
695  return "SCTE Daylight Savings Time Descriptor";
+
696  case 0x97:
+
697  return "SCTE_adaptation_field_data_descriptor()";
+
698  case 0x98:
+
699  return "SCTE Reserved";
+
700  case 0xA0:
+
701  return "extended_channel_name_descriptor";
+
702  case 0xA1:
+
703  return "ATSC service_location_descriptor";
+
704  case 0xA2:
+
705  return "time_shifted_service_descriptor";
+
706  case 0xA3:
+
707  return "component_name_descriptor";
+
708  case 0xA4:
+
709  return "ATSC data_service_descriptor";
+
710  case 0xA5:
+
711  return "ATSC PID Count descriptor";
+
712  case 0xA6:
+
713  return "ATSC Download descriptor";
+
714  case 0xA7:
+
715  return "ATSC Multiprotocol Encapsulation descriptor";
+
716  case 0xA8:
+
717  return "ATSC dcc_departing_request_descriptor";
+
718  case 0xA9:
+
719  return "ATSC dcc_arriving_request_descriptor";
+
720  case 0xAA:
+
721  return "ATSC rc_descriptor";
+
722  case 0xAB:
+
723  return "ATSC Genre descriptor";
+
724  case 0xAC:
+
725  return "SCTE MAC Address List";
+
726  case 0xAD:
+
727  return "ATSC private information descriptor";
+
728  case 0xAE:
+
729  return "ATSC compatibility wrapper descriptor";
+
730  case 0xAF:
+
731  return "ATSC broadcaster policy descriptor";
+
732  case 0xB0:
+
733  return "ATSC service name descriptor";
+
734  case 0xB1:
+
735  return "ATSC URI descriptor";
+
736  case 0xB2:
+
737  return "ATSC enhanced signaling descriptor";
+
738  case 0xB3:
+
739  return "ATSC M/H string mapping descriptor";
+
740  case 0xB4:
+
741  return "ATSC Module Link descriptor";
+
742  case 0xB5:
+
743  return "ATSC CRC32 descriptor";
+
744  case 0xB6:
+
745  return "ATSC Content Identifier Descriptor";
+
746  case 0xB7:
+
747  return "ModuleInfoDescriptor";
+
748  case 0xB8:
+
749  return "ATSC Group Link descriptor";
+
750  case 0xB9:
+
751  return "ATSC Time Stamp descriptor";
+
752  case 0xBA:
+
753  return "ScheduleDescriptor";
+
754  case 0xBB:
+
755  return "Component list descriptor";
+
756  case 0xBC:
+
757  return "ATSC M/H component descriptor";
+
758  case 0xBD:
+
759  return "ATSC M/H rights issuer descriptor";
+
760  case 0xBE:
+
761  return "ATSC M/H current program descriptor";
+
762  case 0xBF:
+
763  return "ATSC M/H original service identification descriptor";
+
764  case 0xC0:
+
765  return "protection_descriptor";
+
766  case 0xC1:
+
767  return "MH_SG_bootstrap_descriptor";
+
768  case 0xC2:
+
769  return "Service ID descriptor";
+
770  case 0xC3:
+
771  return "Protocol Version descriptor";
+
772  case 0xC4:
+
773  return "NRT Service descriptor";
+
774  case 0xC5:
+
775  return "Capabilities descriptor";
+
776  case 0xC6:
+
777  return "Icon descriptor";
+
778  case 0xC7:
+
779  return "Receiver Targeting descriptor";
+
780  case 0xC8:
+
781  return "Time Slot descriptor";
+
782  case 0xC9:
+
783  return "Internet Location Descriptor";
+
784  case 0xCA:
+
785  return "Associated Service descriptor";
+
786  case 0xCB:
+
787  return "Eye Identification Descriptor tag";
+
788  case 0xCC:
+
789  return "E-AC-3 descriptor (A/52 Annex G)";
+
790  case 0xCD:
+
791  return "2D 3D Corresponding Content Descriptor";
+
792  case 0xCE:
+
793  return "Multimedia EPG Linkage Descriptor";
+
794  case 0xE0:
+
795  return "etv_application_information_descriptor()";
+
796  case 0xE1:
+
797  return "etv_media_time_descriptor()";
+
798  case 0xE2:
+
799  return "etv_stream_event_descriptor()";
+
800  case 0xE3:
+
801  return "etv_application_descriptor()";
+
802  case 0xE4:
+
803  return "RBI_signaling_descriptor()";
+
804  case 0xE5:
+
805  return "etv_application_metadata_descriptor()";
+
806  case 0xE6:
+
807  return "etv_bif_platform_descriptor()";
+
808  case 0xE7:
+
809  return "etv_integrated_signaling_descriptor()";
+
810  case 0xE8:
+
811  return "3d_MPEG2_descriptor()";
+
812  case 0XE9:
+
813  return "ebp_descriptor()";
+
814  case 0xEA:
+
815  return "MPEG_AAC_descriptor";
+
816  case 0xEB:
+
817  return "IC3D_event_info_descriptor";
+
818  case 0xEC:
+
819  return "MDTV hybrid stereoscopic service descriptor";
+
820  }
+
821  return "Unknown";
+
822  }
+
823 
+
824  void print_descriptor_info(TSDDescriptor *desc) {
+
825  // print out some interesting descriptor data
+
826  switch (desc->tag) {
+
827  case 0x05: // Registration descriptor
+
828  {
+
829  TSDDescriptorRegistration res;
+
830  if (TSD_OK == tsd_parse_descriptor_registration(
+
831  desc->data, desc->data_length, &res)) {
+
832  LOGD("\n format identififer: 0x%08X", res.format_identifier);
+
833  }
+
834  } break;
+
835  case 0x0A: // ISO 639 Language descriptor
+
836  {
+
837  TSDDescriptorISO639Language res;
+
838  if (TSD_OK == tsd_parse_descriptor_iso639_language(
+
839  desc->data, desc->data_length, &res)) {
+
840  LOGD("\n");
+
841  int i = 0;
+
842  for (; i < res.language_length; ++i) {
+
843  LOGD(" ISO Language Code: 0x%08X, audio type: 0x%02x",
+
844  res.iso_language_code[i], res.audio_type[i]);
+
845  }
+
846  LOGD("\n");
+
847  }
+
848  } break;
+
849  case 0x0E: // Maximum bitrate descriptor
+
850  {
+
851  TSDDescriptorMaxBitrate res;
+
852  if (TSD_OK == tsd_parse_descriptor_max_bitrate(
+
853  desc->data, desc->data_length, &res)) {
+
854  LOGD(" Maximum Bitrate: %d x 50 bytes/second", res.max_bitrate);
+
855  }
+
856  } break;
+
857  default: {
+
858  LOGW(" Unknown Descriptor: 0x%x ", desc->tag);
+
859  } break;
+
860  }
+
861  }
+
862 
+
863  static void* log_malloc (size_t size) {
+
864  void *result = malloc(size);
+
865  LOGI("malloc(%d) -> %p %s\n", (int)size,result, result!=NULL?"OK":"ERROR");
+
866  return result;
+
867  }
+
868 
+
869  static void* log_calloc(size_t num, size_t size){
+
870  void *result = calloc(num, size);
+
871  LOGI("calloc(%d) -> %p %s\n", (int)(num*size),result, result!=NULL?"OK":"ERROR");
+
872  return result;
+
873  }
+
874 
+
875  static void* log_realloc(void *ptr, size_t size){
+
876  void *result = realloc(ptr, size);
+
877  LOGI("realloc(%d) -> %p %s\n", (int)size, result, result!=NULL?"OK":"ERROR");
+
878  return result;
+
879  }
+
880 
+
881  static void log_free (void *mem){
+
882  LOGD("free(%p)\n", mem);
+
883  free(mem);
+
884  }
+
885 
+
886  // // store allocated size in first bytes
+
887  // static void* log_malloc (size_t size) {
+
888  // void *result = malloc(size);
+
889  // memset(result, 0, size);
+
890  // AllocSize entry{result, size};
+
891  // self->alloc_vector.push_back(entry);
+
892  // assert(find_size(result)>=0);
+
893  // LOGI("malloc(%d) -> %p %s\n", (int)size,result, result!=NULL?"OK":"ERROR");
+
894  // return result;
+
895  // }
+
896 
+
897  // static void* log_calloc(size_t num, size_t size){
+
898  // return log_malloc(num*size);
+
899  // }
+
900 
+
901  // static int find_size(void *ptr){
+
902  // for (int j=0;j<self->alloc_vector.size();j++){
+
903  // if (self->alloc_vector[j].data==ptr) return j;
+
904  // }
+
905  // return -1;
+
906  // }
+
907 
+
908  // static void* log_realloc(void *ptr, size_t size){
+
909  // int pos = find_size(ptr);
+
910  // void *result = nullptr;
+
911  // if (pos>=0){
+
912  // result = realloc(ptr, size);
+
913  // // store size in header
+
914  // size_t old_size = self->alloc_vector[pos].size;
+
915  // memset(result+old_size, 0, size-old_size);
+
916  // self->alloc_vector[pos].size = size;
+
917  // } else {
+
918  // LOGE("realloc of unallocatd memory %p", ptr);
+
919  // result = realloc(ptr, size);
+
920  // AllocSize entry{result, size};
+
921  // self->alloc_vector.push_back(entry);
+
922  // assert(find_size(result)>=0);
+
923  // }
+
924 
+
925  // LOGI("realloc(%d) -> %p %s\n", (int)size, result, result!=NULL?"OK":"ERROR");
+
926  // return result;
+
927  // }
+
928 
+
929  // static void log_free (void *mem){
+
930  // LOGD("free(%p)\n", mem);
+
931  // free(mem);
+
932  // int pos = find_size(mem);
+
933  // if (pos>=0){
+
934  // self->alloc_vector.erase(pos);
+
935  // assert(find_size(mem)==-1);
+
936 
+
937  // } else {
+
938  // LOGE("free of unallocatd memory %p", mem);
+
939  // }
+
940  // }
941 
-
942 };
-
943 // init static variable
-
944 MTSDecoder *MTSDecoder::self = nullptr;
-
945 
-
946 } // namespace audio_tools
+
942 
+
943 };
+
944 // init static variable
+
945 MTSDecoder *MTSDecoder::self = nullptr;
+
946 
+
947 } // namespace audio_tools
audio_tools::AudioDecoder
Docoding of encoded audio into PCM data.
Definition: AudioEncoded.h:17
audio_tools::BaseBuffer::writeArray
virtual int writeArray(const T data[], int len)
Fills the buffer data.
Definition: Buffers.h:61
-
audio_tools::MTSDecoder
MPEG-TS (MTS) decoder https://github.com/pschatzmann/arduino-tsdemux.
Definition: CodecMTS.h:47
-
audio_tools::MTSDecoder::resizeBuffer
void resizeBuffer(int size)
Set a new write buffer size (default is 2000)
Definition: CodecMTS.h:142
-
audio_tools::MTSDecoder::setMemoryAllocationLogging
void setMemoryAllocationLogging(bool flag)
Activate logging for memory allocations.
Definition: CodecMTS.h:147
+
audio_tools::MTSDecoder
MPEG-TS (MTS) decoder. Extracts the AAC audio data from a MPEG-TS (MTS) data stream....
Definition: CodecMTS.h:48
+
audio_tools::MTSDecoder::resizeBuffer
void resizeBuffer(int size)
Set a new write buffer size (default is 2000)
Definition: CodecMTS.h:143
+
audio_tools::MTSDecoder::setMemoryAllocationLogging
void setMemoryAllocationLogging(bool flag)
Activate logging for memory allocations.
Definition: CodecMTS.h:148
audio_tools::SingleBuffer::data
T * data()
Provides address of actual data.
Definition: Buffers.h:240
audio_tools::SingleBuffer::available
int available() override
provides the number of entries that are available to read
Definition: Buffers.h:207
audio_tools::SingleBuffer::clearArray
int clearArray(int len) override
consumes len bytes and moves current data to the beginning
Definition: Buffers.h:217
diff --git a/annotated.html b/annotated.html index 9d2a8f2120..0309be921d 100644 --- a/annotated.html +++ b/annotated.html @@ -370,7 +370,7 @@  CMP3EncoderLAMEEncodes PCM data to the MP3 format and writes the result to a stream This is basically just a wrapper using https://github.com/pschatzmann/arduino-liblame  CMP4AtomRepresents a single MPEG4 atom  CMP4ParseBuffer - CMTSDecoderMPEG-TS (MTS) decoder https://github.com/pschatzmann/arduino-tsdemux + CMTSDecoderMPEG-TS (MTS) decoder. Extracts the AAC audio data from a MPEG-TS (MTS) data stream. You can define the relevant stream types via the API. https://github.com/pschatzmann/arduino-tsdemux  CMultiConverterCombines multiple converters  CMultiOutputReplicates the output to multiple destinations  CMusicalNotesDetermination of the frequency of a music note diff --git a/classaudio__tools_1_1_audio_decoder.html b/classaudio__tools_1_1_audio_decoder.html index 3d1db46e80..1322b2c8cd 100644 --- a/classaudio__tools_1_1_audio_decoder.html +++ b/classaudio__tools_1_1_audio_decoder.html @@ -114,7 +114,7 @@ MP3DecoderHelix MP3DecoderMAD MP3DecoderMini -MTSDecoder +MTSDecoder OggContainerDecoder OpusAudioDecoder SBCDecoder diff --git a/classaudio__tools_1_1_audio_info_source.html b/classaudio__tools_1_1_audio_info_source.html index 175c43cc77..3f7660d55c 100644 --- a/classaudio__tools_1_1_audio_info_source.html +++ b/classaudio__tools_1_1_audio_info_source.html @@ -113,7 +113,7 @@ MP3DecoderHelix MP3DecoderMAD MP3DecoderMini -MTSDecoder +MTSDecoder OggContainerDecoder OpusAudioDecoder SBCDecoder diff --git a/classaudio__tools_1_1_audio_writer.html b/classaudio__tools_1_1_audio_writer.html index f10a57496e..96481beefd 100644 --- a/classaudio__tools_1_1_audio_writer.html +++ b/classaudio__tools_1_1_audio_writer.html @@ -113,7 +113,7 @@ MP3DecoderHelix MP3DecoderMAD MP3DecoderMini -MTSDecoder +MTSDecoder OggContainerDecoder OpusAudioDecoder SBCDecoder diff --git a/classaudio__tools_1_1_m_t_s_decoder.html b/classaudio__tools_1_1_m_t_s_decoder.html index a5f553c072..fffff56771 100644 --- a/classaudio__tools_1_1_m_t_s_decoder.html +++ b/classaudio__tools_1_1_m_t_s_decoder.html @@ -77,7 +77,7 @@
-

MPEG-TS (MTS) decoder https://github.com/pschatzmann/arduino-tsdemux. +

MPEG-TS (MTS) decoder. Extracts the AAC audio data from a MPEG-TS (MTS) data stream. You can define the relevant stream types via the API. https://github.com/pschatzmann/arduino-tsdemux. More...

#include <CodecMTS.h>

@@ -261,7 +261,7 @@  

Detailed Description

-

MPEG-TS (MTS) decoder https://github.com/pschatzmann/arduino-tsdemux.

+

MPEG-TS (MTS) decoder. Extracts the AAC audio data from a MPEG-TS (MTS) data stream. You can define the relevant stream types via the API. https://github.com/pschatzmann/arduino-tsdemux.

Author
Phil Schatzmann

The documentation for this class was generated from the following file: