mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 12:37:09 +08:00
调整 addSSRCItem 函数 (#1224)
* update readme. * refactor(sdp): update addSSRCItem. * refactor(sdp): remove addSSRCItem. * refactor(sdp): 调整逻辑,生成a=ssrc-group:FID字段
This commit is contained in:
parent
a95381996e
commit
f7963a9032
@ -126,7 +126,7 @@
|
|||||||
你有三种方法使用ZLMediaKit,分别是:
|
你有三种方法使用ZLMediaKit,分别是:
|
||||||
|
|
||||||
- 1、使用c api,作为sdk使用,请参考[这里](https://github.com/xia-chu/ZLMediaKit/tree/master/api/include).
|
- 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).
|
- 3、如果想做c/c++开发,添加业务逻辑增加功能,可以参考这里的[测试程序](https://github.com/xia-chu/ZLMediaKit/tree/master/tests).
|
||||||
|
|
||||||
## Docker 镜像
|
## Docker 镜像
|
||||||
|
@ -1022,6 +1022,8 @@ string RtcSession::toRtspSdp() const{
|
|||||||
return sdp->toString();
|
return sdp->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addSdpAttrSSRC(const RtcSSRC &rtp_ssrc, vector<SdpItem::Ptr> &items, uint32_t ssrc_num);
|
||||||
|
|
||||||
RtcSessionSdp::Ptr RtcSession::toRtcSessionSdp() const{
|
RtcSessionSdp::Ptr RtcSession::toRtcSessionSdp() const{
|
||||||
RtcSessionSdp::Ptr ret = std::make_shared<RtcSessionSdp>();
|
RtcSessionSdp::Ptr ret = std::make_shared<RtcSessionSdp>();
|
||||||
auto &sdp = *ret;
|
auto &sdp = *ret;
|
||||||
@ -1126,51 +1128,15 @@ RtcSessionSdp::Ptr RtcSession::toRtcSessionSdp() const{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto addSSRCItem = [](const RtcSSRC &rtp_ssrc, vector<SdpItem::Ptr> &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<SdpAttrSSRC>(ssrc)));
|
|
||||||
|
|
||||||
if (!rtp_ssrc.msid.empty()) {
|
|
||||||
ssrc.attribute = "msid";
|
|
||||||
ssrc.attribute_value = rtp_ssrc.msid;
|
|
||||||
items.emplace_back(wrapSdpAttr(std::make_shared<SdpAttrSSRC>(ssrc)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rtp_ssrc.mslabel.empty()) {
|
|
||||||
ssrc.attribute = "mslabel";
|
|
||||||
ssrc.attribute_value = rtp_ssrc.mslabel;
|
|
||||||
items.emplace_back(wrapSdpAttr(std::make_shared<SdpAttrSSRC>(ssrc)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rtp_ssrc.label.empty()) {
|
|
||||||
ssrc.attribute = "label";
|
|
||||||
ssrc.attribute_value = rtp_ssrc.label;
|
|
||||||
items.emplace_back(wrapSdpAttr(std::make_shared<SdpAttrSSRC>(ssrc)));
|
|
||||||
}
|
|
||||||
if (rtp_ssrc.rtx_ssrc) {
|
|
||||||
ssrc_num = rtp_ssrc.rtx_ssrc;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
{
|
{
|
||||||
for (auto &ssrc : m.rtp_rtx_ssrc) {
|
for (auto &ssrc : m.rtp_rtx_ssrc) {
|
||||||
//添加a=ssrc字段
|
//添加a=ssrc字段
|
||||||
addSSRCItem(ssrc, sdp_media.items);
|
CHECK(!ssrc.empty());
|
||||||
}
|
addSdpAttrSSRC(ssrc, sdp_media.items, ssrc.ssrc);
|
||||||
|
|
||||||
for (auto &ssrc : m.rtp_rtx_ssrc) {
|
|
||||||
//生成a=ssrc-group:FID字段
|
|
||||||
if (ssrc.rtx_ssrc) {
|
if (ssrc.rtx_ssrc) {
|
||||||
|
addSdpAttrSSRC(ssrc, sdp_media.items, ssrc.rtx_ssrc);
|
||||||
|
|
||||||
|
//生成a=ssrc-group:FID字段
|
||||||
//有rtx ssrc
|
//有rtx ssrc
|
||||||
auto group = std::make_shared<SdpAttrSSRCGroup>();
|
auto group = std::make_shared<SdpAttrSSRCGroup>();
|
||||||
group->type = "FID";
|
group->type = "FID";
|
||||||
@ -1219,6 +1185,33 @@ RtcSessionSdp::Ptr RtcSession::toRtcSessionSdp() const{
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
void addSdpAttrSSRC(const RtcSSRC &rtp_ssrc, vector<SdpItem::Ptr> &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<SdpAttrSSRC>(ssrc)));
|
||||||
|
|
||||||
|
if (!rtp_ssrc.msid.empty()) {
|
||||||
|
ssrc.attribute = "msid";
|
||||||
|
ssrc.attribute_value = rtp_ssrc.msid;
|
||||||
|
items.emplace_back(wrapSdpAttr(std::make_shared<SdpAttrSSRC>(ssrc)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rtp_ssrc.mslabel.empty()) {
|
||||||
|
ssrc.attribute = "mslabel";
|
||||||
|
ssrc.attribute_value = rtp_ssrc.mslabel;
|
||||||
|
items.emplace_back(wrapSdpAttr(std::make_shared<SdpAttrSSRC>(ssrc)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rtp_ssrc.label.empty()) {
|
||||||
|
ssrc.attribute = "label";
|
||||||
|
ssrc.attribute_value = rtp_ssrc.label;
|
||||||
|
items.emplace_back(wrapSdpAttr(std::make_shared<SdpAttrSSRC>(ssrc)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string RtcSession::toString() const{
|
string RtcSession::toString() const{
|
||||||
return toRtcSessionSdp()->toString();
|
return toRtcSessionSdp()->toString();
|
||||||
|
Loading…
Reference in New Issue
Block a user