From 09aa38334e84b96f9585df29b5ab94c42ad24580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=A5=9A?= <771730766@qq.com> Date: Sat, 22 Jul 2023 17:30:39 +0800 Subject: [PATCH] =?UTF-8?q?H264=20rtsp=20sdp=E7=94=9F=E6=88=90=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=9A=84packetization-mode=20(#2691)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/H264.cpp | 12 ++++++++++-- webrtc/Sdp.cpp | 10 ++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Extension/H264.cpp b/src/Extension/H264.cpp index 2395159b..eeccd600 100644 --- a/src/Extension/H264.cpp +++ b/src/Extension/H264.cpp @@ -12,9 +12,10 @@ #include "SPSParser.h" #include "Util/logger.h" #include "Util/base64.h" +#include "Common/config.h" -using namespace toolkit; using namespace std; +using namespace toolkit; namespace mediakit { @@ -248,7 +249,14 @@ public: _printer << "b=AS:" << bitrate << "\r\n"; } _printer << "a=rtpmap:" << payload_type << " " << getCodecName() << "/" << 90000 << "\r\n"; - _printer << "a=fmtp:" << payload_type << " packetization-mode=1; profile-level-id="; + + /** + Single NAI Unit Mode = 0. // Single NAI mode (Only nals from 1-23 are allowed) + Non Interleaved Mode = 1,// Non-interleaved Mode: 1-23,24 (STAP-A),28 (FU-A) are allowed + Interleaved Mode = 2, // 25 (STAP-B),26 (MTAP16),27 (MTAP24),28 (EU-A),and 29 (EU-B) are allowed. + **/ + GET_CONFIG(bool, h264_stap_a, Rtp::kH264StapA); + _printer << "a=fmtp:" << payload_type << " packetization-mode=" << h264_stap_a << "; profile-level-id="; uint32_t profile_level_id = 0; if (strSPS.length() >= 4) { // sanity check diff --git a/webrtc/Sdp.cpp b/webrtc/Sdp.cpp index 1b08ca8d..7b2e06e9 100644 --- a/webrtc/Sdp.cpp +++ b/webrtc/Sdp.cpp @@ -1816,11 +1816,17 @@ bool RtcConfigure::onCheckCodecProfile(const RtcCodecPlan &plan, CodecId codec) return true; } +/** + Single NAI Unit Mode = 0. // Single NAI mode (Only nals from 1-23 are allowed) + Non Interleaved Mode = 1,// Non-interleaved Mode: 1-23,24 (STAP-A),28 (FU-A) are allowed + Interleaved Mode = 2, // 25 (STAP-B),26 (MTAP16),27 (MTAP24),28 (EU-A),and 29 (EU-B) are allowed. + **/ void RtcConfigure::onSelectPlan(RtcCodecPlan &plan, CodecId codec) const { if (_rtsp_video_plan && codec == CodecH264 && getCodecId(_rtsp_video_plan->codec) == CodecH264) { - //h264时,设置packetization-mod为一致 + // h264时,设置packetization-mod为一致 auto mode = _rtsp_video_plan->fmtp[kMode]; - plan.fmtp[kMode] = mode.empty() ? "0" : mode; + GET_CONFIG(bool, h264_stap_a, Rtp::kH264StapA); + plan.fmtp[kMode] = mode.empty() ? std::to_string(h264_stap_a) : mode; } }