Introduce MediaTransportConfig
Currently we pass media_transport from PeerConnection to media layers. The goal of this change is to replace media_transport with struct MediaTransportCondif, which will enable adding different transports (i.e. we plan to add DatagramTransport) as well as other media-transport related settings without changing 100s of files.
TODO: In the future we should consider also adding rtp_transport in the same config, but it will require a bit more work, so I did not include it in the same change.
Bug: webrtc:9719
Change-Id: Ie31e1faa3ed9e6beefe30a3da208130509ce00cd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137181
Commit-Queue: Anton Sukhanov <sukhanov@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Bjorn Mellem <mellem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28016}
diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h
index 35c6ef7..911b38e 100644
--- a/call/audio_receive_stream.h
+++ b/call/audio_receive_stream.h
@@ -20,7 +20,7 @@
#include "api/audio_codecs/audio_decoder_factory.h"
#include "api/call/transport.h"
#include "api/crypto/crypto_options.h"
-#include "api/media_transport_interface.h"
+#include "api/media_transport_config.h"
#include "api/rtp_parameters.h"
#include "api/rtp_receiver_interface.h"
#include "api/scoped_refptr.h"
@@ -122,7 +122,7 @@
Transport* rtcp_send_transport = nullptr;
- MediaTransportInterface* media_transport = nullptr;
+ MediaTransportConfig media_transport_config;
// NetEq settings.
size_t jitter_buffer_max_packets = 200;
diff --git a/call/audio_send_stream.cc b/call/audio_send_stream.cc
index 0a3555b..6fdb39c 100644
--- a/call/audio_send_stream.cc
+++ b/call/audio_send_stream.cc
@@ -21,12 +21,14 @@
AudioSendStream::Stats::Stats() = default;
AudioSendStream::Stats::~Stats() = default;
-AudioSendStream::Config::Config(Transport* send_transport,
- MediaTransportInterface* media_transport)
- : send_transport(send_transport), media_transport(media_transport) {}
+AudioSendStream::Config::Config(
+ Transport* send_transport,
+ const MediaTransportConfig& media_transport_config)
+ : send_transport(send_transport),
+ media_transport_config(media_transport_config) {}
AudioSendStream::Config::Config(Transport* send_transport)
- : Config(send_transport, nullptr) {}
+ : Config(send_transport, MediaTransportConfig()) {}
AudioSendStream::Config::~Config() = default;
@@ -36,7 +38,7 @@
ss << "{rtp: " << rtp.ToString();
ss << ", rtcp_report_interval_ms: " << rtcp_report_interval_ms;
ss << ", send_transport: " << (send_transport ? "(Transport)" : "null");
- ss << ", media_transport: " << (media_transport ? "(Transport)" : "null");
+ ss << ", media_transport_config: " << media_transport_config.DebugString();
ss << ", min_bitrate_bps: " << min_bitrate_bps;
ss << ", max_bitrate_bps: " << max_bitrate_bps;
ss << ", send_codec_spec: "
diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h
index 7e17b7c..b21b2ef 100644
--- a/call/audio_send_stream.h
+++ b/call/audio_send_stream.h
@@ -23,6 +23,7 @@
#include "api/call/transport.h"
#include "api/crypto/crypto_options.h"
#include "api/crypto/frame_encryptor_interface.h"
+#include "api/media_transport_config.h"
#include "api/media_transport_interface.h"
#include "api/rtp_parameters.h"
#include "api/scoped_refptr.h"
@@ -69,7 +70,8 @@
struct Config {
Config() = delete;
- Config(Transport* send_transport, MediaTransportInterface* media_transport);
+ Config(Transport* send_transport,
+ const MediaTransportConfig& media_transport_config);
explicit Config(Transport* send_transport);
~Config();
std::string ToString() const;
@@ -108,7 +110,7 @@
// the entire life of the AudioSendStream and is owned by the API client.
Transport* send_transport = nullptr;
- MediaTransportInterface* media_transport = nullptr;
+ MediaTransportConfig media_transport_config;
// Bitrate limits used for variable audio bitrate streams. Set both to -1 to
// disable audio bitrate adaptation.
diff --git a/call/call.cc b/call/call.cc
index ee6cbc6..fb60558 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -708,7 +708,8 @@
TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream");
RTC_DCHECK_RUN_ON(&configuration_sequence_checker_);
- RTC_DCHECK(media_transport() == config.media_transport);
+ RTC_DCHECK_EQ(media_transport(),
+ config.media_transport_config.media_transport);
RegisterRateObserver();
diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc
index 4a686ed..0bbf034 100644
--- a/call/call_perf_tests.cc
+++ b/call/call_perf_tests.cc
@@ -244,7 +244,7 @@
CreateMatchingReceiveConfigs(receive_transport.get());
AudioSendStream::Config audio_send_config(audio_send_transport.get(),
- /*media_transport=*/nullptr);
+ MediaTransportConfig());
audio_send_config.rtp.ssrc = kAudioSendSsrc;
audio_send_config.send_codec_spec = AudioSendStream::Config::SendCodecSpec(
kAudioSendPayloadType, {"ISAC", 16000, 1});
diff --git a/call/call_unittest.cc b/call/call_unittest.cc
index 1739036..4c78413 100644
--- a/call/call_unittest.cc
+++ b/call/call_unittest.cc
@@ -64,8 +64,7 @@
TEST(CallTest, CreateDestroy_AudioSendStream) {
CallHelper call;
MockTransport send_transport;
- AudioSendStream::Config config(&send_transport,
- /*media_transport=*/nullptr);
+ AudioSendStream::Config config(&send_transport, MediaTransportConfig());
config.rtp.ssrc = 42;
AudioSendStream* stream = call->CreateAudioSendStream(config);
EXPECT_NE(stream, nullptr);
@@ -88,8 +87,7 @@
TEST(CallTest, CreateDestroy_AudioSendStreams) {
CallHelper call;
MockTransport send_transport;
- AudioSendStream::Config config(&send_transport,
- /*media_transport=*/nullptr);
+ AudioSendStream::Config config(&send_transport, MediaTransportConfig());
std::list<AudioSendStream*> streams;
for (int i = 0; i < 2; ++i) {
for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) {
@@ -148,8 +146,7 @@
EXPECT_NE(recv_stream, nullptr);
MockTransport send_transport;
- AudioSendStream::Config send_config(&send_transport,
- /*media_transport=*/nullptr);
+ AudioSendStream::Config send_config(&send_transport, MediaTransportConfig());
send_config.rtp.ssrc = 777;
AudioSendStream* send_stream = call->CreateAudioSendStream(send_config);
EXPECT_NE(send_stream, nullptr);
@@ -168,8 +165,7 @@
TEST(CallTest, CreateDestroy_AssociateAudioSendReceiveStreams_SendFirst) {
CallHelper call;
MockTransport send_transport;
- AudioSendStream::Config send_config(&send_transport,
- /*media_transport=*/nullptr);
+ AudioSendStream::Config send_config(&send_transport, MediaTransportConfig());
send_config.rtp.ssrc = 777;
AudioSendStream* send_stream = call->CreateAudioSendStream(send_config);
EXPECT_NE(send_stream, nullptr);
@@ -273,8 +269,7 @@
auto create_stream_and_get_rtp_state = [&](uint32_t ssrc) {
MockTransport send_transport;
- AudioSendStream::Config config(&send_transport,
- /*media_transport=*/nullptr);
+ AudioSendStream::Config config(&send_transport, MediaTransportConfig());
config.rtp.ssrc = ssrc;
AudioSendStream* stream = call->CreateAudioSendStream(config);
const RtpState rtp_state =
@@ -305,7 +300,7 @@
// RTCPSender requires one.
MockTransport send_transport;
AudioSendStream::Config config(&send_transport,
- /*media_transport=*/&fake_media_transport);
+ MediaTransportConfig(&fake_media_transport));
call->MediaTransportChange(&fake_media_transport);
AudioSendStream* stream = call->CreateAudioSendStream(config);
diff --git a/call/video_receive_stream.cc b/call/video_receive_stream.cc
index 86ef88a..92787cc 100644
--- a/call/video_receive_stream.cc
+++ b/call/video_receive_stream.cc
@@ -67,11 +67,11 @@
VideoReceiveStream::Config::Config(const Config&) = default;
VideoReceiveStream::Config::Config(Config&&) = default;
VideoReceiveStream::Config::Config(Transport* rtcp_send_transport,
- MediaTransportInterface* media_transport)
+ MediaTransportConfig media_transport_config)
: rtcp_send_transport(rtcp_send_transport),
- media_transport(media_transport) {}
+ media_transport_config(media_transport_config) {}
VideoReceiveStream::Config::Config(Transport* rtcp_send_transport)
- : Config(rtcp_send_transport, nullptr) {}
+ : Config(rtcp_send_transport, MediaTransportConfig()) {}
VideoReceiveStream::Config& VideoReceiveStream::Config::operator=(Config&&) =
default;
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index affc256..a1fa86d 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -18,6 +18,7 @@
#include "api/call/transport.h"
#include "api/crypto/crypto_options.h"
+#include "api/media_transport_config.h"
#include "api/media_transport_interface.h"
#include "api/rtp_headers.h"
#include "api/rtp_parameters.h"
@@ -121,7 +122,7 @@
Config() = delete;
Config(Config&&);
Config(Transport* rtcp_send_transport,
- MediaTransportInterface* media_transport);
+ MediaTransportConfig media_transport_config);
explicit Config(Transport* rtcp_send_transport);
Config& operator=(Config&&);
Config& operator=(const Config&) = delete;
@@ -132,6 +133,10 @@
std::string ToString() const;
+ MediaTransportInterface* media_transport() const {
+ return media_transport_config.media_transport;
+ }
+
// Decoders for every payload that we can receive.
std::vector<Decoder> decoders;
@@ -197,7 +202,7 @@
// Transport for outgoing packets (RTCP).
Transport* rtcp_send_transport = nullptr;
- MediaTransportInterface* media_transport = nullptr;
+ MediaTransportConfig media_transport_config;
// Must always be set.
rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr;