Allow more than one registered network change callback in MediaTransport

Adds methods AddNetworkChangeCallback and RemoveNetworkChangeCallback,
to replace SetNetworkChangeCallback. Needed because both VideoChannel and
VoiceChannel register such a callback.

Bug: webrtc:9719
Change-Id: Ic592b2d775d721a0f44ba0af88ed963bf02d73a3
Reviewed-on: https://webrtc-review.googlesource.com/c/121460
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Peter Slatala <psla@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26575}
This commit is contained in:
Niels Möller 2019-02-05 17:32:57 +01:00 committed by Commit Bot
parent 3e6188868b
commit fe6e50f0af
3 changed files with 5 additions and 2 deletions

View File

@ -111,6 +111,7 @@ specific_include_rules = {
"media_transport_interface\.h": [
"+rtc_base/copy_on_write_buffer.h", # As used by datachannelinterface.h
"+rtc_base/network_route.h",
"+rtc_base/deprecation.h",
],
"peer_connection_factory_proxy\.h": [

View File

@ -29,6 +29,7 @@
#include "api/units/data_rate.h"
#include "api/video/encoded_image.h"
#include "rtc_base/copy_on_write_buffer.h"
#include "rtc_base/deprecation.h"
#include "rtc_base/network_route.h"
namespace rtc {
@ -435,6 +436,7 @@ class MediaTransportInterface {
// setting it to nullptr.
// TODO(nisse): The SetNetworkChangeCallback is being replaced with Add/Remove
// methods, because both video channel and voice channel need to register.
RTC_DEPRECATED
virtual void SetNetworkChangeCallback(
MediaTransportNetworkChangeCallback* callback);
virtual void AddNetworkChangeCallback(

View File

@ -154,7 +154,7 @@ BaseChannel::~BaseChannel() {
RTC_DCHECK_RUN_ON(worker_thread_);
if (media_transport_) {
media_transport_->SetNetworkChangeCallback(nullptr);
media_transport_->RemoveNetworkChangeCallback(this);
}
// Eats any outstanding messages or packets.
@ -217,7 +217,7 @@ void BaseChannel::Init_w(webrtc::RtpTransportInternal* rtp_transport,
RTC_LOG(LS_INFO) << "BaseChannel::Init_w, media_transport="
<< (media_transport_ != nullptr);
if (media_transport_) {
media_transport_->SetNetworkChangeCallback(this);
media_transport_->AddNetworkChangeCallback(this);
}
}