mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
Refine(webrtc/sdp): 函数 WebRtcTransport::onCheckSdp() 拆分为WebRtcTransport::onCheckAnswer() 和 RtcSession::checkSdp()
This commit is contained in:
parent
c7633fb5bb
commit
0f4289a584
@ -1381,6 +1381,16 @@ bool RtcSession::supportSimulcast() const {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
void RtcSession::checkSdp() const {
|
||||||
|
for (auto &m : media) {
|
||||||
|
if (m.type != TrackApplication && !m.rtcp_mux) {
|
||||||
|
throw std::invalid_argument("只支持rtcp-mux模式");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (group.mids.empty()) {
|
||||||
|
throw std::invalid_argument("只支持group BUNDLE模式");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string const SdpConst::kTWCCRtcpFb = "transport-cc";
|
string const SdpConst::kTWCCRtcpFb = "transport-cc";
|
||||||
string const SdpConst::kRembRtcpFb = "goog-remb";
|
string const SdpConst::kRembRtcpFb = "goog-remb";
|
||||||
|
@ -667,6 +667,7 @@ public:
|
|||||||
void loadFrom(const string &sdp, bool check = true);
|
void loadFrom(const string &sdp, bool check = true);
|
||||||
void checkValid() const;
|
void checkValid() const;
|
||||||
//offer sdp,如果指定了发送rtp,那么应该指定ssrc
|
//offer sdp,如果指定了发送rtp,那么应该指定ssrc
|
||||||
|
void checkSdp() const;
|
||||||
void checkValidSSRC() const;
|
void checkValidSSRC() const;
|
||||||
string toString() const;
|
string toString() const;
|
||||||
string toRtspSdp() const;
|
string toRtspSdp() const;
|
||||||
|
@ -174,19 +174,6 @@ void WebRtcTransport::setRemoteDtlsFingerprint(const RtcSession &remote){
|
|||||||
_dtls_transport->SetRemoteFingerprint(remote_fingerprint);
|
_dtls_transport->SetRemoteFingerprint(remote_fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRtcTransport::onCheckSdp(SdpType type, RtcSession &sdp){
|
|
||||||
for (auto &m : sdp.media) {
|
|
||||||
if (m.type != TrackApplication && !m.rtcp_mux) {
|
|
||||||
throw std::invalid_argument("只支持rtcp-mux模式");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sdp.group.mids.empty()) {
|
|
||||||
throw std::invalid_argument("只支持group BUNDLE模式");
|
|
||||||
}
|
|
||||||
if (type == SdpType::offer) {
|
|
||||||
sdp.checkValidSSRC();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebRtcTransport::onRtcConfigure(RtcConfigure &configure) const {
|
void WebRtcTransport::onRtcConfigure(RtcConfigure &configure) const {
|
||||||
//开启remb后关闭twcc,因为开启twcc后remb无效
|
//开启remb后关闭twcc,因为开启twcc后remb无效
|
||||||
@ -199,7 +186,8 @@ std::string WebRtcTransport::getAnswerSdp(const string &offer){
|
|||||||
//// 解析offer sdp ////
|
//// 解析offer sdp ////
|
||||||
_offer_sdp = std::make_shared<RtcSession>();
|
_offer_sdp = std::make_shared<RtcSession>();
|
||||||
_offer_sdp->loadFrom(offer);
|
_offer_sdp->loadFrom(offer);
|
||||||
onCheckSdp(SdpType::offer, *_offer_sdp);
|
_offer_sdp->checkSdp();
|
||||||
|
_offer_sdp->checkValidSSRC();
|
||||||
setRemoteDtlsFingerprint(*_offer_sdp);
|
setRemoteDtlsFingerprint(*_offer_sdp);
|
||||||
|
|
||||||
//// sdp 配置 ////
|
//// sdp 配置 ////
|
||||||
@ -213,7 +201,8 @@ std::string WebRtcTransport::getAnswerSdp(const string &offer){
|
|||||||
|
|
||||||
//// 生成answer sdp ////
|
//// 生成answer sdp ////
|
||||||
_answer_sdp = configure.createAnswer(*_offer_sdp);
|
_answer_sdp = configure.createAnswer(*_offer_sdp);
|
||||||
onCheckSdp(SdpType::answer, *_answer_sdp);
|
_answer_sdp->checkSdp();
|
||||||
|
onCheckAnswer(*_answer_sdp);
|
||||||
return _answer_sdp->toString();
|
return _answer_sdp->toString();
|
||||||
} catch (exception &ex) {
|
} catch (exception &ex) {
|
||||||
onShutdown(SockException(Err_shutdown, ex.what()));
|
onShutdown(SockException(Err_shutdown, ex.what()));
|
||||||
@ -520,13 +509,7 @@ void WebRtcTransportImp::onStartWebRTC() {
|
|||||||
_play_src = nullptr;
|
_play_src = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRtcTransportImp::onCheckSdp(SdpType type, RtcSession &sdp){
|
void WebRtcTransportImp::onCheckAnswer(RtcSession &sdp) {
|
||||||
WebRtcTransport::onCheckSdp(type, sdp);
|
|
||||||
if (type != SdpType::answer) {
|
|
||||||
//我们只修改answer sdp
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//修改answer sdp的ip、端口信息
|
//修改answer sdp的ip、端口信息
|
||||||
GET_CONFIG(string, extern_ip, RTC::kExternIP);
|
GET_CONFIG(string, extern_ip, RTC::kExternIP);
|
||||||
for (auto &m : sdp.media) {
|
for (auto &m : sdp.media) {
|
||||||
|
@ -106,7 +106,7 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
virtual void onStartWebRTC() = 0;
|
virtual void onStartWebRTC() = 0;
|
||||||
virtual void onRtcConfigure(RtcConfigure &configure) const;
|
virtual void onRtcConfigure(RtcConfigure &configure) const;
|
||||||
virtual void onCheckSdp(SdpType type, RtcSession &sdp);
|
virtual void onCheckAnswer(RtcSession &sdp) = 0;
|
||||||
virtual void onSendSockData(const char *buf, size_t len, struct sockaddr_in *dst, bool flush = true) = 0;
|
virtual void onSendSockData(const char *buf, size_t len, struct sockaddr_in *dst, bool flush = true) = 0;
|
||||||
|
|
||||||
virtual void onRtp(const char *buf, size_t len, uint64_t stamp_ms) = 0;
|
virtual void onRtp(const char *buf, size_t len, uint64_t stamp_ms) = 0;
|
||||||
@ -184,7 +184,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void onStartWebRTC() override;
|
void onStartWebRTC() override;
|
||||||
void onSendSockData(const char *buf, size_t len, struct sockaddr_in *dst, bool flush = true) override;
|
void onSendSockData(const char *buf, size_t len, struct sockaddr_in *dst, bool flush = true) override;
|
||||||
void onCheckSdp(SdpType type, RtcSession &sdp) override;
|
void onCheckAnswer(RtcSession &sdp) override;
|
||||||
void onRtcConfigure(RtcConfigure &configure) const override;
|
void onRtcConfigure(RtcConfigure &configure) const override;
|
||||||
|
|
||||||
void onRtp(const char *buf, size_t len, uint64_t stamp_ms) override;
|
void onRtp(const char *buf, size_t len, uint64_t stamp_ms) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user