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}
This commit is contained in:
Anton Sukhanov 2019-05-21 11:12:57 -07:00 committed by Commit Bot
parent 4880e15707
commit 4f08faae82
42 changed files with 329 additions and 206 deletions

View file

@ -108,6 +108,8 @@ rtc_static_library("libjingle_peerconnection_api") {
"media_stream_interface.h", "media_stream_interface.h",
"media_stream_proxy.h", "media_stream_proxy.h",
"media_stream_track_proxy.h", "media_stream_track_proxy.h",
"media_transport_config.cc",
"media_transport_config.h",
"media_transport_interface.cc", "media_transport_interface.cc",
"media_transport_interface.h", "media_transport_interface.h",
"media_types.cc", "media_types.cc",

View file

@ -0,0 +1,20 @@
/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "api/media_transport_config.h"
namespace webrtc {
std::string MediaTransportConfig::DebugString() const {
return (media_transport != nullptr ? "{media_transport: (Transport)}"
: "{media_transport: null}");
}
} // namespace webrtc

View file

@ -0,0 +1,42 @@
/* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef API_MEDIA_TRANSPORT_CONFIG_H_
#define API_MEDIA_TRANSPORT_CONFIG_H_
#include <memory>
#include <string>
#include <utility>
namespace webrtc {
class MediaTransportInterface;
// MediaTransportConfig contains meida transport (if provided) and passed from
// PeerConnection to call obeject and media layers that require access to media
// transport. In the future we can add other transport (for example, datagram
// transport) and related configuration.
struct MediaTransportConfig {
// Default constructor for no-media transport scenarios.
MediaTransportConfig() = default;
// TODO(sukhanov): Consider adding RtpTransport* to MediaTransportConfig,
// because it's almost always passes along with media_transport.
// Does not own media_transport.
explicit MediaTransportConfig(MediaTransportInterface* media_transport)
: media_transport(media_transport) {}
std::string DebugString() const;
// If provided, all media is sent through media_transport.
MediaTransportInterface* media_transport = nullptr;
};
} // namespace webrtc
#endif // API_MEDIA_TRANSPORT_CONFIG_H_

View file

@ -123,6 +123,7 @@ if (rtc_include_tests) {
deps = [ deps = [
":audio", ":audio",
":audio_end_to_end_test", ":audio_end_to_end_test",
"../api:libjingle_peerconnection_api",
"../api:loopback_media_transport", "../api:loopback_media_transport",
"../api:mock_audio_mixer", "../api:mock_audio_mixer",
"../api:mock_frame_decryptor", "../api:mock_frame_decryptor",

View file

@ -56,7 +56,7 @@ std::string AudioReceiveStream::Config::ToString() const {
ss << "{rtp: " << rtp.ToString(); ss << "{rtp: " << rtp.ToString();
ss << ", rtcp_send_transport: " ss << ", rtcp_send_transport: "
<< (rtcp_send_transport ? "(Transport)" : "null"); << (rtcp_send_transport ? "(Transport)" : "null");
ss << ", media_transport: " << (media_transport ? "(Transport)" : "null"); ss << ", media_transport_config: " << media_transport_config.DebugString();
if (!sync_group.empty()) { if (!sync_group.empty()) {
ss << ", sync_group: " << sync_group; ss << ", sync_group: " << sync_group;
} }
@ -77,7 +77,7 @@ std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive(
static_cast<internal::AudioState*>(audio_state); static_cast<internal::AudioState*>(audio_state);
return voe::CreateChannelReceive( return voe::CreateChannelReceive(
clock, module_process_thread, internal_audio_state->audio_device_module(), clock, module_process_thread, internal_audio_state->audio_device_module(),
config.media_transport, config.rtcp_send_transport, event_log, config.media_transport_config, config.rtcp_send_transport, event_log,
config.rtp.remote_ssrc, config.jitter_buffer_max_packets, config.rtp.remote_ssrc, config.jitter_buffer_max_packets,
config.jitter_buffer_fast_accelerate, config.jitter_buffer_min_delay_ms, config.jitter_buffer_fast_accelerate, config.jitter_buffer_min_delay_ms,
config.jitter_buffer_enable_rtx_handling, config.decoder_factory, config.jitter_buffer_enable_rtx_handling, config.decoder_factory,
@ -122,7 +122,7 @@ AudioReceiveStream::AudioReceiveStream(
module_process_thread_checker_.Detach(); module_process_thread_checker_.Detach();
if (!config.media_transport) { if (!config.media_transport_config.media_transport) {
RTC_DCHECK(receiver_controller); RTC_DCHECK(receiver_controller);
RTC_DCHECK(packet_router); RTC_DCHECK(packet_router);
// Configure bandwidth estimation. // Configure bandwidth estimation.
@ -140,7 +140,7 @@ AudioReceiveStream::~AudioReceiveStream() {
RTC_LOG(LS_INFO) << "~AudioReceiveStream: " << config_.rtp.remote_ssrc; RTC_LOG(LS_INFO) << "~AudioReceiveStream: " << config_.rtp.remote_ssrc;
Stop(); Stop();
channel_receive_->SetAssociatedSendChannel(nullptr); channel_receive_->SetAssociatedSendChannel(nullptr);
if (!config_.media_transport) { if (!config_.media_transport_config.media_transport) {
channel_receive_->ResetReceiverCongestionControlObjects(); channel_receive_->ResetReceiverCongestionControlObjects();
} }
} }

View file

@ -220,7 +220,8 @@ TEST(AudioReceiveStreamTest, ConfigToString) {
"{rtp: {remote_ssrc: 1234, local_ssrc: 5678, transport_cc: off, nack: " "{rtp: {remote_ssrc: 1234, local_ssrc: 5678, transport_cc: off, nack: "
"{rtp_history_ms: 0}, extensions: [{uri: " "{rtp_history_ms: 0}, extensions: [{uri: "
"urn:ietf:params:rtp-hdrext:ssrc-audio-level, id: 3}]}, " "urn:ietf:params:rtp-hdrext:ssrc-audio-level, id: 3}]}, "
"rtcp_send_transport: null, media_transport: null}", "rtcp_send_transport: null, media_transport_config: {media_transport: "
"null}}",
config.ToString()); config.ToString());
} }

View file

@ -21,6 +21,7 @@
#include "api/call/transport.h" #include "api/call/transport.h"
#include "api/crypto/frame_encryptor_interface.h" #include "api/crypto/frame_encryptor_interface.h"
#include "api/function_view.h" #include "api/function_view.h"
#include "api/media_transport_config.h"
#include "audio/audio_state.h" #include "audio/audio_state.h"
#include "audio/channel_send.h" #include "audio/channel_send.h"
#include "audio/conversion.h" #include "audio/conversion.h"
@ -104,7 +105,7 @@ AudioSendStream::AudioSendStream(
voe::CreateChannelSend(clock, voe::CreateChannelSend(clock,
task_queue_factory, task_queue_factory,
module_process_thread, module_process_thread,
config.media_transport, config.media_transport_config,
/*overhead_observer=*/this, /*overhead_observer=*/this,
config.send_transport, config.send_transport,
rtcp_rtt_stats, rtcp_rtt_stats,
@ -127,8 +128,7 @@ AudioSendStream::AudioSendStream(
std::unique_ptr<voe::ChannelSendInterface> channel_send) std::unique_ptr<voe::ChannelSendInterface> channel_send)
: clock_(clock), : clock_(clock),
worker_queue_(rtp_transport->GetWorkerQueue()), worker_queue_(rtp_transport->GetWorkerQueue()),
config_(Config(/*send_transport=*/nullptr, config_(Config(/*send_transport=*/nullptr, MediaTransportConfig())),
/*media_transport=*/nullptr)),
audio_state_(audio_state), audio_state_(audio_state),
channel_send_(std::move(channel_send)), channel_send_(std::move(channel_send)),
event_log_(event_log), event_log_(event_log),
@ -151,15 +151,15 @@ AudioSendStream::AudioSendStream(
// time being, we can have either. When media transport is injected, there // time being, we can have either. When media transport is injected, there
// should be no rtp_transport, and below check should be strengthened to XOR // should be no rtp_transport, and below check should be strengthened to XOR
// (either rtp_transport or media_transport but not both). // (either rtp_transport or media_transport but not both).
RTC_DCHECK(rtp_transport || config.media_transport); RTC_DCHECK(rtp_transport || config.media_transport_config.media_transport);
if (config.media_transport) { if (config.media_transport_config.media_transport) {
// TODO(sukhanov): Currently media transport audio overhead is considered // TODO(sukhanov): Currently media transport audio overhead is considered
// constant, we will not get overhead_observer calls when using // constant, we will not get overhead_observer calls when using
// media_transport. In the future when we introduce RTP media transport we // media_transport. In the future when we introduce RTP media transport we
// should make audio overhead interface consistent and work for both RTP and // should make audio overhead interface consistent and work for both RTP and
// non-RTP implementations. // non-RTP implementations.
audio_overhead_per_packet_bytes_ = audio_overhead_per_packet_bytes_ =
config.media_transport->GetAudioPacketOverhead(); config.media_transport_config.media_transport->GetAudioPacketOverhead();
} }
rtp_rtcp_module_ = channel_send_->GetRtpRtcp(); rtp_rtcp_module_ = channel_send_->GetRtpRtcp();
RTC_DCHECK(rtp_rtcp_module_); RTC_DCHECK(rtp_rtcp_module_);

View file

@ -136,7 +136,7 @@ struct ConfigHelper {
ConfigHelper(bool audio_bwe_enabled, bool expect_set_encoder_call) ConfigHelper(bool audio_bwe_enabled, bool expect_set_encoder_call)
: clock_(1000000), : clock_(1000000),
task_queue_factory_(CreateDefaultTaskQueueFactory()), task_queue_factory_(CreateDefaultTaskQueueFactory()),
stream_config_(/*send_transport=*/nullptr, /*media_transport=*/nullptr), stream_config_(/*send_transport=*/nullptr, MediaTransportConfig()),
audio_processing_(new rtc::RefCountedObject<MockAudioProcessing>()), audio_processing_(new rtc::RefCountedObject<MockAudioProcessing>()),
bitrate_allocator_(&clock_, &limit_observer_), bitrate_allocator_(&clock_, &limit_observer_),
worker_queue_(task_queue_factory_->CreateTaskQueue( worker_queue_(task_queue_factory_->CreateTaskQueue(
@ -321,7 +321,7 @@ struct ConfigHelper {
TEST(AudioSendStreamTest, ConfigToString) { TEST(AudioSendStreamTest, ConfigToString) {
AudioSendStream::Config config(/*send_transport=*/nullptr, AudioSendStream::Config config(/*send_transport=*/nullptr,
/*media_transport=*/nullptr); MediaTransportConfig());
config.rtp.ssrc = kSsrc; config.rtp.ssrc = kSsrc;
config.rtp.c_name = kCName; config.rtp.c_name = kCName;
config.min_bitrate_bps = 12000; config.min_bitrate_bps = 12000;
@ -340,7 +340,7 @@ TEST(AudioSendStreamTest, ConfigToString) {
"{rtp: {ssrc: 1234, extmap-allow-mixed: true, extensions: [{uri: " "{rtp: {ssrc: 1234, extmap-allow-mixed: true, extensions: [{uri: "
"urn:ietf:params:rtp-hdrext:ssrc-audio-level, id: 2}], " "urn:ietf:params:rtp-hdrext:ssrc-audio-level, id: 2}], "
"c_name: foo_name}, rtcp_report_interval_ms: 2500, " "c_name: foo_name}, rtcp_report_interval_ms: 2500, "
"send_transport: null, media_transport: null, " "send_transport: null, media_transport_config: {media_transport: null}, "
"min_bitrate_bps: 12000, max_bitrate_bps: 34000, " "min_bitrate_bps: 12000, max_bitrate_bps: 34000, "
"send_codec_spec: {nack_enabled: true, transport_cc_enabled: false, " "send_codec_spec: {nack_enabled: true, transport_cc_enabled: false, "
"cng_payload_type: 42, payload_type: 103, " "cng_payload_type: 42, payload_type: 103, "

View file

@ -79,7 +79,7 @@ class ChannelReceive : public ChannelReceiveInterface,
ChannelReceive(Clock* clock, ChannelReceive(Clock* clock,
ProcessThread* module_process_thread, ProcessThread* module_process_thread,
AudioDeviceModule* audio_device_module, AudioDeviceModule* audio_device_module,
MediaTransportInterface* media_transport, const MediaTransportConfig& media_transport_config,
Transport* rtcp_send_transport, Transport* rtcp_send_transport,
RtcEventLog* rtc_event_log, RtcEventLog* rtc_event_log,
uint32_t remote_ssrc, uint32_t remote_ssrc,
@ -157,6 +157,12 @@ class ChannelReceive : public ChannelReceiveInterface,
std::vector<RtpSource> GetSources() const override; std::vector<RtpSource> GetSources() const override;
// TODO(sukhanov): Return const pointer. It requires making media transport
// getters like GetLatestTargetTransferRate to be also const.
MediaTransportInterface* media_transport() const {
return media_transport_config_.media_transport;
}
private: private:
bool ReceivePacket(const uint8_t* packet, bool ReceivePacket(const uint8_t* packet,
size_t packet_length, size_t packet_length,
@ -254,7 +260,7 @@ class ChannelReceive : public ChannelReceiveInterface,
rtc::ThreadChecker construction_thread_; rtc::ThreadChecker construction_thread_;
MediaTransportInterface* const media_transport_; MediaTransportConfig media_transport_config_;
// E2EE Audio Frame Decryption // E2EE Audio Frame Decryption
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor_; rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor_;
@ -265,7 +271,7 @@ int32_t ChannelReceive::OnReceivedPayloadData(const uint8_t* payloadData,
size_t payloadSize, size_t payloadSize,
const RTPHeader& rtp_header) { const RTPHeader& rtp_header) {
// We should not be receiving any RTP packets if media_transport is set. // We should not be receiving any RTP packets if media_transport is set.
RTC_CHECK(!media_transport_); RTC_CHECK(!media_transport());
if (!Playing()) { if (!Playing()) {
// Avoid inserting into NetEQ when we are not playing. Count the // Avoid inserting into NetEQ when we are not playing. Count the
@ -296,7 +302,7 @@ int32_t ChannelReceive::OnReceivedPayloadData(const uint8_t* payloadData,
// MediaTransportAudioSinkInterface override. // MediaTransportAudioSinkInterface override.
void ChannelReceive::OnData(uint64_t channel_id, void ChannelReceive::OnData(uint64_t channel_id,
MediaTransportEncodedAudioFrame frame) { MediaTransportEncodedAudioFrame frame) {
RTC_CHECK(media_transport_); RTC_CHECK(media_transport());
if (!Playing()) { if (!Playing()) {
// Avoid inserting into NetEQ when we are not playing. Count the // Avoid inserting into NetEQ when we are not playing. Count the
@ -432,7 +438,7 @@ ChannelReceive::ChannelReceive(
Clock* clock, Clock* clock,
ProcessThread* module_process_thread, ProcessThread* module_process_thread,
AudioDeviceModule* audio_device_module, AudioDeviceModule* audio_device_module,
MediaTransportInterface* media_transport, const MediaTransportConfig& media_transport_config,
Transport* rtcp_send_transport, Transport* rtcp_send_transport,
RtcEventLog* rtc_event_log, RtcEventLog* rtc_event_log,
uint32_t remote_ssrc, uint32_t remote_ssrc,
@ -458,7 +464,7 @@ ChannelReceive::ChannelReceive(
_audioDeviceModulePtr(audio_device_module), _audioDeviceModulePtr(audio_device_module),
_outputGain(1.0f), _outputGain(1.0f),
associated_send_channel_(nullptr), associated_send_channel_(nullptr),
media_transport_(media_transport), media_transport_config_(media_transport_config),
frame_decryptor_(frame_decryptor), frame_decryptor_(frame_decryptor),
crypto_options_(crypto_options) { crypto_options_(crypto_options) {
// TODO(nisse): Use _moduleProcessThreadPtr instead? // TODO(nisse): Use _moduleProcessThreadPtr instead?
@ -503,16 +509,16 @@ ChannelReceive::ChannelReceive(
// RTCP is enabled by default. // RTCP is enabled by default.
_rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound); _rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound);
if (media_transport_) { if (media_transport()) {
media_transport_->SetReceiveAudioSink(this); media_transport()->SetReceiveAudioSink(this);
} }
} }
ChannelReceive::~ChannelReceive() { ChannelReceive::~ChannelReceive() {
RTC_DCHECK(construction_thread_.IsCurrent()); RTC_DCHECK(construction_thread_.IsCurrent());
if (media_transport_) { if (media_transport()) {
media_transport_->SetReceiveAudioSink(nullptr); media_transport()->SetReceiveAudioSink(nullptr);
} }
StopPlayout(); StopPlayout();
@ -921,8 +927,8 @@ int ChannelReceive::GetRtpTimestampRateHz() const {
} }
int64_t ChannelReceive::GetRTT() const { int64_t ChannelReceive::GetRTT() const {
if (media_transport_) { if (media_transport()) {
auto target_rate = media_transport_->GetLatestTargetTransferRate(); auto target_rate = media_transport()->GetLatestTargetTransferRate();
if (target_rate.has_value()) { if (target_rate.has_value()) {
return target_rate->network_estimate.round_trip_time.ms(); return target_rate->network_estimate.round_trip_time.ms();
} }
@ -966,7 +972,7 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
Clock* clock, Clock* clock,
ProcessThread* module_process_thread, ProcessThread* module_process_thread,
AudioDeviceModule* audio_device_module, AudioDeviceModule* audio_device_module,
MediaTransportInterface* media_transport, const MediaTransportConfig& media_transport_config,
Transport* rtcp_send_transport, Transport* rtcp_send_transport,
RtcEventLog* rtc_event_log, RtcEventLog* rtc_event_log,
uint32_t remote_ssrc, uint32_t remote_ssrc,
@ -979,7 +985,7 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor, rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options) { const webrtc::CryptoOptions& crypto_options) {
return absl::make_unique<ChannelReceive>( return absl::make_unique<ChannelReceive>(
clock, module_process_thread, audio_device_module, media_transport, clock, module_process_thread, audio_device_module, media_transport_config,
rtcp_send_transport, rtc_event_log, remote_ssrc, rtcp_send_transport, rtc_event_log, remote_ssrc,
jitter_buffer_max_packets, jitter_buffer_fast_playout, jitter_buffer_max_packets, jitter_buffer_fast_playout,
jitter_buffer_min_delay_ms, jitter_buffer_enable_rtx_handling, jitter_buffer_min_delay_ms, jitter_buffer_enable_rtx_handling,

View file

@ -22,6 +22,7 @@
#include "api/call/audio_sink.h" #include "api/call/audio_sink.h"
#include "api/call/transport.h" #include "api/call/transport.h"
#include "api/crypto/crypto_options.h" #include "api/crypto/crypto_options.h"
#include "api/media_transport_config.h"
#include "api/media_transport_interface.h" #include "api/media_transport_interface.h"
#include "api/rtp_receiver_interface.h" #include "api/rtp_receiver_interface.h"
#include "call/rtp_packet_sink_interface.h" #include "call/rtp_packet_sink_interface.h"
@ -143,7 +144,7 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
Clock* clock, Clock* clock,
ProcessThread* module_process_thread, ProcessThread* module_process_thread,
AudioDeviceModule* audio_device_module, AudioDeviceModule* audio_device_module,
MediaTransportInterface* media_transport, const MediaTransportConfig& media_transport_config,
Transport* rtcp_send_transport, Transport* rtcp_send_transport,
RtcEventLog* rtc_event_log, RtcEventLog* rtc_event_log,
uint32_t remote_ssrc, uint32_t remote_ssrc,

View file

@ -89,7 +89,7 @@ class ChannelSend : public ChannelSendInterface,
ChannelSend(Clock* clock, ChannelSend(Clock* clock,
TaskQueueFactory* task_queue_factory, TaskQueueFactory* task_queue_factory,
ProcessThread* module_process_thread, ProcessThread* module_process_thread,
MediaTransportInterface* media_transport, const MediaTransportConfig& media_transport_config,
OverheadObserver* overhead_observer, OverheadObserver* overhead_observer,
Transport* rtp_transport, Transport* rtp_transport,
RtcpRttStats* rtcp_rtt_stats, RtcpRttStats* rtcp_rtt_stats,
@ -205,7 +205,9 @@ class ChannelSend : public ChannelSendInterface,
RTC_RUN_ON(encoder_queue_); RTC_RUN_ON(encoder_queue_);
// Return media transport or nullptr if using RTP. // Return media transport or nullptr if using RTP.
MediaTransportInterface* media_transport() { return media_transport_; } MediaTransportInterface* media_transport() {
return media_transport_config_.media_transport;
}
// Called on the encoder task queue when a new input audio frame is ready // Called on the encoder task queue when a new input audio frame is ready
// for encoding. // for encoding.
@ -266,7 +268,7 @@ class ChannelSend : public ChannelSendInterface,
bool encoder_queue_is_active_ RTC_GUARDED_BY(encoder_queue_) = false; bool encoder_queue_is_active_ RTC_GUARDED_BY(encoder_queue_) = false;
MediaTransportInterface* const media_transport_; MediaTransportConfig media_transport_config_;
int media_transport_sequence_number_ RTC_GUARDED_BY(encoder_queue_) = 0; int media_transport_sequence_number_ RTC_GUARDED_BY(encoder_queue_) = 0;
rtc::CriticalSection media_transport_lock_; rtc::CriticalSection media_transport_lock_;
@ -618,7 +620,7 @@ int32_t ChannelSend::SendMediaTransportAudio(
ChannelSend::ChannelSend(Clock* clock, ChannelSend::ChannelSend(Clock* clock,
TaskQueueFactory* task_queue_factory, TaskQueueFactory* task_queue_factory,
ProcessThread* module_process_thread, ProcessThread* module_process_thread,
MediaTransportInterface* media_transport, const MediaTransportConfig& media_transport_config,
OverheadObserver* overhead_observer, OverheadObserver* overhead_observer,
Transport* rtp_transport, Transport* rtp_transport,
RtcpRttStats* rtcp_rtt_stats, RtcpRttStats* rtcp_rtt_stats,
@ -642,7 +644,7 @@ ChannelSend::ChannelSend(Clock* clock,
new RateLimiter(clock, kMaxRetransmissionWindowMs)), new RateLimiter(clock, kMaxRetransmissionWindowMs)),
use_twcc_plr_for_ana_( use_twcc_plr_for_ana_(
webrtc::field_trial::FindFullName("UseTwccPlrForAna") == "Enabled"), webrtc::field_trial::FindFullName("UseTwccPlrForAna") == "Enabled"),
media_transport_(media_transport), media_transport_config_(media_transport_config),
frame_encryptor_(frame_encryptor), frame_encryptor_(frame_encryptor),
crypto_options_(crypto_options), crypto_options_(crypto_options),
encoder_queue_(task_queue_factory->CreateTaskQueue( encoder_queue_(task_queue_factory->CreateTaskQueue(
@ -659,7 +661,7 @@ ChannelSend::ChannelSend(Clock* clock,
// transport. All of this logic should be moved to the future // transport. All of this logic should be moved to the future
// RTPMediaTransport. In this case it means that overhead and bandwidth // RTPMediaTransport. In this case it means that overhead and bandwidth
// observers should not be called when using media transport. // observers should not be called when using media transport.
if (!media_transport_) { if (!media_transport_config.media_transport) {
configuration.overhead_observer = overhead_observer; configuration.overhead_observer = overhead_observer;
configuration.bandwidth_callback = rtcp_observer_.get(); configuration.bandwidth_callback = rtcp_observer_.get();
configuration.transport_feedback_callback = feedback_observer_proxy_.get(); configuration.transport_feedback_callback = feedback_observer_proxy_.get();
@ -689,10 +691,11 @@ ChannelSend::ChannelSend(Clock* clock,
// We want to invoke the 'TargetRateObserver' and |OnOverheadChanged| // We want to invoke the 'TargetRateObserver' and |OnOverheadChanged|
// callbacks after the audio_coding_ is fully initialized. // callbacks after the audio_coding_ is fully initialized.
if (media_transport_) { if (media_transport_config.media_transport) {
RTC_DLOG(LS_INFO) << "Setting media_transport_ rate observers."; RTC_DLOG(LS_INFO) << "Setting media_transport_ rate observers.";
media_transport_->AddTargetTransferRateObserver(this); media_transport_config.media_transport->AddTargetTransferRateObserver(this);
media_transport_->SetAudioOverheadObserver(overhead_observer); media_transport_config.media_transport->SetAudioOverheadObserver(
overhead_observer);
} else { } else {
RTC_DLOG(LS_INFO) << "Not setting media_transport_ rate observers."; RTC_DLOG(LS_INFO) << "Not setting media_transport_ rate observers.";
} }
@ -714,9 +717,10 @@ ChannelSend::ChannelSend(Clock* clock,
ChannelSend::~ChannelSend() { ChannelSend::~ChannelSend() {
RTC_DCHECK(construction_thread_.IsCurrent()); RTC_DCHECK(construction_thread_.IsCurrent());
if (media_transport_) { if (media_transport_config_.media_transport) {
media_transport_->RemoveTargetTransferRateObserver(this); media_transport_config_.media_transport->RemoveTargetTransferRateObserver(
media_transport_->SetAudioOverheadObserver(nullptr); this);
media_transport_config_.media_transport->SetAudioOverheadObserver(nullptr);
} }
StopSend(); StopSend();
@ -779,7 +783,7 @@ void ChannelSend::SetEncoder(int payload_type,
encoder->RtpTimestampRateHz(), encoder->RtpTimestampRateHz(),
encoder->NumChannels(), 0); encoder->NumChannels(), 0);
if (media_transport_) { if (media_transport_config_.media_transport) {
rtc::CritScope cs(&media_transport_lock_); rtc::CritScope cs(&media_transport_lock_);
media_transport_payload_type_ = payload_type; media_transport_payload_type_ = payload_type;
// TODO(nisse): Currently broken for G722, since timestamps passed through // TODO(nisse): Currently broken for G722, since timestamps passed through
@ -856,7 +860,7 @@ void ChannelSend::OnUplinkPacketLossRate(float packet_loss_rate) {
void ChannelSend::ReceivedRTCPPacket(const uint8_t* data, size_t length) { void ChannelSend::ReceivedRTCPPacket(const uint8_t* data, size_t length) {
// May be called on either worker thread or network thread. // May be called on either worker thread or network thread.
if (media_transport_) { if (media_transport_config_.media_transport) {
// Ignore RTCP packets while media transport is used. // Ignore RTCP packets while media transport is used.
// Those packets should not arrive, but we are seeing occasional packets. // Those packets should not arrive, but we are seeing occasional packets.
return; return;
@ -931,7 +935,7 @@ void ChannelSend::SetLocalSSRC(uint32_t ssrc) {
RTC_DCHECK_RUN_ON(&worker_thread_checker_); RTC_DCHECK_RUN_ON(&worker_thread_checker_);
RTC_DCHECK(!sending_); RTC_DCHECK(!sending_);
if (media_transport_) { if (media_transport_config_.media_transport) {
rtc::CritScope cs(&media_transport_lock_); rtc::CritScope cs(&media_transport_lock_);
media_transport_channel_id_ = ssrc; media_transport_channel_id_ = ssrc;
} }
@ -1165,12 +1169,13 @@ int ChannelSend::SetSendRtpHeaderExtension(bool enable,
} }
int64_t ChannelSend::GetRTT() const { int64_t ChannelSend::GetRTT() const {
if (media_transport_) { if (media_transport_config_.media_transport) {
// GetRTT is generally used in the RTCP codepath, where media transport is // GetRTT is generally used in the RTCP codepath, where media transport is
// not present and so it shouldn't be needed. But it's also invoked in // not present and so it shouldn't be needed. But it's also invoked in
// 'GetStats' method, and for now returning media transport RTT here gives // 'GetStats' method, and for now returning media transport RTT here gives
// us "free" rtt stats for media transport. // us "free" rtt stats for media transport.
auto target_rate = media_transport_->GetLatestTargetTransferRate(); auto target_rate =
media_transport_config_.media_transport->GetLatestTargetTransferRate();
if (target_rate.has_value()) { if (target_rate.has_value()) {
return target_rate.value().network_estimate.round_trip_time.ms(); return target_rate.value().network_estimate.round_trip_time.ms();
} }
@ -1214,7 +1219,7 @@ void ChannelSend::SetFrameEncryptor(
// AudioSendStream. Since AudioSendStream owns encoder and configures ANA, it // AudioSendStream. Since AudioSendStream owns encoder and configures ANA, it
// makes sense to consolidate all rate (and overhead) calculation there. // makes sense to consolidate all rate (and overhead) calculation there.
void ChannelSend::OnTargetTransferRate(TargetTransferRate rate) { void ChannelSend::OnTargetTransferRate(TargetTransferRate rate) {
RTC_DCHECK(media_transport_); RTC_DCHECK(media_transport_config_.media_transport);
OnReceivedRtt(rate.network_estimate.round_trip_time.ms()); OnReceivedRtt(rate.network_estimate.round_trip_time.ms());
} }
@ -1230,7 +1235,7 @@ std::unique_ptr<ChannelSendInterface> CreateChannelSend(
Clock* clock, Clock* clock,
TaskQueueFactory* task_queue_factory, TaskQueueFactory* task_queue_factory,
ProcessThread* module_process_thread, ProcessThread* module_process_thread,
MediaTransportInterface* media_transport, const MediaTransportConfig& media_transport_config,
OverheadObserver* overhead_observer, OverheadObserver* overhead_observer,
Transport* rtp_transport, Transport* rtp_transport,
RtcpRttStats* rtcp_rtt_stats, RtcpRttStats* rtcp_rtt_stats,
@ -1240,7 +1245,7 @@ std::unique_ptr<ChannelSendInterface> CreateChannelSend(
bool extmap_allow_mixed, bool extmap_allow_mixed,
int rtcp_report_interval_ms) { int rtcp_report_interval_ms) {
return absl::make_unique<ChannelSend>( return absl::make_unique<ChannelSend>(
clock, task_queue_factory, module_process_thread, media_transport, clock, task_queue_factory, module_process_thread, media_transport_config,
overhead_observer, rtp_transport, rtcp_rtt_stats, rtc_event_log, overhead_observer, rtp_transport, rtcp_rtt_stats, rtc_event_log,
frame_encryptor, crypto_options, extmap_allow_mixed, frame_encryptor, crypto_options, extmap_allow_mixed,
rtcp_report_interval_ms); rtcp_report_interval_ms);

View file

@ -19,6 +19,7 @@
#include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_encoder.h"
#include "api/crypto/crypto_options.h" #include "api/crypto/crypto_options.h"
#include "api/function_view.h" #include "api/function_view.h"
#include "api/media_transport_config.h"
#include "api/media_transport_interface.h" #include "api/media_transport_interface.h"
#include "api/task_queue/task_queue_factory.h" #include "api/task_queue/task_queue_factory.h"
#include "modules/rtp_rtcp/include/rtp_rtcp.h" #include "modules/rtp_rtcp/include/rtp_rtcp.h"
@ -125,7 +126,7 @@ std::unique_ptr<ChannelSendInterface> CreateChannelSend(
Clock* clock, Clock* clock,
TaskQueueFactory* task_queue_factory, TaskQueueFactory* task_queue_factory,
ProcessThread* module_process_thread, ProcessThread* module_process_thread,
MediaTransportInterface* media_transport, const MediaTransportConfig& media_transport_config,
OverheadObserver* overhead_observer, OverheadObserver* overhead_observer,
Transport* rtp_transport, Transport* rtp_transport,
RtcpRttStats* rtcp_rtt_stats, RtcpRttStats* rtcp_rtt_stats,

View file

@ -13,6 +13,7 @@
#include "api/audio_codecs/audio_encoder_factory_template.h" #include "api/audio_codecs/audio_encoder_factory_template.h"
#include "api/audio_codecs/opus/audio_decoder_opus.h" #include "api/audio_codecs/opus/audio_decoder_opus.h"
#include "api/audio_codecs/opus/audio_encoder_opus.h" #include "api/audio_codecs/opus/audio_encoder_opus.h"
#include "api/media_transport_config.h"
#include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/default_task_queue_factory.h"
#include "api/test/loopback_media_transport.h" #include "api/test/loopback_media_transport.h"
#include "api/test/mock_audio_mixer.h" #include "api/test/mock_audio_mixer.h"
@ -100,7 +101,8 @@ TEST(AudioWithMediaTransport, DeliversAudio) {
// TODO(nisse): Update AudioReceiveStream to not require rtcp_send_transport // TODO(nisse): Update AudioReceiveStream to not require rtcp_send_transport
// when a MediaTransport is provided. // when a MediaTransport is provided.
receive_config.rtcp_send_transport = &rtcp_send_transport; receive_config.rtcp_send_transport = &rtcp_send_transport;
receive_config.media_transport = transport_pair.first(); receive_config.media_transport_config.media_transport =
transport_pair.first();
receive_config.decoder_map.emplace(kPayloadTypeOpus, audio_format); receive_config.decoder_map.emplace(kPayloadTypeOpus, audio_format);
receive_config.decoder_factory = receive_config.decoder_factory =
CreateAudioDecoderFactory<AudioDecoderOpus>(); CreateAudioDecoderFactory<AudioDecoderOpus>();
@ -116,7 +118,8 @@ TEST(AudioWithMediaTransport, DeliversAudio) {
// TODO(nisse): Update AudioSendStream to not require send_transport when a // TODO(nisse): Update AudioSendStream to not require send_transport when a
// MediaTransport is provided. // MediaTransport is provided.
AudioSendStream::Config send_config(&send_transport, transport_pair.second()); AudioSendStream::Config send_config(
&send_transport, webrtc::MediaTransportConfig(transport_pair.second()));
send_config.send_codec_spec = send_config.send_codec_spec =
AudioSendStream::Config::SendCodecSpec(kPayloadTypeOpus, audio_format); AudioSendStream::Config::SendCodecSpec(kPayloadTypeOpus, audio_format);
send_config.encoder_factory = CreateAudioEncoderFactory<AudioEncoderOpus>(); send_config.encoder_factory = CreateAudioEncoderFactory<AudioEncoderOpus>();

View file

@ -20,7 +20,7 @@
#include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/audio_decoder_factory.h"
#include "api/call/transport.h" #include "api/call/transport.h"
#include "api/crypto/crypto_options.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_parameters.h"
#include "api/rtp_receiver_interface.h" #include "api/rtp_receiver_interface.h"
#include "api/scoped_refptr.h" #include "api/scoped_refptr.h"
@ -122,7 +122,7 @@ class AudioReceiveStream {
Transport* rtcp_send_transport = nullptr; Transport* rtcp_send_transport = nullptr;
MediaTransportInterface* media_transport = nullptr; MediaTransportConfig media_transport_config;
// NetEq settings. // NetEq settings.
size_t jitter_buffer_max_packets = 200; size_t jitter_buffer_max_packets = 200;

View file

@ -21,12 +21,14 @@ namespace webrtc {
AudioSendStream::Stats::Stats() = default; AudioSendStream::Stats::Stats() = default;
AudioSendStream::Stats::~Stats() = default; AudioSendStream::Stats::~Stats() = default;
AudioSendStream::Config::Config(Transport* send_transport, AudioSendStream::Config::Config(
MediaTransportInterface* media_transport) Transport* send_transport,
: send_transport(send_transport), media_transport(media_transport) {} const MediaTransportConfig& media_transport_config)
: send_transport(send_transport),
media_transport_config(media_transport_config) {}
AudioSendStream::Config::Config(Transport* send_transport) AudioSendStream::Config::Config(Transport* send_transport)
: Config(send_transport, nullptr) {} : Config(send_transport, MediaTransportConfig()) {}
AudioSendStream::Config::~Config() = default; AudioSendStream::Config::~Config() = default;
@ -36,7 +38,7 @@ std::string AudioSendStream::Config::ToString() const {
ss << "{rtp: " << rtp.ToString(); ss << "{rtp: " << rtp.ToString();
ss << ", rtcp_report_interval_ms: " << rtcp_report_interval_ms; ss << ", rtcp_report_interval_ms: " << rtcp_report_interval_ms;
ss << ", send_transport: " << (send_transport ? "(Transport)" : "null"); 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 << ", min_bitrate_bps: " << min_bitrate_bps;
ss << ", max_bitrate_bps: " << max_bitrate_bps; ss << ", max_bitrate_bps: " << max_bitrate_bps;
ss << ", send_codec_spec: " ss << ", send_codec_spec: "

View file

@ -23,6 +23,7 @@
#include "api/call/transport.h" #include "api/call/transport.h"
#include "api/crypto/crypto_options.h" #include "api/crypto/crypto_options.h"
#include "api/crypto/frame_encryptor_interface.h" #include "api/crypto/frame_encryptor_interface.h"
#include "api/media_transport_config.h"
#include "api/media_transport_interface.h" #include "api/media_transport_interface.h"
#include "api/rtp_parameters.h" #include "api/rtp_parameters.h"
#include "api/scoped_refptr.h" #include "api/scoped_refptr.h"
@ -69,7 +70,8 @@ class AudioSendStream {
struct Config { struct Config {
Config() = delete; Config() = delete;
Config(Transport* send_transport, MediaTransportInterface* media_transport); Config(Transport* send_transport,
const MediaTransportConfig& media_transport_config);
explicit Config(Transport* send_transport); explicit Config(Transport* send_transport);
~Config(); ~Config();
std::string ToString() const; std::string ToString() const;
@ -108,7 +110,7 @@ class AudioSendStream {
// the entire life of the AudioSendStream and is owned by the API client. // the entire life of the AudioSendStream and is owned by the API client.
Transport* send_transport = nullptr; 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 // Bitrate limits used for variable audio bitrate streams. Set both to -1 to
// disable audio bitrate adaptation. // disable audio bitrate adaptation.

View file

@ -708,7 +708,8 @@ webrtc::AudioSendStream* Call::CreateAudioSendStream(
TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream"); TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream");
RTC_DCHECK_RUN_ON(&configuration_sequence_checker_); 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(); RegisterRateObserver();

View file

@ -244,7 +244,7 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec,
CreateMatchingReceiveConfigs(receive_transport.get()); CreateMatchingReceiveConfigs(receive_transport.get());
AudioSendStream::Config audio_send_config(audio_send_transport.get(), AudioSendStream::Config audio_send_config(audio_send_transport.get(),
/*media_transport=*/nullptr); MediaTransportConfig());
audio_send_config.rtp.ssrc = kAudioSendSsrc; audio_send_config.rtp.ssrc = kAudioSendSsrc;
audio_send_config.send_codec_spec = AudioSendStream::Config::SendCodecSpec( audio_send_config.send_codec_spec = AudioSendStream::Config::SendCodecSpec(
kAudioSendPayloadType, {"ISAC", 16000, 1}); kAudioSendPayloadType, {"ISAC", 16000, 1});

View file

@ -64,8 +64,7 @@ TEST(CallTest, ConstructDestruct) {
TEST(CallTest, CreateDestroy_AudioSendStream) { TEST(CallTest, CreateDestroy_AudioSendStream) {
CallHelper call; CallHelper call;
MockTransport send_transport; MockTransport send_transport;
AudioSendStream::Config config(&send_transport, AudioSendStream::Config config(&send_transport, MediaTransportConfig());
/*media_transport=*/nullptr);
config.rtp.ssrc = 42; config.rtp.ssrc = 42;
AudioSendStream* stream = call->CreateAudioSendStream(config); AudioSendStream* stream = call->CreateAudioSendStream(config);
EXPECT_NE(stream, nullptr); EXPECT_NE(stream, nullptr);
@ -88,8 +87,7 @@ TEST(CallTest, CreateDestroy_AudioReceiveStream) {
TEST(CallTest, CreateDestroy_AudioSendStreams) { TEST(CallTest, CreateDestroy_AudioSendStreams) {
CallHelper call; CallHelper call;
MockTransport send_transport; MockTransport send_transport;
AudioSendStream::Config config(&send_transport, AudioSendStream::Config config(&send_transport, MediaTransportConfig());
/*media_transport=*/nullptr);
std::list<AudioSendStream*> streams; std::list<AudioSendStream*> streams;
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) { for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) {
@ -148,8 +146,7 @@ TEST(CallTest, CreateDestroy_AssociateAudioSendReceiveStreams_RecvFirst) {
EXPECT_NE(recv_stream, nullptr); EXPECT_NE(recv_stream, nullptr);
MockTransport send_transport; MockTransport send_transport;
AudioSendStream::Config send_config(&send_transport, AudioSendStream::Config send_config(&send_transport, MediaTransportConfig());
/*media_transport=*/nullptr);
send_config.rtp.ssrc = 777; send_config.rtp.ssrc = 777;
AudioSendStream* send_stream = call->CreateAudioSendStream(send_config); AudioSendStream* send_stream = call->CreateAudioSendStream(send_config);
EXPECT_NE(send_stream, nullptr); EXPECT_NE(send_stream, nullptr);
@ -168,8 +165,7 @@ TEST(CallTest, CreateDestroy_AssociateAudioSendReceiveStreams_RecvFirst) {
TEST(CallTest, CreateDestroy_AssociateAudioSendReceiveStreams_SendFirst) { TEST(CallTest, CreateDestroy_AssociateAudioSendReceiveStreams_SendFirst) {
CallHelper call; CallHelper call;
MockTransport send_transport; MockTransport send_transport;
AudioSendStream::Config send_config(&send_transport, AudioSendStream::Config send_config(&send_transport, MediaTransportConfig());
/*media_transport=*/nullptr);
send_config.rtp.ssrc = 777; send_config.rtp.ssrc = 777;
AudioSendStream* send_stream = call->CreateAudioSendStream(send_config); AudioSendStream* send_stream = call->CreateAudioSendStream(send_config);
EXPECT_NE(send_stream, nullptr); EXPECT_NE(send_stream, nullptr);
@ -273,8 +269,7 @@ TEST(CallTest, RecreatingAudioStreamWithSameSsrcReusesRtpState) {
auto create_stream_and_get_rtp_state = [&](uint32_t ssrc) { auto create_stream_and_get_rtp_state = [&](uint32_t ssrc) {
MockTransport send_transport; MockTransport send_transport;
AudioSendStream::Config config(&send_transport, AudioSendStream::Config config(&send_transport, MediaTransportConfig());
/*media_transport=*/nullptr);
config.rtp.ssrc = ssrc; config.rtp.ssrc = ssrc;
AudioSendStream* stream = call->CreateAudioSendStream(config); AudioSendStream* stream = call->CreateAudioSendStream(config);
const RtpState rtp_state = const RtpState rtp_state =
@ -305,7 +300,7 @@ TEST(CallTest, RegisterMediaTransportBitrateCallbacksInCreateStream) {
// RTCPSender requires one. // RTCPSender requires one.
MockTransport send_transport; MockTransport send_transport;
AudioSendStream::Config config(&send_transport, AudioSendStream::Config config(&send_transport,
/*media_transport=*/&fake_media_transport); MediaTransportConfig(&fake_media_transport));
call->MediaTransportChange(&fake_media_transport); call->MediaTransportChange(&fake_media_transport);
AudioSendStream* stream = call->CreateAudioSendStream(config); AudioSendStream* stream = call->CreateAudioSendStream(config);

View file

@ -67,11 +67,11 @@ std::string VideoReceiveStream::Stats::ToString(int64_t time_ms) const {
VideoReceiveStream::Config::Config(const Config&) = default; VideoReceiveStream::Config::Config(const Config&) = default;
VideoReceiveStream::Config::Config(Config&&) = default; VideoReceiveStream::Config::Config(Config&&) = default;
VideoReceiveStream::Config::Config(Transport* rtcp_send_transport, VideoReceiveStream::Config::Config(Transport* rtcp_send_transport,
MediaTransportInterface* media_transport) MediaTransportConfig media_transport_config)
: rtcp_send_transport(rtcp_send_transport), : rtcp_send_transport(rtcp_send_transport),
media_transport(media_transport) {} media_transport_config(media_transport_config) {}
VideoReceiveStream::Config::Config(Transport* rtcp_send_transport) VideoReceiveStream::Config::Config(Transport* rtcp_send_transport)
: Config(rtcp_send_transport, nullptr) {} : Config(rtcp_send_transport, MediaTransportConfig()) {}
VideoReceiveStream::Config& VideoReceiveStream::Config::operator=(Config&&) = VideoReceiveStream::Config& VideoReceiveStream::Config::operator=(Config&&) =
default; default;

View file

@ -18,6 +18,7 @@
#include "api/call/transport.h" #include "api/call/transport.h"
#include "api/crypto/crypto_options.h" #include "api/crypto/crypto_options.h"
#include "api/media_transport_config.h"
#include "api/media_transport_interface.h" #include "api/media_transport_interface.h"
#include "api/rtp_headers.h" #include "api/rtp_headers.h"
#include "api/rtp_parameters.h" #include "api/rtp_parameters.h"
@ -121,7 +122,7 @@ class VideoReceiveStream {
Config() = delete; Config() = delete;
Config(Config&&); Config(Config&&);
Config(Transport* rtcp_send_transport, Config(Transport* rtcp_send_transport,
MediaTransportInterface* media_transport); MediaTransportConfig media_transport_config);
explicit Config(Transport* rtcp_send_transport); explicit Config(Transport* rtcp_send_transport);
Config& operator=(Config&&); Config& operator=(Config&&);
Config& operator=(const Config&) = delete; Config& operator=(const Config&) = delete;
@ -132,6 +133,10 @@ class VideoReceiveStream {
std::string ToString() const; std::string ToString() const;
MediaTransportInterface* media_transport() const {
return media_transport_config.media_transport;
}
// Decoders for every payload that we can receive. // Decoders for every payload that we can receive.
std::vector<Decoder> decoders; std::vector<Decoder> decoders;
@ -197,7 +202,7 @@ class VideoReceiveStream {
// Transport for outgoing packets (RTCP). // Transport for outgoing packets (RTCP).
Transport* rtcp_send_transport = nullptr; Transport* rtcp_send_transport = nullptr;
MediaTransportInterface* media_transport = nullptr; MediaTransportConfig media_transport_config;
// Must always be set. // Must always be set.
rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr; rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr;

View file

@ -24,10 +24,10 @@ MediaChannel::~MediaChannel() {}
void MediaChannel::SetInterface( void MediaChannel::SetInterface(
NetworkInterface* iface, NetworkInterface* iface,
webrtc::MediaTransportInterface* media_transport) { const webrtc::MediaTransportConfig& media_transport_config) {
rtc::CritScope cs(&network_interface_crit_); rtc::CritScope cs(&network_interface_crit_);
network_interface_ = iface; network_interface_ = iface;
media_transport_ = media_transport; media_transport_config_ = media_transport_config;
UpdateDscp(); UpdateDscp();
} }

View file

@ -22,7 +22,7 @@
#include "api/audio_options.h" #include "api/audio_options.h"
#include "api/crypto/frame_decryptor_interface.h" #include "api/crypto/frame_decryptor_interface.h"
#include "api/crypto/frame_encryptor_interface.h" #include "api/crypto/frame_encryptor_interface.h"
#include "api/media_transport_interface.h" #include "api/media_transport_config.h"
#include "api/rtc_error.h" #include "api/rtc_error.h"
#include "api/rtp_parameters.h" #include "api/rtp_parameters.h"
#include "api/rtp_receiver_interface.h" #include "api/rtp_receiver_interface.h"
@ -193,8 +193,9 @@ class MediaChannel : public sigslot::has_slots<> {
// TODO(sukhanov): Currently media transport can co-exist with RTP/RTCP, but // TODO(sukhanov): Currently media transport can co-exist with RTP/RTCP, but
// in the future we will refactor code to send all frames with media // in the future we will refactor code to send all frames with media
// transport. // transport.
virtual void SetInterface(NetworkInterface* iface, virtual void SetInterface(
webrtc::MediaTransportInterface* media_transport); NetworkInterface* iface,
const webrtc::MediaTransportConfig& media_transport_config);
// Called when a RTP packet is received. // Called when a RTP packet is received.
virtual void OnPacketReceived(rtc::CopyOnWriteBuffer packet, virtual void OnPacketReceived(rtc::CopyOnWriteBuffer packet,
int64_t packet_time_us) = 0; int64_t packet_time_us) = 0;
@ -261,8 +262,12 @@ class MediaChannel : public sigslot::has_slots<> {
return network_interface_->SetOption(type, opt, option); return network_interface_->SetOption(type, opt, option);
} }
const webrtc::MediaTransportConfig& media_transport_config() const {
return media_transport_config_;
}
webrtc::MediaTransportInterface* media_transport() { webrtc::MediaTransportInterface* media_transport() {
return media_transport_; return media_transport_config_.media_transport;
} }
// Corresponds to the SDP attribute extmap-allow-mixed, see RFC8285. // Corresponds to the SDP attribute extmap-allow-mixed, see RFC8285.
@ -331,7 +336,7 @@ class MediaChannel : public sigslot::has_slots<> {
nullptr; nullptr;
rtc::DiffServCodePoint preferred_dscp_ rtc::DiffServCodePoint preferred_dscp_
RTC_GUARDED_BY(network_interface_crit_) = rtc::DSCP_DEFAULT; RTC_GUARDED_BY(network_interface_crit_) = rtc::DSCP_DEFAULT;
webrtc::MediaTransportInterface* media_transport_ = nullptr; webrtc::MediaTransportConfig media_transport_config_;
bool extmap_allow_mixed_ = false; bool extmap_allow_mixed_ = false;
}; };

View file

@ -12,6 +12,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "api/media_transport_config.h"
#include "media/base/fake_network_interface.h" #include "media/base/fake_network_interface.h"
#include "media/base/media_constants.h" #include "media/base/media_constants.h"
#include "media/base/rtp_data_engine.h" #include "media/base/rtp_data_engine.h"
@ -73,7 +74,8 @@ class RtpDataMediaChannelTest : public ::testing::Test {
cricket::MediaConfig config; cricket::MediaConfig config;
cricket::RtpDataMediaChannel* channel = cricket::RtpDataMediaChannel* channel =
static_cast<cricket::RtpDataMediaChannel*>(dme->CreateChannel(config)); static_cast<cricket::RtpDataMediaChannel*>(dme->CreateChannel(config));
channel->SetInterface(iface_.get(), /*media_transport=*/nullptr); channel->SetInterface(iface_.get(), webrtc::MediaTransportConfig(
/*media_transport=*/nullptr));
channel->SignalDataReceived.connect(receiver_.get(), channel->SignalDataReceived.connect(receiver_.get(),
&FakeDataReceiver::OnDataReceived); &FakeDataReceiver::OnDataReceived);
return channel; return channel;

View file

@ -1209,7 +1209,7 @@ bool WebRtcVideoChannel::AddRecvStream(const StreamParams& sp,
for (uint32_t used_ssrc : sp.ssrcs) for (uint32_t used_ssrc : sp.ssrcs)
receive_ssrcs_.insert(used_ssrc); receive_ssrcs_.insert(used_ssrc);
webrtc::VideoReceiveStream::Config config(this, media_transport()); webrtc::VideoReceiveStream::Config config(this, media_transport_config());
webrtc::FlexfecReceiveStream::Config flexfec_config(this); webrtc::FlexfecReceiveStream::Config flexfec_config(this);
ConfigureReceiverRtp(&config, &flexfec_config, sp); ConfigureReceiverRtp(&config, &flexfec_config, sp);
@ -1540,9 +1540,9 @@ void WebRtcVideoChannel::OnNetworkRouteChanged(
void WebRtcVideoChannel::SetInterface( void WebRtcVideoChannel::SetInterface(
NetworkInterface* iface, NetworkInterface* iface,
webrtc::MediaTransportInterface* media_transport) { const webrtc::MediaTransportConfig& media_transport_config) {
RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK_RUN_ON(&thread_checker_);
MediaChannel::SetInterface(iface, media_transport); MediaChannel::SetInterface(iface, media_transport_config);
// Set the RTP recv/send buffer to a bigger size. // Set the RTP recv/send buffer to a bigger size.
// The group should be a positive integer with an explicit size, in // The group should be a positive integer with an explicit size, in
@ -1723,7 +1723,11 @@ WebRtcVideoChannel::WebRtcVideoSendStream::WebRtcVideoSendStream(
parameters_(std::move(config), options, max_bitrate_bps, codec_settings), parameters_(std::move(config), options, max_bitrate_bps, codec_settings),
rtp_parameters_(CreateRtpParametersWithEncodings(sp)), rtp_parameters_(CreateRtpParametersWithEncodings(sp)),
sending_(false) { sending_(false) {
parameters_.config.rtp.max_packet_size = kVideoMtu; // Maximum packet size may come in RtpConfig from external transport, for
// example from QuicTransportInterface implementation, so do not exceed
// given max_packet_size.
parameters_.config.rtp.max_packet_size =
std::min<size_t>(parameters_.config.rtp.max_packet_size, kVideoMtu);
parameters_.conference_mode = send_params.conference_mode; parameters_.conference_mode = send_params.conference_mode;
sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs); sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs);

View file

@ -152,8 +152,9 @@ class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport {
void OnReadyToSend(bool ready) override; void OnReadyToSend(bool ready) override;
void OnNetworkRouteChanged(const std::string& transport_name, void OnNetworkRouteChanged(const std::string& transport_name,
const rtc::NetworkRoute& network_route) override; const rtc::NetworkRoute& network_route) override;
void SetInterface(NetworkInterface* iface, void SetInterface(
webrtc::MediaTransportInterface* media_transport) override; NetworkInterface* iface,
const webrtc::MediaTransportConfig& media_transport_config) override;
// E2E Encrypted Video Frame API // E2E Encrypted Video Frame API
// Set a frame decryptor to a particular ssrc that will intercept all // Set a frame decryptor to a particular ssrc that will intercept all

View file

@ -16,6 +16,7 @@
#include "absl/algorithm/container.h" #include "absl/algorithm/container.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "api/media_transport_config.h"
#include "api/rtp_parameters.h" #include "api/rtp_parameters.h"
#include "api/test/fake_media_transport.h" #include "api/test/fake_media_transport.h"
#include "api/test/mock_video_bitrate_allocator.h" #include "api/test/mock_video_bitrate_allocator.h"
@ -1292,7 +1293,7 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test {
channel_->OnReadyToSend(true); channel_->OnReadyToSend(true);
EXPECT_TRUE(channel_.get() != NULL); EXPECT_TRUE(channel_.get() != NULL);
network_interface_.SetDestination(channel_.get()); network_interface_.SetDestination(channel_.get());
channel_->SetInterface(&network_interface_, /*media_transport=*/nullptr); channel_->SetInterface(&network_interface_, webrtc::MediaTransportConfig());
cricket::VideoRecvParameters parameters; cricket::VideoRecvParameters parameters;
parameters.codecs = engine_.codecs(); parameters.codecs = engine_.codecs();
channel_->SetRecvParameters(parameters); channel_->SetRecvParameters(parameters);
@ -4017,7 +4018,8 @@ TEST_F(WebRtcVideoChannelTest,
webrtc::FakeMediaTransport fake_media_transport(settings); webrtc::FakeMediaTransport fake_media_transport(settings);
std::unique_ptr<cricket::FakeNetworkInterface> network_interface( std::unique_ptr<cricket::FakeNetworkInterface> network_interface(
new cricket::FakeNetworkInterface); new cricket::FakeNetworkInterface);
channel_->SetInterface(network_interface.get(), &fake_media_transport); channel_->SetInterface(network_interface.get(),
webrtc::MediaTransportConfig(&fake_media_transport));
send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "100"; send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "100";
send_parameters_.codecs[0].params[kCodecParamStartBitrate] = "200"; send_parameters_.codecs[0].params[kCodecParamStartBitrate] = "200";
@ -4624,7 +4626,8 @@ TEST_F(WebRtcVideoChannelTest, TestSetDscpOptions) {
static_cast<cricket::WebRtcVideoChannel*>(engine_.CreateMediaChannel( static_cast<cricket::WebRtcVideoChannel*>(engine_.CreateMediaChannel(
call_.get(), config, VideoOptions(), webrtc::CryptoOptions(), call_.get(), config, VideoOptions(), webrtc::CryptoOptions(),
video_bitrate_allocator_factory_.get()))); video_bitrate_allocator_factory_.get())));
channel->SetInterface(network_interface.get(), /*media_transport=*/nullptr); channel->SetInterface(network_interface.get(),
webrtc::MediaTransportConfig());
// Default value when DSCP is disabled should be DSCP_DEFAULT. // Default value when DSCP is disabled should be DSCP_DEFAULT.
EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp());
@ -4635,7 +4638,8 @@ TEST_F(WebRtcVideoChannelTest, TestSetDscpOptions) {
static_cast<cricket::WebRtcVideoChannel*>(engine_.CreateMediaChannel( static_cast<cricket::WebRtcVideoChannel*>(engine_.CreateMediaChannel(
call_.get(), config, VideoOptions(), webrtc::CryptoOptions(), call_.get(), config, VideoOptions(), webrtc::CryptoOptions(),
video_bitrate_allocator_factory_.get()))); video_bitrate_allocator_factory_.get())));
channel->SetInterface(network_interface.get(), /*media_transport=*/nullptr); channel->SetInterface(network_interface.get(),
webrtc::MediaTransportConfig());
EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp());
// Create a send stream to configure // Create a send stream to configure
@ -4669,7 +4673,8 @@ TEST_F(WebRtcVideoChannelTest, TestSetDscpOptions) {
static_cast<cricket::WebRtcVideoChannel*>(engine_.CreateMediaChannel( static_cast<cricket::WebRtcVideoChannel*>(engine_.CreateMediaChannel(
call_.get(), config, VideoOptions(), webrtc::CryptoOptions(), call_.get(), config, VideoOptions(), webrtc::CryptoOptions(),
video_bitrate_allocator_factory_.get()))); video_bitrate_allocator_factory_.get())));
channel->SetInterface(network_interface.get(), /*media_transport=*/nullptr); channel->SetInterface(network_interface.get(),
webrtc::MediaTransportConfig());
EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp());
} }

View file

@ -699,13 +699,13 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
const absl::optional<std::string>& audio_network_adaptor_config, const absl::optional<std::string>& audio_network_adaptor_config,
webrtc::Call* call, webrtc::Call* call,
webrtc::Transport* send_transport, webrtc::Transport* send_transport,
webrtc::MediaTransportInterface* media_transport, const webrtc::MediaTransportConfig& media_transport_config,
const rtc::scoped_refptr<webrtc::AudioEncoderFactory>& encoder_factory, const rtc::scoped_refptr<webrtc::AudioEncoderFactory>& encoder_factory,
const absl::optional<webrtc::AudioCodecPairId> codec_pair_id, const absl::optional<webrtc::AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<webrtc::FrameEncryptorInterface> frame_encryptor, rtc::scoped_refptr<webrtc::FrameEncryptorInterface> frame_encryptor,
const webrtc::CryptoOptions& crypto_options) const webrtc::CryptoOptions& crypto_options)
: call_(call), : call_(call),
config_(send_transport, media_transport), config_(send_transport, media_transport_config),
max_send_bitrate_bps_(max_send_bitrate_bps), max_send_bitrate_bps_(max_send_bitrate_bps),
rtp_parameters_(CreateRtpParametersWithOneEncoding()) { rtp_parameters_(CreateRtpParametersWithOneEncoding()) {
RTC_DCHECK(call); RTC_DCHECK(call);
@ -1055,7 +1055,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
const std::vector<webrtc::RtpExtension>& extensions, const std::vector<webrtc::RtpExtension>& extensions,
webrtc::Call* call, webrtc::Call* call,
webrtc::Transport* rtcp_send_transport, webrtc::Transport* rtcp_send_transport,
webrtc::MediaTransportInterface* media_transport, const webrtc::MediaTransportConfig& media_transport_config,
const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory, const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory,
const std::map<int, webrtc::SdpAudioFormat>& decoder_map, const std::map<int, webrtc::SdpAudioFormat>& decoder_map,
absl::optional<webrtc::AudioCodecPairId> codec_pair_id, absl::optional<webrtc::AudioCodecPairId> codec_pair_id,
@ -1073,7 +1073,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0; config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0;
config_.rtp.extensions = extensions; config_.rtp.extensions = extensions;
config_.rtcp_send_transport = rtcp_send_transport; config_.rtcp_send_transport = rtcp_send_transport;
config_.media_transport = media_transport; config_.media_transport_config = media_transport_config;
config_.jitter_buffer_max_packets = jitter_buffer_max_packets; config_.jitter_buffer_max_packets = jitter_buffer_max_packets;
config_.jitter_buffer_fast_accelerate = jitter_buffer_fast_accelerate; config_.jitter_buffer_fast_accelerate = jitter_buffer_fast_accelerate;
config_.jitter_buffer_min_delay_ms = jitter_buffer_min_delay_ms; config_.jitter_buffer_min_delay_ms = jitter_buffer_min_delay_ms;
@ -1804,7 +1804,7 @@ bool WebRtcVoiceMediaChannel::AddSendStream(const StreamParams& sp) {
ssrc, mid_, sp.cname, sp.id, send_codec_spec_, ExtmapAllowMixed(), ssrc, mid_, sp.cname, sp.id, send_codec_spec_, ExtmapAllowMixed(),
send_rtp_extensions_, max_send_bitrate_bps_, send_rtp_extensions_, max_send_bitrate_bps_,
audio_config_.rtcp_report_interval_ms, audio_network_adaptor_config, audio_config_.rtcp_report_interval_ms, audio_network_adaptor_config,
call_, this, media_transport(), engine()->encoder_factory_, call_, this, media_transport_config(), engine()->encoder_factory_,
codec_pair_id_, nullptr, crypto_options_); codec_pair_id_, nullptr, crypto_options_);
send_streams_.insert(std::make_pair(ssrc, stream)); send_streams_.insert(std::make_pair(ssrc, stream));
@ -1886,16 +1886,16 @@ bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) {
// Create a new channel for receiving audio data. // Create a new channel for receiving audio data.
recv_streams_.insert(std::make_pair( recv_streams_.insert(std::make_pair(
ssrc, ssrc, new WebRtcAudioReceiveStream(
new WebRtcAudioReceiveStream( ssrc, receiver_reports_ssrc_, recv_transport_cc_enabled_,
ssrc, receiver_reports_ssrc_, recv_transport_cc_enabled_, recv_nack_enabled_, sp.stream_ids(), recv_rtp_extensions_,
recv_nack_enabled_, sp.stream_ids(), recv_rtp_extensions_, call_, call_, this, media_transport_config(),
this, media_transport(), engine()->decoder_factory_, decoder_map_, engine()->decoder_factory_, decoder_map_, codec_pair_id_,
codec_pair_id_, engine()->audio_jitter_buffer_max_packets_, engine()->audio_jitter_buffer_max_packets_,
engine()->audio_jitter_buffer_fast_accelerate_, engine()->audio_jitter_buffer_fast_accelerate_,
engine()->audio_jitter_buffer_min_delay_ms_, engine()->audio_jitter_buffer_min_delay_ms_,
engine()->audio_jitter_buffer_enable_rtx_handling_, engine()->audio_jitter_buffer_enable_rtx_handling_,
unsignaled_frame_decryptor_, crypto_options_))); unsignaled_frame_decryptor_, crypto_options_)));
recv_streams_[ssrc]->SetPlayout(playout_); recv_streams_[ssrc]->SetPlayout(playout_);
return true; return true;

View file

@ -14,6 +14,7 @@
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/media_transport_config.h"
#include "api/rtp_parameters.h" #include "api/rtp_parameters.h"
#include "api/scoped_refptr.h" #include "api/scoped_refptr.h"
#include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/default_task_queue_factory.h"
@ -3031,7 +3032,7 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
channel.reset(static_cast<cricket::WebRtcVoiceMediaChannel*>( channel.reset(static_cast<cricket::WebRtcVoiceMediaChannel*>(
engine_->CreateMediaChannel(&call_, config, cricket::AudioOptions(), engine_->CreateMediaChannel(&call_, config, cricket::AudioOptions(),
webrtc::CryptoOptions()))); webrtc::CryptoOptions())));
channel->SetInterface(&network_interface, /*media_transport=*/nullptr); channel->SetInterface(&network_interface, webrtc::MediaTransportConfig());
// Default value when DSCP is disabled should be DSCP_DEFAULT. // Default value when DSCP is disabled should be DSCP_DEFAULT.
EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp()); EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp());
@ -3039,7 +3040,7 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
channel.reset(static_cast<cricket::WebRtcVoiceMediaChannel*>( channel.reset(static_cast<cricket::WebRtcVoiceMediaChannel*>(
engine_->CreateMediaChannel(&call_, config, cricket::AudioOptions(), engine_->CreateMediaChannel(&call_, config, cricket::AudioOptions(),
webrtc::CryptoOptions()))); webrtc::CryptoOptions())));
channel->SetInterface(&network_interface, /*media_transport=*/nullptr); channel->SetInterface(&network_interface, webrtc::MediaTransportConfig());
EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp()); EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp());
// Create a send stream to configure // Create a send stream to configure
@ -3072,11 +3073,11 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
channel.reset(static_cast<cricket::WebRtcVoiceMediaChannel*>( channel.reset(static_cast<cricket::WebRtcVoiceMediaChannel*>(
engine_->CreateMediaChannel(&call_, config, cricket::AudioOptions(), engine_->CreateMediaChannel(&call_, config, cricket::AudioOptions(),
webrtc::CryptoOptions()))); webrtc::CryptoOptions())));
channel->SetInterface(&network_interface, /*media_transport=*/nullptr); channel->SetInterface(&network_interface, webrtc::MediaTransportConfig());
// Default value when DSCP is disabled should be DSCP_DEFAULT. // Default value when DSCP is disabled should be DSCP_DEFAULT.
EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp()); EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp());
channel->SetInterface(nullptr, nullptr); channel->SetInterface(nullptr, webrtc::MediaTransportConfig());
} }
TEST_F(WebRtcVoiceEngineTestFake, SetOutputVolume) { TEST_F(WebRtcVoiceEngineTestFake, SetOutputVolume) {

View file

@ -8,17 +8,21 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "pc/channel.h"
#include <iterator> #include <iterator>
#include <utility> #include <utility>
#include "pc/channel.h"
#include "absl/algorithm/container.h" #include "absl/algorithm/container.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "api/call/audio_sink.h" #include "api/call/audio_sink.h"
#include "api/media_transport_config.h"
#include "media/base/media_constants.h" #include "media/base/media_constants.h"
#include "media/base/rtp_utils.h" #include "media/base/rtp_utils.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "p2p/base/packet_transport_internal.h"
#include "pc/channel_manager.h"
#include "pc/rtp_media_utils.h"
#include "rtc_base/bind.h" #include "rtc_base/bind.h"
#include "rtc_base/byte_order.h" #include "rtc_base/byte_order.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
@ -28,9 +32,6 @@
#include "rtc_base/network_route.h" #include "rtc_base/network_route.h"
#include "rtc_base/strings/string_builder.h" #include "rtc_base/strings/string_builder.h"
#include "rtc_base/trace_event.h" #include "rtc_base/trace_event.h"
#include "p2p/base/packet_transport_internal.h"
#include "pc/channel_manager.h"
#include "pc/rtp_media_utils.h"
namespace cricket { namespace cricket {
using rtc::Bind; using rtc::Bind;
@ -148,8 +149,8 @@ BaseChannel::~BaseChannel() {
TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel"); TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel");
RTC_DCHECK_RUN_ON(worker_thread_); RTC_DCHECK_RUN_ON(worker_thread_);
if (media_transport_) { if (media_transport_config_.media_transport) {
media_transport_->RemoveNetworkChangeCallback(this); media_transport_config_.media_transport->RemoveNetworkChangeCallback(this);
} }
// Eats any outstanding messages or packets. // Eats any outstanding messages or packets.
@ -174,7 +175,7 @@ bool BaseChannel::ConnectToRtpTransport() {
// If media transport is used, it's responsible for providing network // If media transport is used, it's responsible for providing network
// route changed callbacks. // route changed callbacks.
if (!media_transport_) { if (!media_transport_config_.media_transport) {
rtp_transport_->SignalNetworkRouteChanged.connect( rtp_transport_->SignalNetworkRouteChanged.connect(
this, &BaseChannel::OnNetworkRouteChanged); this, &BaseChannel::OnNetworkRouteChanged);
} }
@ -197,29 +198,30 @@ void BaseChannel::DisconnectFromRtpTransport() {
rtp_transport_->SignalSentPacket.disconnect(this); rtp_transport_->SignalSentPacket.disconnect(this);
} }
void BaseChannel::Init_w(webrtc::RtpTransportInternal* rtp_transport, void BaseChannel::Init_w(
webrtc::MediaTransportInterface* media_transport) { webrtc::RtpTransportInternal* rtp_transport,
const webrtc::MediaTransportConfig& media_transport_config) {
RTC_DCHECK_RUN_ON(worker_thread_); RTC_DCHECK_RUN_ON(worker_thread_);
media_transport_ = media_transport; media_transport_config_ = media_transport_config;
network_thread_->Invoke<void>( network_thread_->Invoke<void>(
RTC_FROM_HERE, [this, rtp_transport] { SetRtpTransport(rtp_transport); }); RTC_FROM_HERE, [this, rtp_transport] { SetRtpTransport(rtp_transport); });
// Both RTP and RTCP channels should be set, we can call SetInterface on // Both RTP and RTCP channels should be set, we can call SetInterface on
// the media channel and it can set network options. // the media channel and it can set network options.
media_channel_->SetInterface(this, media_transport); media_channel_->SetInterface(this, media_transport_config);
RTC_LOG(LS_INFO) << "BaseChannel::Init_w, media_transport=" RTC_LOG(LS_INFO) << "BaseChannel::Init_w, media_transport_config="
<< (media_transport_ != nullptr); << media_transport_config.DebugString();
if (media_transport_) { if (media_transport_config_.media_transport) {
media_transport_->AddNetworkChangeCallback(this); media_transport_config_.media_transport->AddNetworkChangeCallback(this);
} }
} }
void BaseChannel::Deinit() { void BaseChannel::Deinit() {
RTC_DCHECK(worker_thread_->IsCurrent()); RTC_DCHECK(worker_thread_->IsCurrent());
media_channel_->SetInterface(/*iface=*/nullptr, media_channel_->SetInterface(/*iface=*/nullptr,
/*media_transport=*/nullptr); webrtc::MediaTransportConfig());
// Packets arrive on the network thread, processing packets calls virtual // Packets arrive on the network thread, processing packets calls virtual
// functions, so need to stop this process in Deinit that is called in // functions, so need to stop this process in Deinit that is called in
// derived classes destructor. // derived classes destructor.
@ -836,11 +838,13 @@ void BaseChannel::OnNetworkRouteChanged(
OnNetworkRouteChanged(absl::make_optional(network_route)); OnNetworkRouteChanged(absl::make_optional(network_route));
} }
void VoiceChannel::Init_w(webrtc::RtpTransportInternal* rtp_transport, void VoiceChannel::Init_w(
webrtc::MediaTransportInterface* media_transport) { webrtc::RtpTransportInternal* rtp_transport,
BaseChannel::Init_w(rtp_transport, media_transport); const webrtc::MediaTransportConfig& media_transport_config) {
if (BaseChannel::media_transport()) { BaseChannel::Init_w(rtp_transport, media_transport_config);
this->media_transport()->SetFirstAudioPacketReceivedObserver(this); if (media_transport_config.media_transport) {
media_transport_config.media_transport->SetFirstAudioPacketReceivedObserver(
this);
} }
} }
@ -1125,9 +1129,10 @@ RtpDataChannel::~RtpDataChannel() {
Deinit(); Deinit();
} }
void RtpDataChannel::Init_w(webrtc::RtpTransportInternal* rtp_transport, void RtpDataChannel::Init_w(
webrtc::MediaTransportInterface* media_transport) { webrtc::RtpTransportInternal* rtp_transport,
BaseChannel::Init_w(rtp_transport, /*media_transport=*/nullptr); const webrtc::MediaTransportConfig& media_transport_config) {
BaseChannel::Init_w(rtp_transport, media_transport_config);
media_channel()->SignalDataReceived.connect(this, media_channel()->SignalDataReceived.connect(this,
&RtpDataChannel::OnDataReceived); &RtpDataChannel::OnDataReceived);
media_channel()->SignalReadyToSend.connect( media_channel()->SignalReadyToSend.connect(

View file

@ -20,7 +20,7 @@
#include "api/call/audio_sink.h" #include "api/call/audio_sink.h"
#include "api/jsep.h" #include "api/jsep.h"
#include "api/media_transport_interface.h" #include "api/media_transport_config.h"
#include "api/rtp_receiver_interface.h" #include "api/rtp_receiver_interface.h"
#include "api/video/video_sink_interface.h" #include "api/video/video_sink_interface.h"
#include "api/video/video_source_interface.h" #include "api/video/video_source_interface.h"
@ -92,8 +92,9 @@ class BaseChannel : public ChannelInterface,
webrtc::CryptoOptions crypto_options, webrtc::CryptoOptions crypto_options,
rtc::UniqueRandomIdGenerator* ssrc_generator); rtc::UniqueRandomIdGenerator* ssrc_generator);
virtual ~BaseChannel(); virtual ~BaseChannel();
virtual void Init_w(webrtc::RtpTransportInternal* rtp_transport, virtual void Init_w(
webrtc::MediaTransportInterface* media_transport); webrtc::RtpTransportInternal* rtp_transport,
const webrtc::MediaTransportConfig& media_transport_config);
// Deinit may be called multiple times and is simply ignored if it's already // Deinit may be called multiple times and is simply ignored if it's already
// done. // done.
@ -169,7 +170,7 @@ class BaseChannel : public ChannelInterface,
// Returns media transport, can be null if media transport is not available. // Returns media transport, can be null if media transport is not available.
webrtc::MediaTransportInterface* media_transport() { webrtc::MediaTransportInterface* media_transport() {
return media_transport_; return media_transport_config_.media_transport;
} }
// From RtpTransport - public for testing only // From RtpTransport - public for testing only
@ -322,10 +323,8 @@ class BaseChannel : public ChannelInterface,
webrtc::RtpTransportInternal* rtp_transport_ = nullptr; webrtc::RtpTransportInternal* rtp_transport_ = nullptr;
// Optional media transport (experimental). // Optional media transport configuration (experimental).
// If provided, audio and video will be sent through media_transport instead webrtc::MediaTransportConfig media_transport_config_;
// of RTP/RTCP. Currently media_transport can co-exist with rtp_transport.
webrtc::MediaTransportInterface* media_transport_ = nullptr;
std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; std::vector<std::pair<rtc::Socket::Option, int> > socket_options_;
std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_;
@ -379,8 +378,9 @@ class VoiceChannel : public BaseChannel,
cricket::MediaType media_type() const override { cricket::MediaType media_type() const override {
return cricket::MEDIA_TYPE_AUDIO; return cricket::MEDIA_TYPE_AUDIO;
} }
void Init_w(webrtc::RtpTransportInternal* rtp_transport, void Init_w(
webrtc::MediaTransportInterface* media_transport) override; webrtc::RtpTransportInternal* rtp_transport,
const webrtc::MediaTransportConfig& media_transport_config) override;
private: private:
// overrides from BaseChannel // overrides from BaseChannel
@ -464,7 +464,7 @@ class RtpDataChannel : public BaseChannel {
rtc::PacketTransportInternal* rtcp_packet_transport); rtc::PacketTransportInternal* rtcp_packet_transport);
void Init_w( void Init_w(
webrtc::RtpTransportInternal* rtp_transport, webrtc::RtpTransportInternal* rtp_transport,
webrtc::MediaTransportInterface* media_transport = nullptr) override; const webrtc::MediaTransportConfig& media_transport_config) override;
virtual bool SendData(const SendDataParams& params, virtual bool SendData(const SendDataParams& params,
const rtc::CopyOnWriteBuffer& payload, const rtc::CopyOnWriteBuffer& payload,

View file

@ -158,7 +158,7 @@ VoiceChannel* ChannelManager::CreateVoiceChannel(
webrtc::Call* call, webrtc::Call* call,
const cricket::MediaConfig& media_config, const cricket::MediaConfig& media_config,
webrtc::RtpTransportInternal* rtp_transport, webrtc::RtpTransportInternal* rtp_transport,
webrtc::MediaTransportInterface* media_transport, const webrtc::MediaTransportConfig& media_transport_config,
rtc::Thread* signaling_thread, rtc::Thread* signaling_thread,
const std::string& content_name, const std::string& content_name,
bool srtp_required, bool srtp_required,
@ -167,9 +167,10 @@ VoiceChannel* ChannelManager::CreateVoiceChannel(
const AudioOptions& options) { const AudioOptions& options) {
if (!worker_thread_->IsCurrent()) { if (!worker_thread_->IsCurrent()) {
return worker_thread_->Invoke<VoiceChannel*>(RTC_FROM_HERE, [&] { return worker_thread_->Invoke<VoiceChannel*>(RTC_FROM_HERE, [&] {
return CreateVoiceChannel( return CreateVoiceChannel(call, media_config, rtp_transport,
call, media_config, rtp_transport, media_transport, signaling_thread, media_transport_config, signaling_thread,
content_name, srtp_required, crypto_options, ssrc_generator, options); content_name, srtp_required, crypto_options,
ssrc_generator, options);
}); });
} }
@ -191,7 +192,7 @@ VoiceChannel* ChannelManager::CreateVoiceChannel(
absl::WrapUnique(media_channel), content_name, srtp_required, absl::WrapUnique(media_channel), content_name, srtp_required,
crypto_options, ssrc_generator); crypto_options, ssrc_generator);
voice_channel->Init_w(rtp_transport, media_transport); voice_channel->Init_w(rtp_transport, media_transport_config);
VoiceChannel* voice_channel_ptr = voice_channel.get(); VoiceChannel* voice_channel_ptr = voice_channel.get();
voice_channels_.push_back(std::move(voice_channel)); voice_channels_.push_back(std::move(voice_channel));
@ -227,7 +228,7 @@ VideoChannel* ChannelManager::CreateVideoChannel(
webrtc::Call* call, webrtc::Call* call,
const cricket::MediaConfig& media_config, const cricket::MediaConfig& media_config,
webrtc::RtpTransportInternal* rtp_transport, webrtc::RtpTransportInternal* rtp_transport,
webrtc::MediaTransportInterface* media_transport, const webrtc::MediaTransportConfig& media_transport_config,
rtc::Thread* signaling_thread, rtc::Thread* signaling_thread,
const std::string& content_name, const std::string& content_name,
bool srtp_required, bool srtp_required,
@ -237,10 +238,10 @@ VideoChannel* ChannelManager::CreateVideoChannel(
webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) { webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) {
if (!worker_thread_->IsCurrent()) { if (!worker_thread_->IsCurrent()) {
return worker_thread_->Invoke<VideoChannel*>(RTC_FROM_HERE, [&] { return worker_thread_->Invoke<VideoChannel*>(RTC_FROM_HERE, [&] {
return CreateVideoChannel(call, media_config, rtp_transport, return CreateVideoChannel(
media_transport, signaling_thread, content_name, call, media_config, rtp_transport, media_transport_config,
srtp_required, crypto_options, ssrc_generator, signaling_thread, content_name, srtp_required, crypto_options,
options, video_bitrate_allocator_factory); ssrc_generator, options, video_bitrate_allocator_factory);
}); });
} }
@ -263,7 +264,7 @@ VideoChannel* ChannelManager::CreateVideoChannel(
absl::WrapUnique(media_channel), content_name, srtp_required, absl::WrapUnique(media_channel), content_name, srtp_required,
crypto_options, ssrc_generator); crypto_options, ssrc_generator);
video_channel->Init_w(rtp_transport, media_transport); video_channel->Init_w(rtp_transport, media_transport_config);
VideoChannel* video_channel_ptr = video_channel.get(); VideoChannel* video_channel_ptr = video_channel.get();
video_channels_.push_back(std::move(video_channel)); video_channels_.push_back(std::move(video_channel));
@ -323,7 +324,9 @@ RtpDataChannel* ChannelManager::CreateRtpDataChannel(
worker_thread_, network_thread_, signaling_thread, worker_thread_, network_thread_, signaling_thread,
absl::WrapUnique(media_channel), content_name, srtp_required, absl::WrapUnique(media_channel), content_name, srtp_required,
crypto_options, ssrc_generator); crypto_options, ssrc_generator);
data_channel->Init_w(rtp_transport);
// Media Transports are not supported with Rtp Data Channel.
data_channel->Init_w(rtp_transport, webrtc::MediaTransportConfig());
RtpDataChannel* data_channel_ptr = data_channel.get(); RtpDataChannel* data_channel_ptr = data_channel.get();
data_channels_.push_back(std::move(data_channel)); data_channels_.push_back(std::move(data_channel));

View file

@ -12,13 +12,14 @@
#define PC_CHANNEL_MANAGER_H_ #define PC_CHANNEL_MANAGER_H_
#include <stdint.h> #include <stdint.h>
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
#include "api/audio_options.h" #include "api/audio_options.h"
#include "api/crypto/crypto_options.h" #include "api/crypto/crypto_options.h"
#include "api/media_transport_interface.h" #include "api/media_transport_config.h"
#include "call/call.h" #include "call/call.h"
#include "media/base/codec.h" #include "media/base/codec.h"
#include "media/base/media_channel.h" #include "media/base/media_channel.h"
@ -95,7 +96,7 @@ class ChannelManager final {
webrtc::Call* call, webrtc::Call* call,
const cricket::MediaConfig& media_config, const cricket::MediaConfig& media_config,
webrtc::RtpTransportInternal* rtp_transport, webrtc::RtpTransportInternal* rtp_transport,
webrtc::MediaTransportInterface* media_transport, const webrtc::MediaTransportConfig& media_transport_config,
rtc::Thread* signaling_thread, rtc::Thread* signaling_thread,
const std::string& content_name, const std::string& content_name,
bool srtp_required, bool srtp_required,
@ -112,7 +113,7 @@ class ChannelManager final {
webrtc::Call* call, webrtc::Call* call,
const cricket::MediaConfig& media_config, const cricket::MediaConfig& media_config,
webrtc::RtpTransportInternal* rtp_transport, webrtc::RtpTransportInternal* rtp_transport,
webrtc::MediaTransportInterface* media_transport, const webrtc::MediaTransportConfig& media_transport_config,
rtc::Thread* signaling_thread, rtc::Thread* signaling_thread,
const std::string& content_name, const std::string& content_name,
bool srtp_required, bool srtp_required,

View file

@ -8,9 +8,12 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "pc/channel_manager.h"
#include <memory> #include <memory>
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "api/media_transport_config.h"
#include "api/rtc_error.h" #include "api/rtc_error.h"
#include "api/test/fake_media_transport.h" #include "api/test/fake_media_transport.h"
#include "api/video/builtin_video_bitrate_allocator_factory.h" #include "api/video/builtin_video_bitrate_allocator_factory.h"
@ -21,7 +24,6 @@
#include "p2p/base/fake_dtls_transport.h" #include "p2p/base/fake_dtls_transport.h"
#include "p2p/base/p2p_constants.h" #include "p2p/base/p2p_constants.h"
#include "p2p/base/packet_transport_internal.h" #include "p2p/base/packet_transport_internal.h"
#include "pc/channel_manager.h"
#include "pc/dtls_srtp_transport.h" #include "pc/dtls_srtp_transport.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
@ -84,17 +86,18 @@ class ChannelManagerTest : public ::testing::Test {
void TestCreateDestroyChannels( void TestCreateDestroyChannels(
webrtc::RtpTransportInternal* rtp_transport, webrtc::RtpTransportInternal* rtp_transport,
webrtc::MediaTransportInterface* media_transport) { webrtc::MediaTransportConfig media_transport_config) {
cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
&fake_call_, cricket::MediaConfig(), rtp_transport, media_transport, &fake_call_, cricket::MediaConfig(), rtp_transport,
rtc::Thread::Current(), cricket::CN_AUDIO, kDefaultSrtpRequired, media_transport_config, rtc::Thread::Current(), cricket::CN_AUDIO,
webrtc::CryptoOptions(), &ssrc_generator_, AudioOptions()); kDefaultSrtpRequired, webrtc::CryptoOptions(), &ssrc_generator_,
AudioOptions());
EXPECT_TRUE(voice_channel != nullptr); EXPECT_TRUE(voice_channel != nullptr);
cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( cricket::VideoChannel* video_channel = cm_->CreateVideoChannel(
&fake_call_, cricket::MediaConfig(), rtp_transport, media_transport, &fake_call_, cricket::MediaConfig(), rtp_transport,
rtc::Thread::Current(), cricket::CN_VIDEO, kDefaultSrtpRequired, media_transport_config, rtc::Thread::Current(), cricket::CN_VIDEO,
webrtc::CryptoOptions(), &ssrc_generator_, VideoOptions(), kDefaultSrtpRequired, webrtc::CryptoOptions(), &ssrc_generator_,
video_bitrate_allocator_factory_.get()); VideoOptions(), video_bitrate_allocator_factory_.get());
EXPECT_TRUE(video_channel != nullptr); EXPECT_TRUE(video_channel != nullptr);
cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel( cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel(
cricket::MediaConfig(), rtp_transport, rtc::Thread::Current(), cricket::MediaConfig(), rtp_transport, rtc::Thread::Current(),
@ -183,7 +186,8 @@ TEST_F(ChannelManagerTest, SetVideoRtxEnabled) {
TEST_F(ChannelManagerTest, CreateDestroyChannels) { TEST_F(ChannelManagerTest, CreateDestroyChannels) {
EXPECT_TRUE(cm_->Init()); EXPECT_TRUE(cm_->Init());
auto rtp_transport = CreateDtlsSrtpTransport(); auto rtp_transport = CreateDtlsSrtpTransport();
TestCreateDestroyChannels(rtp_transport.get(), /*media_transport=*/nullptr); TestCreateDestroyChannels(rtp_transport.get(),
webrtc::MediaTransportConfig());
} }
TEST_F(ChannelManagerTest, CreateDestroyChannelsWithMediaTransport) { TEST_F(ChannelManagerTest, CreateDestroyChannelsWithMediaTransport) {
@ -191,7 +195,8 @@ TEST_F(ChannelManagerTest, CreateDestroyChannelsWithMediaTransport) {
auto rtp_transport = CreateDtlsSrtpTransport(); auto rtp_transport = CreateDtlsSrtpTransport();
auto media_transport = auto media_transport =
CreateMediaTransport(rtp_transport->rtcp_packet_transport()); CreateMediaTransport(rtp_transport->rtcp_packet_transport());
TestCreateDestroyChannels(rtp_transport.get(), media_transport.get()); TestCreateDestroyChannels(
rtp_transport.get(), webrtc::MediaTransportConfig(media_transport.get()));
} }
TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) {
@ -201,7 +206,8 @@ TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) {
EXPECT_TRUE(cm_->set_network_thread(network_.get())); EXPECT_TRUE(cm_->set_network_thread(network_.get()));
EXPECT_TRUE(cm_->Init()); EXPECT_TRUE(cm_->Init());
auto rtp_transport = CreateDtlsSrtpTransport(); auto rtp_transport = CreateDtlsSrtpTransport();
TestCreateDestroyChannels(rtp_transport.get(), /*media_transport=*/nullptr); TestCreateDestroyChannels(rtp_transport.get(),
webrtc::MediaTransportConfig());
} }
} // namespace cricket } // namespace cricket

View file

@ -8,6 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "pc/channel.h"
#include <cstdint> #include <cstdint>
#include <memory> #include <memory>
#include <utility> #include <utility>
@ -15,6 +17,7 @@
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "api/array_view.h" #include "api/array_view.h"
#include "api/audio_options.h" #include "api/audio_options.h"
#include "api/media_transport_config.h"
#include "api/rtp_parameters.h" #include "api/rtp_parameters.h"
#include "media/base/codec.h" #include "media/base/codec.h"
#include "media/base/fake_media_engine.h" #include "media/base/fake_media_engine.h"
@ -25,7 +28,6 @@
#include "p2p/base/fake_packet_transport.h" #include "p2p/base/fake_packet_transport.h"
#include "p2p/base/ice_transport_internal.h" #include "p2p/base/ice_transport_internal.h"
#include "p2p/base/p2p_constants.h" #include "p2p/base/p2p_constants.h"
#include "pc/channel.h"
#include "pc/dtls_srtp_transport.h" #include "pc/dtls_srtp_transport.h"
#include "pc/jsep_transport.h" #include "pc/jsep_transport.h"
#include "pc/rtp_transport.h" #include "pc/rtp_transport.h"
@ -263,7 +265,7 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> {
worker_thread, network_thread, signaling_thread, std::move(ch), worker_thread, network_thread, signaling_thread, std::move(ch),
cricket::CN_AUDIO, (flags & DTLS) != 0, webrtc::CryptoOptions(), cricket::CN_AUDIO, (flags & DTLS) != 0, webrtc::CryptoOptions(),
&ssrc_generator_); &ssrc_generator_);
channel->Init_w(rtp_transport, /*media_transport=*/nullptr); channel->Init_w(rtp_transport, webrtc::MediaTransportConfig());
return channel; return channel;
} }
@ -1626,7 +1628,7 @@ std::unique_ptr<cricket::VideoChannel> ChannelTest<VideoTraits>::CreateChannel(
worker_thread, network_thread, signaling_thread, std::move(ch), worker_thread, network_thread, signaling_thread, std::move(ch),
cricket::CN_VIDEO, (flags & DTLS) != 0, webrtc::CryptoOptions(), cricket::CN_VIDEO, (flags & DTLS) != 0, webrtc::CryptoOptions(),
&ssrc_generator_); &ssrc_generator_);
channel->Init_w(rtp_transport, /*media_transport=*/nullptr); channel->Init_w(rtp_transport, webrtc::MediaTransportConfig());
return channel; return channel;
} }
@ -2299,7 +2301,7 @@ std::unique_ptr<cricket::RtpDataChannel> ChannelTest<DataTraits>::CreateChannel(
worker_thread, network_thread, signaling_thread, std::move(ch), worker_thread, network_thread, signaling_thread, std::move(ch),
cricket::CN_DATA, (flags & DTLS) != 0, webrtc::CryptoOptions(), cricket::CN_DATA, (flags & DTLS) != 0, webrtc::CryptoOptions(),
&ssrc_generator_); &ssrc_generator_);
channel->Init_w(rtp_transport); channel->Init_w(rtp_transport, webrtc::MediaTransportConfig());
return channel; return channel;
} }

View file

@ -6290,9 +6290,9 @@ cricket::VoiceChannel* PeerConnection::CreateVoiceChannel(
} }
cricket::VoiceChannel* voice_channel = channel_manager()->CreateVoiceChannel( cricket::VoiceChannel* voice_channel = channel_manager()->CreateVoiceChannel(
call_ptr_, configuration_.media_config, rtp_transport, media_transport, call_ptr_, configuration_.media_config, rtp_transport,
signaling_thread(), mid, SrtpRequired(), GetCryptoOptions(), MediaTransportConfig(media_transport), signaling_thread(), mid,
&ssrc_generator_, audio_options_); SrtpRequired(), GetCryptoOptions(), &ssrc_generator_, audio_options_);
if (!voice_channel) { if (!voice_channel) {
return nullptr; return nullptr;
} }
@ -6315,9 +6315,10 @@ cricket::VideoChannel* PeerConnection::CreateVideoChannel(
} }
cricket::VideoChannel* video_channel = channel_manager()->CreateVideoChannel( cricket::VideoChannel* video_channel = channel_manager()->CreateVideoChannel(
call_ptr_, configuration_.media_config, rtp_transport, media_transport, call_ptr_, configuration_.media_config, rtp_transport,
signaling_thread(), mid, SrtpRequired(), GetCryptoOptions(), MediaTransportConfig(media_transport), signaling_thread(), mid,
&ssrc_generator_, video_options_, video_bitrate_allocator_factory_.get()); SrtpRequired(), GetCryptoOptions(), &ssrc_generator_, video_options_,
video_bitrate_allocator_factory_.get());
if (!video_channel) { if (!video_channel) {
return nullptr; return nullptr;
} }

View file

@ -122,12 +122,12 @@ class RtpSenderReceiverTest
voice_channel_ = channel_manager_.CreateVoiceChannel( voice_channel_ = channel_manager_.CreateVoiceChannel(
&fake_call_, cricket::MediaConfig(), rtp_transport_.get(), &fake_call_, cricket::MediaConfig(), rtp_transport_.get(),
/*media_transport=*/nullptr, rtc::Thread::Current(), cricket::CN_AUDIO, MediaTransportConfig(), rtc::Thread::Current(), cricket::CN_AUDIO,
srtp_required, webrtc::CryptoOptions(), &ssrc_generator_, srtp_required, webrtc::CryptoOptions(), &ssrc_generator_,
cricket::AudioOptions()); cricket::AudioOptions());
video_channel_ = channel_manager_.CreateVideoChannel( video_channel_ = channel_manager_.CreateVideoChannel(
&fake_call_, cricket::MediaConfig(), rtp_transport_.get(), &fake_call_, cricket::MediaConfig(), rtp_transport_.get(),
/*media_transport=*/nullptr, rtc::Thread::Current(), cricket::CN_VIDEO, MediaTransportConfig(), rtc::Thread::Current(), cricket::CN_VIDEO,
srtp_required, webrtc::CryptoOptions(), &ssrc_generator_, srtp_required, webrtc::CryptoOptions(), &ssrc_generator_,
cricket::VideoOptions(), video_bitrate_allocator_factory_.get()); cricket::VideoOptions(), video_bitrate_allocator_factory_.get());
voice_channel_->Enable(true); voice_channel_->Enable(true);

View file

@ -34,8 +34,7 @@ CallTest::CallTest()
task_queue_factory_(CreateDefaultTaskQueueFactory()), task_queue_factory_(CreateDefaultTaskQueueFactory()),
send_event_log_(RtcEventLog::CreateNull()), send_event_log_(RtcEventLog::CreateNull()),
recv_event_log_(RtcEventLog::CreateNull()), recv_event_log_(RtcEventLog::CreateNull()),
audio_send_config_(/*send_transport=*/nullptr, audio_send_config_(/*send_transport=*/nullptr, MediaTransportConfig()),
/*media_transport=*/nullptr),
audio_send_stream_(nullptr), audio_send_stream_(nullptr),
frame_generator_capturer_(nullptr), frame_generator_capturer_(nullptr),
fake_encoder_factory_([this]() { fake_encoder_factory_([this]() {
@ -273,7 +272,7 @@ void CallTest::CreateAudioAndFecSendConfigs(size_t num_audio_streams,
RTC_DCHECK_LE(num_flexfec_streams, 1); RTC_DCHECK_LE(num_flexfec_streams, 1);
if (num_audio_streams > 0) { if (num_audio_streams > 0) {
AudioSendStream::Config audio_send_config(send_transport, AudioSendStream::Config audio_send_config(send_transport,
/*media_transport=*/nullptr); MediaTransportConfig());
audio_send_config.rtp.ssrc = kAudioSendSsrc; audio_send_config.rtp.ssrc = kAudioSendSsrc;
audio_send_config.send_codec_spec = AudioSendStream::Config::SendCodecSpec( audio_send_config.send_codec_spec = AudioSendStream::Config::SendCodecSpec(
kAudioSendPayloadType, {"opus", 48000, 2, {{"stereo", "1"}}}); kAudioSendPayloadType, {"opus", 48000, 2, {{"stereo", "1"}}});

View file

@ -70,7 +70,7 @@ SendAudioStream::SendAudioStream(
Transport* send_transport) Transport* send_transport)
: sender_(sender), config_(config) { : sender_(sender), config_(config) {
AudioSendStream::Config send_config(send_transport, AudioSendStream::Config send_config(send_transport,
/*media_transport=*/nullptr); webrtc::MediaTransportConfig());
ssrc_ = sender->GetNextAudioSsrc(); ssrc_ = sender->GetNextAudioSsrc();
send_config.rtp.ssrc = ssrc_; send_config.rtp.ssrc = ssrc_;
SdpAudioFormat::Parameters sdp_params; SdpAudioFormat::Parameters sdp_params;

View file

@ -247,6 +247,7 @@ if (rtc_include_tests) {
deps = [ deps = [
":frame_dumping_decoder", ":frame_dumping_decoder",
"../api:fec_controller_api", "../api:fec_controller_api",
"../api:libjingle_peerconnection_api",
"../api:rtc_event_log_output_file", "../api:rtc_event_log_output_file",
"../api:test_dependency_factory", "../api:test_dependency_factory",
"../api:video_quality_test_fixture_api", "../api:video_quality_test_fixture_api",

View file

@ -17,6 +17,7 @@
#include <vector> #include <vector>
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "api/media_transport_config.h"
#include "api/rtc_event_log_output_file.h" #include "api/rtc_event_log_output_file.h"
#include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/default_task_queue_factory.h"
#include "api/video/builtin_video_bitrate_allocator_factory.h" #include "api/video/builtin_video_bitrate_allocator_factory.h"
@ -1380,7 +1381,7 @@ void VideoQualityTest::InitializeAudioDevice(Call::Config* send_call_config,
void VideoQualityTest::SetupAudio(Transport* transport) { void VideoQualityTest::SetupAudio(Transport* transport) {
AudioSendStream::Config audio_send_config(transport, AudioSendStream::Config audio_send_config(transport,
/*media_transport=*/nullptr); webrtc::MediaTransportConfig());
audio_send_config.rtp.ssrc = kAudioSendSsrc; audio_send_config.rtp.ssrc = kAudioSendSsrc;
// Add extension to enable audio send side BWE, and allow audio bit rate // Add extension to enable audio send side BWE, and allow audio bit rate

View file

@ -244,10 +244,9 @@ VideoReceiveStream::VideoReceiveStream(
new video_coding::FrameBuffer(clock_, timing_.get(), &stats_proxy_)); new video_coding::FrameBuffer(clock_, timing_.get(), &stats_proxy_));
process_thread_->RegisterModule(&rtp_stream_sync_, RTC_FROM_HERE); process_thread_->RegisterModule(&rtp_stream_sync_, RTC_FROM_HERE);
if (config_.media_transport()) {
if (config_.media_transport) { config_.media_transport()->SetReceiveVideoSink(this);
config_.media_transport->SetReceiveVideoSink(this); config_.media_transport()->AddRttObserver(this);
config_.media_transport->AddRttObserver(this);
} else { } else {
// Register with RtpStreamReceiverController. // Register with RtpStreamReceiverController.
media_receiver_ = receiver_controller->CreateReceiver( media_receiver_ = receiver_controller->CreateReceiver(
@ -288,9 +287,9 @@ VideoReceiveStream::~VideoReceiveStream() {
RTC_DCHECK_RUN_ON(&worker_sequence_checker_); RTC_DCHECK_RUN_ON(&worker_sequence_checker_);
RTC_LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); RTC_LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString();
Stop(); Stop();
if (config_.media_transport) { if (config_.media_transport()) {
config_.media_transport->SetReceiveVideoSink(nullptr); config_.media_transport()->SetReceiveVideoSink(nullptr);
config_.media_transport->RemoveRttObserver(this); config_.media_transport()->RemoveRttObserver(this);
} }
process_thread_->DeRegisterModule(&rtp_stream_sync_); process_thread_->DeRegisterModule(&rtp_stream_sync_);
} }
@ -512,8 +511,8 @@ void VideoReceiveStream::SendNack(
} }
void VideoReceiveStream::RequestKeyFrame() { void VideoReceiveStream::RequestKeyFrame() {
if (config_.media_transport) { if (config_.media_transport()) {
config_.media_transport->RequestKeyFrame(config_.rtp.remote_ssrc); config_.media_transport()->RequestKeyFrame(config_.rtp.remote_ssrc);
} else { } else {
rtp_video_stream_receiver_.RequestKeyFrame(); rtp_video_stream_receiver_.RequestKeyFrame();
} }