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 14:06:28 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6d4e4d3da2d14e851b92401d8ce51d393a85b519
6d4e4d3d
1 parent
b2fe7fb8
update the ts_info, parse the PES packet
显示空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
296 行增加
和
59 行删除
trunk/research/ts_info.cpp
trunk/research/ts_info.cpp
查看文件 @
6d4e4d3
...
...
@@ -440,15 +440,51 @@ public:
// 1B
u_int8_t
PES_header_data_length
;
//8bits
/**
* logic data.
*/
// generated by PTS_DTS_flags
int64_t
pts
;
// 33bits
int64_t
dts
;
// 33bits
int16_t
ESCR_extension
;
//9bits
int64_t
ESCR_base
;
//33bits
int32_t
ES_rate
;
//22bits
int8_t
trick_mode_control
;
//3bits
int8_t
trick_mode_value
;
//5bits
int8_t
additional_copy_info
;
//7bits
int16_t
previous_PES_packet_CRC
;
//16bits
int8_t
PES_private_data_flag
;
//1bit
int8_t
pack_header_field_flag
;
//1bit
int8_t
program_packet_sequence_counter_flag
;
//1bit
int8_t
P_STD_buffer_flag
;
//1bit
// reserved 3bits
int8_t
PES_extension_flag_2
;
//1bit
// 16B
char
*
PES_private_data
;
//128bits
int8_t
pack_field_length
;
//8bits
char
*
pack_field
;
//[pack_field_length] bytes
int8_t
program_packet_sequence_counter
;
//7bits
int8_t
MPEG1_MPEG2_identifier
;
//1bit
int8_t
original_stuff_length
;
//6bits
int8_t
P_STD_buffer_scale
;
//1bit
int16_t
P_STD_buffer_size
;
//13bits
int8_t
PES_extension_field_length
;
//7bits
char
*
PES_extension_field
;
//[PES_extension_field_length] bytes
int
stuffing_size
;
char
*
stuffing_byte
;
char
*
PES_packet_data_byte
;
//[PES_packet_length] bytes
TSPayloadPES
();
virtual
~
TSPayloadPES
();
int64_t
decode_33bits_int
(
u_int8_t
*&
p
,
int64_t
&
temp
);
int64_t
decode_33bits_int
(
int64_t
&
temp
);
int
demux
(
TSContext
*
ctx
,
TSPacket
*
pkt
,
u_int8_t
*
start
,
u_int8_t
*
last
,
u_int8_t
*&
p
);
};
...
...
@@ -537,10 +573,38 @@ void TSContext::push(TSPidType type, int16_t pid)
TSAdaptionField
::
TSAdaptionField
()
{
adaption_field_length
=
0
;
discontinuity_indicator
=
0
;
random_access_indicator
=
0
;
elementary_stream_priority_indicator
=
0
;
PCR_flag
=
0
;
OPCR_flag
=
0
;
splicing_point_flag
=
0
;
transport_private_data_flag
=
0
;
adaptation_field_extension_flag
=
0
;
program_clock_reference_base
=
0
;
program_clock_reference_extension
=
0
;
original_program_clock_reference_base
=
0
;
original_program_clock_reference_extension
=
0
;
splice_countdown
=
0
;
transport_private_data_length
=
0
;
transport_private_data
=
NULL
;
adaptation_field_extension_length
=
0
;
ltw_flag
=
0
;
piecewise_rate_flag
=
0
;
seamless_splice_flag
=
0
;
ltw_valid_flag
=
0
;
ltw_offset
=
0
;
piecewise_rate
=
0
;
splice_type
=
0
;
DTS_next_AU0
=
0
;
marker_bit0
=
0
;
DTS_next_AU1
=
0
;
marker_bit1
=
0
;
DTS_next_AU2
=
0
;
marker_bit2
=
0
;
af_ext_reserved
=
NULL
;
af_reserved
=
NULL
;
__user_size
=
0
;
}
...
...
@@ -719,7 +783,18 @@ int TSPayloadReserved::demux(TSContext* ctx, TSPacket* pkt, u_int8_t* start, u_i
TSPayloadPAT
::
TSPayloadPAT
()
{
table_id
=
0
;
section_syntax_indicator
=
0
;
const0_value
=
0
;
section_length
=
0
;
transport_stream_id
=
0
;
version_number
=
0
;
current_next_indicator
=
0
;
section_number
=
0
;
last_section_number
=
0
;
program_size
=
0
;
programs
=
NULL
;
CRC_32
=
0
;
}
TSPayloadPAT
::~
TSPayloadPAT
()
...
...
@@ -781,6 +856,8 @@ int TSPayloadPAT::demux(TSContext* ctx, TSPacket* pkt, u_int8_t* start, u_int8_t
TSPMTESInfo
::
TSPMTESInfo
()
{
stream_type
=
0
;
elementary_PID
=
0
;
ES_info_length
=
0
;
ES_info
=
NULL
;
}
...
...
@@ -792,8 +869,19 @@ TSPMTESInfo::~TSPMTESInfo()
TSPayloadPMT
::
TSPayloadPMT
()
{
table_id
=
0
;
section_syntax_indicator
=
0
;
const0_value
=
0
;
section_length
=
0
;
program_number
=
0
;
version_number
=
0
;
current_next_indicator
=
0
;
section_number
=
0
;
last_section_number
=
0
;
PCR_PID
=
0
;
program_info_length
=
0
;
program_info_desc
=
NULL
;
CRC_32
=
0
;
}
TSPayloadPMT
::~
TSPayloadPMT
()
...
...
@@ -904,11 +992,92 @@ int TSPayloadPMT::demux(TSContext* ctx, TSPacket* pkt, u_int8_t* start, u_int8_t
TSPayloadPES
::
TSPayloadPES
()
{
pts
=
dts
=
0
;
packet_start_code_prefix
=
0
;
stream_id
=
0
;
PES_packet_length
=
0
;
PES_scrambling_control
=
0
;
PES_priority
=
0
;
data_alignment_indicator
=
0
;
copyright
=
0
;
original_or_copy
=
0
;
PTS_DTS_flags
=
0
;
ESCR_flag
=
0
;
ES_rate_flag
=
0
;
DSM_trick_mode_flag
=
0
;
additional_copy_info_flag
=
0
;
PES_CRC_flag
=
0
;
PES_extension_flag
=
0
;
PES_header_data_length
=
0
;
pts
=
0
;
dts
=
0
;
ESCR_extension
=
0
;
ESCR_base
=
0
;
ES_rate
=
0
;
trick_mode_control
=
0
;
trick_mode_value
=
0
;
additional_copy_info
=
0
;
previous_PES_packet_CRC
=
0
;
PES_private_data_flag
=
0
;
pack_header_field_flag
=
0
;
program_packet_sequence_counter_flag
=
0
;
P_STD_buffer_flag
=
0
;
PES_extension_flag_2
=
0
;
PES_private_data
=
NULL
;
pack_field_length
=
0
;
pack_field
=
NULL
;
program_packet_sequence_counter
=
0
;
MPEG1_MPEG2_identifier
=
0
;
original_stuff_length
=
0
;
P_STD_buffer_scale
=
0
;
P_STD_buffer_size
=
0
;
PES_extension_field_length
=
0
;
PES_extension_field
=
NULL
;
stuffing_size
=
0
;
stuffing_byte
=
NULL
;
PES_packet_data_byte
=
NULL
;
}
TSPayloadPES
::~
TSPayloadPES
()
{
srs_freepa
(
PES_private_data
);
srs_freepa
(
pack_field
);
srs_freepa
(
PES_extension_field
);
srs_freepa
(
stuffing_byte
);
srs_freepa
(
PES_packet_data_byte
);
}
int64_t
TSPayloadPES
::
decode_33bits_int
(
u_int8_t
*&
p
,
int64_t
&
temp
)
{
char
*
pp
=
(
char
*
)
&
temp
;
pp
[
4
]
=
*
p
++
;
pp
[
3
]
=
*
p
++
;
pp
[
2
]
=
*
p
++
;
pp
[
1
]
=
*
p
++
;
pp
[
0
]
=
*
p
++
;
return
decode_33bits_int
(
temp
);
}
int64_t
TSPayloadPES
::
decode_33bits_int
(
int64_t
&
temp
)
{
int64_t
ret
=
0
;
// marker_bit 1bit
temp
=
temp
>>
1
;
// PTS [14..0] 15bits
ret
|=
temp
&
0x3fff
;
// marker_bit 1bit
temp
=
temp
>>
1
;
// PTS [29..15] 15bits, 15zero, 29-15+1one
ret
|=
temp
&
0x3fff8000
;
// marker_bit 1bit
temp
=
temp
>>
1
;
// PTS [32..30] 3bits
ret
|=
temp
&
0x1c0000000
;
temp
=
temp
>>
33
;
return
ret
;
}
int
TSPayloadPES
::
demux
(
TSContext
*
ctx
,
TSPacket
*
pkt
,
u_int8_t
*
start
,
u_int8_t
*
last
,
u_int8_t
*&
p
)
...
...
@@ -957,36 +1126,28 @@ int TSPayloadPES::demux(TSContext* ctx, TSPacket* pkt, u_int8_t* start, u_int8_t
PES_extension_flag
&=
0x01
;
PES_header_data_length
=
*
p
++
;
u_int8_t
*
pos
=
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
;
if
(
PTS_DTS_flags
==
0x2
)
{
pts
=
decode_33bits_int
(
p
,
temp
);
// '0010' 4bits
//int8_t const4bits =
(temp >> 32)
& 0x0F;
//int8_t const4bits =
temp
& 0x0F;
}
if
(
PTS_DTS_flags
==
0x3
)
{
int64_t
temp
=
0
;
pts
=
decode_33bits_int
(
p
,
temp
);
// '0011' 4bits
//int8_t const4bits = temp & 0x0F;
dts
=
decode_33bits_int
(
p
,
temp
);
// '0001' 4bits
//int8_t const4bits = temp & 0x0F;
}
if
(
ESCR_flag
)
{
pp
=
(
char
*
)
&
temp
;
pp
[
5
]
=
*
p
++
;
pp
[
4
]
=
*
p
++
;
pp
[
3
]
=
*
p
++
;
pp
[
2
]
=
*
p
++
;
...
...
@@ -995,44 +1156,111 @@ int TSPayloadPES::demux(TSContext* ctx, TSPacket* pkt, u_int8_t* start, u_int8_t
// 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;
// ESCR_extension 9bits
ESCR_extension
=
temp
&
0x1f
;
temp
=
temp
>>
9
;
pp
=
(
char
*
)
&
temp
;
pp
[
4
]
=
*
p
++
;
pp
[
3
]
=
*
p
++
;
ESCR_base
=
decode_33bits_int
(
temp
);
// reserved 2bits
//int8_t reserved2bits = temp & 0x03;
}
if
(
ES_rate_flag
)
{
pp
=
(
char
*
)
&
ES_rate
;
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;
ES_rate
=
ES_rate
>>
1
;
ES_rate
&=
0x3FFFFF
;
}
if
(
ESCR_flag
)
{
if
(
DSM_trick_mode_flag
)
{
trick_mode_control
=
*
p
++
;
trick_mode_value
=
trick_mode_control
&
0x1f
;
trick_mode_control
=
(
trick_mode_control
>>
5
)
&
0x03
;
}
if
(
additional_copy_info_flag
)
{
additional_copy_info
=
*
p
++
;
additional_copy_info
&=
0x7f
;
}
if
(
PES_CRC_flag
)
{
pp
=
(
char
*
)
&
previous_PES_packet_CRC
;
pp
[
1
]
=
*
p
++
;
pp
[
0
]
=
*
p
++
;
}
if
(
PES_extension_flag
)
{
PES_extension_flag_2
=
*
p
++
;
PES_private_data_flag
=
(
PES_extension_flag_2
>>
7
)
&
0x01
;
pack_header_field_flag
=
(
PES_extension_flag_2
>>
6
)
&
0x01
;
program_packet_sequence_counter_flag
=
(
PES_extension_flag_2
>>
5
)
&
0x01
;
P_STD_buffer_flag
=
(
PES_extension_flag_2
>>
4
)
&
0x01
;
PES_extension_flag_2
&=
PES_extension_flag_2
&
0x01
;
if
(
PES_private_data_flag
)
{
PES_private_data
=
new
char
[
16
];
memcpy
(
PES_private_data
,
p
,
16
);
p
+=
16
;
}
if
(
pack_header_field_flag
)
{
pack_field_length
=
*
p
++
;
if
(
pack_field_length
>
0
)
{
pack_field
=
new
char
[
pack_field_length
];
memcpy
(
pack_field
,
p
,
pack_field_length
);
p
+=
pack_field_length
;
}
}
if
(
program_packet_sequence_counter_flag
)
{
program_packet_sequence_counter
=
*
p
++
;
program_packet_sequence_counter
&=
0x7f
;
original_stuff_length
=
*
p
++
;
MPEG1_MPEG2_identifier
=
(
original_stuff_length
>>
6
)
&
0x01
;
original_stuff_length
&=
0x3f
;
}
if
(
P_STD_buffer_flag
)
{
pp
=
(
char
*
)
&
P_STD_buffer_size
;
pp
[
1
]
=
*
p
++
;
pp
[
0
]
=
*
p
++
;
// '01'
//int8_t const2bits = (P_STD_buffer_scale >>14) & 0x03;
P_STD_buffer_scale
=
(
P_STD_buffer_scale
>>
13
)
&
0x01
;
P_STD_buffer_size
&=
0x1FFF
;
}
if
(
PES_extension_flag_2
)
{
PES_extension_field_length
=
*
p
++
;
PES_extension_field_length
&=
0x07
;
if
(
PES_extension_field_length
>
0
)
{
PES_extension_field
=
new
char
[
PES_extension_field_length
];
memcpy
(
PES_extension_field
,
p
,
PES_extension_field_length
);
p
+=
PES_extension_field_length
;
}
}
}
// stuffing_byte
int
stuffing_size
=
PES_header_data_length
-
(
p
-
pos
);
if
(
stuffing_size
>
0
)
{
stuffing_byte
=
new
char
[
stuffing_size
];
memcpy
(
stuffing_byte
,
p
,
stuffing_size
);
p
+=
stuffing_size
;
}
// PES_packet_data_byte
PES_packet_data_byte
=
new
char
[
PES_packet_length
];
}
else
if
(
stream_id
==
PES_program_stream_map
||
stream_id
==
PES_private_stream_2
||
stream_id
==
PES_ECM_stream
...
...
@@ -1064,12 +1292,13 @@ TSPayload::TSPayload()
{
size
=
0
;
pointer_field_size
=
0
;
type
=
TSPidTypeReserved
;
pointer_field
=
0
;
reserved
=
NULL
;
pat
=
NULL
;
pmt
=
NULL
;
pes
=
NULL
;
}
TSPayload
::~
TSPayload
()
...
...
@@ -1179,6 +1408,14 @@ int TSPacket::finish()
TSHeader
::
TSHeader
()
{
sync_byte
=
0
;
transport_error_indicator
=
0
;
payload_unit_start_indicator
=
0
;
transport_priority
=
0
;
pid
=
0
;
transport_scrambling_control
=
0
;
adaption_field_control
=
0
;
continuity_counter
=
0
;
}
TSHeader
::~
TSHeader
()
...
...
请
注册
或
登录
后发表评论