mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Fix RBSP issue, where 0x03 should be removed. v5.0.178 v6.0.75 (#3597)
ISO_IEC_14496-10-AVC-2012.pdf, page 65 7.4.1.1 Encapsulation of an SODB within an RBSP (informative) ... 00 00 03 xx, the 03 byte should be drop where xx represents any 2 bit pattern: 00, 01, 10, or 11. --------- Co-authored-by: john <hondaxiao@tencent.com> Co-authored-by: chundonglinlin <chundonglinlin@163.com> Co-authored-by: winlin <winlin@vip.126.com>
This commit is contained in:
parent
6f42ca67cb
commit
add0f369c5
9 changed files with 339 additions and 86 deletions
|
@ -1328,7 +1328,6 @@ vhost stream.control.com {
|
||||||
vhost publish.srs.com {
|
vhost publish.srs.com {
|
||||||
# the config for FMLE/Flash publisher, which push RTMP to SRS.
|
# the config for FMLE/Flash publisher, which push RTMP to SRS.
|
||||||
publish {
|
publish {
|
||||||
# about MR, read https://github.com/ossrs/srs/issues/241
|
|
||||||
# when enabled the mr, SRS will read as large as possible.
|
# when enabled the mr, SRS will read as large as possible.
|
||||||
# Overwrite by env SRS_VHOST_PUBLISH_MR for all vhosts.
|
# Overwrite by env SRS_VHOST_PUBLISH_MR for all vhosts.
|
||||||
# default: off
|
# default: off
|
||||||
|
@ -1401,7 +1400,6 @@ vhost refer.anti_suck.com {
|
||||||
# the security to allow or deny clients.
|
# the security to allow or deny clients.
|
||||||
vhost security.srs.com {
|
vhost security.srs.com {
|
||||||
# security for host to allow or deny clients.
|
# security for host to allow or deny clients.
|
||||||
# @see https://github.com/ossrs/srs/issues/211
|
|
||||||
security {
|
security {
|
||||||
# whether enable the security for vhost.
|
# whether enable the security for vhost.
|
||||||
# default: off
|
# default: off
|
||||||
|
@ -1781,7 +1779,6 @@ vhost hls.srs.com {
|
||||||
# the hls m3u8 target duration ratio,
|
# the hls m3u8 target duration ratio,
|
||||||
# EXT-X-TARGETDURATION = hls_td_ratio * hls_fragment // init
|
# EXT-X-TARGETDURATION = hls_td_ratio * hls_fragment // init
|
||||||
# EXT-X-TARGETDURATION = max(ts_duration, EXT-X-TARGETDURATION) // for each ts
|
# EXT-X-TARGETDURATION = max(ts_duration, EXT-X-TARGETDURATION) // for each ts
|
||||||
# @see https://github.com/ossrs/srs/issues/304#issuecomment-74000081
|
|
||||||
# Overwrite by env SRS_VHOST_HLS_HLS_TD_RATIO for all vhosts.
|
# Overwrite by env SRS_VHOST_HLS_HLS_TD_RATIO for all vhosts.
|
||||||
# default: 1.5
|
# default: 1.5
|
||||||
hls_td_ratio 1.5;
|
hls_td_ratio 1.5;
|
||||||
|
@ -1800,7 +1797,6 @@ vhost hls.srs.com {
|
||||||
# ignore, disable the hls.
|
# ignore, disable the hls.
|
||||||
# disconnect, require encoder republish.
|
# disconnect, require encoder republish.
|
||||||
# continue, ignore failed try to continue output hls.
|
# continue, ignore failed try to continue output hls.
|
||||||
# @see https://github.com/ossrs/srs/issues/264
|
|
||||||
# Overwrite by env SRS_VHOST_HLS_HLS_ON_ERROR for all vhosts.
|
# Overwrite by env SRS_VHOST_HLS_HLS_ON_ERROR for all vhosts.
|
||||||
# default: continue
|
# default: continue
|
||||||
hls_on_error continue;
|
hls_on_error continue;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# security config for srs, allow play and deny publish.
|
# security config for srs, allow play and deny publish.
|
||||||
# @see https://github.com/ossrs/srs/issues/211#issuecomment-68507035
|
|
||||||
# @see full.conf for detail config.
|
# @see full.conf for detail config.
|
||||||
|
|
||||||
listen 1935;
|
listen 1935;
|
||||||
|
|
|
@ -7,6 +7,7 @@ The changelog for SRS.
|
||||||
<a name="v6-changes"></a>
|
<a name="v6-changes"></a>
|
||||||
|
|
||||||
## SRS 6.0 Changelog
|
## SRS 6.0 Changelog
|
||||||
|
* v6.0, 2023-09-08, Merge [#3597](https://github.com/ossrs/srs/pull/3597): Fix RBSP stream parsing bug, should drop 0x03. v6.0.75 (#3597)
|
||||||
* v6.0, 2023-09-08, Merge [#3794](https://github.com/ossrs/srs/pull/3794): Support SRS Stack token for authentication. v6.0.74 (#3794)
|
* v6.0, 2023-09-08, Merge [#3794](https://github.com/ossrs/srs/pull/3794): Support SRS Stack token for authentication. v6.0.74 (#3794)
|
||||||
* v6.0, 2023-09-07, Merge [#3795](https://github.com/ossrs/srs/pull/3795): Fix dash crash if format not supported. v6.0.73 (#3795)
|
* v6.0, 2023-09-07, Merge [#3795](https://github.com/ossrs/srs/pull/3795): Fix dash crash if format not supported. v6.0.73 (#3795)
|
||||||
* v6.0, 2023-08-30, Merge [#3776](https://github.com/ossrs/srs/pull/3776): Compile: Add aarch64 to the conditions of use of the cbrt function. v6.0.72 (#3776)
|
* v6.0, 2023-08-30, Merge [#3776](https://github.com/ossrs/srs/pull/3776): Compile: Add aarch64 to the conditions of use of the cbrt function. v6.0.72 (#3776)
|
||||||
|
@ -86,6 +87,7 @@ The changelog for SRS.
|
||||||
<a name="v5-changes"></a>
|
<a name="v5-changes"></a>
|
||||||
|
|
||||||
## SRS 5.0 Changelog
|
## SRS 5.0 Changelog
|
||||||
|
* v5.0, 2023-09-08, Merge [#3597](https://github.com/ossrs/srs/pull/3597): Fix RBSP stream parsing bug, should drop 0x03. v5.0.178 (#3597)
|
||||||
* v5.0, 2023-09-07, Merge [#3795](https://github.com/ossrs/srs/pull/3795): Fix dash crash if format not supported. v5.0.177 (#3795)
|
* v5.0, 2023-09-07, Merge [#3795](https://github.com/ossrs/srs/pull/3795): Fix dash crash if format not supported. v5.0.177 (#3795)
|
||||||
* v5.0, 2023-08-30, Merge [#3779](https://github.com/ossrs/srs/pull/3779): Support HTTP-API for fetching reload result. v5.0.176 (#3779)
|
* v5.0, 2023-08-30, Merge [#3779](https://github.com/ossrs/srs/pull/3779): Support HTTP-API for fetching reload result. v5.0.176 (#3779)
|
||||||
* v5.0, 2023-08-28, Merge [#3503](https://github.com/ossrs/srs/pull/3503): SrsContextId assignment can be improved without create a duplicated one. v5.0.175 (#3503)
|
* v5.0, 2023-08-28, Merge [#3503](https://github.com/ossrs/srs/pull/3503): SrsContextId assignment can be improved without create a duplicated one. v5.0.175 (#3503)
|
||||||
|
|
|
@ -9,6 +9,6 @@
|
||||||
|
|
||||||
#define VERSION_MAJOR 5
|
#define VERSION_MAJOR 5
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 177
|
#define VERSION_REVISION 178
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,6 +9,6 @@
|
||||||
|
|
||||||
#define VERSION_MAJOR 6
|
#define VERSION_MAJOR 6
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 74
|
#define VERSION_REVISION 75
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -867,6 +867,44 @@ bool SrsFormat::is_avc_sequence_header()
|
||||||
&& video && video->avc_packet_type == SrsVideoAvcFrameTraitSequenceHeader;
|
&& video && video->avc_packet_type == SrsVideoAvcFrameTraitSequenceHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove the emulation bytes from stream, and return num of bytes of the rbsp.
|
||||||
|
int srs_rbsp_remove_emulation_bytes(SrsBuffer* stream, std::vector<uint8_t>& rbsp)
|
||||||
|
{
|
||||||
|
int nb_rbsp = 0;
|
||||||
|
while (!stream->empty()) {
|
||||||
|
rbsp[nb_rbsp] = stream->read_1bytes();
|
||||||
|
|
||||||
|
// .. 00 00 03 xx, the 03 byte should be drop where xx represents any
|
||||||
|
// 2 bit pattern: 00, 01, 10, or 11.
|
||||||
|
if (nb_rbsp >= 2 && rbsp[nb_rbsp - 2] == 0 && rbsp[nb_rbsp - 1] == 0 && rbsp[nb_rbsp] == 3) {
|
||||||
|
// read 1byte more.
|
||||||
|
if (stream->empty()) {
|
||||||
|
nb_rbsp++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// |---------------------|----------------------------|
|
||||||
|
// | rbsp | nalu with emulation bytes |
|
||||||
|
// |---------------------|----------------------------|
|
||||||
|
// | 0x00 0x00 0x00 | 0x00 0x00 0x03 0x00 |
|
||||||
|
// | 0x00 0x00 0x01 | 0x00 0x00 0x03 0x01 |
|
||||||
|
// | 0x00 0x00 0x02 | 0x00 0x00 0x03 0x02 |
|
||||||
|
// | 0x00 0x00 0x03 | 0x00 0x00 0x03 0x03 |
|
||||||
|
// | 0x00 0x00 0x03 0x04 | 0x00 0x00 0x03 0x04 |
|
||||||
|
// |---------------------|----------------------------|
|
||||||
|
uint8_t ev = stream->read_1bytes();
|
||||||
|
if (ev > 3) {
|
||||||
|
nb_rbsp++;
|
||||||
|
}
|
||||||
|
rbsp[nb_rbsp] = ev;
|
||||||
|
}
|
||||||
|
|
||||||
|
nb_rbsp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nb_rbsp;
|
||||||
|
}
|
||||||
|
|
||||||
srs_error_t SrsFormat::video_avc_demux(SrsBuffer* stream, int64_t timestamp)
|
srs_error_t SrsFormat::video_avc_demux(SrsBuffer* stream, int64_t timestamp)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
@ -1224,26 +1262,9 @@ srs_error_t SrsFormat::hevc_demux_vps(SrsBuffer *stream)
|
||||||
|
|
||||||
// decode the rbsp from vps.
|
// decode the rbsp from vps.
|
||||||
// rbsp[ i ] a raw byte sequence payload is specified as an ordered sequence of bytes.
|
// rbsp[ i ] a raw byte sequence payload is specified as an ordered sequence of bytes.
|
||||||
std::vector<int8_t> rbsp(stream->size());
|
std::vector<uint8_t> rbsp(stream->size());
|
||||||
|
|
||||||
int nb_rbsp = 0;
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(stream, rbsp);
|
||||||
while (!stream->empty()) {
|
|
||||||
rbsp[nb_rbsp] = stream->read_1bytes();
|
|
||||||
|
|
||||||
// XX 00 00 03 XX, the 03 byte should be drop.
|
|
||||||
if (nb_rbsp > 2 && rbsp[nb_rbsp - 2] == 0 && rbsp[nb_rbsp - 1] == 0 && rbsp[nb_rbsp] == 3) {
|
|
||||||
// read 1byte more.
|
|
||||||
if (stream->empty()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rbsp[nb_rbsp] = stream->read_1bytes();
|
|
||||||
nb_rbsp++;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
nb_rbsp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hevc_demux_vps_rbsp((char*)&rbsp[0], nb_rbsp);
|
return hevc_demux_vps_rbsp((char*)&rbsp[0], nb_rbsp);
|
||||||
}
|
}
|
||||||
|
@ -1370,26 +1391,9 @@ srs_error_t SrsFormat::hevc_demux_sps(SrsBuffer *stream)
|
||||||
|
|
||||||
// decode the rbsp from sps.
|
// decode the rbsp from sps.
|
||||||
// rbsp[ i ] a raw byte sequence payload is specified as an ordered sequence of bytes.
|
// rbsp[ i ] a raw byte sequence payload is specified as an ordered sequence of bytes.
|
||||||
std::vector<int8_t> rbsp(stream->size());
|
std::vector<uint8_t> rbsp(stream->size());
|
||||||
|
|
||||||
int nb_rbsp = 0;
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(stream, rbsp);
|
||||||
while (!stream->empty()) {
|
|
||||||
rbsp[nb_rbsp] = stream->read_1bytes();
|
|
||||||
|
|
||||||
// XX 00 00 03 XX, the 03 byte should be drop.
|
|
||||||
if (nb_rbsp > 2 && rbsp[nb_rbsp - 2] == 0 && rbsp[nb_rbsp - 1] == 0 && rbsp[nb_rbsp] == 3) {
|
|
||||||
// read 1byte more.
|
|
||||||
if (stream->empty()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rbsp[nb_rbsp] = stream->read_1bytes();
|
|
||||||
nb_rbsp++;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
nb_rbsp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hevc_demux_sps_rbsp((char*)&rbsp[0], nb_rbsp);
|
return hevc_demux_sps_rbsp((char*)&rbsp[0], nb_rbsp);
|
||||||
}
|
}
|
||||||
|
@ -1571,28 +1575,11 @@ srs_error_t SrsFormat::hevc_demux_pps(SrsBuffer *stream)
|
||||||
// nuh_layer_id + nuh_temporal_id_plus1
|
// nuh_layer_id + nuh_temporal_id_plus1
|
||||||
stream->skip(1);
|
stream->skip(1);
|
||||||
|
|
||||||
// decode the rbsp from sps.
|
// decode the rbsp from pps.
|
||||||
// rbsp[ i ] a raw byte sequence payload is specified as an ordered sequence of bytes.
|
// rbsp[ i ] a raw byte sequence payload is specified as an ordered sequence of bytes.
|
||||||
std::vector<int8_t> rbsp(stream->size());
|
std::vector<uint8_t> rbsp(stream->size());
|
||||||
|
|
||||||
int nb_rbsp = 0;
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(stream, rbsp);
|
||||||
while (!stream->empty()) {
|
|
||||||
rbsp[nb_rbsp] = stream->read_1bytes();
|
|
||||||
|
|
||||||
// XX 00 00 03 XX, the 03 byte should be drop.
|
|
||||||
if (nb_rbsp > 2 && rbsp[nb_rbsp - 2] == 0 && rbsp[nb_rbsp - 1] == 0 && rbsp[nb_rbsp] == 3) {
|
|
||||||
// read 1byte more.
|
|
||||||
if (stream->empty()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rbsp[nb_rbsp] = stream->read_1bytes();
|
|
||||||
nb_rbsp++;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
nb_rbsp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hevc_demux_pps_rbsp((char*)&rbsp[0], nb_rbsp);
|
return hevc_demux_pps_rbsp((char*)&rbsp[0], nb_rbsp);
|
||||||
}
|
}
|
||||||
|
@ -2270,31 +2257,13 @@ srs_error_t SrsFormat::avc_demux_sps()
|
||||||
|
|
||||||
// decode the rbsp from sps.
|
// decode the rbsp from sps.
|
||||||
// rbsp[ i ] a raw byte sequence payload is specified as an ordered sequence of bytes.
|
// rbsp[ i ] a raw byte sequence payload is specified as an ordered sequence of bytes.
|
||||||
std::vector<int8_t> rbsp(vcodec->sequenceParameterSetNALUnit.size());
|
std::vector<uint8_t> rbsp(vcodec->sequenceParameterSetNALUnit.size());
|
||||||
|
|
||||||
int nb_rbsp = 0;
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&stream, rbsp);
|
||||||
while (!stream.empty()) {
|
|
||||||
rbsp[nb_rbsp] = stream.read_1bytes();
|
|
||||||
|
|
||||||
// XX 00 00 03 XX, the 03 byte should be drop.
|
|
||||||
if (nb_rbsp > 2 && rbsp[nb_rbsp - 2] == 0 && rbsp[nb_rbsp - 1] == 0 && rbsp[nb_rbsp] == 3) {
|
|
||||||
// read 1byte more.
|
|
||||||
if (stream.empty()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rbsp[nb_rbsp] = stream.read_1bytes();
|
|
||||||
nb_rbsp++;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
nb_rbsp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return avc_demux_sps_rbsp((char*)&rbsp[0], nb_rbsp);
|
return avc_demux_sps_rbsp((char*)&rbsp[0], nb_rbsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
srs_error_t SrsFormat::avc_demux_sps_rbsp(char* rbsp, int nb_rbsp)
|
srs_error_t SrsFormat::avc_demux_sps_rbsp(char* rbsp, int nb_rbsp)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
|
@ -3887,6 +3887,80 @@ VOID TEST(KernelCodecTest, VideoFormatSepcial)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID TEST(KernelCoecTest, VideoFormatRbspData)
|
||||||
|
{
|
||||||
|
if (true) {
|
||||||
|
vector<uint8_t> nalu = {
|
||||||
|
0x25, 0x00, 0x1f, 0xe2, 0x22, 0x00, 0x00, 0x02, 0x00, 0x00, 0x80, 0xab, 0xff
|
||||||
|
};
|
||||||
|
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)nalu.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), nalu.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
SrsFormat f;
|
||||||
|
vector<uint8_t> nalu = {
|
||||||
|
0x25, 0x00, 0x1f, 0xe2, 0x22, 0x00, 0x00, 0x03, 0x02, 0x00, 0x00, 0x80, 0xab, 0xff
|
||||||
|
};
|
||||||
|
vector<uint8_t> expect = {
|
||||||
|
0x25, 0x00, 0x1f, 0xe2, 0x22, 0x00, 0x00, 0x02, 0x00, 0x00, 0x80, 0xab, 0xff
|
||||||
|
};
|
||||||
|
|
||||||
|
// |----------------|----------------------------|
|
||||||
|
// | rbsp | nalu with emulation bytes |
|
||||||
|
// |----------------|----------------------------|
|
||||||
|
// | 0x00 0x00 0x00 | 0x00 0x00 0x03 0x00 |
|
||||||
|
// | 0x00 0x00 0x01 | 0x00 0x00 0x03 0x01 |
|
||||||
|
// | 0x00 0x00 0x02 | 0x00 0x00 0x03 0x02 |
|
||||||
|
// | 0x00 0x00 0x03 | 0x00 0x00 0x03 0x03 |
|
||||||
|
// |----------------|----------------------------|
|
||||||
|
for (int i = 0; i <= 3; ++i) {
|
||||||
|
nalu[8] = uint8_t(i);
|
||||||
|
expect[7] = uint8_t(i);
|
||||||
|
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0x00 0x00 0x04 ~ 0x00 0x00 0xFF, no need to add emulation bytes.
|
||||||
|
for (int i = 4; i <= 0xff; ++i) {
|
||||||
|
nalu[8] = uint8_t(i);
|
||||||
|
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)nalu.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), nalu.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
vector<uint8_t> nalu = {
|
||||||
|
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x03, 0x02, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x04
|
||||||
|
};
|
||||||
|
vector<uint8_t> expect = {
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x04
|
||||||
|
};
|
||||||
|
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VOID TEST(KernelCodecTest, VideoFormat)
|
VOID TEST(KernelCodecTest, VideoFormat)
|
||||||
{
|
{
|
||||||
srs_error_t err;
|
srs_error_t err;
|
||||||
|
@ -6346,4 +6420,4 @@ VOID TEST(KernelUtilityTest, Base64Decode)
|
||||||
HELPER_EXPECT_FAILED(srs_av_base64_decode("YWRtaW46YWRtaW", plaintext));
|
HELPER_EXPECT_FAILED(srs_av_base64_decode("YWRtaW46YWRtaW", plaintext));
|
||||||
EXPECT_STRNE("admin:admin", plaintext.c_str());
|
EXPECT_STRNE("admin:admin", plaintext.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <srs_kernel_ts.hpp>
|
#include <srs_kernel_ts.hpp>
|
||||||
#include <srs_kernel_ps.hpp>
|
#include <srs_kernel_ps.hpp>
|
||||||
#include <srs_kernel_stream.hpp>
|
#include <srs_kernel_stream.hpp>
|
||||||
|
#include <srs_kernel_utility.hpp>
|
||||||
|
|
||||||
class MockSrsFile
|
class MockSrsFile
|
||||||
{
|
{
|
||||||
|
@ -155,5 +156,7 @@ public:
|
||||||
MockPsHandler* clear();
|
MockPsHandler* clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern int srs_rbsp_remove_emulation_bytes(SrsBuffer* stream, std::vector<uint8_t>& rbsp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -526,3 +526,213 @@ VOID TEST(KernelCodecTest, VideoFormatSepcialAsan_DJI_M30)
|
||||||
memcpy(data, "\x27\x01\x00\x00\x00\x00\x00\x00\x00", sizeof(data));
|
memcpy(data, "\x27\x01\x00\x00\x00\x00\x00\x00\x00", sizeof(data));
|
||||||
HELPER_EXPECT_SUCCESS(f.on_video(0, data, sizeof(data)));
|
HELPER_EXPECT_SUCCESS(f.on_video(0, data, sizeof(data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID TEST(KernelCodecTest, VideoFormatRbspSimple)
|
||||||
|
{
|
||||||
|
// |---------------------|----------------------------|
|
||||||
|
// | rbsp | nalu with emulation bytes |
|
||||||
|
// |---------------------|----------------------------|
|
||||||
|
// | 0x00 0x00 0x00 | 0x00 0x00 0x03 0x00 |
|
||||||
|
// | 0x00 0x00 0x01 | 0x00 0x00 0x03 0x01 |
|
||||||
|
// | 0x00 0x00 0x02 | 0x00 0x00 0x03 0x02 |
|
||||||
|
// | 0x00 0x00 0x03 | 0x00 0x00 0x03 0x03 |
|
||||||
|
// | 0x00 0x00 0x03 0x04 | 0x00 0x00 0x03 0x04 |
|
||||||
|
// |---------------------|----------------------------|
|
||||||
|
if (true) {
|
||||||
|
vector<uint8_t> nalu = {0x00, 0x00, 0x03, 0x00};
|
||||||
|
vector<uint8_t> expect = {0x00, 0x00, 0x00};
|
||||||
|
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
vector<uint8_t> nalu = {0x00, 0x00, 0x03, 0x01};
|
||||||
|
vector<uint8_t> expect = {0x00, 0x00, 0x01};
|
||||||
|
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
vector<uint8_t> nalu = {0x00, 0x00, 0x03, 0x02};
|
||||||
|
vector<uint8_t> expect = {0x00, 0x00, 0x02};
|
||||||
|
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
vector<uint8_t> nalu = {0x00, 0x00, 0x03, 0x03};
|
||||||
|
vector<uint8_t> expect = {0x00, 0x00, 0x03};
|
||||||
|
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
vector<uint8_t> nalu = {0x00, 0x00, 0x03, 0x04};
|
||||||
|
vector<uint8_t> expect = {0x00, 0x00, 0x03, 0x04};
|
||||||
|
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
vector<uint8_t> nalu = {0x00, 0x00, 0x03, 0xff};
|
||||||
|
vector<uint8_t> expect = {0x00, 0x00, 0x03, 0xff};
|
||||||
|
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID TEST(KernelCodecTest, VideoFormatRbspEdge)
|
||||||
|
{
|
||||||
|
if (true) {
|
||||||
|
vector<uint8_t> nalu = {0x00, 0x00, 0x03};
|
||||||
|
vector<uint8_t> expect = {0x00, 0x00, 0x03};
|
||||||
|
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
vector<uint8_t> nalu = {0xff, 0x00, 0x00, 0x03};
|
||||||
|
vector<uint8_t> expect = {0xff, 0x00, 0x00, 0x03};
|
||||||
|
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint16_t v = 0x01; v <= 0xff; v++) {
|
||||||
|
vector<uint8_t> nalu = {(uint8_t)v, 0x00, 0x00, 0x03};
|
||||||
|
vector<uint8_t> expect = {(uint8_t)v, 0x00, 0x00, 0x03};
|
||||||
|
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID TEST(KernelCodecTest, VideoFormatRbspNormal)
|
||||||
|
{
|
||||||
|
for (uint16_t v = 0x01; v <= 0xff; v++) {
|
||||||
|
vector<uint8_t> nalu = {0x00, (uint8_t)v, 0x03, 0x00};
|
||||||
|
vector<uint8_t> expect = {0x00, (uint8_t)v, 0x03, 0x00};
|
||||||
|
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint16_t v = 0x01; v <= 0xff; v++) {
|
||||||
|
vector<uint8_t> nalu = {(uint8_t)v, 0x00, 0x03, 0x00};
|
||||||
|
vector<uint8_t> expect = {(uint8_t)v, 0x00, 0x03, 0x00};
|
||||||
|
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint16_t v = 0x00; v <= 0xff; v++) {
|
||||||
|
vector<uint8_t> nalu = {0x00, 0x00, (uint8_t)v};
|
||||||
|
vector<uint8_t> expect = {0x00, 0x00, (uint8_t)v};
|
||||||
|
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint16_t v = 0x00; v <= 0xff; v++) {
|
||||||
|
vector<uint8_t> nalu = {0x00, (uint8_t)v};
|
||||||
|
vector<uint8_t> expect = {0x00, (uint8_t)v};
|
||||||
|
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint16_t v = 0x00; v <= 0xff; v++) {
|
||||||
|
vector<uint8_t> nalu = {(uint8_t)v};
|
||||||
|
vector<uint8_t> expect = {(uint8_t)v};
|
||||||
|
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint16_t v = 0x00; v <= 0xff; v++) {
|
||||||
|
vector<uint8_t> nalu = {(uint8_t)v, (uint8_t)v};
|
||||||
|
vector<uint8_t> expect = {(uint8_t)v, (uint8_t)v};
|
||||||
|
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint16_t v = 0x00; v <= 0xff; v++) {
|
||||||
|
vector<uint8_t> nalu = {(uint8_t)v, (uint8_t)v, (uint8_t)v};
|
||||||
|
vector<uint8_t> expect = {(uint8_t)v, (uint8_t)v, (uint8_t)v};
|
||||||
|
|
||||||
|
vector<uint8_t> rbsp(nalu.size());
|
||||||
|
SrsBuffer b((char*)nalu.data(), nalu.size());
|
||||||
|
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
|
||||||
|
|
||||||
|
ASSERT_EQ(nb_rbsp, (int)expect.size());
|
||||||
|
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue