添加rtc配置类

This commit is contained in:
ziyue 2021-03-30 11:51:39 +08:00
parent 2065b6fea8
commit 6d16ae91e6
2 changed files with 123 additions and 0 deletions

View File

@ -493,6 +493,7 @@ void SdpAttrExtmap::parse(const string &str) {
if (sscanf(str.data(), "%" SCNd32 " %127s", &index, buf) != 2) {
SDP_THROW();
}
direction = RtpDirection::sendrecv;
} else {
direction = getRtpDirection(direction_buf);
}
@ -1076,4 +1077,82 @@ void RtcSession::checkValid() const{
for (auto &item : media) {
item.checkValid();
}
}
void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){
enable = true;
rtcp_mux = true;
rtcp_rsize = false;
group_bundle = true;
unified_plan = false;
support_rtx = true;
support_red = false;
support_ulpfec = false;
support_simulcast = false;
ice_lite = true;
ice_trickle = true;
ice_renomination = false;
switch (type) {
case TrackVideo: {
preferred_codec = {CodecAAC, CodecOpus, CodecG711U, CodecG711A};
rtcp_fb = {"transport-cc"};
extmap = {"1 urn:ietf:params:rtp-hdrext:ssrc-audio-level"};
break;
}
case TrackAudio: {
preferred_codec = {CodecH264, CodecH265};
rtcp_fb = {"nack", "ccm fir", "nack pli", "goog-remb", "transport-cc"};
extmap = {"2 urn:ietf:params:rtp-hdrext:toffset",
"3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",
"4 urn:3gpp:video-orientation",
"5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",
"6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"};
break;
}
case TrackApplication: {
enable = false;
break;
}
default: break;
}
}
void RtcConfigure::setDefaultSetting(string ice_ufrag,
string ice_pwd,
DtlsRole role,
RtpDirection direction,
const SdpAttrFingerprint &fingerprint) {
video.setDefaultSetting(TrackVideo);
audio.setDefaultSetting(TrackAudio);
application.setDefaultSetting(TrackApplication);
video.ice_ufrag = audio.ice_ufrag = application.ice_ufrag = ice_ufrag;
video.ice_pwd = audio.ice_pwd = application.ice_pwd = ice_ufrag;
video.role = audio.role = application.role = role;
video.direction = audio.direction = application.direction = direction;
video.fingerprint = audio.fingerprint = application.fingerprint = fingerprint;
}
void RtcConfigure::addCandidate(const SdpAttrCandidate &candidate, TrackType type) {
switch (type) {
case TrackAudio: {
audio.candidate.emplace_back(candidate);
break;
}
case TrackVideo: {
video.candidate.emplace_back(candidate);
break;
}
case TrackApplication: {
application.candidate.emplace_back(candidate);
break;
}
default: {
audio.candidate.emplace_back(candidate);
video.candidate.emplace_back(candidate);
application.candidate.emplace_back(candidate);
break;
}
}
}

View File

@ -609,5 +609,49 @@ public:
void checkValid() const;
};
class RtcConfigure {
public:
class RtcTrackConfigure {
public:
bool enable;
bool rtcp_mux;
bool rtcp_rsize;
bool group_bundle;
bool unified_plan;
bool support_rtx;
bool support_red;
bool support_ulpfec;
bool support_simulcast;
bool ice_lite;
bool ice_trickle;
bool ice_renomination;
string ice_ufrag;
string ice_pwd;
DtlsRole role{DtlsRole::invalid};
RtpDirection direction{RtpDirection::invalid};
SdpAttrFingerprint fingerprint;
vector<string> rtcp_fb;
vector<CodecId> preferred_codec;
vector<string> extmap;
vector<SdpAttrCandidate> candidate;
void setDefaultSetting(TrackType type);
};
RtcTrackConfigure video;
RtcTrackConfigure audio;
RtcTrackConfigure application;
void setDefaultSetting(string ice_ufrag,
string ice_pwd,
DtlsRole role,
RtpDirection direction,
const SdpAttrFingerprint &fingerprint);
void addCandidate(const SdpAttrCandidate &candidate, TrackType type = TrackInvalid);
};
#endif //ZLMEDIAKIT_SDP_H