Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2013-11-19 11:06:28 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b2fe7fb8a18d962e815f67b94c431c804d90e751
b2fe7fb8
1 parent
a47a53f2
update ts_info, parse the PES packet dts/pts.
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
198 行增加
和
0 行删除
trunk/research/ts_info.cpp
trunk/research/ts_info.cpp
查看文件 @
b2fe7fb
...
...
@@ -2,6 +2,12 @@
g++ -o ts_info ts_info.cpp -g -O0 -ansi
*/
#if 1
// for int64_t print using PRId64 format.
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
...
...
@@ -361,6 +367,45 @@ public:
int
demux
(
TSContext
*
ctx
,
TSPacket
*
pkt
,
u_int8_t
*
start
,
u_int8_t
*
last
,
u_int8_t
*&
p
);
};
/**
* Table 2-18 – Stream_id assignments. page 52.
*/
enum
TSPESStreamId
{
PES_program_stream_map
=
0
b10111100
,
PES_private_stream_1
=
0
b10111101
,
PES_padding_stream
=
0
b10111110
,
PES_private_stream_2
=
0
b10111111
,
// 110x xxxx
// ISO/IEC 13818-3 or ISO/IEC 11172-3 or ISO/IEC 13818-7 or ISO/IEC
// 14496-3 audio stream number x xxxx
// (stream_id>>5)&0x07 == PES_audio_prefix
PES_audio_prefix
=
0
b110
,
// 1110 xxxx
// ITU-T Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 11172-2 or ISO/IEC
// 14496-2 video stream number xxxx
// (stream_id>>5)&0x07 == PES_audio_prefix
PES_video_prefix
=
0
b1110
,
PES_ECM_stream
=
0
b11110000
,
PES_EMM_stream
=
0
b11110001
,
PES_DSMCC_stream
=
0
b11110010
,
PES_13522_stream
=
0
b11110011
,
PES_H_222_1_type_A
=
0
b11110100
,
PES_H_222_1_type_B
=
0
b11110101
,
PES_H_222_1_type_C
=
0
b11110110
,
PES_H_222_1_type_D
=
0
b11110111
,
PES_H_222_1_type_E
=
0
b11111000
,
PES_ancillary_stream
=
0
b11111001
,
PES_SL_packetized_stream
=
0
b11111010
,
PES_FlexMux_stream
=
0
b11111011
,
// reserved data stream
// 1111 1100 … 1111 1110
PES_program_stream_directory
=
0
b11111111
,
};
/**
* 2.4.3.7 Semantic definition of fields in PES packet. page 49.
...
...
@@ -374,6 +419,33 @@ public:
u_int8_t
stream_id
;
//8bits
// 2B
u_int16_t
PES_packet_length
;
//16bits
// 1B
// 2bits const '10'
int8_t
PES_scrambling_control
;
//2bits
int8_t
PES_priority
;
//1bit
int8_t
data_alignment_indicator
;
//1bit
int8_t
copyright
;
//1bit
int8_t
original_or_copy
;
//1bit
// 1B
int8_t
PTS_DTS_flags
;
//2bits
int8_t
ESCR_flag
;
//1bit
int8_t
ES_rate_flag
;
//1bit
int8_t
DSM_trick_mode_flag
;
//1bit
int8_t
additional_copy_info_flag
;
//1bit
int8_t
PES_CRC_flag
;
//1bit
int8_t
PES_extension_flag
;
//1bit
// 1B
u_int8_t
PES_header_data_length
;
//8bits
/**
* logic data.
*/
// generated by PTS_DTS_flags
int64_t
pts
;
// 33bits
int64_t
dts
;
// 33bits
TSPayloadPES
();
virtual
~
TSPayloadPES
();
...
...
@@ -832,6 +904,7 @@ int TSPayloadPMT::demux(TSContext* ctx, TSPacket* pkt, u_int8_t* start, u_int8_t
TSPayloadPES
::
TSPayloadPES
()
{
pts
=
dts
=
0
;
}
TSPayloadPES
::~
TSPayloadPES
()
...
...
@@ -854,6 +927,131 @@ int TSPayloadPES::demux(TSContext* ctx, TSPacket* pkt, u_int8_t* start, u_int8_t
pp
=
(
char
*
)
&
PES_packet_length
;
pp
[
1
]
=
*
p
++
;
pp
[
0
]
=
*
p
++
;
if
(
stream_id
!=
PES_program_stream_map
&&
stream_id
!=
PES_padding_stream
&&
stream_id
!=
PES_private_stream_2
&&
stream_id
!=
PES_ECM_stream
&&
stream_id
!=
PES_EMM_stream
&&
stream_id
!=
PES_program_stream_directory
&&
stream_id
!=
PES_DSMCC_stream
&&
stream_id
!=
PES_H_222_1_type_E
)
{
original_or_copy
=
*
p
++
;
//int8_t const2bits = (original_or_copy >> 6) & 0x03;
PES_scrambling_control
=
(
original_or_copy
>>
4
)
&
0x03
;
PES_priority
=
(
original_or_copy
>>
3
)
&
0x01
;
data_alignment_indicator
=
(
original_or_copy
>>
2
)
&
0x01
;
copyright
=
(
original_or_copy
>>
1
)
&
0x01
;
original_or_copy
&=
0x01
;
PES_extension_flag
=
*
p
++
;
PTS_DTS_flags
=
(
PES_extension_flag
>>
6
)
&
0x03
;
ESCR_flag
=
(
PES_extension_flag
>>
5
)
&
0x01
;
ES_rate_flag
=
(
PES_extension_flag
>>
4
)
&
0x01
;
DSM_trick_mode_flag
=
(
PES_extension_flag
>>
3
)
&
0x01
;
additional_copy_info_flag
=
(
PES_extension_flag
>>
2
)
&
0x01
;
PES_CRC_flag
=
(
PES_extension_flag
>>
1
)
&
0x01
;
PES_extension_flag
&=
0x01
;
PES_header_data_length
=
*
p
++
;
if
(
PTS_DTS_flags
==
0x2
)
{
int64_t
temp
=
0
;
pp
=
(
char
*
)
&
temp
;
pp
[
4
]
=
*
p
++
;
pp
[
3
]
=
*
p
++
;
pp
[
2
]
=
*
p
++
;
pp
[
1
]
=
*
p
++
;
pp
[
0
]
=
*
p
++
;
// marker_bit 1bit
temp
=
temp
>>
1
;
// PTS [14..0] 15bits
pts
|=
temp
&
0x3FFF
;
// marker_bit 1bit
temp
=
temp
>>
1
;
// PTS [29..15] 15bits
pts
|=
temp
&
0x3fff8000
;
// marker_bit 1bit
temp
=
temp
>>
1
;
// PTS [32..30] 3bits
pts
|=
temp
&
0x1c0000000
;
// '0010' 4bits
//int8_t const4bits = (temp >> 32) & 0x0F;
}
if
(
PTS_DTS_flags
==
0x3
)
{
int64_t
temp
=
0
;
pp
=
(
char
*
)
&
temp
;
pp
[
4
]
=
*
p
++
;
pp
[
3
]
=
*
p
++
;
pp
[
2
]
=
*
p
++
;
pp
[
1
]
=
*
p
++
;
pp
[
0
]
=
*
p
++
;
// marker_bit 1bit
temp
=
temp
>>
1
;
// PTS [14..0] 15bits
pts
|=
temp
&
0x3FFF
;
// marker_bit 1bit
temp
=
temp
>>
1
;
// PTS [29..15] 15bits
pts
|=
temp
&
0x3fff8000
;
// marker_bit 1bit
temp
=
temp
>>
1
;
// PTS [32..30] 3bits
pts
|=
temp
&
0x1c0000000
;
// '0010' 4bits
//int8_t const4bits = (temp >> 32) & 0x0F;
pp
=
(
char
*
)
&
temp
;
pp
[
4
]
=
*
p
++
;
pp
[
3
]
=
*
p
++
;
pp
[
2
]
=
*
p
++
;
pp
[
1
]
=
*
p
++
;
pp
[
0
]
=
*
p
++
;
// marker_bit 1bit
temp
=
temp
>>
1
;
// PTS [14..0] 15bits
dts
|=
temp
&
0x3FFF
;
// marker_bit 1bit
temp
=
temp
>>
1
;
// PTS [29..15] 15bits
dts
|=
temp
&
0x3fff8000
;
// marker_bit 1bit
temp
=
temp
>>
1
;
// PTS [32..30] 3bits
dts
|=
temp
&
0x1c0000000
;
// '0010' 4bits
//int8_t const4bits = (temp >> 32) & 0x0F;
}
if
(
ESCR_flag
)
{
}
}
else
if
(
stream_id
==
PES_program_stream_map
||
stream_id
==
PES_private_stream_2
||
stream_id
==
PES_ECM_stream
||
stream_id
==
PES_EMM_stream
||
stream_id
==
PES_program_stream_directory
||
stream_id
==
PES_DSMCC_stream
||
stream_id
==
PES_H_222_1_type_E
)
{
// for (i = 0; i < PES_packet_length; i++) {
// PES_packet_data_byte
// }
}
else
if
(
stream_id
!=
PES_padding_stream
)
{
// for (i = 0; i < PES_packet_length; i++) {
// padding_byte
// }
}
trace
(
"ts+pes stream_id: %d size: %d pts: %"
PRId64
" dts: %"
PRId64
""
,
stream_id
,
PES_packet_length
,
pts
,
dts
);
return
ret
;
}
...
...
请
注册
或
登录
后发表评论