From 65f17ca6b4cff0a342144cd71376e10bbabc054f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Thu, 12 Sep 2019 13:59:36 +0200 Subject: [PATCH] Move MediaTransportInterface out of the libjingle_peerconnection_api target And move related files into api/transport/ and api/transport/media/. The moved files are unchanged, except that congestion_control_interface.h and datagram_transport_interface.h no longer include media_transport_interface.h, instead, they forward declare the few MediaTransport* types they reference. Bug: webrtc:8733 Change-Id: I4f4000d0d111f10d15a54c99af27ec26c46ae652 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/152482 Commit-Queue: Niels Moller Reviewed-by: Bjorn Mellem Reviewed-by: Mirko Bonadei Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#29178} --- api/BUILD.gn | 13 +- api/congestion_control_interface.h | 56 +-- api/data_channel_transport_interface.h | 114 +----- api/datagram_transport_interface.h | 138 +------- api/media_transport_config.h | 37 +- api/media_transport_interface.h | 317 +---------------- api/peer_connection_interface.h | 2 +- api/test/fake_datagram_transport.h | 3 +- api/test/fake_media_transport.h | 2 +- api/test/loopback_media_transport.h | 4 +- .../peerconnection_quality_test_fixture.h | 2 +- api/transport/BUILD.gn | 19 + api/transport/congestion_control_interface.h | 75 ++++ .../data_channel_transport_interface.cc | 2 +- .../data_channel_transport_interface.h | 125 +++++++ api/transport/datagram_transport_interface.h | 150 ++++++++ api/transport/media/BUILD.gn | 25 ++ .../media}/media_transport_config.cc | 2 +- api/transport/media/media_transport_config.h | 46 +++ .../media}/media_transport_interface.cc | 4 +- .../media/media_transport_interface.h | 328 ++++++++++++++++++ audio/BUILD.gn | 2 + audio/audio_send_stream.cc | 2 +- audio/channel_receive.h | 4 +- audio/channel_send.h | 4 +- audio/test/media_transport_test.cc | 2 +- call/BUILD.gn | 4 +- call/audio_receive_stream.h | 2 +- call/audio_send_stream.h | 4 +- call/video_receive_stream.h | 4 +- call/video_send_stream.h | 2 +- media/BUILD.gn | 4 + media/base/media_channel.h | 2 +- media/base/rtp_data_engine_unittest.cc | 2 +- media/engine/webrtc_video_engine.cc | 2 +- media/engine/webrtc_video_engine_unittest.cc | 2 +- media/engine/webrtc_voice_engine.cc | 2 +- media/engine/webrtc_voice_engine_unittest.cc | 2 +- pc/BUILD.gn | 6 + pc/channel.cc | 2 +- pc/channel.h | 2 +- pc/channel_manager.h | 2 +- pc/channel_manager_unittest.cc | 2 +- pc/channel_unittest.cc | 2 +- pc/datagram_rtp_transport.h | 2 +- pc/jsep_transport.h | 4 +- pc/jsep_transport_controller.cc | 4 +- pc/jsep_transport_controller.h | 4 +- pc/jsep_transport_controller_unittest.cc | 2 +- pc/peer_connection.h | 4 +- pc/peer_connection_data_channel_unittest.cc | 2 +- pc/peer_connection_factory.cc | 2 +- pc/peer_connection_factory.h | 2 +- sdk/BUILD.gn | 2 + .../api/peerconnection/RTCPeerConnection.mm | 2 +- .../RTCPeerConnectionFactory.mm | 2 +- .../RTCPeerConnectionFactoryBuilder.mm | 2 +- .../RTCPeerConnectionFactoryBuilderTest.mm | 2 +- test/pc/e2e/BUILD.gn | 1 + .../e2e/peer_connection_quality_test_params.h | 2 +- video/BUILD.gn | 2 + video/encoder_rtcp_feedback.h | 2 +- video/video_quality_test.cc | 2 +- video/video_receive_stream.h | 2 +- 64 files changed, 866 insertions(+), 707 deletions(-) create mode 100644 api/transport/congestion_control_interface.h rename api/{ => transport}/data_channel_transport_interface.cc (95%) create mode 100644 api/transport/data_channel_transport_interface.h create mode 100644 api/transport/datagram_transport_interface.h rename api/{ => transport/media}/media_transport_config.cc (95%) create mode 100644 api/transport/media/media_transport_config.h rename api/{ => transport/media}/media_transport_interface.cc (96%) create mode 100644 api/transport/media/media_transport_interface.h diff --git a/api/BUILD.gn b/api/BUILD.gn index a4cd2bc4e4..fc7121c499 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -114,7 +114,6 @@ rtc_static_library("libjingle_peerconnection_api") { "crypto_params.h", "data_channel_interface.cc", "data_channel_interface.h", - "data_channel_transport_interface.cc", "data_channel_transport_interface.h", "datagram_transport_interface.h", "dtls_transport_interface.cc", @@ -130,9 +129,7 @@ rtc_static_library("libjingle_peerconnection_api") { "media_stream_interface.h", "media_stream_proxy.h", "media_stream_track_proxy.h", - "media_transport_config.cc", "media_transport_config.h", - "media_transport_interface.cc", "media_transport_interface.h", "notifier.h", "packet_socket_factory.h", @@ -175,8 +172,10 @@ rtc_static_library("libjingle_peerconnection_api") { "rtc_event_log", "task_queue", "transport:bitrate_settings", + "transport:datagram_transport_interface", "transport:network_control", "transport/media:audio_interfaces", + "transport/media:media_transport_interface", "transport/media:video_interfaces", "transport/rtp:rtp_source", "units:data_rate", @@ -256,6 +255,7 @@ rtc_source_set("video_quality_test_fixture_api") { "../test:test_common", "../test:video_test_common", "transport:network_control", + "transport/media:media_transport_interface", "video_codecs:video_codecs_api", ] } @@ -350,6 +350,7 @@ rtc_source_set("peer_connection_quality_test_fixture_api") { "rtc_event_log", "task_queue", "transport:network_control", + "transport/media:media_transport_interface", "units:time_delta", "video_codecs:video_codecs_api", "//third_party/abseil-cpp/absl/memory", @@ -873,8 +874,9 @@ if (rtc_include_tests) { ] deps = [ - ":libjingle_peerconnection_api", "../rtc_base:checks", + "transport:datagram_transport_interface", + "transport/media:media_transport_interface", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", ] @@ -889,9 +891,10 @@ if (rtc_include_tests) { ] deps = [ - ":libjingle_peerconnection_api", "../rtc_base", "../rtc_base:checks", + "transport:datagram_transport_interface", + "transport/media:media_transport_interface", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", ] diff --git a/api/congestion_control_interface.h b/api/congestion_control_interface.h index 2e822db1ea..3666022488 100644 --- a/api/congestion_control_interface.h +++ b/api/congestion_control_interface.h @@ -7,61 +7,11 @@ * be found in the AUTHORS file in the root of the source tree. */ -// This is EXPERIMENTAL interface for media and datagram transports. - #ifndef API_CONGESTION_CONTROL_INTERFACE_H_ #define API_CONGESTION_CONTROL_INTERFACE_H_ -#include -#include -#include - -#include "api/media_transport_interface.h" -#include "api/units/data_rate.h" - -namespace webrtc { - -// Defines congestion control feedback interface for media and datagram -// transports. -class CongestionControlInterface { - public: - virtual ~CongestionControlInterface() = default; - - // Updates allocation limits. - virtual void SetAllocatedBitrateLimits( - const MediaTransportAllocatedBitrateLimits& limits) = 0; - - // Sets starting rate. - virtual void SetTargetBitrateLimits( - const MediaTransportTargetRateConstraints& target_rate_constraints) = 0; - - // Intended for receive side. AddRttObserver registers an observer to be - // called for each RTT measurement, typically once per ACK. Before media - // transport is destructed the observer must be unregistered. - // - // TODO(sukhanov): Looks like AddRttObserver and RemoveRttObserver were - // never implemented for media transport, so keeping noop implementation. - virtual void AddRttObserver(MediaTransportRttObserver* observer) {} - virtual void RemoveRttObserver(MediaTransportRttObserver* observer) {} - - // Adds a target bitrate observer. Before media transport is destructed - // the observer must be unregistered (by calling - // RemoveTargetTransferRateObserver). - // A newly registered observer will be called back with the latest recorded - // target rate, if available. - virtual void AddTargetTransferRateObserver( - TargetTransferRateObserver* observer) = 0; - - // Removes an existing |observer| from observers. If observer was never - // registered, an error is logged and method does nothing. - virtual void RemoveTargetTransferRateObserver( - TargetTransferRateObserver* observer) = 0; - - // Returns the last known target transfer rate as reported to the above - // observers. - virtual absl::optional GetLatestTargetTransferRate() = 0; -}; - -} // namespace webrtc +// TODO(bugs.webrtc.org/8733): Delete once users are updated for the new +// location. +#include "api/transport/congestion_control_interface.h" #endif // API_CONGESTION_CONTROL_INTERFACE_H_ diff --git a/api/data_channel_transport_interface.h b/api/data_channel_transport_interface.h index a6825f69b9..dcb693c6bf 100644 --- a/api/data_channel_transport_interface.h +++ b/api/data_channel_transport_interface.h @@ -7,119 +7,11 @@ * be found in the AUTHORS file in the root of the source tree. */ -// This is an experimental interface and is subject to change without notice. - #ifndef API_DATA_CHANNEL_TRANSPORT_INTERFACE_H_ #define API_DATA_CHANNEL_TRANSPORT_INTERFACE_H_ -#include "absl/types/optional.h" -#include "api/rtc_error.h" -#include "rtc_base/copy_on_write_buffer.h" - -namespace webrtc { - -// Supported types of application data messages. -enum class DataMessageType { - // Application data buffer with the binary bit unset. - kText, - - // Application data buffer with the binary bit set. - kBinary, - - // Transport-agnostic control messages, such as open or open-ack messages. - kControl, -}; - -// Parameters for sending data. The parameters may change from message to -// message, even within a single channel. For example, control messages may be -// sent reliably and in-order, even if the data channel is configured for -// unreliable delivery. -struct SendDataParams { - SendDataParams(); - SendDataParams(const SendDataParams&); - - DataMessageType type = DataMessageType::kText; - - // Whether to deliver the message in order with respect to other ordered - // messages with the same channel_id. - bool ordered = false; - - // If set, the maximum number of times this message may be - // retransmitted by the transport before it is dropped. - // Setting this value to zero disables retransmission. - // Must be non-negative. |max_rtx_count| and |max_rtx_ms| may not be set - // simultaneously. - absl::optional max_rtx_count; - - // If set, the maximum number of milliseconds for which the transport - // may retransmit this message before it is dropped. - // Setting this value to zero disables retransmission. - // Must be non-negative. |max_rtx_count| and |max_rtx_ms| may not be set - // simultaneously. - absl::optional max_rtx_ms; -}; - -// Sink for callbacks related to a data channel. -class DataChannelSink { - public: - virtual ~DataChannelSink() = default; - - // Callback issued when data is received by the transport. - virtual void OnDataReceived(int channel_id, - DataMessageType type, - const rtc::CopyOnWriteBuffer& buffer) = 0; - - // Callback issued when a remote data channel begins the closing procedure. - // Messages sent after the closing procedure begins will not be transmitted. - virtual void OnChannelClosing(int channel_id) = 0; - - // Callback issued when a (remote or local) data channel completes the closing - // procedure. Closing channels become closed after all pending data has been - // transmitted. - virtual void OnChannelClosed(int channel_id) = 0; - - // Callback issued when the data channel becomes ready to send. - // This callback will be issued immediately when the data channel sink is - // registered if the transport is ready at that time. This callback may be - // invoked again following send errors (eg. due to the transport being - // temporarily blocked or unavailable). - // TODO(mellem): Make pure virtual when downstream sinks override this. - virtual void OnReadyToSend(); -}; - -// Transport for data channels. -class DataChannelTransportInterface { - public: - virtual ~DataChannelTransportInterface() = default; - - // Opens a data |channel_id| for sending. May return an error if the - // specified |channel_id| is unusable. Must be called before |SendData|. - virtual RTCError OpenChannel(int channel_id); - - // Sends a data buffer to the remote endpoint using the given send parameters. - // |buffer| may not be larger than 256 KiB. Returns an error if the send - // fails. - virtual RTCError SendData(int channel_id, - const SendDataParams& params, - const rtc::CopyOnWriteBuffer& buffer); - - // Closes |channel_id| gracefully. Returns an error if |channel_id| is not - // open. Data sent after the closing procedure begins will not be - // transmitted. The channel becomes closed after pending data is transmitted. - virtual RTCError CloseChannel(int channel_id); - - // Sets a sink for data messages and channel state callbacks. Before media - // transport is destroyed, the sink must be unregistered by setting it to - // nullptr. - virtual void SetDataSink(DataChannelSink* sink); - - // Returns whether this data channel transport is ready to send. - // Note: the default implementation always returns false (as it assumes no one - // has implemented the interface). This default implementation is temporary. - // TODO(mellem): Change this to pure virtual. - virtual bool IsReadyToSend() const; -}; - -} // namespace webrtc +// TODO(bugs.webrtc.org/8733): Delete once users are updated for the new +// location. +#include "api/transport/data_channel_transport_interface.h" #endif // API_DATA_CHANNEL_TRANSPORT_INTERFACE_H_ diff --git a/api/datagram_transport_interface.h b/api/datagram_transport_interface.h index 38d6dd5791..f36f5b3a6e 100644 --- a/api/datagram_transport_interface.h +++ b/api/datagram_transport_interface.h @@ -7,143 +7,11 @@ * be found in the AUTHORS file in the root of the source tree. */ -// This is EXPERIMENTAL interface for media and datagram transports. - #ifndef API_DATAGRAM_TRANSPORT_INTERFACE_H_ #define API_DATAGRAM_TRANSPORT_INTERFACE_H_ -#include -#include -#include - -#include "absl/types/optional.h" -#include "api/array_view.h" -#include "api/congestion_control_interface.h" -#include "api/data_channel_transport_interface.h" -#include "api/media_transport_interface.h" -#include "api/rtc_error.h" -#include "api/units/data_rate.h" -#include "api/units/timestamp.h" - -namespace rtc { -class PacketTransportInternal; -} // namespace rtc - -namespace webrtc { - -typedef int64_t DatagramId; - -struct DatagramAck { - // |datagram_id| is same as passed in - // DatagramTransportInterface::SendDatagram. - DatagramId datagram_id; - - // The timestamp at which the remote peer received the identified datagram, - // according to that peer's clock. - Timestamp receive_timestamp = Timestamp::MinusInfinity(); -}; - -// All sink methods are called on network thread. -class DatagramSinkInterface { - public: - virtual ~DatagramSinkInterface() {} - - // Called when new packet is received. - virtual void OnDatagramReceived(rtc::ArrayView data) = 0; - - // Called when datagram is actually sent (datragram can be delayed due - // to congestion control or fusing). |datagram_id| is same as passed in - // DatagramTransportInterface::SendDatagram. - virtual void OnDatagramSent(DatagramId datagram_id) = 0; - - // Called when datagram is ACKed. - // TODO(sukhanov): Make pure virtual. - virtual void OnDatagramAcked(const DatagramAck& datagram_ack) {} - - // Called when a datagram is lost. - virtual void OnDatagramLost(DatagramId datagram_id) {} -}; - -// Datagram transport allows to send and receive unreliable packets (datagrams) -// and receive feedback from congestion control (via -// CongestionControlInterface). The idea is to send RTP packets as datagrams and -// have underlying implementation of datagram transport to use QUIC datagram -// protocol. -class DatagramTransportInterface : public DataChannelTransportInterface { - public: - virtual ~DatagramTransportInterface() = default; - - // Connect the datagram transport to the ICE transport. - // The implementation must be able to ignore incoming packets that don't - // belong to it. - virtual void Connect(rtc::PacketTransportInternal* packet_transport) = 0; - - // Returns congestion control feedback interface or nullptr if datagram - // transport does not implement congestion control. - // - // Note that right now datagram transport is used without congestion control, - // but we plan to use it in the future. - virtual CongestionControlInterface* congestion_control() = 0; - - // Sets a state observer callback. Before datagram transport is destroyed, the - // callback must be unregistered by setting it to nullptr. - // A newly registered callback will be called with the current state. - // Datagram transport does not invoke this callback concurrently. - virtual void SetTransportStateCallback( - MediaTransportStateCallback* callback) = 0; - - // Start asynchronous send of datagram. The status returned by this method - // only pertains to the synchronous operations (e.g. serialization / - // packetization), not to the asynchronous operation. - // - // Datagrams larger than GetLargestDatagramSize() will fail and return error. - // - // Datagrams are sent in FIFO order. - // - // |datagram_id| is only used in ACK/LOST notifications in - // DatagramSinkInterface and does not need to be unique. - virtual RTCError SendDatagram(rtc::ArrayView data, - DatagramId datagram_id) = 0; - - // Returns maximum size of datagram message, does not change. - // TODO(sukhanov): Because value may be undefined before connection setup - // is complete, consider returning error when called before connection is - // established. Currently returns hardcoded const, because integration - // prototype may call before connection is established. - virtual size_t GetLargestDatagramSize() const = 0; - - // Sets packet sink. Sink must be unset by calling - // SetDataTransportSink(nullptr) before the data transport is destroyed or - // before new sink is set. - virtual void SetDatagramSink(DatagramSinkInterface* sink) = 0; - - // Retrieves callers config (i.e. media transport offer) that should be passed - // to the callee, before the call is connected. Such config is opaque to SDP - // (sdp just passes it through). The config is a binary blob, so SDP may - // choose to use base64 to serialize it (or any other approach that guarantees - // that the binary blob goes through). This should only be called for the - // caller's perspective. - // - // TODO(mellem): Delete. - virtual absl::optional GetTransportParametersOffer() const { - return absl::nullopt; - } - - // Retrieves transport parameters for this datagram transport. May be called - // on either client- or server-perspective transports. - // - // For servers, the parameters represent what kind of connections and data the - // server is prepared to accept. This is generally a superset of acceptable - // parameters. - // - // For clients, the parameters echo the server configuration used to create - // the client, possibly removing any fields or parameters which the client - // does not understand. - // - // TODO(mellem): Make pure virtual. - virtual std::string GetTransportParameters() const { return ""; } -}; - -} // namespace webrtc +// TODO(bugs.webrtc.org/8733): Delete once users are updated for the new +// location. +#include "api/transport/datagram_transport_interface.h" #endif // API_DATAGRAM_TRANSPORT_INTERFACE_H_ diff --git a/api/media_transport_config.h b/api/media_transport_config.h index 7c5104b1f9..c74f38dc05 100644 --- a/api/media_transport_config.h +++ b/api/media_transport_config.h @@ -9,39 +9,8 @@ #ifndef API_MEDIA_TRANSPORT_CONFIG_H_ #define API_MEDIA_TRANSPORT_CONFIG_H_ -#include -#include -#include - -#include "absl/types/optional.h" - -namespace webrtc { - -class MediaTransportInterface; - -// Media transport config is made available to both transport and audio / video -// layers, but access to individual interfaces should not be open without -// necessity. -struct MediaTransportConfig { - // Default constructor for no-media transport scenarios. - MediaTransportConfig() = default; - - // Constructor for media transport scenarios. - // Note that |media_transport| may not be nullptr. - explicit MediaTransportConfig(MediaTransportInterface* media_transport); - - // Constructor for datagram transport scenarios. - explicit MediaTransportConfig(size_t rtp_max_packet_size); - - std::string DebugString() const; - - // If provided, all media is sent through media_transport. - MediaTransportInterface* media_transport = nullptr; - - // If provided, limits RTP packet size (excludes ICE, IP or network overhead). - absl::optional rtp_max_packet_size; -}; - -} // namespace webrtc +// TODO(bugs.webrtc.org/8733): Delete once users are updated for the new +// location. +#include "api/transport/media/media_transport_config.h" #endif // API_MEDIA_TRANSPORT_CONFIG_H_ diff --git a/api/media_transport_interface.h b/api/media_transport_interface.h index 609ae2c5c1..867871bde7 100644 --- a/api/media_transport_interface.h +++ b/api/media_transport_interface.h @@ -7,322 +7,11 @@ * be found in the AUTHORS file in the root of the source tree. */ -// This is EXPERIMENTAL interface for media transport. -// -// The goal is to refactor WebRTC code so that audio and video frames -// are sent / received through the media transport interface. This will -// enable different media transport implementations, including QUIC-based -// media transport. - #ifndef API_MEDIA_TRANSPORT_INTERFACE_H_ #define API_MEDIA_TRANSPORT_INTERFACE_H_ -#include -#include -#include +// TODO(bugs.webrtc.org/8733): Delete once users are updated for the new +// location. +#include "api/transport/media/media_transport_interface.h" -#include "absl/types/optional.h" -#include "api/array_view.h" -#include "api/data_channel_transport_interface.h" -#include "api/rtc_error.h" -#include "api/transport/media/audio_transport.h" -#include "api/transport/media/video_transport.h" -#include "api/transport/network_control.h" -#include "api/units/data_rate.h" -#include "common_types.h" // NOLINT(build/include) -#include "rtc_base/copy_on_write_buffer.h" -#include "rtc_base/network_route.h" - -namespace rtc { -class PacketTransportInternal; -class Thread; -} // namespace rtc - -namespace webrtc { - -class DatagramTransportInterface; -class RtcEventLog; - -class AudioPacketReceivedObserver { - public: - virtual ~AudioPacketReceivedObserver() = default; - - // Invoked for the first received audio packet on a given channel id. - // It will be invoked once for each channel id. - virtual void OnFirstAudioPacketReceived(int64_t channel_id) = 0; -}; - -// Used to configure stream allocations. -struct MediaTransportAllocatedBitrateLimits { - DataRate min_pacing_rate = DataRate::Zero(); - DataRate max_padding_bitrate = DataRate::Zero(); - DataRate max_total_allocated_bitrate = DataRate::Zero(); -}; - -// Used to configure target bitrate constraints. -// If the value is provided, the constraint is updated. -// If the value is omitted, the value is left unchanged. -struct MediaTransportTargetRateConstraints { - absl::optional min_bitrate; - absl::optional max_bitrate; - absl::optional starting_bitrate; -}; - -// A collection of settings for creation of media transport. -struct MediaTransportSettings final { - MediaTransportSettings(); - MediaTransportSettings(const MediaTransportSettings&); - MediaTransportSettings& operator=(const MediaTransportSettings&); - ~MediaTransportSettings(); - - // Group calls are not currently supported, in 1:1 call one side must set - // is_caller = true and another is_caller = false. - bool is_caller; - - // Must be set if a pre-shared key is used for the call. - // TODO(bugs.webrtc.org/9944): This should become zero buffer in the distant - // future. - absl::optional pre_shared_key; - - // If present, this is a config passed from the caller to the answerer in the - // offer. Each media transport knows how to understand its own parameters. - absl::optional remote_transport_parameters; - - // If present, provides the event log that media transport should use. - // Media transport does not own it. The lifetime of |event_log| will exceed - // the lifetime of the instance of MediaTransportInterface instance. - RtcEventLog* event_log = nullptr; -}; - -// Callback to notify about network route changes. -class MediaTransportNetworkChangeCallback { - public: - virtual ~MediaTransportNetworkChangeCallback() = default; - - // Called when the network route is changed, with the new network route. - virtual void OnNetworkRouteChanged( - const rtc::NetworkRoute& new_network_route) = 0; -}; - -// State of the media transport. Media transport begins in the pending state. -// It transitions to writable when it is ready to send media. It may transition -// back to pending if the connection is blocked. It may transition to closed at -// any time. Closed is terminal: a transport will never re-open once closed. -enum class MediaTransportState { - kPending, - kWritable, - kClosed, -}; - -// Callback invoked whenever the state of the media transport changes. -class MediaTransportStateCallback { - public: - virtual ~MediaTransportStateCallback() = default; - - // Invoked whenever the state of the media transport changes. - virtual void OnStateChanged(MediaTransportState state) = 0; -}; - -// Callback for RTT measurements on the receive side. -// TODO(nisse): Related interfaces: CallStatsObserver and RtcpRttStats. It's -// somewhat unclear what type of measurement is needed. It's used to configure -// NACK generation and playout buffer. Either raw measurement values or recent -// maximum would make sense for this use. Need consolidation of RTT signalling. -class MediaTransportRttObserver { - public: - virtual ~MediaTransportRttObserver() = default; - - // Invoked when a new RTT measurement is available, typically once per ACK. - virtual void OnRttUpdated(int64_t rtt_ms) = 0; -}; - -// Media transport interface for sending / receiving encoded audio/video frames -// and receiving bandwidth estimate update from congestion control. -class MediaTransportInterface : public DataChannelTransportInterface { - public: - MediaTransportInterface(); - virtual ~MediaTransportInterface(); - - // Retrieves callers config (i.e. media transport offer) that should be passed - // to the callee, before the call is connected. Such config is opaque to SDP - // (sdp just passes it through). The config is a binary blob, so SDP may - // choose to use base64 to serialize it (or any other approach that guarantees - // that the binary blob goes through). This should only be called for the - // caller's perspective. - // - // This may return an unset optional, which means that the given media - // transport is not supported / disabled and shouldn't be reported in SDP. - // - // It may also return an empty string, in which case the media transport is - // supported, but without any extra settings. - // TODO(psla): Make abstract. - virtual absl::optional GetTransportParametersOffer() const; - - // Connect the media transport to the ICE transport. - // The implementation must be able to ignore incoming packets that don't - // belong to it. - // TODO(psla): Make abstract. - virtual void Connect(rtc::PacketTransportInternal* packet_transport); - - // Start asynchronous send of audio frame. The status returned by this method - // only pertains to the synchronous operations (e.g. - // serialization/packetization), not to the asynchronous operation. - - virtual RTCError SendAudioFrame(uint64_t channel_id, - MediaTransportEncodedAudioFrame frame) = 0; - - // Start asynchronous send of video frame. The status returned by this method - // only pertains to the synchronous operations (e.g. - // serialization/packetization), not to the asynchronous operation. - virtual RTCError SendVideoFrame( - uint64_t channel_id, - const MediaTransportEncodedVideoFrame& frame) = 0; - - // Used by video sender to be notified on key frame requests. - virtual void SetKeyFrameRequestCallback( - MediaTransportKeyFrameRequestCallback* callback); - - // Requests a keyframe for the particular channel (stream). The caller should - // check that the keyframe is not present in a jitter buffer already (i.e. - // don't request a keyframe if there is one that you will get from the jitter - // buffer in a moment). - virtual RTCError RequestKeyFrame(uint64_t channel_id) = 0; - - // Sets audio sink. Sink must be unset by calling SetReceiveAudioSink(nullptr) - // before the media transport is destroyed or before new sink is set. - virtual void SetReceiveAudioSink(MediaTransportAudioSinkInterface* sink) = 0; - - // Registers a video sink. Before destruction of media transport, you must - // pass a nullptr. - virtual void SetReceiveVideoSink(MediaTransportVideoSinkInterface* sink) = 0; - - // Adds a target bitrate observer. Before media transport is destructed - // the observer must be unregistered (by calling - // RemoveTargetTransferRateObserver). - // A newly registered observer will be called back with the latest recorded - // target rate, if available. - virtual void AddTargetTransferRateObserver( - TargetTransferRateObserver* observer); - - // Removes an existing |observer| from observers. If observer was never - // registered, an error is logged and method does nothing. - virtual void RemoveTargetTransferRateObserver( - TargetTransferRateObserver* observer); - - // Sets audio packets observer, which gets informed about incoming audio - // packets. Before destruction, the observer must be unregistered by setting - // nullptr. - // - // This method may be temporary, when the multiplexer is implemented (or - // multiplexer may use it to demultiplex channel ids). - virtual void SetFirstAudioPacketReceivedObserver( - AudioPacketReceivedObserver* observer); - - // Intended for receive side. AddRttObserver registers an observer to be - // called for each RTT measurement, typically once per ACK. Before media - // transport is destructed the observer must be unregistered. - virtual void AddRttObserver(MediaTransportRttObserver* observer); - virtual void RemoveRttObserver(MediaTransportRttObserver* observer); - - // Returns the last known target transfer rate as reported to the above - // observers. - virtual absl::optional GetLatestTargetTransferRate(); - - // Gets the audio packet overhead in bytes. Returned overhead does not include - // transport overhead (ipv4/6, turn channeldata, tcp/udp, etc.). - // If the transport is capable of fusing packets together, this overhead - // might not be a very accurate number. - // TODO(nisse): Deprecated. - virtual size_t GetAudioPacketOverhead() const; - - // Corresponding observers for audio and video overhead. Before destruction, - // the observers must be unregistered by setting nullptr. - - // TODO(nisse): Should move to per-stream objects, since packetization - // overhead can vary per stream, e.g., depending on negotiated extensions. In - // addition, we should move towards reporting total overhead including all - // layers. Currently, overhead of the lower layers is reported elsewhere, - // e.g., on route change between IPv4 and IPv6. - virtual void SetAudioOverheadObserver(OverheadObserver* observer) {} - - // Registers an observer for network change events. If the network route is - // already established when the callback is added, |callback| will be called - // immediately with the current network route. Before media transport is - // destroyed, the callback must be removed. - virtual void AddNetworkChangeCallback( - MediaTransportNetworkChangeCallback* callback); - virtual void RemoveNetworkChangeCallback( - MediaTransportNetworkChangeCallback* callback); - - // Sets a state observer callback. Before media transport is destroyed, the - // callback must be unregistered by setting it to nullptr. - // A newly registered callback will be called with the current state. - // Media transport does not invoke this callback concurrently. - virtual void SetMediaTransportStateCallback( - MediaTransportStateCallback* callback) = 0; - - // Updates allocation limits. - // TODO(psla): Make abstract when downstream implementation implement it. - virtual void SetAllocatedBitrateLimits( - const MediaTransportAllocatedBitrateLimits& limits); - - // Sets starting rate. - // TODO(psla): Make abstract when downstream implementation implement it. - virtual void SetTargetBitrateLimits( - const MediaTransportTargetRateConstraints& target_rate_constraints) {} - - // TODO(sukhanov): RtcEventLogs. -}; - -// If media transport factory is set in peer connection factory, it will be -// used to create media transport for sending/receiving encoded frames and -// this transport will be used instead of default RTP/SRTP transport. -// -// Currently Media Transport negotiation is not supported in SDP. -// If application is using media transport, it must negotiate it before -// setting media transport factory in peer connection. -class MediaTransportFactory { - public: - virtual ~MediaTransportFactory() = default; - - // Creates media transport. - // - Does not take ownership of packet_transport or network_thread. - // - Does not support group calls, in 1:1 call one side must set - // is_caller = true and another is_caller = false. - virtual RTCErrorOr> - CreateMediaTransport(rtc::PacketTransportInternal* packet_transport, - rtc::Thread* network_thread, - const MediaTransportSettings& settings); - - // Creates a new Media Transport in a disconnected state. If the media - // transport for the caller is created, one can then call - // MediaTransportInterface::GetTransportParametersOffer on that new instance. - // TODO(psla): Make abstract. - virtual RTCErrorOr> - CreateMediaTransport(rtc::Thread* network_thread, - const MediaTransportSettings& settings); - - // Creates a new Datagram Transport in a disconnected state. If the datagram - // transport for the caller is created, one can then call - // DatagramTransportInterface::GetTransportParametersOffer on that new - // instance. - // - // TODO(sukhanov): Consider separating media and datagram transport factories. - // TODO(sukhanov): Move factory to a separate .h file. - virtual RTCErrorOr> - CreateDatagramTransport(rtc::Thread* network_thread, - const MediaTransportSettings& settings); - - // Gets a transport name which is supported by the implementation. - // Different factories should return different transport names, and at runtime - // it will be checked that different names were used. - // For example, "rtp" or "generic" may be returned by two different - // implementations. - // The value returned by this method must never change in the lifetime of the - // factory. - // TODO(psla): Make abstract. - virtual std::string GetTransportName() const; -}; - -} // namespace webrtc #endif // API_MEDIA_TRANSPORT_INTERFACE_H_ diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h index afa771fa79..835e9aef37 100644 --- a/api/peer_connection_interface.h +++ b/api/peer_connection_interface.h @@ -84,7 +84,6 @@ #include "api/fec_controller.h" #include "api/jsep.h" #include "api/media_stream_interface.h" -#include "api/media_transport_interface.h" #include "api/network_state_predictor.h" #include "api/packet_socket_factory.h" #include "api/rtc_error.h" @@ -98,6 +97,7 @@ #include "api/stats_types.h" #include "api/task_queue/task_queue_factory.h" #include "api/transport/bitrate_settings.h" +#include "api/transport/media/media_transport_interface.h" #include "api/transport/network_control.h" #include "api/turn_customizer.h" #include "media/base/media_config.h" diff --git a/api/test/fake_datagram_transport.h b/api/test/fake_datagram_transport.h index 9a1ddef12e..8cb399cd22 100644 --- a/api/test/fake_datagram_transport.h +++ b/api/test/fake_datagram_transport.h @@ -14,7 +14,8 @@ #include #include -#include "api/datagram_transport_interface.h" +#include "api/transport/datagram_transport_interface.h" +#include "api/transport/media/media_transport_interface.h" namespace webrtc { diff --git a/api/test/fake_media_transport.h b/api/test/fake_media_transport.h index 025965b737..3bd4eba0fd 100644 --- a/api/test/fake_media_transport.h +++ b/api/test/fake_media_transport.h @@ -18,8 +18,8 @@ #include "absl/algorithm/container.h" #include "absl/memory/memory.h" -#include "api/media_transport_interface.h" #include "api/test/fake_datagram_transport.h" +#include "api/transport/media/media_transport_interface.h" namespace webrtc { diff --git a/api/test/loopback_media_transport.h b/api/test/loopback_media_transport.h index cc66d627ae..e00cc23b6e 100644 --- a/api/test/loopback_media_transport.h +++ b/api/test/loopback_media_transport.h @@ -17,8 +17,8 @@ #include #include "absl/memory/memory.h" -#include "api/datagram_transport_interface.h" -#include "api/media_transport_interface.h" +#include "api/transport/datagram_transport_interface.h" +#include "api/transport/media/media_transport_interface.h" #include "rtc_base/async_invoker.h" #include "rtc_base/critical_section.h" #include "rtc_base/thread.h" diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h index fa63ca01e1..3a654dda45 100644 --- a/api/test/peerconnection_quality_test_fixture.h +++ b/api/test/peerconnection_quality_test_fixture.h @@ -21,7 +21,6 @@ #include "api/call/call_factory_interface.h" #include "api/fec_controller.h" #include "api/function_view.h" -#include "api/media_transport_interface.h" #include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log_factory_interface.h" #include "api/task_queue/task_queue_factory.h" @@ -29,6 +28,7 @@ #include "api/test/simulated_network.h" #include "api/test/stats_observer_interface.h" #include "api/test/video_quality_analyzer_interface.h" +#include "api/transport/media/media_transport_interface.h" #include "api/transport/network_control.h" #include "api/units/time_delta.h" #include "api/video_codecs/video_decoder_factory.h" diff --git a/api/transport/BUILD.gn b/api/transport/BUILD.gn index 1b485554e4..b07021bb29 100644 --- a/api/transport/BUILD.gn +++ b/api/transport/BUILD.gn @@ -69,6 +69,25 @@ rtc_source_set("field_trial_based_config") { ] } +rtc_source_set("datagram_transport_interface") { + visibility = [ "*" ] + sources = [ + "congestion_control_interface.h", + "data_channel_transport_interface.cc", + "data_channel_transport_interface.h", + "datagram_transport_interface.h", + ] + deps = [ + ":network_control", + "..:array_view", + "..:rtc_error", + "../../rtc_base:rtc_base_approved", + "../units:data_rate", + "../units:timestamp", + "//third_party/abseil-cpp/absl/types:optional", + ] +} + rtc_static_library("goog_cc") { visibility = [ "*" ] sources = [ diff --git a/api/transport/congestion_control_interface.h b/api/transport/congestion_control_interface.h new file mode 100644 index 0000000000..40552cb4ff --- /dev/null +++ b/api/transport/congestion_control_interface.h @@ -0,0 +1,75 @@ +/* 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. + */ + +// This is EXPERIMENTAL interface for media and datagram transports. + +#ifndef API_TRANSPORT_CONGESTION_CONTROL_INTERFACE_H_ +#define API_TRANSPORT_CONGESTION_CONTROL_INTERFACE_H_ + +#include +#include +#include + +#include "api/transport/network_control.h" +#include "api/units/data_rate.h" + +namespace webrtc { + +// TODO(nisse): Defined together with MediaTransportInterface. But we should use +// types that aren't tied to media, so that MediaTransportInterface can depend +// on CongestionControlInterface, but not the other way around. +// api/transport/network_control.h may be a reasonable place. +class MediaTransportRttObserver; +struct MediaTransportAllocatedBitrateLimits; +struct MediaTransportTargetRateConstraints; + +// Defines congestion control feedback interface for media and datagram +// transports. +class CongestionControlInterface { + public: + virtual ~CongestionControlInterface() = default; + + // Updates allocation limits. + virtual void SetAllocatedBitrateLimits( + const MediaTransportAllocatedBitrateLimits& limits) = 0; + + // Sets starting rate. + virtual void SetTargetBitrateLimits( + const MediaTransportTargetRateConstraints& target_rate_constraints) = 0; + + // Intended for receive side. AddRttObserver registers an observer to be + // called for each RTT measurement, typically once per ACK. Before media + // transport is destructed the observer must be unregistered. + // + // TODO(sukhanov): Looks like AddRttObserver and RemoveRttObserver were + // never implemented for media transport, so keeping noop implementation. + virtual void AddRttObserver(MediaTransportRttObserver* observer) {} + virtual void RemoveRttObserver(MediaTransportRttObserver* observer) {} + + // Adds a target bitrate observer. Before media transport is destructed + // the observer must be unregistered (by calling + // RemoveTargetTransferRateObserver). + // A newly registered observer will be called back with the latest recorded + // target rate, if available. + virtual void AddTargetTransferRateObserver( + TargetTransferRateObserver* observer) = 0; + + // Removes an existing |observer| from observers. If observer was never + // registered, an error is logged and method does nothing. + virtual void RemoveTargetTransferRateObserver( + TargetTransferRateObserver* observer) = 0; + + // Returns the last known target transfer rate as reported to the above + // observers. + virtual absl::optional GetLatestTargetTransferRate() = 0; +}; + +} // namespace webrtc + +#endif // API_TRANSPORT_CONGESTION_CONTROL_INTERFACE_H_ diff --git a/api/data_channel_transport_interface.cc b/api/transport/data_channel_transport_interface.cc similarity index 95% rename from api/data_channel_transport_interface.cc rename to api/transport/data_channel_transport_interface.cc index d9947e2c97..122e282525 100644 --- a/api/data_channel_transport_interface.cc +++ b/api/transport/data_channel_transport_interface.cc @@ -7,7 +7,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "api/data_channel_transport_interface.h" +#include "api/transport/data_channel_transport_interface.h" namespace webrtc { diff --git a/api/transport/data_channel_transport_interface.h b/api/transport/data_channel_transport_interface.h new file mode 100644 index 0000000000..9b29323514 --- /dev/null +++ b/api/transport/data_channel_transport_interface.h @@ -0,0 +1,125 @@ +/* Copyright 2019 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. + */ + +// This is an experimental interface and is subject to change without notice. + +#ifndef API_TRANSPORT_DATA_CHANNEL_TRANSPORT_INTERFACE_H_ +#define API_TRANSPORT_DATA_CHANNEL_TRANSPORT_INTERFACE_H_ + +#include "absl/types/optional.h" +#include "api/rtc_error.h" +#include "rtc_base/copy_on_write_buffer.h" + +namespace webrtc { + +// Supported types of application data messages. +enum class DataMessageType { + // Application data buffer with the binary bit unset. + kText, + + // Application data buffer with the binary bit set. + kBinary, + + // Transport-agnostic control messages, such as open or open-ack messages. + kControl, +}; + +// Parameters for sending data. The parameters may change from message to +// message, even within a single channel. For example, control messages may be +// sent reliably and in-order, even if the data channel is configured for +// unreliable delivery. +struct SendDataParams { + SendDataParams(); + SendDataParams(const SendDataParams&); + + DataMessageType type = DataMessageType::kText; + + // Whether to deliver the message in order with respect to other ordered + // messages with the same channel_id. + bool ordered = false; + + // If set, the maximum number of times this message may be + // retransmitted by the transport before it is dropped. + // Setting this value to zero disables retransmission. + // Must be non-negative. |max_rtx_count| and |max_rtx_ms| may not be set + // simultaneously. + absl::optional max_rtx_count; + + // If set, the maximum number of milliseconds for which the transport + // may retransmit this message before it is dropped. + // Setting this value to zero disables retransmission. + // Must be non-negative. |max_rtx_count| and |max_rtx_ms| may not be set + // simultaneously. + absl::optional max_rtx_ms; +}; + +// Sink for callbacks related to a data channel. +class DataChannelSink { + public: + virtual ~DataChannelSink() = default; + + // Callback issued when data is received by the transport. + virtual void OnDataReceived(int channel_id, + DataMessageType type, + const rtc::CopyOnWriteBuffer& buffer) = 0; + + // Callback issued when a remote data channel begins the closing procedure. + // Messages sent after the closing procedure begins will not be transmitted. + virtual void OnChannelClosing(int channel_id) = 0; + + // Callback issued when a (remote or local) data channel completes the closing + // procedure. Closing channels become closed after all pending data has been + // transmitted. + virtual void OnChannelClosed(int channel_id) = 0; + + // Callback issued when the data channel becomes ready to send. + // This callback will be issued immediately when the data channel sink is + // registered if the transport is ready at that time. This callback may be + // invoked again following send errors (eg. due to the transport being + // temporarily blocked or unavailable). + // TODO(mellem): Make pure virtual when downstream sinks override this. + virtual void OnReadyToSend(); +}; + +// Transport for data channels. +class DataChannelTransportInterface { + public: + virtual ~DataChannelTransportInterface() = default; + + // Opens a data |channel_id| for sending. May return an error if the + // specified |channel_id| is unusable. Must be called before |SendData|. + virtual RTCError OpenChannel(int channel_id); + + // Sends a data buffer to the remote endpoint using the given send parameters. + // |buffer| may not be larger than 256 KiB. Returns an error if the send + // fails. + virtual RTCError SendData(int channel_id, + const SendDataParams& params, + const rtc::CopyOnWriteBuffer& buffer); + + // Closes |channel_id| gracefully. Returns an error if |channel_id| is not + // open. Data sent after the closing procedure begins will not be + // transmitted. The channel becomes closed after pending data is transmitted. + virtual RTCError CloseChannel(int channel_id); + + // Sets a sink for data messages and channel state callbacks. Before media + // transport is destroyed, the sink must be unregistered by setting it to + // nullptr. + virtual void SetDataSink(DataChannelSink* sink); + + // Returns whether this data channel transport is ready to send. + // Note: the default implementation always returns false (as it assumes no one + // has implemented the interface). This default implementation is temporary. + // TODO(mellem): Change this to pure virtual. + virtual bool IsReadyToSend() const; +}; + +} // namespace webrtc + +#endif // API_TRANSPORT_DATA_CHANNEL_TRANSPORT_INTERFACE_H_ diff --git a/api/transport/datagram_transport_interface.h b/api/transport/datagram_transport_interface.h new file mode 100644 index 0000000000..9820c7505a --- /dev/null +++ b/api/transport/datagram_transport_interface.h @@ -0,0 +1,150 @@ +/* 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. + */ + +// This is EXPERIMENTAL interface for media and datagram transports. + +#ifndef API_TRANSPORT_DATAGRAM_TRANSPORT_INTERFACE_H_ +#define API_TRANSPORT_DATAGRAM_TRANSPORT_INTERFACE_H_ + +#include +#include +#include + +#include "absl/types/optional.h" +#include "api/array_view.h" +#include "api/rtc_error.h" +#include "api/transport/congestion_control_interface.h" +#include "api/transport/data_channel_transport_interface.h" +#include "api/units/data_rate.h" +#include "api/units/timestamp.h" + +namespace rtc { +class PacketTransportInternal; +} // namespace rtc + +namespace webrtc { + +class MediaTransportStateCallback; + +typedef int64_t DatagramId; + +struct DatagramAck { + // |datagram_id| is same as passed in + // DatagramTransportInterface::SendDatagram. + DatagramId datagram_id; + + // The timestamp at which the remote peer received the identified datagram, + // according to that peer's clock. + Timestamp receive_timestamp = Timestamp::MinusInfinity(); +}; + +// All sink methods are called on network thread. +class DatagramSinkInterface { + public: + virtual ~DatagramSinkInterface() {} + + // Called when new packet is received. + virtual void OnDatagramReceived(rtc::ArrayView data) = 0; + + // Called when datagram is actually sent (datragram can be delayed due + // to congestion control or fusing). |datagram_id| is same as passed in + // DatagramTransportInterface::SendDatagram. + virtual void OnDatagramSent(DatagramId datagram_id) = 0; + + // Called when datagram is ACKed. + // TODO(sukhanov): Make pure virtual. + virtual void OnDatagramAcked(const DatagramAck& datagram_ack) {} + + // Called when a datagram is lost. + virtual void OnDatagramLost(DatagramId datagram_id) {} +}; + +// Datagram transport allows to send and receive unreliable packets (datagrams) +// and receive feedback from congestion control (via +// CongestionControlInterface). The idea is to send RTP packets as datagrams and +// have underlying implementation of datagram transport to use QUIC datagram +// protocol. +class DatagramTransportInterface : public DataChannelTransportInterface { + public: + virtual ~DatagramTransportInterface() = default; + + // Connect the datagram transport to the ICE transport. + // The implementation must be able to ignore incoming packets that don't + // belong to it. + virtual void Connect(rtc::PacketTransportInternal* packet_transport) = 0; + + // Returns congestion control feedback interface or nullptr if datagram + // transport does not implement congestion control. + // + // Note that right now datagram transport is used without congestion control, + // but we plan to use it in the future. + virtual CongestionControlInterface* congestion_control() = 0; + + // Sets a state observer callback. Before datagram transport is destroyed, the + // callback must be unregistered by setting it to nullptr. + // A newly registered callback will be called with the current state. + // Datagram transport does not invoke this callback concurrently. + virtual void SetTransportStateCallback( + MediaTransportStateCallback* callback) = 0; + + // Start asynchronous send of datagram. The status returned by this method + // only pertains to the synchronous operations (e.g. serialization / + // packetization), not to the asynchronous operation. + // + // Datagrams larger than GetLargestDatagramSize() will fail and return error. + // + // Datagrams are sent in FIFO order. + // + // |datagram_id| is only used in ACK/LOST notifications in + // DatagramSinkInterface and does not need to be unique. + virtual RTCError SendDatagram(rtc::ArrayView data, + DatagramId datagram_id) = 0; + + // Returns maximum size of datagram message, does not change. + // TODO(sukhanov): Because value may be undefined before connection setup + // is complete, consider returning error when called before connection is + // established. Currently returns hardcoded const, because integration + // prototype may call before connection is established. + virtual size_t GetLargestDatagramSize() const = 0; + + // Sets packet sink. Sink must be unset by calling + // SetDataTransportSink(nullptr) before the data transport is destroyed or + // before new sink is set. + virtual void SetDatagramSink(DatagramSinkInterface* sink) = 0; + + // Retrieves callers config (i.e. media transport offer) that should be passed + // to the callee, before the call is connected. Such config is opaque to SDP + // (sdp just passes it through). The config is a binary blob, so SDP may + // choose to use base64 to serialize it (or any other approach that guarantees + // that the binary blob goes through). This should only be called for the + // caller's perspective. + // + // TODO(mellem): Delete. + virtual absl::optional GetTransportParametersOffer() const { + return absl::nullopt; + } + + // Retrieves transport parameters for this datagram transport. May be called + // on either client- or server-perspective transports. + // + // For servers, the parameters represent what kind of connections and data the + // server is prepared to accept. This is generally a superset of acceptable + // parameters. + // + // For clients, the parameters echo the server configuration used to create + // the client, possibly removing any fields or parameters which the client + // does not understand. + // + // TODO(mellem): Make pure virtual. + virtual std::string GetTransportParameters() const { return ""; } +}; + +} // namespace webrtc + +#endif // API_TRANSPORT_DATAGRAM_TRANSPORT_INTERFACE_H_ diff --git a/api/transport/media/BUILD.gn b/api/transport/media/BUILD.gn index f338021bca..fe8e4e4a3b 100644 --- a/api/transport/media/BUILD.gn +++ b/api/transport/media/BUILD.gn @@ -8,6 +8,31 @@ import("../../../webrtc.gni") +rtc_source_set("media_transport_interface") { + visibility = [ "*" ] + sources = [ + "media_transport_config.cc", + "media_transport_config.h", + "media_transport_interface.cc", + "media_transport_interface.h", + ] + deps = [ + ":audio_interfaces", + ":video_interfaces", + "..:datagram_transport_interface", + "..:network_control", + "../..:array_view", + "../..:rtc_error", + "../../..:webrtc_common", + "../../../rtc_base", + "../../../rtc_base:checks", + "../../../rtc_base:rtc_base_approved", + "../../../rtc_base:stringutils", + "../../units:data_rate", + "//third_party/abseil-cpp/absl/types:optional", + ] +} + rtc_source_set("audio_interfaces") { visibility = [ "*" ] sources = [ diff --git a/api/media_transport_config.cc b/api/transport/media/media_transport_config.cc similarity index 95% rename from api/media_transport_config.cc rename to api/transport/media/media_transport_config.cc index 08a8756a61..cea3f163c4 100644 --- a/api/media_transport_config.cc +++ b/api/transport/media/media_transport_config.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "api/media_transport_config.h" +#include "api/transport/media/media_transport_config.h" #include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h" diff --git a/api/transport/media/media_transport_config.h b/api/transport/media/media_transport_config.h new file mode 100644 index 0000000000..6a12630295 --- /dev/null +++ b/api/transport/media/media_transport_config.h @@ -0,0 +1,46 @@ +/* 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_TRANSPORT_MEDIA_MEDIA_TRANSPORT_CONFIG_H_ +#define API_TRANSPORT_MEDIA_MEDIA_TRANSPORT_CONFIG_H_ + +#include +#include +#include + +#include "absl/types/optional.h" +#include "api/transport/media/media_transport_interface.h" + +namespace webrtc { + +// Media transport config is made available to both transport and audio / video +// layers, but access to individual interfaces should not be open without +// necessity. +struct MediaTransportConfig { + // Default constructor for no-media transport scenarios. + MediaTransportConfig() = default; + + // Constructor for media transport scenarios. + // Note that |media_transport| may not be nullptr. + explicit MediaTransportConfig(MediaTransportInterface* media_transport); + + // Constructor for datagram transport scenarios. + explicit MediaTransportConfig(size_t rtp_max_packet_size); + + std::string DebugString() const; + + // If provided, all media is sent through media_transport. + MediaTransportInterface* media_transport = nullptr; + + // If provided, limits RTP packet size (excludes ICE, IP or network overhead). + absl::optional rtp_max_packet_size; +}; + +} // namespace webrtc + +#endif // API_TRANSPORT_MEDIA_MEDIA_TRANSPORT_CONFIG_H_ diff --git a/api/media_transport_interface.cc b/api/transport/media/media_transport_interface.cc similarity index 96% rename from api/media_transport_interface.cc rename to api/transport/media/media_transport_interface.cc index 69f993eb4b..323ddca689 100644 --- a/api/media_transport_interface.cc +++ b/api/transport/media/media_transport_interface.cc @@ -15,12 +15,12 @@ // enable different media transport implementations, including QUIC-based // media transport. -#include "api/media_transport_interface.h" +#include "api/transport/media/media_transport_interface.h" #include #include -#include "api/datagram_transport_interface.h" +#include "api/transport/datagram_transport_interface.h" namespace webrtc { diff --git a/api/transport/media/media_transport_interface.h b/api/transport/media/media_transport_interface.h new file mode 100644 index 0000000000..04a8e50031 --- /dev/null +++ b/api/transport/media/media_transport_interface.h @@ -0,0 +1,328 @@ +/* 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. + */ + +// This is EXPERIMENTAL interface for media transport. +// +// The goal is to refactor WebRTC code so that audio and video frames +// are sent / received through the media transport interface. This will +// enable different media transport implementations, including QUIC-based +// media transport. + +#ifndef API_TRANSPORT_MEDIA_MEDIA_TRANSPORT_INTERFACE_H_ +#define API_TRANSPORT_MEDIA_MEDIA_TRANSPORT_INTERFACE_H_ + +#include +#include +#include + +#include "absl/types/optional.h" +#include "api/array_view.h" +#include "api/rtc_error.h" +#include "api/transport/data_channel_transport_interface.h" +#include "api/transport/media/audio_transport.h" +#include "api/transport/media/video_transport.h" +#include "api/transport/network_control.h" +#include "api/units/data_rate.h" +#include "common_types.h" // NOLINT(build/include) +#include "rtc_base/copy_on_write_buffer.h" +#include "rtc_base/network_route.h" + +namespace rtc { +class PacketTransportInternal; +class Thread; +} // namespace rtc + +namespace webrtc { + +class DatagramTransportInterface; +class RtcEventLog; + +class AudioPacketReceivedObserver { + public: + virtual ~AudioPacketReceivedObserver() = default; + + // Invoked for the first received audio packet on a given channel id. + // It will be invoked once for each channel id. + virtual void OnFirstAudioPacketReceived(int64_t channel_id) = 0; +}; + +// Used to configure stream allocations. +struct MediaTransportAllocatedBitrateLimits { + DataRate min_pacing_rate = DataRate::Zero(); + DataRate max_padding_bitrate = DataRate::Zero(); + DataRate max_total_allocated_bitrate = DataRate::Zero(); +}; + +// Used to configure target bitrate constraints. +// If the value is provided, the constraint is updated. +// If the value is omitted, the value is left unchanged. +struct MediaTransportTargetRateConstraints { + absl::optional min_bitrate; + absl::optional max_bitrate; + absl::optional starting_bitrate; +}; + +// A collection of settings for creation of media transport. +struct MediaTransportSettings final { + MediaTransportSettings(); + MediaTransportSettings(const MediaTransportSettings&); + MediaTransportSettings& operator=(const MediaTransportSettings&); + ~MediaTransportSettings(); + + // Group calls are not currently supported, in 1:1 call one side must set + // is_caller = true and another is_caller = false. + bool is_caller; + + // Must be set if a pre-shared key is used for the call. + // TODO(bugs.webrtc.org/9944): This should become zero buffer in the distant + // future. + absl::optional pre_shared_key; + + // If present, this is a config passed from the caller to the answerer in the + // offer. Each media transport knows how to understand its own parameters. + absl::optional remote_transport_parameters; + + // If present, provides the event log that media transport should use. + // Media transport does not own it. The lifetime of |event_log| will exceed + // the lifetime of the instance of MediaTransportInterface instance. + RtcEventLog* event_log = nullptr; +}; + +// Callback to notify about network route changes. +class MediaTransportNetworkChangeCallback { + public: + virtual ~MediaTransportNetworkChangeCallback() = default; + + // Called when the network route is changed, with the new network route. + virtual void OnNetworkRouteChanged( + const rtc::NetworkRoute& new_network_route) = 0; +}; + +// State of the media transport. Media transport begins in the pending state. +// It transitions to writable when it is ready to send media. It may transition +// back to pending if the connection is blocked. It may transition to closed at +// any time. Closed is terminal: a transport will never re-open once closed. +enum class MediaTransportState { + kPending, + kWritable, + kClosed, +}; + +// Callback invoked whenever the state of the media transport changes. +class MediaTransportStateCallback { + public: + virtual ~MediaTransportStateCallback() = default; + + // Invoked whenever the state of the media transport changes. + virtual void OnStateChanged(MediaTransportState state) = 0; +}; + +// Callback for RTT measurements on the receive side. +// TODO(nisse): Related interfaces: CallStatsObserver and RtcpRttStats. It's +// somewhat unclear what type of measurement is needed. It's used to configure +// NACK generation and playout buffer. Either raw measurement values or recent +// maximum would make sense for this use. Need consolidation of RTT signalling. +class MediaTransportRttObserver { + public: + virtual ~MediaTransportRttObserver() = default; + + // Invoked when a new RTT measurement is available, typically once per ACK. + virtual void OnRttUpdated(int64_t rtt_ms) = 0; +}; + +// Media transport interface for sending / receiving encoded audio/video frames +// and receiving bandwidth estimate update from congestion control. +class MediaTransportInterface : public DataChannelTransportInterface { + public: + MediaTransportInterface(); + virtual ~MediaTransportInterface(); + + // Retrieves callers config (i.e. media transport offer) that should be passed + // to the callee, before the call is connected. Such config is opaque to SDP + // (sdp just passes it through). The config is a binary blob, so SDP may + // choose to use base64 to serialize it (or any other approach that guarantees + // that the binary blob goes through). This should only be called for the + // caller's perspective. + // + // This may return an unset optional, which means that the given media + // transport is not supported / disabled and shouldn't be reported in SDP. + // + // It may also return an empty string, in which case the media transport is + // supported, but without any extra settings. + // TODO(psla): Make abstract. + virtual absl::optional GetTransportParametersOffer() const; + + // Connect the media transport to the ICE transport. + // The implementation must be able to ignore incoming packets that don't + // belong to it. + // TODO(psla): Make abstract. + virtual void Connect(rtc::PacketTransportInternal* packet_transport); + + // Start asynchronous send of audio frame. The status returned by this method + // only pertains to the synchronous operations (e.g. + // serialization/packetization), not to the asynchronous operation. + + virtual RTCError SendAudioFrame(uint64_t channel_id, + MediaTransportEncodedAudioFrame frame) = 0; + + // Start asynchronous send of video frame. The status returned by this method + // only pertains to the synchronous operations (e.g. + // serialization/packetization), not to the asynchronous operation. + virtual RTCError SendVideoFrame( + uint64_t channel_id, + const MediaTransportEncodedVideoFrame& frame) = 0; + + // Used by video sender to be notified on key frame requests. + virtual void SetKeyFrameRequestCallback( + MediaTransportKeyFrameRequestCallback* callback); + + // Requests a keyframe for the particular channel (stream). The caller should + // check that the keyframe is not present in a jitter buffer already (i.e. + // don't request a keyframe if there is one that you will get from the jitter + // buffer in a moment). + virtual RTCError RequestKeyFrame(uint64_t channel_id) = 0; + + // Sets audio sink. Sink must be unset by calling SetReceiveAudioSink(nullptr) + // before the media transport is destroyed or before new sink is set. + virtual void SetReceiveAudioSink(MediaTransportAudioSinkInterface* sink) = 0; + + // Registers a video sink. Before destruction of media transport, you must + // pass a nullptr. + virtual void SetReceiveVideoSink(MediaTransportVideoSinkInterface* sink) = 0; + + // Adds a target bitrate observer. Before media transport is destructed + // the observer must be unregistered (by calling + // RemoveTargetTransferRateObserver). + // A newly registered observer will be called back with the latest recorded + // target rate, if available. + virtual void AddTargetTransferRateObserver( + TargetTransferRateObserver* observer); + + // Removes an existing |observer| from observers. If observer was never + // registered, an error is logged and method does nothing. + virtual void RemoveTargetTransferRateObserver( + TargetTransferRateObserver* observer); + + // Sets audio packets observer, which gets informed about incoming audio + // packets. Before destruction, the observer must be unregistered by setting + // nullptr. + // + // This method may be temporary, when the multiplexer is implemented (or + // multiplexer may use it to demultiplex channel ids). + virtual void SetFirstAudioPacketReceivedObserver( + AudioPacketReceivedObserver* observer); + + // Intended for receive side. AddRttObserver registers an observer to be + // called for each RTT measurement, typically once per ACK. Before media + // transport is destructed the observer must be unregistered. + virtual void AddRttObserver(MediaTransportRttObserver* observer); + virtual void RemoveRttObserver(MediaTransportRttObserver* observer); + + // Returns the last known target transfer rate as reported to the above + // observers. + virtual absl::optional GetLatestTargetTransferRate(); + + // Gets the audio packet overhead in bytes. Returned overhead does not include + // transport overhead (ipv4/6, turn channeldata, tcp/udp, etc.). + // If the transport is capable of fusing packets together, this overhead + // might not be a very accurate number. + // TODO(nisse): Deprecated. + virtual size_t GetAudioPacketOverhead() const; + + // Corresponding observers for audio and video overhead. Before destruction, + // the observers must be unregistered by setting nullptr. + + // TODO(nisse): Should move to per-stream objects, since packetization + // overhead can vary per stream, e.g., depending on negotiated extensions. In + // addition, we should move towards reporting total overhead including all + // layers. Currently, overhead of the lower layers is reported elsewhere, + // e.g., on route change between IPv4 and IPv6. + virtual void SetAudioOverheadObserver(OverheadObserver* observer) {} + + // Registers an observer for network change events. If the network route is + // already established when the callback is added, |callback| will be called + // immediately with the current network route. Before media transport is + // destroyed, the callback must be removed. + virtual void AddNetworkChangeCallback( + MediaTransportNetworkChangeCallback* callback); + virtual void RemoveNetworkChangeCallback( + MediaTransportNetworkChangeCallback* callback); + + // Sets a state observer callback. Before media transport is destroyed, the + // callback must be unregistered by setting it to nullptr. + // A newly registered callback will be called with the current state. + // Media transport does not invoke this callback concurrently. + virtual void SetMediaTransportStateCallback( + MediaTransportStateCallback* callback) = 0; + + // Updates allocation limits. + // TODO(psla): Make abstract when downstream implementation implement it. + virtual void SetAllocatedBitrateLimits( + const MediaTransportAllocatedBitrateLimits& limits); + + // Sets starting rate. + // TODO(psla): Make abstract when downstream implementation implement it. + virtual void SetTargetBitrateLimits( + const MediaTransportTargetRateConstraints& target_rate_constraints) {} + + // TODO(sukhanov): RtcEventLogs. +}; + +// If media transport factory is set in peer connection factory, it will be +// used to create media transport for sending/receiving encoded frames and +// this transport will be used instead of default RTP/SRTP transport. +// +// Currently Media Transport negotiation is not supported in SDP. +// If application is using media transport, it must negotiate it before +// setting media transport factory in peer connection. +class MediaTransportFactory { + public: + virtual ~MediaTransportFactory() = default; + + // Creates media transport. + // - Does not take ownership of packet_transport or network_thread. + // - Does not support group calls, in 1:1 call one side must set + // is_caller = true and another is_caller = false. + virtual RTCErrorOr> + CreateMediaTransport(rtc::PacketTransportInternal* packet_transport, + rtc::Thread* network_thread, + const MediaTransportSettings& settings); + + // Creates a new Media Transport in a disconnected state. If the media + // transport for the caller is created, one can then call + // MediaTransportInterface::GetTransportParametersOffer on that new instance. + // TODO(psla): Make abstract. + virtual RTCErrorOr> + CreateMediaTransport(rtc::Thread* network_thread, + const MediaTransportSettings& settings); + + // Creates a new Datagram Transport in a disconnected state. If the datagram + // transport for the caller is created, one can then call + // DatagramTransportInterface::GetTransportParametersOffer on that new + // instance. + // + // TODO(sukhanov): Consider separating media and datagram transport factories. + // TODO(sukhanov): Move factory to a separate .h file. + virtual RTCErrorOr> + CreateDatagramTransport(rtc::Thread* network_thread, + const MediaTransportSettings& settings); + + // Gets a transport name which is supported by the implementation. + // Different factories should return different transport names, and at runtime + // it will be checked that different names were used. + // For example, "rtp" or "generic" may be returned by two different + // implementations. + // The value returned by this method must never change in the lifetime of the + // factory. + // TODO(psla): Make abstract. + virtual std::string GetTransportName() const; +}; + +} // namespace webrtc +#endif // API_TRANSPORT_MEDIA_MEDIA_TRANSPORT_INTERFACE_H_ diff --git a/audio/BUILD.gn b/audio/BUILD.gn index abf4c67270..dba7b583a1 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -54,6 +54,7 @@ rtc_static_library("audio") { "../api/audio_codecs:audio_codecs_api", "../api/rtc_event_log", "../api/task_queue", + "../api/transport/media:media_transport_interface", "../api/transport/rtp:rtp_source", "../call:bitrate_allocator", "../call:call_interfaces", @@ -139,6 +140,7 @@ if (rtc_include_tests) { "../api/audio_codecs/opus:audio_encoder_opus", "../api/rtc_event_log", "../api/task_queue:default_task_queue_factory", + "../api/transport/media:media_transport_interface", "../api/units:time_delta", "../call:mock_bitrate_allocator", "../call:mock_call_interfaces", diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index 479216aabf..cd137d9c89 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -21,8 +21,8 @@ #include "api/call/transport.h" #include "api/crypto/frame_encryptor_interface.h" #include "api/function_view.h" -#include "api/media_transport_config.h" #include "api/rtc_event_log/rtc_event_log.h" +#include "api/transport/media/media_transport_config.h" #include "audio/audio_state.h" #include "audio/channel_send.h" #include "audio/conversion.h" diff --git a/audio/channel_receive.h b/audio/channel_receive.h index a7151bcb8e..7527ef2454 100644 --- a/audio/channel_receive.h +++ b/audio/channel_receive.h @@ -22,8 +22,8 @@ #include "api/call/audio_sink.h" #include "api/call/transport.h" #include "api/crypto/crypto_options.h" -#include "api/media_transport_config.h" -#include "api/media_transport_interface.h" +#include "api/transport/media/media_transport_config.h" +#include "api/transport/media/media_transport_interface.h" #include "api/transport/rtp/rtp_source.h" #include "call/rtp_packet_sink_interface.h" #include "call/syncable.h" diff --git a/audio/channel_send.h b/audio/channel_send.h index 575f71febe..6f946101d9 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h @@ -19,9 +19,9 @@ #include "api/audio_codecs/audio_encoder.h" #include "api/crypto/crypto_options.h" #include "api/function_view.h" -#include "api/media_transport_config.h" -#include "api/media_transport_interface.h" #include "api/task_queue/task_queue_factory.h" +#include "api/transport/media/media_transport_config.h" +#include "api/transport/media/media_transport_interface.h" #include "modules/rtp_rtcp/include/report_block_data.h" #include "modules/rtp_rtcp/include/rtp_rtcp.h" #include "modules/rtp_rtcp/source/rtp_sender_audio.h" diff --git a/audio/test/media_transport_test.cc b/audio/test/media_transport_test.cc index cc360df49d..aacee1e88f 100644 --- a/audio/test/media_transport_test.cc +++ b/audio/test/media_transport_test.cc @@ -13,11 +13,11 @@ #include "api/audio_codecs/audio_encoder_factory_template.h" #include "api/audio_codecs/opus/audio_decoder_opus.h" #include "api/audio_codecs/opus/audio_encoder_opus.h" -#include "api/media_transport_config.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/task_queue/default_task_queue_factory.h" #include "api/test/loopback_media_transport.h" #include "api/test/mock_audio_mixer.h" +#include "api/transport/media/media_transport_config.h" #include "audio/audio_receive_stream.h" #include "audio/audio_send_stream.h" #include "call/rtp_transport_controller_send.h" diff --git a/call/BUILD.gn b/call/BUILD.gn index 912abc223a..f35c1f0a14 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -33,7 +33,7 @@ rtc_source_set("call_interfaces") { "../api:fec_controller_api", "../api:rtc_error", - # For api/media_transport_config.h + # For api/crypto/crypto_options.h "../api:libjingle_peerconnection_api", "../api:network_state_predictor_api", "../api:rtp_headers", @@ -44,6 +44,7 @@ rtc_source_set("call_interfaces") { "../api/audio_codecs:audio_codecs_api", "../api/task_queue", "../api/transport:network_control", + "../api/transport/media:media_transport_interface", "../api/transport/rtp:rtp_source", "../modules/audio_device", "../modules/audio_processing", @@ -286,6 +287,7 @@ rtc_source_set("video_stream_api") { "../api:rtp_headers", "../api:rtp_parameters", "../api:transport_api", + "../api/transport/media:media_transport_interface", "../api/transport/rtp:rtp_source", "../api/video:video_frame", "../api/video:video_rtp_headers", diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h index 0b764a1995..935aaed401 100644 --- a/call/audio_receive_stream.h +++ b/call/audio_receive_stream.h @@ -21,9 +21,9 @@ #include "api/call/transport.h" #include "api/crypto/crypto_options.h" #include "api/crypto/frame_decryptor_interface.h" -#include "api/media_transport_config.h" #include "api/rtp_parameters.h" #include "api/scoped_refptr.h" +#include "api/transport/media/media_transport_config.h" #include "api/transport/rtp/rtp_source.h" #include "call/rtp_config.h" diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h index 1f3d1d07bb..fb711c4efe 100644 --- a/call/audio_send_stream.h +++ b/call/audio_send_stream.h @@ -23,10 +23,10 @@ #include "api/call/transport.h" #include "api/crypto/crypto_options.h" #include "api/crypto/frame_encryptor_interface.h" -#include "api/media_transport_config.h" -#include "api/media_transport_interface.h" #include "api/rtp_parameters.h" #include "api/scoped_refptr.h" +#include "api/transport/media/media_transport_config.h" +#include "api/transport/media/media_transport_interface.h" #include "call/rtp_config.h" #include "modules/audio_processing/include/audio_processing_statistics.h" #include "modules/rtp_rtcp/include/report_block_data.h" diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h index 3869c8117a..b1d45ace1f 100644 --- a/call/video_receive_stream.h +++ b/call/video_receive_stream.h @@ -20,10 +20,10 @@ #include "api/call/transport.h" #include "api/crypto/crypto_options.h" #include "api/crypto/frame_decryptor_interface.h" -#include "api/media_transport_config.h" -#include "api/media_transport_interface.h" #include "api/rtp_headers.h" #include "api/rtp_parameters.h" +#include "api/transport/media/media_transport_config.h" +#include "api/transport/media/media_transport_interface.h" #include "api/transport/rtp/rtp_source.h" #include "api/video/video_content_type.h" #include "api/video/video_frame.h" diff --git a/call/video_send_stream.h b/call/video_send_stream.h index 2c31de0f8c..478d73cf33 100644 --- a/call/video_send_stream.h +++ b/call/video_send_stream.h @@ -20,8 +20,8 @@ #include "absl/types/optional.h" #include "api/call/transport.h" #include "api/crypto/crypto_options.h" -#include "api/media_transport_interface.h" #include "api/rtp_parameters.h" +#include "api/transport/media/media_transport_interface.h" #include "api/video/video_content_type.h" #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" diff --git a/media/BUILD.gn b/media/BUILD.gn index 24cf303ac1..be5b2b3fc3 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -79,6 +79,7 @@ rtc_static_library("rtc_media_base") { "../api:rtp_parameters", "../api:scoped_refptr", "../api/audio_codecs:audio_codecs_api", + "../api/transport/media:media_transport_interface", "../api/transport/rtp:rtp_source", "../api/video:video_bitrate_allocation", "../api/video:video_bitrate_allocator_factory", @@ -266,6 +267,8 @@ rtc_static_library("rtc_audio_video") { "../api/audio:audio_mixer_api", "../api/audio_codecs:audio_codecs_api", "../api/task_queue", + "../api/transport:datagram_transport_interface", + "../api/transport/media:media_transport_interface", "../api/transport/rtp:rtp_source", "../api/video:video_bitrate_allocation", "../api/video:video_bitrate_allocator_factory", @@ -530,6 +533,7 @@ if (rtc_include_tests) { "../api/task_queue", "../api/task_queue:default_task_queue_factory", "../api/test/video:function_video_factory", + "../api/transport/media:media_transport_interface", "../api/units:time_delta", "../api/video:builtin_video_bitrate_allocator_factory", "../api/video:video_bitrate_allocation", diff --git a/media/base/media_channel.h b/media/base/media_channel.h index 9cc787690d..da4f0d2baa 100644 --- a/media/base/media_channel.h +++ b/media/base/media_channel.h @@ -22,9 +22,9 @@ #include "api/audio_options.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/crypto/frame_encryptor_interface.h" -#include "api/media_transport_config.h" #include "api/rtc_error.h" #include "api/rtp_parameters.h" +#include "api/transport/media/media_transport_config.h" #include "api/transport/rtp/rtp_source.h" #include "api/video/video_content_type.h" #include "api/video/video_sink_interface.h" diff --git a/media/base/rtp_data_engine_unittest.cc b/media/base/rtp_data_engine_unittest.cc index cd11eb5cbd..79fb2b27c9 100644 --- a/media/base/rtp_data_engine_unittest.cc +++ b/media/base/rtp_data_engine_unittest.cc @@ -15,7 +15,7 @@ #include #include -#include "api/media_transport_config.h" +#include "api/transport/media/media_transport_config.h" #include "media/base/fake_network_interface.h" #include "media/base/media_constants.h" #include "media/base/rtp_utils.h" diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc index 4fbb2c8277..f31d69f5a0 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -19,7 +19,7 @@ #include "absl/algorithm/container.h" #include "absl/strings/match.h" -#include "api/datagram_transport_interface.h" +#include "api/transport/datagram_transport_interface.h" #include "api/video/video_codec_constants.h" #include "api/video/video_codec_type.h" #include "api/video_codecs/sdp_video_format.h" diff --git a/media/engine/webrtc_video_engine_unittest.cc b/media/engine/webrtc_video_engine_unittest.cc index ba1f671d2a..50dd8d8fb7 100644 --- a/media/engine/webrtc_video_engine_unittest.cc +++ b/media/engine/webrtc_video_engine_unittest.cc @@ -19,7 +19,6 @@ #include "absl/algorithm/container.h" #include "absl/memory/memory.h" #include "absl/strings/match.h" -#include "api/media_transport_config.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/rtp_parameters.h" #include "api/task_queue/default_task_queue_factory.h" @@ -28,6 +27,7 @@ #include "api/test/mock_video_bitrate_allocator_factory.h" #include "api/test/mock_video_decoder_factory.h" #include "api/test/mock_video_encoder_factory.h" +#include "api/transport/media/media_transport_config.h" #include "api/units/time_delta.h" #include "api/video/builtin_video_bitrate_allocator_factory.h" #include "api/video/i420_buffer.h" diff --git a/media/engine/webrtc_voice_engine.cc b/media/engine/webrtc_voice_engine.cc index 5ac32c44ec..1125780b46 100644 --- a/media/engine/webrtc_voice_engine.cc +++ b/media/engine/webrtc_voice_engine.cc @@ -21,7 +21,7 @@ #include "absl/strings/match.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/call/audio_sink.h" -#include "api/media_transport_interface.h" +#include "api/transport/media/media_transport_interface.h" #include "media/base/audio_source.h" #include "media/base/media_constants.h" #include "media/base/stream_params.h" diff --git a/media/engine/webrtc_voice_engine_unittest.cc b/media/engine/webrtc_voice_engine_unittest.cc index 909cdaf974..2ecf89e8f4 100644 --- a/media/engine/webrtc_voice_engine_unittest.cc +++ b/media/engine/webrtc_voice_engine_unittest.cc @@ -17,11 +17,11 @@ #include "absl/strings/match.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" -#include "api/media_transport_config.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/rtp_parameters.h" #include "api/scoped_refptr.h" #include "api/task_queue/default_task_queue_factory.h" +#include "api/transport/media/media_transport_config.h" #include "call/call.h" #include "media/base/fake_media_engine.h" #include "media/base/fake_network_interface.h" diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 7e1d53f8fe..e75188d376 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -88,6 +88,8 @@ rtc_static_library("rtc_pc_base") { "../api:rtp_parameters", "../api:scoped_refptr", "../api/rtc_event_log", + "../api/transport:datagram_transport_interface", + "../api/transport/media:media_transport_interface", "../api/video:builtin_video_bitrate_allocator_factory", "../api/video:video_frame", "../api/video:video_rtp_headers", @@ -227,6 +229,8 @@ rtc_static_library("peerconnection") { "../api:scoped_refptr", "../api/rtc_event_log", "../api/task_queue", + "../api/transport:datagram_transport_interface", + "../api/transport/media:media_transport_interface", "../api/units:data_rate", "../api/video:builtin_video_bitrate_allocator_factory", "../api/video:video_frame", @@ -314,6 +318,7 @@ if (rtc_include_tests) { "../api:rtc_error", "../api:rtp_headers", "../api:rtp_parameters", + "../api/transport/media:media_transport_interface", "../api/video:builtin_video_bitrate_allocator_factory", "../call:rtp_interfaces", "../call:rtp_receiver", @@ -547,6 +552,7 @@ if (rtc_include_tests) { "../api/rtc_event_log", "../api/rtc_event_log:rtc_event_log_factory", "../api/task_queue:default_task_queue_factory", + "../api/transport/media:media_transport_interface", "../api/transport/rtp:rtp_source", "../api/units:time_delta", "../api/video:builtin_video_bitrate_allocator_factory", diff --git a/pc/channel.cc b/pc/channel.cc index 95be5b65fb..59669510b5 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -16,7 +16,7 @@ #include "absl/algorithm/container.h" #include "absl/memory/memory.h" #include "api/call/audio_sink.h" -#include "api/media_transport_config.h" +#include "api/transport/media/media_transport_config.h" #include "media/base/media_constants.h" #include "media/base/rtp_utils.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" diff --git a/pc/channel.h b/pc/channel.h index 5222d98eed..6774f7e585 100644 --- a/pc/channel.h +++ b/pc/channel.h @@ -20,8 +20,8 @@ #include "api/call/audio_sink.h" #include "api/jsep.h" -#include "api/media_transport_config.h" #include "api/rtp_receiver_interface.h" +#include "api/transport/media/media_transport_config.h" #include "api/video/video_sink_interface.h" #include "api/video/video_source_interface.h" #include "call/rtp_packet_sink_interface.h" diff --git a/pc/channel_manager.h b/pc/channel_manager.h index cae812f3c5..661ab4bbde 100644 --- a/pc/channel_manager.h +++ b/pc/channel_manager.h @@ -19,7 +19,7 @@ #include "api/audio_options.h" #include "api/crypto/crypto_options.h" -#include "api/media_transport_config.h" +#include "api/transport/media/media_transport_config.h" #include "call/call.h" #include "media/base/codec.h" #include "media/base/media_channel.h" diff --git a/pc/channel_manager_unittest.cc b/pc/channel_manager_unittest.cc index c7216144f1..e88b09cb4f 100644 --- a/pc/channel_manager_unittest.cc +++ b/pc/channel_manager_unittest.cc @@ -13,9 +13,9 @@ #include #include "absl/memory/memory.h" -#include "api/media_transport_config.h" #include "api/rtc_error.h" #include "api/test/fake_media_transport.h" +#include "api/transport/media/media_transport_config.h" #include "api/video/builtin_video_bitrate_allocator_factory.h" #include "media/base/fake_media_engine.h" #include "media/base/test_utils.h" diff --git a/pc/channel_unittest.cc b/pc/channel_unittest.cc index db0e8a8d02..5b388ea967 100644 --- a/pc/channel_unittest.cc +++ b/pc/channel_unittest.cc @@ -17,8 +17,8 @@ #include "absl/memory/memory.h" #include "api/array_view.h" #include "api/audio_options.h" -#include "api/media_transport_config.h" #include "api/rtp_parameters.h" +#include "api/transport/media/media_transport_config.h" #include "media/base/codec.h" #include "media/base/fake_media_engine.h" #include "media/base/fake_rtp.h" diff --git a/pc/datagram_rtp_transport.h b/pc/datagram_rtp_transport.h index 1dfa37b77c..8aadf977bb 100644 --- a/pc/datagram_rtp_transport.h +++ b/pc/datagram_rtp_transport.h @@ -17,7 +17,7 @@ #include #include "api/crypto/crypto_options.h" -#include "api/datagram_transport_interface.h" +#include "api/transport/datagram_transport_interface.h" #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" #include "p2p/base/ice_transport_internal.h" diff --git a/pc/jsep_transport.h b/pc/jsep_transport.h index 1a0e7b499a..7bd0b0719e 100644 --- a/pc/jsep_transport.h +++ b/pc/jsep_transport.h @@ -18,9 +18,9 @@ #include "absl/types/optional.h" #include "api/candidate.h" -#include "api/datagram_transport_interface.h" #include "api/jsep.h" -#include "api/media_transport_interface.h" +#include "api/transport/datagram_transport_interface.h" +#include "api/transport/media/media_transport_interface.h" #include "p2p/base/dtls_transport.h" #include "p2p/base/p2p_constants.h" #include "p2p/base/transport_info.h" diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc index cfb971aed0..10250ced13 100644 --- a/pc/jsep_transport_controller.cc +++ b/pc/jsep_transport_controller.cc @@ -15,8 +15,8 @@ #include "absl/algorithm/container.h" #include "absl/memory/memory.h" -#include "api/datagram_transport_interface.h" -#include "api/media_transport_interface.h" +#include "api/transport/datagram_transport_interface.h" +#include "api/transport/media/media_transport_interface.h" #include "p2p/base/ice_transport_internal.h" #include "p2p/base/no_op_dtls_transport.h" #include "p2p/base/port.h" diff --git a/pc/jsep_transport_controller.h b/pc/jsep_transport_controller.h index de75db9432..bad1315892 100644 --- a/pc/jsep_transport_controller.h +++ b/pc/jsep_transport_controller.h @@ -19,10 +19,10 @@ #include "api/candidate.h" #include "api/crypto/crypto_options.h" -#include "api/media_transport_config.h" -#include "api/media_transport_interface.h" #include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log.h" +#include "api/transport/media/media_transport_config.h" +#include "api/transport/media/media_transport_interface.h" #include "media/sctp/sctp_transport_internal.h" #include "p2p/base/dtls_transport.h" #include "p2p/base/p2p_transport_channel.h" diff --git a/pc/jsep_transport_controller_unittest.cc b/pc/jsep_transport_controller_unittest.cc index 887f12b7fd..35ebb87cb4 100644 --- a/pc/jsep_transport_controller_unittest.cc +++ b/pc/jsep_transport_controller_unittest.cc @@ -14,9 +14,9 @@ #include #include "absl/memory/memory.h" -#include "api/media_transport_interface.h" #include "api/test/fake_media_transport.h" #include "api/test/loopback_media_transport.h" +#include "api/transport/media/media_transport_interface.h" #include "p2p/base/fake_dtls_transport.h" #include "p2p/base/fake_ice_transport.h" #include "p2p/base/no_op_dtls_transport.h" diff --git a/pc/peer_connection.h b/pc/peer_connection.h index b6da82a898..3da8658b59 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -18,9 +18,9 @@ #include #include -#include "api/data_channel_transport_interface.h" -#include "api/media_transport_interface.h" #include "api/peer_connection_interface.h" +#include "api/transport/data_channel_transport_interface.h" +#include "api/transport/media/media_transport_interface.h" #include "api/turn_customizer.h" #include "pc/ice_server_parsing.h" #include "pc/jsep_transport_controller.h" diff --git a/pc/peer_connection_data_channel_unittest.cc b/pc/peer_connection_data_channel_unittest.cc index 787e5ba64d..609a718063 100644 --- a/pc/peer_connection_data_channel_unittest.cc +++ b/pc/peer_connection_data_channel_unittest.cc @@ -17,13 +17,13 @@ #include "absl/types/optional.h" #include "api/call/call_factory_interface.h" #include "api/jsep.h" -#include "api/media_transport_interface.h" #include "api/media_types.h" #include "api/peer_connection_interface.h" #include "api/peer_connection_proxy.h" #include "api/scoped_refptr.h" #include "api/task_queue/default_task_queue_factory.h" #include "api/test/fake_media_transport.h" +#include "api/transport/media/media_transport_interface.h" #include "media/base/codec.h" #include "media/base/fake_media_engine.h" #include "media/base/media_constants.h" diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc index 1052b3b9eb..16fb928eae 100644 --- a/pc/peer_connection_factory.cc +++ b/pc/peer_connection_factory.cc @@ -18,11 +18,11 @@ #include "api/fec_controller.h" #include "api/media_stream_proxy.h" #include "api/media_stream_track_proxy.h" -#include "api/media_transport_interface.h" #include "api/network_state_predictor.h" #include "api/peer_connection_factory_proxy.h" #include "api/peer_connection_proxy.h" #include "api/rtc_event_log/rtc_event_log.h" +#include "api/transport/media/media_transport_interface.h" #include "api/turn_customizer.h" #include "api/units/data_rate.h" #include "api/video_track_source_proxy.h" diff --git a/pc/peer_connection_factory.h b/pc/peer_connection_factory.h index 9160730149..648a3af145 100644 --- a/pc/peer_connection_factory.h +++ b/pc/peer_connection_factory.h @@ -16,9 +16,9 @@ #include #include "api/media_stream_interface.h" -#include "api/media_transport_interface.h" #include "api/peer_connection_interface.h" #include "api/scoped_refptr.h" +#include "api/transport/media/media_transport_interface.h" #include "media/sctp/sctp_transport_internal.h" #include "pc/channel_manager.h" #include "rtc_base/rtc_certificate_generator.h" diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 11582296d6..125c6cb9cc 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -929,6 +929,7 @@ if (is_ios || is_mac) { "../api/audio_codecs:builtin_audio_encoder_factory", "../api/rtc_event_log:rtc_event_log_factory", "../api/task_queue:default_task_queue_factory", + "../api/transport/media:media_transport_interface", "../api/video:video_frame", "../api/video:video_rtp_headers", "../api/video_codecs:video_codecs_api", @@ -1203,6 +1204,7 @@ if (is_ios || is_mac) { "../api/audio_codecs:audio_codecs_api", "../api/audio_codecs:builtin_audio_decoder_factory", "../api/audio_codecs:builtin_audio_encoder_factory", + "../api/transport/media:media_transport_interface", "../api/video_codecs:video_codecs_api", "../media:rtc_media_base", "../modules:module_api", diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection.mm b/sdk/objc/api/peerconnection/RTCPeerConnection.mm index f3e91c4dbc..097eeb4e41 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnection.mm @@ -28,8 +28,8 @@ #include #include "api/jsep_ice_candidate.h" -#include "api/media_transport_interface.h" #include "api/rtc_event_log_output_file.h" +#include "api/transport/media/media_transport_interface.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm index bb695b57c0..d63c08e1e5 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm @@ -52,7 +52,7 @@ // TODO(zhihuang): Remove nogncheck once MediaEngineInterface is moved to C++ // API layer. #include "absl/memory/memory.h" -#include "api/media_transport_interface.h" +#include "api/transport/media/media_transport_interface.h" #include "media/engine/webrtc_media_engine.h" // nogncheck @implementation RTCPeerConnectionFactory { diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm index 0adaa30e4f..af3d259e68 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm @@ -13,7 +13,7 @@ #include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/audio_encoder_factory.h" -#include "api/media_transport_interface.h" +#include "api/transport/media/media_transport_interface.h" #include "api/video_codecs/video_decoder_factory.h" #include "api/video_codecs/video_encoder_factory.h" #include "modules/audio_device/include/audio_device.h" diff --git a/sdk/objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm b/sdk/objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm index 5f889a699d..40b3aa0399 100644 --- a/sdk/objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm +++ b/sdk/objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm @@ -22,7 +22,7 @@ extern "C" { #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" -#include "api/media_transport_interface.h" +#include "api/transport/media/media_transport_interface.h" #include "api/video_codecs/video_decoder_factory.h" #include "api/video_codecs/video_encoder_factory.h" #include "modules/audio_device/include/audio_device.h" diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn index a718589c4d..497fbe274a 100644 --- a/test/pc/e2e/BUILD.gn +++ b/test/pc/e2e/BUILD.gn @@ -57,6 +57,7 @@ rtc_source_set("peer_connection_quality_test_params") { "../../../api/rtc_event_log", "../../../api/task_queue", "../../../api/transport:network_control", + "../../../api/transport/media:media_transport_interface", "../../../api/video_codecs:video_codecs_api", "../../../rtc_base", "//third_party/abseil-cpp/absl/memory", diff --git a/test/pc/e2e/peer_connection_quality_test_params.h b/test/pc/e2e/peer_connection_quality_test_params.h index ea011f8d22..cb6add8731 100644 --- a/test/pc/e2e/peer_connection_quality_test_params.h +++ b/test/pc/e2e/peer_connection_quality_test_params.h @@ -18,10 +18,10 @@ #include "api/async_resolver_factory.h" #include "api/call/call_factory_interface.h" #include "api/fec_controller.h" -#include "api/media_transport_interface.h" #include "api/rtc_event_log/rtc_event_log_factory_interface.h" #include "api/task_queue/task_queue_factory.h" #include "api/test/peerconnection_quality_test_fixture.h" +#include "api/transport/media/media_transport_interface.h" #include "api/transport/network_control.h" #include "api/video_codecs/video_decoder_factory.h" #include "api/video_codecs/video_encoder_factory.h" diff --git a/video/BUILD.gn b/video/BUILD.gn index 8edb069dc5..af34436158 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -60,6 +60,7 @@ rtc_static_library("video") { "../api:transport_api", "../api/rtc_event_log", "../api/task_queue", + "../api/transport/media:media_transport_interface", "../api/video:encoded_image", "../api/video:video_bitrate_allocation", "../api/video:video_bitrate_allocator", @@ -266,6 +267,7 @@ if (rtc_include_tests) { "../api/rtc_event_log:rtc_event_log_factory", "../api/task_queue", "../api/task_queue:default_task_queue_factory", + "../api/transport/media:media_transport_interface", "../api/video:builtin_video_bitrate_allocator_factory", "../api/video:video_bitrate_allocator_factory", "../api/video:video_frame", diff --git a/video/encoder_rtcp_feedback.h b/video/encoder_rtcp_feedback.h index 8f10442aa1..21624dbdaa 100644 --- a/video/encoder_rtcp_feedback.h +++ b/video/encoder_rtcp_feedback.h @@ -12,7 +12,7 @@ #include -#include "api/media_transport_interface.h" +#include "api/transport/media/media_transport_interface.h" #include "api/video/video_stream_encoder_interface.h" #include "call/rtp_video_sender_interface.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc index 663452a53a..15112542fe 100644 --- a/video/video_quality_test.cc +++ b/video/video_quality_test.cc @@ -19,9 +19,9 @@ #include "absl/memory/memory.h" #include "api/fec_controller_override.h" -#include "api/media_transport_config.h" #include "api/rtc_event_log_output_file.h" #include "api/task_queue/default_task_queue_factory.h" +#include "api/transport/media/media_transport_config.h" #include "api/video/builtin_video_bitrate_allocator_factory.h" #include "api/video_codecs/video_encoder.h" #include "call/fake_network_pipe.h" diff --git a/video/video_receive_stream.h b/video/video_receive_stream.h index 87a40e91f5..0d0c66a410 100644 --- a/video/video_receive_stream.h +++ b/video/video_receive_stream.h @@ -14,8 +14,8 @@ #include #include -#include "api/media_transport_interface.h" #include "api/task_queue/task_queue_factory.h" +#include "api/transport/media/media_transport_interface.h" #include "call/rtp_packet_sink_interface.h" #include "call/syncable.h" #include "call/video_receive_stream.h"