mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
支持单独的datachannel通道 (#1894)
* 支持单独的datachannel 通道 * 当仅有datachannel时 ,忽略rtp和rtcp超时 * 单独开启datachannel时,通过dtls包维持心跳 Co-authored-by: xiongziliang <771730766@qq.com>
This commit is contained in:
parent
39d2255771
commit
b7ef766701
@ -1311,6 +1311,10 @@ void RtcSession::checkValid() const{
|
|||||||
bool have_active_media = false;
|
bool have_active_media = false;
|
||||||
for (auto &item : media) {
|
for (auto &item : media) {
|
||||||
item.checkValid();
|
item.checkValid();
|
||||||
|
|
||||||
|
if (TrackApplication == item.type) {
|
||||||
|
have_active_media = true;
|
||||||
|
}
|
||||||
switch (item.direction) {
|
switch (item.direction) {
|
||||||
case RtpDirection::sendrecv:
|
case RtpDirection::sendrecv:
|
||||||
case RtpDirection::sendonly:
|
case RtpDirection::sendonly:
|
||||||
@ -1348,6 +1352,10 @@ bool RtcSession::supportSimulcast() const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RtcSession::isOnlyDatachannel() const {
|
||||||
|
return 1 == media.size() && TrackApplication == media[0].type;
|
||||||
|
}
|
||||||
|
|
||||||
string const SdpConst::kTWCCRtcpFb = "transport-cc";
|
string const SdpConst::kTWCCRtcpFb = "transport-cc";
|
||||||
string const SdpConst::kRembRtcpFb = "goog-remb";
|
string const SdpConst::kRembRtcpFb = "goog-remb";
|
||||||
|
|
||||||
@ -1596,6 +1604,10 @@ RETRY:
|
|||||||
#ifdef ENABLE_SCTP
|
#ifdef ENABLE_SCTP
|
||||||
answer_media.direction = matchDirection(offer_media.direction, configure.direction);
|
answer_media.direction = matchDirection(offer_media.direction, configure.direction);
|
||||||
answer_media.candidate = configure.candidate;
|
answer_media.candidate = configure.candidate;
|
||||||
|
answer_media.ice_ufrag = configure.ice_ufrag;
|
||||||
|
answer_media.ice_pwd = configure.ice_pwd;
|
||||||
|
answer_media.fingerprint = configure.fingerprint;
|
||||||
|
answer_media.ice_lite = configure.ice_lite;
|
||||||
#else
|
#else
|
||||||
answer_media.direction = RtpDirection::inactive;
|
answer_media.direction = RtpDirection::inactive;
|
||||||
#endif
|
#endif
|
||||||
|
@ -678,6 +678,7 @@ public:
|
|||||||
const RtcMedia *getMedia(mediakit::TrackType type) const;
|
const RtcMedia *getMedia(mediakit::TrackType type) const;
|
||||||
bool supportRtcpFb(const std::string &name, mediakit::TrackType type = mediakit::TrackType::TrackVideo) const;
|
bool supportRtcpFb(const std::string &name, mediakit::TrackType type = mediakit::TrackType::TrackVideo) const;
|
||||||
bool supportSimulcast() const;
|
bool supportSimulcast() const;
|
||||||
|
bool isOnlyDatachannel() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RtcSessionSdp::Ptr toRtcSessionSdp() const;
|
RtcSessionSdp::Ptr toRtcSessionSdp() const;
|
||||||
|
@ -377,7 +377,7 @@ void WebRtcTransportImp::onCreate() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (strong_self->_alive_ticker.elapsedTime() > timeoutSec * 1000) {
|
if (strong_self->_alive_ticker.elapsedTime() > timeoutSec * 1000) {
|
||||||
strong_self->onShutdown(SockException(Err_timeout, "接受rtp和rtcp超时"));
|
strong_self->onShutdown(SockException(Err_timeout, "接受rtp/rtcp/datachannel超时"));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
@ -386,6 +386,15 @@ void WebRtcTransportImp::onCreate() {
|
|||||||
_twcc_ctx.setOnSendTwccCB([this](uint32_t ssrc, string fci) { onSendTwcc(ssrc, fci); });
|
_twcc_ctx.setOnSendTwccCB([this](uint32_t ssrc, string fci) { onSendTwcc(ssrc, fci); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebRtcTransportImp::OnDtlsTransportApplicationDataReceived(const RTC::DtlsTransport *dtlsTransport, const uint8_t *data, size_t len) {
|
||||||
|
WebRtcTransport::OnDtlsTransportApplicationDataReceived(dtlsTransport, data, len);
|
||||||
|
#ifdef ENABLE_SCTP
|
||||||
|
if (_answer_sdp->isOnlyDatachannel()) {
|
||||||
|
_alive_ticker.resetTime();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
WebRtcTransportImp::WebRtcTransportImp(const EventPoller::Ptr &poller)
|
WebRtcTransportImp::WebRtcTransportImp(const EventPoller::Ptr &poller)
|
||||||
: WebRtcTransport(poller) {
|
: WebRtcTransport(poller) {
|
||||||
InfoL << getIdentifier();
|
InfoL << getIdentifier();
|
||||||
|
@ -248,6 +248,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebRtcTransportImp(const EventPoller::Ptr &poller);
|
WebRtcTransportImp(const EventPoller::Ptr &poller);
|
||||||
|
void OnDtlsTransportApplicationDataReceived(const RTC::DtlsTransport *dtlsTransport, const uint8_t *data, size_t len) override;
|
||||||
void onStartWebRTC() override;
|
void onStartWebRTC() override;
|
||||||
void onSendSockData(Buffer::Ptr buf, bool flush = true, RTC::TransportTuple *tuple = nullptr) override;
|
void onSendSockData(Buffer::Ptr buf, bool flush = true, RTC::TransportTuple *tuple = nullptr) override;
|
||||||
void onCheckSdp(SdpType type, RtcSession &sdp) override;
|
void onCheckSdp(SdpType type, RtcSession &sdp) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user