Skip to content

Commit 9f19544

Browse files
author
印体亮
committed
1. add stream_type hevc & cvs.
2. add some explicit type conversion to satisfy MS VC compile.
1 parent 88e4dbf commit 9f19544

File tree

3 files changed

+40
-17
lines changed

3 files changed

+40
-17
lines changed

examples/tsinfo.c

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ const char* descriptor_tag_to_str(uint8_t tag);
2121
void print_descriptor_info(TSDDescriptor *desc);
2222

2323
int main(int argc, char **charv) {
24+
FILE *file_input = NULL;
25+
if (argc < 2)
26+
{
27+
printf("not enough params\n");
28+
return -10;
29+
}
30+
31+
file_input = fopen(charv[1], "rb");
32+
if (!file_input)
33+
{
34+
printf("failed to open file %s\n", charv[1]);
35+
return -20;
36+
}
37+
2438
// create a demuxing context.
2539
TSDemuxContext ctx;
2640
// set default values onto the context.
@@ -44,7 +58,7 @@ int main(int argc, char **charv) {
4458
// at the end of the do loop, we write back any remainder bytes into
4559
// the buffer, this is why we write into the buffer at the location
4660
// &buffer[count - parsed].
47-
count = fread(&buffer[count - parsed], 1, 1880 - (count - parsed), stdin);
61+
count = fread(&buffer[count - parsed], 1, 1880 - (count - parsed), file_input);
4862

4963
if(count > 0) {
5064
// with res, we could report any errors found during demuxing
@@ -69,6 +83,9 @@ int main(int argc, char **charv) {
6983
// destroy context
7084
tsd_context_destroy(&ctx);
7185

86+
if (file_input)
87+
fclose(file_input);
88+
7289
return 0;
7390
}
7491

@@ -138,7 +155,7 @@ void print_pmt(TSDemuxContext *ctx, void *data) {
138155
for(i=0;i<pmt->program_elements_length; ++i) {
139156
TSDProgramElement *prog = &pmt->program_elements[i];
140157
printf(" -----\nProgram #%d\n", i);
141-
printf(" stream type: (0x%04X) %s\n", prog->stream_type, stream_type_to_str(prog->stream_type));
158+
printf(" stream type: (0x%04X) %s\n", prog->stream_type, stream_type_to_str(TSDPESStreamId(prog->stream_type)));
142159
printf(" elementary pid: 0x%04X\n", prog->elementary_pid);
143160
printf(" es info length: %d\n", prog->es_info_length);
144161
printf(" descriptors length: %d\n", prog->descriptors_length);
@@ -166,20 +183,20 @@ void print_pmt(TSDemuxContext *ctx, void *data) {
166183
}
167184

168185
const char* stream_type_to_str(TSDPESStreamId stream_id) {
169-
if(stream_id >= 0x1C && stream_id <= 0x7F) {
170-
stream_id = 0x1C;
186+
if(stream_id >= 0x1C && stream_id <= 0x7F && stream_id != 0x24 && stream_id != 0x42) {
187+
stream_id = (TSDPESStreamId)0x1C;
171188
}else if(stream_id >= 0x8A && stream_id <= 0x8F) {
172-
stream_id = 0x8A;
189+
stream_id = (TSDPESStreamId)0x8A;
173190
}else if(stream_id >= 0x93 && stream_id <= 0x94) {
174-
stream_id = 0x93;
191+
stream_id = (TSDPESStreamId)0x93;
175192
}else if(stream_id >= 0x96 && stream_id <= 0x9F) {
176-
stream_id = 0x96;
193+
stream_id = (TSDPESStreamId)0x96;
177194
}else if(stream_id >= 0xA1 && stream_id <= 0xBF ){
178-
stream_id = 0xA1;
195+
stream_id = (TSDPESStreamId)0xA1;
179196
}else if(stream_id >= 0xC4 && stream_id <= 0xE9 ){
180-
stream_id = 0xC4;
197+
stream_id = (TSDPESStreamId)0xC4;
181198
}else if(stream_id >= 0xEB && stream_id <= 0xFF ){
182-
stream_id = 0xEB;
199+
stream_id = (TSDPESStreamId)0xEB;
183200
}
184201

185202
switch(stream_id) {
@@ -212,6 +229,8 @@ const char* stream_type_to_str(TSDPESStreamId stream_id) {
212229
case 0x1A : return "IPMP stream (defined in ISO/IEC 13818-11, MPEG-2 IPMP)";
213230
case 0X1B : return "AVC video stream as defined in ITU-T Rec. H.264 | ISO/IEC 14496-10 Video";
214231
case 0x1C : return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved";
232+
case 0x24 : return "ITU-T Rec. H.265 and ISO/IEC 23008-2 (Ultra HD video) in a packetized stream";
233+
case 0x42 : return "Chinese Video Standard in a packetized stream";
215234
case 0x80 : return "DigiCipher® II video | Identical to ITU-T Rec. H.262 | ISO/IEC 13818-2 Video";
216235
case 0x81 : return "ATSC A/53 audio [2] | AC-3 audio";
217236
case 0x82 : return "SCTE Standard Subtitle";

src/tsdemux.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ TSDCode tsd_parse_packet_header(TSDemuxContext *ctx,
150150
hdr->pid = parse_u16(ptr) & 0x1FFF;
151151
ptr+=2;
152152

153-
hdr->transport_scrambling_control = ((*ptr) >> 6) & 0x03;
154-
hdr->adaptation_field_control = ((*ptr) >> 4) & 0x03;
153+
hdr->transport_scrambling_control = (TSDScramblingControl)(((*ptr) >> 6) & 0x03);
154+
hdr->adaptation_field_control = (TSDAdaptionFieldControl)(((*ptr) >> 4) & 0x03);
155155
hdr->continuity_counter = (*ptr) & 0x0F;
156156
ptr++;
157157

@@ -816,7 +816,7 @@ TSDCode tsd_parse_pes(TSDemuxContext *ctx,
816816
} else {
817817
uint8_t value = *ptr;
818818
ptr++;
819-
pes->scrambling_control = (value & 0x30) >> 6;
819+
pes->scrambling_control = (TSDPESScramblingControl)((value & 0x30) >> 6);
820820
pes->flags = ((value & 0x0F) << 8) | *ptr;
821821
ptr++;
822822
pes->header_data_length = *ptr;
@@ -849,7 +849,7 @@ TSDCode tsd_parse_pes(TSDemuxContext *ctx,
849849
ptr = &ptr[3];
850850
}
851851
if(pes->flags & TSD_PPF_DSM_TRICK_MODE_FLAG) {
852-
pes->trick_mode.control = ((*ptr) >> 5) & 0x07;
852+
pes->trick_mode.control = (TSDTrickModeControl)(((*ptr) >> 5) & 0x07);
853853
if(pes->trick_mode.control == TSD_TMC_FAST_FORWARD ||
854854
pes->trick_mode.control == TSD_TMC_FAST_REVERSE) {
855855
pes->trick_mode.field_id = ((*ptr) >> 3) & 0x03;
@@ -1164,7 +1164,7 @@ TSDCode tsd_table_data_extract(TSDemuxContext *ctx,
11641164
}
11651165

11661166
*size = written;
1167-
*mem = block;
1167+
*mem = (uint8_t *)block;
11681168

11691169
// reset the block of data
11701170
tsd_data_context_reset(ctx, data);
@@ -1415,6 +1415,8 @@ TSDCode demux_adaptation_field_prv_data(TSDemuxContext *ctx, TSDPacket *hdr, int
14151415
hdr->pid,
14161416
TSD_EVENT_ADAP_FIELD_PRV_DATA,
14171417
&hdr->adaptation_field);
1418+
1419+
return TSD_OK;
14181420
}
14191421

14201422
size_t tsd_demux(TSDemuxContext *ctx,
@@ -1503,7 +1505,7 @@ size_t tsd_demux(TSDemuxContext *ctx,
15031505
}
15041506
}
15051507

1506-
// if this isn't a PMT PID, check to usee if the user has registerd it
1508+
// if this isn't a PMT PID, check to see if the user has registerd it
15071509
if(parsed == 0) {
15081510
size_t i;
15091511
for(i=0; i < ctx->registered_pids_length; ++i) {
@@ -1620,7 +1622,7 @@ TSDCode tsd_parse_descriptor_video_stream(const uint8_t *data,
16201622
desc->length = ptr[1];
16211623
desc->frame_rate_code = (ptr[2] >> 3) & 0x0F;
16221624
desc->flags = ptr[2] & 0x87;
1623-
if(desc-> flags & TSD_DFVS_MPEG_1_ONLY == 0) {
1625+
if((desc-> flags & TSD_DFVS_MPEG_1_ONLY) == 0) {
16241626
desc->profile_and_level_indication = ptr[3];
16251627
desc->chroma_format = (ptr[4] >> 6) & 0x03;
16261628
desc->flags |= (ptr[4] & 0x20);

src/tsdemux.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ typedef enum TSDPIDValue {
150150
TSD_PID_TSDT = 0x0002,
151151
/** MPEG-2 Systems Reserved **/
152152
TSD_PID_RESERVED_MPEG2 = 0x000F,
153+
/** SDT Service Information (of DVB) **/
154+
TSD_PID_SDT = 0x0011,
153155
/** DVB Service Information **/
154156
TSD_PID_RESERVED_DVB_SI = 0x001F,
155157
/** ARIB Service Information **/

0 commit comments

Comments
 (0)