Skip to content

Commit dcbd085

Browse files
committed
Avoid errors when unregistering sinks
1 parent 2249619 commit dcbd085

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

pc/peer_connection.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,12 +1843,12 @@ void PeerConnection::Close() {
18431843
RTC_DCHECK_RUN_ON(network_thread());
18441844

18451845
// RingRTC change to receive RTP data
1846-
if (rtp_packet_observer_) {
1846+
if (rtp_demuxer_sink_registered_ && rtp_packet_observer_ != nullptr) {
18471847
JsepTransportController *transport_controller = this->transport_controller_n();
18481848
RtpTransportInternal *rtp_transport = transport_controller->GetBundledRtpTransport();
1849-
rtp_transport->UnregisterRtpDemuxerSink(rtp_packet_observer_);
1850-
rtp_packet_observer_ = nullptr;
1849+
rtp_demuxer_sink_registered_ = !rtp_transport->UnregisterRtpDemuxerSink(rtp_packet_observer_);
18511850
}
1851+
rtp_packet_observer_ = nullptr;
18521852

18531853
TeardownDataChannelTransport_n({});
18541854
transport_controller_.reset();
@@ -3144,7 +3144,8 @@ bool PeerConnection::ReceiveRtp(uint8_t pt, bool enable_incoming) {
31443144
if (enable_incoming) {
31453145
rtp_transport->SetIncomingRtpEnabled(true);
31463146
}
3147-
return rtp_transport->RegisterRtpDemuxerSink(demux_criteria, rtp_packet_observer_);
3147+
rtp_demuxer_sink_registered_ = rtp_transport->RegisterRtpDemuxerSink(demux_criteria, rtp_packet_observer_);
3148+
return rtp_demuxer_sink_registered_;
31483149
});
31493150
}
31503151

pc/peer_connection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ class PeerConnection : public PeerConnectionInternal,
766766
scoped_refptr<IceGathererInterface> shared_ice_gatherer_;
767767

768768
// RingRTC change to receive RTP data
769+
bool rtp_demuxer_sink_registered_ = false;
769770
RtpPacketSinkInterface* rtp_packet_observer_ RTC_GUARDED_BY(network_thread()) = nullptr;
770771

771772
std::unique_ptr<CodecLookupHelper> codec_lookup_helper_;

ringrtc/rffi/src/rtp_observer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ namespace rffi {
1414
RtpObserverRffi::RtpObserverRffi(void* observer,
1515
const RtpObserverCallbacks* callbacks)
1616
: observer_(observer), callbacks_(*callbacks) {
17-
RTC_LOG(LS_WARNING) << "RtpObserverRffi:ctor(): " << this->observer_;
17+
RTC_LOG(LS_INFO) << "RtpObserverRffi:ctor(): " << this->observer_;
1818
}
1919

2020
RtpObserverRffi::~RtpObserverRffi() {
21-
RTC_LOG(LS_WARNING) << "RtpObserverRffi:dtor(): " << this->observer_;
21+
RTC_LOG(LS_INFO) << "RtpObserverRffi:dtor(): " << this->observer_;
2222
}
2323

2424
void RtpObserverRffi::OnRtpPacket(const RtpPacketReceived& rtp_packet) {

0 commit comments

Comments
 (0)