diff --git a/README.md b/README.md index d0e5967f..25fdca10 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ 你有三种方法使用ZLMediaKit,分别是: - 1、使用c api,作为sdk使用,请参考[这里](https://github.com/xia-chu/ZLMediaKit/tree/master/api/include). - - 2、作为独立的流媒体服务器使用,不想做c/c++开发的,可以参考[restful api](https://github.com/xia-chu/ZLMediaKit/wiki/MediaServer%E6%94%AF%E6%8C%81%E7%9A%84HTTP-API)和[web hook](https://github.com/xia-chu/ZLMediaKit/wiki/MediaServer%E6%94%AF%E6%8C%81%E7%9A%84HTTP-HOOK-API). + - 2、作为独立的流媒体服务器使用,不想做c/c++开发的,可以参考 [restful api](https://github.com/xia-chu/ZLMediaKit/wiki/MediaServer支持的HTTP-API) 和 [web hook](https://github.com/xia-chu/ZLMediaKit/wiki/MediaServer支持的HTTP-HOOK-API ). - 3、如果想做c/c++开发,添加业务逻辑增加功能,可以参考这里的[测试程序](https://github.com/xia-chu/ZLMediaKit/tree/master/tests). ## Docker 镜像 @@ -175,7 +175,7 @@ bash build_docker_images.sh ## 联系方式 - 邮箱:<1213642868@qq.com>(本项目相关或流媒体相关问题请走issue流程,否则恕不邮件答复) - - QQ群:690854210 (加群前请先把[wiki](https://github.com/ZLMediaKit/ZLMediaKit/wiki)看完,文档有涉及的问题不答复) + - QQ群:690854210 (加群前请先把 [wiki](https://github.com/ZLMediaKit/ZLMediaKit/wiki) 看完,文档有涉及的问题不答复) ## 怎么提问? diff --git a/webrtc/Sdp.cpp b/webrtc/Sdp.cpp index b9717a40..33d1ad0a 100644 --- a/webrtc/Sdp.cpp +++ b/webrtc/Sdp.cpp @@ -1022,6 +1022,8 @@ string RtcSession::toRtspSdp() const{ return sdp->toString(); } +void addSdpAttrSSRC(const RtcSSRC &rtp_ssrc, vector &items, uint32_t ssrc_num); + RtcSessionSdp::Ptr RtcSession::toRtcSessionSdp() const{ RtcSessionSdp::Ptr ret = std::make_shared(); auto &sdp = *ret; @@ -1126,51 +1128,15 @@ RtcSessionSdp::Ptr RtcSession::toRtcSessionSdp() const{ } } - static auto addSSRCItem = [](const RtcSSRC &rtp_ssrc, vector &items) { - CHECK(!rtp_ssrc.empty()); - auto ssrc_num = rtp_ssrc.ssrc; - for (auto i = 0; i < 2; ++i) { - SdpAttrSSRC ssrc; - ssrc.ssrc = ssrc_num; - - ssrc.attribute = "cname"; - ssrc.attribute_value = rtp_ssrc.cname; - items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); - - if (!rtp_ssrc.msid.empty()) { - ssrc.attribute = "msid"; - ssrc.attribute_value = rtp_ssrc.msid; - items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); - } - - if (!rtp_ssrc.mslabel.empty()) { - ssrc.attribute = "mslabel"; - ssrc.attribute_value = rtp_ssrc.mslabel; - items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); - } - - if (!rtp_ssrc.label.empty()) { - ssrc.attribute = "label"; - ssrc.attribute_value = rtp_ssrc.label; - items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); - } - if (rtp_ssrc.rtx_ssrc) { - ssrc_num = rtp_ssrc.rtx_ssrc; - } else { - break; - } - } - }; - { for (auto &ssrc : m.rtp_rtx_ssrc) { //添加a=ssrc字段 - addSSRCItem(ssrc, sdp_media.items); - } - - for (auto &ssrc : m.rtp_rtx_ssrc) { - //生成a=ssrc-group:FID字段 + CHECK(!ssrc.empty()); + addSdpAttrSSRC(ssrc, sdp_media.items, ssrc.ssrc); if (ssrc.rtx_ssrc) { + addSdpAttrSSRC(ssrc, sdp_media.items, ssrc.rtx_ssrc); + + //生成a=ssrc-group:FID字段 //有rtx ssrc auto group = std::make_shared(); group->type = "FID"; @@ -1219,6 +1185,33 @@ RtcSessionSdp::Ptr RtcSession::toRtcSessionSdp() const{ } return ret; } +void addSdpAttrSSRC(const RtcSSRC &rtp_ssrc, vector &items, uint32_t ssrc_num) { + assert(ssrc_num); + SdpAttrSSRC ssrc; + ssrc.ssrc = ssrc_num; + + ssrc.attribute = "cname"; + ssrc.attribute_value = rtp_ssrc.cname; + items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); + + if (!rtp_ssrc.msid.empty()) { + ssrc.attribute = "msid"; + ssrc.attribute_value = rtp_ssrc.msid; + items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); + } + + if (!rtp_ssrc.mslabel.empty()) { + ssrc.attribute = "mslabel"; + ssrc.attribute_value = rtp_ssrc.mslabel; + items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); + } + + if (!rtp_ssrc.label.empty()) { + ssrc.attribute = "label"; + ssrc.attribute_value = rtp_ssrc.label; + items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); + } +} string RtcSession::toString() const{ return toRtcSessionSdp()->toString();