winlin

add ts_info.cpp for HLS research

  1 +/**
  2 +g++ -o ts_info ts_info.cpp -g -O0 -ansi
  3 +*/
  4 +#include <sys/types.h>
  5 +#include <sys/stat.h>
  6 +#include <fcntl.h>
  7 +#include <unistd.h>
  8 +#include <stdio.h>
  9 +#include <string.h>
  10 +
  11 +/**
  12 +ISO/IEC 13818-1:2000(E)
  13 +Introduction
  14 +SECTION 1 ¨C GENERAL
  15 +SECTION 2 ¨C TECHNICAL ELEMENTS
  16 + 2.4 Transport Stream bitstream requirements
  17 + 2.5 Program Stream bitstream requirements
  18 + 2.6 Program and program element descriptors
  19 + 2.7 Restrictions on the multiplexed stream semantics
  20 +Annex A ¨C CRC Decoder Model
  21 +*/
  22 +
  23 +#define trace(msg, ...) printf(msg"\n", ##__VA_ARGS__);
  24 +
  25 +int main(int /*argc*/, char** /*argv*/)
  26 +{
  27 + const char* file = "livestream-1347.ts";
  28 + int fd = open(file, O_RDONLY);
  29 +
  30 + trace("demuxer+read packet count offset P+0 P+1 P+2 P+x P+L2 P+L1 P+L0");
  31 + for (int i = 0, offset = 0; ; i++) {
  32 + unsigned char PES[188];
  33 + memset(PES, 0, sizeof(PES));
  34 +
  35 + int ret = read(fd, PES, sizeof(PES));
  36 + if (ret == 0) {
  37 + trace("demuxer+read EOF, read completed, offset: %07d.", offset);
  38 + break;
  39 + }
  40 + trace("demuxer+read packet %04d %07d 0x%02x 0x%02x 0x%02x ... 0x%02x 0x%02x 0x%02x",
  41 + i, offset, PES[0], PES[1], PES[2], PES[185], PES[186], PES[187]);
  42 +
  43 +
  44 + offset += ret;
  45 + }
  46 +
  47 + close(fd);
  48 + return 0;
  49 +}
  50 +