From 40a09958c4d01f30a2231b77bea7096f82fc3155 Mon Sep 17 00:00:00 2001 From: runner365 Date: Sun, 1 Mar 2020 19:42:32 +0800 Subject: [PATCH 1/3] add checking for pes_parse --- trunk/src/srt/ts_demux.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/trunk/src/srt/ts_demux.cpp b/trunk/src/srt/ts_demux.cpp index ead598bbe2..db486d5ad7 100644 --- a/trunk/src/srt/ts_demux.cpp +++ b/trunk/src/srt/ts_demux.cpp @@ -265,7 +265,11 @@ int ts_demux::decode_unit(unsigned char* data_p, std::string key_path, TS_DATA_C //callback last media data in data buffer on_callback(callback, _last_pid, key_path, _last_dts, _last_pts); - pes_parse(data_p+npos, npos, &ret_data_p, ret_size, dts, pts); + int ret = pes_parse(data_p+npos, npos, &ret_data_p, ret_size, dts, pts); + assert(ret <= 188); + if (ret > 188) { + return -1; + } _last_pts = pts; _last_dts = (dts == 0) ? pts : dts; From 4242985b36a50f6ccb46534d2afa1893021217c0 Mon Sep 17 00:00:00 2001 From: runner365 Date: Sat, 7 Mar 2020 15:15:14 +0800 Subject: [PATCH 2/3] update only support h264+aac --- trunk/src/srt/srt_to_rtmp.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/trunk/src/srt/srt_to_rtmp.cpp b/trunk/src/srt/srt_to_rtmp.cpp index ec2d7d8288..0d13c6733e 100644 --- a/trunk/src/srt/srt_to_rtmp.cpp +++ b/trunk/src/srt/srt_to_rtmp.cpp @@ -624,8 +624,7 @@ void rtmp_client::on_data_callback(SRT_DATA_MSG_PTR data_ptr, unsigned int media } else if (media_type == STREAM_TYPE_AUDIO_AAC) { on_ts_audio(avs_ptr, dts, pts); } else { - srs_error("mpegts demux unkown stream type:0x%02x", media_type); - assert(0); + srs_error("mpegts demux unkown stream type:0x%02x, only support h264+aac", media_type); } return; } From a2839aacdf8582a2eda3f951d8ef1dffe6f9d0be Mon Sep 17 00:00:00 2001 From: runner365 Date: Sat, 7 Mar 2020 16:15:36 +0800 Subject: [PATCH 3/3] add h264 sei filter --- trunk/src/app/srs_app_config.cpp | 16 +++++++++++++++- trunk/src/app/srs_app_config.hpp | 2 ++ trunk/src/srt/srt_handle.cpp | 3 ++- trunk/src/srt/srt_to_rtmp.cpp | 6 ++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 5781d2f1be..f66ca5cec8 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -3530,7 +3530,7 @@ srs_error_t SrsConfig::check_normal_config() && n != "mss" && n != "latency" && n != "recvlatency" && n != "peerlatency" && n != "tlpkdrop" && n != "connect_timeout" && n != "sendbuf" && n != "recvbuf" && n != "payloadsize" - && n != "default_app" && n != "mix_correct") { + && n != "default_app" && n != "mix_correct" && n != "sei_filter") { return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal srt_stream.%s", n.c_str()); } } @@ -6838,6 +6838,20 @@ int SrsConfig::get_srto_peer_latency() { return atoi(conf->arg0().c_str()); } +bool SrsConfig::get_srt_sei_filter() { + static bool DEFAULT = true; + SrsConfDirective* conf = root->get("srt_server"); + if (!conf) { + return DEFAULT; + } + + conf = conf->get("sei_filter"); + if (!conf || conf->arg0().empty()) { + return DEFAULT; + } + return SRS_CONF_PERFER_TRUE(conf->arg0()); +} + bool SrsConfig::get_srto_tlpkdrop() { static bool DEFAULT = true; SrsConfDirective* conf = root->get("srt_server"); diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 4360c41da5..c276b34dba 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -613,6 +613,8 @@ class SrsConfig virtual int get_srto_recv_latency(); // Get the srt SRTO_PEERLATENCY, peer latency, default is 0.. virtual int get_srto_peer_latency(); + // Get the srt h264 sei filter, default is on, it will drop h264 sei packet. + virtual bool get_srt_sei_filter(); // Get the srt SRTO_TLPKDROP, Too-late Packet Drop, default is true. virtual bool get_srto_tlpkdrop(); // Get the srt SRTO_CONNTIMEO, connection timeout, default is 3000ms. diff --git a/trunk/src/srt/srt_handle.cpp b/trunk/src/srt/srt_handle.cpp index 6343762755..a6351548ec 100644 --- a/trunk/src/srt/srt_handle.cpp +++ b/trunk/src/srt/srt_handle.cpp @@ -145,7 +145,8 @@ void srt_handle::add_newconn(SRT_CONN_PTR conn_ptr, int events) { srs_trace("srto SRTO_RCVBUF=%d", val_i); srt_getsockopt(conn_ptr->get_conn(), 0, SRTO_MAXBW, &val_i, &opt_len); srs_trace("srto SRTO_MAXBW=%d", val_i); - srs_trace("srt mix_correct is %s", _srs_config->get_srt_mix_correct() ? "enable" : "disable"); + srs_trace("srt mix_correct is %s.", _srs_config->get_srt_mix_correct() ? "enable" : "disable"); + srs_trace("srt h264 sei filter is %s.", _srs_config->get_srt_sei_filter() ? "enable" : "disable"); if (conn_ptr->get_mode() == PULL_SRT_MODE) { add_new_puller(conn_ptr, conn_ptr->get_subpath()); diff --git a/trunk/src/srt/srt_to_rtmp.cpp b/trunk/src/srt/srt_to_rtmp.cpp index 0d13c6733e..0842a7e7f0 100644 --- a/trunk/src/srt/srt_to_rtmp.cpp +++ b/trunk/src/srt/srt_to_rtmp.cpp @@ -459,6 +459,12 @@ srs_error_t rtmp_client::on_ts_video(std::shared_ptr avs_ptr, uint64_ if (nal_unit_type == SrsAvcNaluTypeAccessUnitDelimiter) { continue; } + + if (_srs_config->get_srt_sei_filter()) { + if (nal_unit_type == SrsAvcNaluTypeSEI) { + continue; + } + } // for sps if (_avc_ptr->is_sps(frame, frame_size)) {