rtc stop push unregister mediasource

This commit is contained in:
xiongguangjie 2022-09-07 19:10:06 +08:00
parent 6ca736f88a
commit 7f86299c80
4 changed files with 19 additions and 0 deletions

View File

@ -150,4 +150,15 @@ void WebRtcPusher::onRtcConfigure(RtcConfigure &configure) const {
float WebRtcPusher::getLossRate(MediaSource &sender,mediakit::TrackType type){ float WebRtcPusher::getLossRate(MediaSource &sender,mediakit::TrackType type){
return WebRtcTransportImp::getLossRate(type); return WebRtcTransportImp::getLossRate(type);
}
void WebRtcPusher::OnDtlsTransportClosed(const RTC::DtlsTransport *dtlsTransport) {
//主动关闭推流,那么不等待重推
_push_src = nullptr;
WebRtcTransportImp::OnDtlsTransportClosed(dtlsTransport);
}
void WebRtcPusher::onRtcpBye(){
_push_src = nullptr;
WebRtcTransportImp::onRtcpBye();
} }

View File

@ -26,6 +26,9 @@ protected:
void onDestory() override; void onDestory() override;
void onRtcConfigure(RtcConfigure &configure) const override; void onRtcConfigure(RtcConfigure &configure) const override;
void onRecvRtp(MediaTrack &track, const std::string &rid, mediakit::RtpPacket::Ptr rtp) override; void onRecvRtp(MediaTrack &track, const std::string &rid, mediakit::RtpPacket::Ptr rtp) override;
void onRtcpBye() override;
//// dtls相关的回调 ////
void OnDtlsTransportClosed(const RTC::DtlsTransport *dtlsTransport) override;
protected: protected:
///////MediaSourceEvent override/////// ///////MediaSourceEvent override///////

View File

@ -766,6 +766,7 @@ void WebRtcTransportImp::onRtcp(const char *buf, size_t len) {
} }
_ssrc_to_track.erase(it); _ssrc_to_track.erase(it);
} }
onRtcpBye();
onShutdown(SockException(Err_eof, "rtcp bye message received")); onShutdown(SockException(Err_eof, "rtcp bye message received"));
break; break;
} }
@ -1051,6 +1052,8 @@ uint64_t WebRtcTransportImp::getDuration() const {
return _alive_ticker.createdTime() / 1000; return _alive_ticker.createdTime() / 1000;
} }
void WebRtcTransportImp::onRtcpBye(){}
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
void WebRtcTransportImp::registerSelf() { void WebRtcTransportImp::registerSelf() {

View File

@ -154,6 +154,7 @@ protected:
virtual void onShutdown(const SockException &ex) = 0; virtual void onShutdown(const SockException &ex) = 0;
virtual void onBeforeEncryptRtp(const char *buf, int &len, void *ctx) = 0; virtual void onBeforeEncryptRtp(const char *buf, int &len, void *ctx) = 0;
virtual void onBeforeEncryptRtcp(const char *buf, int &len, void *ctx) = 0; virtual void onBeforeEncryptRtcp(const char *buf, int &len, void *ctx) = 0;
virtual void onRtcpBye() = 0;
protected: protected:
RTC::TransportTuple* getSelectedTuple() const; RTC::TransportTuple* getSelectedTuple() const;
@ -264,6 +265,7 @@ protected:
virtual void onRecvRtp(MediaTrack &track, const std::string &rid, mediakit::RtpPacket::Ptr rtp) = 0; virtual void onRecvRtp(MediaTrack &track, const std::string &rid, mediakit::RtpPacket::Ptr rtp) = 0;
void updateTicker(); void updateTicker();
float getLossRate(mediakit::TrackType type); float getLossRate(mediakit::TrackType type);
void onRtcpBye() override;
private: private:
void onSortedRtp(MediaTrack &track, const std::string &rid, mediakit::RtpPacket::Ptr rtp); void onSortedRtp(MediaTrack &track, const std::string &rid, mediakit::RtpPacket::Ptr rtp);