blob: ee1b8e3a0fd9b550dc2eb671e73bda89b47f3656 [file] [log] [blame]
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -07001/* Copyright 2018 The WebRTC project authors. All Rights Reserved.
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -04002 *
3 * Use of this source code is governed by a BSD-style license
4 * that can be found in the LICENSE file in the root of the source
5 * tree. An additional intellectual property rights grant can be found
6 * in the file PATENTS. All contributing project authors may
7 * be found in the AUTHORS file in the root of the source tree.
8 */
9
10// This is EXPERIMENTAL interface for media transport.
11//
12// The goal is to refactor WebRTC code so that audio and video frames
13// are sent / received through the media transport interface. This will
14// enable different media transport implementations, including QUIC-based
15// media transport.
16
17#ifndef API_MEDIA_TRANSPORT_INTERFACE_H_
18#define API_MEDIA_TRANSPORT_INTERFACE_H_
19
Piotr (Peter) Slatala6b9d8232018-10-26 07:59:46 -070020#include <api/transport/network_control.h>
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -040021#include <memory>
Piotr (Peter) Slatalaa0677d12018-10-29 07:31:42 -070022#include <string>
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -040023#include <utility>
24#include <vector>
25
Piotr (Peter) Slatalaa0677d12018-10-29 07:31:42 -070026#include "absl/types/optional.h"
Yves Gerey988cc082018-10-23 12:03:01 +020027#include "api/array_view.h"
Steve Anton10542f22019-01-11 09:11:00 -080028#include "api/rtc_error.h"
Niels Möller3a742392018-10-08 11:13:58 +020029#include "api/video/encoded_image.h"
Steve Anton10542f22019-01-11 09:11:00 -080030#include "rtc_base/copy_on_write_buffer.h"
Niels Möllerd8a1b7a2018-12-06 13:00:27 +010031#include "rtc_base/deprecation.h"
Steve Anton10542f22019-01-11 09:11:00 -080032#include "rtc_base/network_route.h"
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -040033
34namespace rtc {
35class PacketTransportInternal;
36class Thread;
37} // namespace rtc
38
39namespace webrtc {
40
Piotr (Peter) Slatala0c022502018-12-28 10:39:39 -080041class RtcEventLog;
42
Piotr (Peter) Slatalaa0677d12018-10-29 07:31:42 -070043// A collection of settings for creation of media transport.
44struct MediaTransportSettings final {
45 MediaTransportSettings();
Piotr (Peter) Slatalaed7b8b12018-10-29 10:43:16 -070046 MediaTransportSettings(const MediaTransportSettings&);
47 MediaTransportSettings& operator=(const MediaTransportSettings&);
Piotr (Peter) Slatalaa0677d12018-10-29 07:31:42 -070048 ~MediaTransportSettings();
49
50 // Group calls are not currently supported, in 1:1 call one side must set
51 // is_caller = true and another is_caller = false.
52 bool is_caller;
53
54 // Must be set if a pre-shared key is used for the call.
Piotr (Peter) Slatala9f956252018-10-31 08:25:26 -070055 // TODO(bugs.webrtc.org/9944): This should become zero buffer in the distant
56 // future.
Piotr (Peter) Slatalaa0677d12018-10-29 07:31:42 -070057 absl::optional<std::string> pre_shared_key;
Piotr (Peter) Slatala0c022502018-12-28 10:39:39 -080058
59 // If present, provides the event log that media transport should use.
60 // Media transport does not own it. The lifetime of |event_log| will exceed
61 // the lifetime of the instance of MediaTransportInterface instance.
62 RtcEventLog* event_log = nullptr;
Piotr (Peter) Slatalaa0677d12018-10-29 07:31:42 -070063};
64
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -040065// Represents encoded audio frame in any encoding (type of encoding is opaque).
66// To avoid copying of encoded data use move semantics when passing by value.
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -070067class MediaTransportEncodedAudioFrame final {
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -040068 public:
69 enum class FrameType {
70 // Normal audio frame (equivalent to webrtc::kAudioFrameSpeech).
71 kSpeech,
72
73 // DTX frame (equivalent to webrtc::kAudioFrameCN).
Niels Möller7d76a312018-10-26 12:57:07 +020074 // DTX frame (equivalent to webrtc::kAudioFrameCN).
75 kDiscontinuousTransmission,
76 // TODO(nisse): Mis-spelled version, update users, then delete.
77 kDiscountinuousTransmission = kDiscontinuousTransmission,
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -040078 };
79
80 MediaTransportEncodedAudioFrame(
81 // Audio sampling rate, for example 48000.
82 int sampling_rate_hz,
83
84 // Starting sample index of the frame, i.e. how many audio samples were
85 // before this frame since the beginning of the call or beginning of time
86 // in one channel (the starting point should not matter for NetEq). In
87 // WebRTC it is used as a timestamp of the frame.
88 // TODO(sukhanov): Starting_sample_index is currently adjusted on the
89 // receiver side in RTP path. Non-RTP implementations should preserve it.
90 // For NetEq initial offset should not matter so we should consider fixing
91 // RTP path.
92 int starting_sample_index,
93
94 // Number of audio samples in audio frame in 1 channel.
95 int samples_per_channel,
96
97 // Sequence number of the frame in the order sent, it is currently
98 // required by NetEq, but we can fix NetEq, because starting_sample_index
99 // should be enough.
100 int sequence_number,
101
102 // If audio frame is a speech or discontinued transmission.
103 FrameType frame_type,
104
105 // Opaque payload type. In RTP codepath payload type is stored in RTP
106 // header. In other implementations it should be simply passed through the
107 // wire -- it's needed for decoder.
Niels Möllerd8a1b7a2018-12-06 13:00:27 +0100108 int payload_type,
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400109
110 // Vector with opaque encoded data.
Niels Möller3a742392018-10-08 11:13:58 +0200111 std::vector<uint8_t> encoded_data);
112
113 ~MediaTransportEncodedAudioFrame();
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -0700114 MediaTransportEncodedAudioFrame(const MediaTransportEncodedAudioFrame&);
115 MediaTransportEncodedAudioFrame& operator=(
116 const MediaTransportEncodedAudioFrame& other);
117 MediaTransportEncodedAudioFrame& operator=(
118 MediaTransportEncodedAudioFrame&& other);
119 MediaTransportEncodedAudioFrame(MediaTransportEncodedAudioFrame&&);
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400120
121 // Getters.
122 int sampling_rate_hz() const { return sampling_rate_hz_; }
123 int starting_sample_index() const { return starting_sample_index_; }
124 int samples_per_channel() const { return samples_per_channel_; }
125 int sequence_number() const { return sequence_number_; }
126
Niels Möllerd8a1b7a2018-12-06 13:00:27 +0100127 int payload_type() const { return payload_type_; }
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400128 FrameType frame_type() const { return frame_type_; }
129
130 rtc::ArrayView<const uint8_t> encoded_data() const { return encoded_data_; }
131
132 private:
133 int sampling_rate_hz_;
134 int starting_sample_index_;
135 int samples_per_channel_;
136
137 // TODO(sukhanov): Refactor NetEq so we don't need sequence number.
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700138 // Having sample_index and samples_per_channel should be enough.
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400139 int sequence_number_;
140
141 FrameType frame_type_;
142
Niels Möllerd8a1b7a2018-12-06 13:00:27 +0100143 int payload_type_;
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400144
145 std::vector<uint8_t> encoded_data_;
146};
147
Piotr (Peter) Slatalaada077f2018-11-08 07:43:31 -0800148// Callback to notify about network route changes.
149class MediaTransportNetworkChangeCallback {
150 public:
151 virtual ~MediaTransportNetworkChangeCallback() = default;
152
153 // Called when the network route is changed, with the new network route.
154 virtual void OnNetworkRouteChanged(
155 const rtc::NetworkRoute& new_network_route) = 0;
156};
157
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400158// Interface for receiving encoded audio frames from MediaTransportInterface
159// implementations.
160class MediaTransportAudioSinkInterface {
161 public:
162 virtual ~MediaTransportAudioSinkInterface() = default;
163
164 // Called when new encoded audio frame is received.
165 virtual void OnData(uint64_t channel_id,
166 MediaTransportEncodedAudioFrame frame) = 0;
167};
168
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700169// Represents encoded video frame, along with the codec information.
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -0700170class MediaTransportEncodedVideoFrame final {
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700171 public:
Niels Möllerd8a1b7a2018-12-06 13:00:27 +0100172 // TODO(bugs.webrtc.org/9719): Switch to payload_type
173 RTC_DEPRECATED MediaTransportEncodedVideoFrame(
174 int64_t frame_id,
175 std::vector<int64_t> referenced_frame_ids,
176 VideoCodecType codec_type,
177 const webrtc::EncodedImage& encoded_image);
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700178 MediaTransportEncodedVideoFrame(int64_t frame_id,
179 std::vector<int64_t> referenced_frame_ids,
Niels Möllerd8a1b7a2018-12-06 13:00:27 +0100180 int payload_type,
Niels Möller3a742392018-10-08 11:13:58 +0200181 const webrtc::EncodedImage& encoded_image);
182 ~MediaTransportEncodedVideoFrame();
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -0700183 MediaTransportEncodedVideoFrame(const MediaTransportEncodedVideoFrame&);
184 MediaTransportEncodedVideoFrame& operator=(
185 const MediaTransportEncodedVideoFrame& other);
186 MediaTransportEncodedVideoFrame& operator=(
187 MediaTransportEncodedVideoFrame&& other);
188 MediaTransportEncodedVideoFrame(MediaTransportEncodedVideoFrame&&);
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700189
Niels Möllerd8a1b7a2018-12-06 13:00:27 +0100190 // TODO(bugs.webrtc.org/9719): Switch to payload_type
191 RTC_DEPRECATED VideoCodecType codec_type() const { return codec_type_; }
192 int payload_type() const { return payload_type_; }
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700193 const webrtc::EncodedImage& encoded_image() const { return encoded_image_; }
194
195 int64_t frame_id() const { return frame_id_; }
196 const std::vector<int64_t>& referenced_frame_ids() const {
197 return referenced_frame_ids_;
198 }
199
Niels Möllerd5696fb2018-11-28 15:34:37 +0100200 // Hack to workaround lack of ownership of the encoded_image_._buffer. If we
201 // don't already own the underlying data, make a copy.
202 void Retain();
203
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700204 private:
Niels Möllerd5696fb2018-11-28 15:34:37 +0100205 MediaTransportEncodedVideoFrame();
206
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700207 VideoCodecType codec_type_;
Niels Möllerd8a1b7a2018-12-06 13:00:27 +0100208 int payload_type_;
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700209
Niels Möllerd5696fb2018-11-28 15:34:37 +0100210 // The buffer is not owned by the encoded image. On the sender it means that
211 // it will need to make a copy using the Retain() method, if it wants to
212 // deliver it asynchronously.
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700213 webrtc::EncodedImage encoded_image_;
214
Niels Möllerd5696fb2018-11-28 15:34:37 +0100215 // If non-empty, this is the data for the encoded image.
216 std::vector<uint8_t> encoded_data_;
217
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700218 // Frame id uniquely identifies a frame in a stream. It needs to be unique in
219 // a given time window (i.e. technically unique identifier for the lifetime of
220 // the connection is not needed, but you need to guarantee that remote side
221 // got rid of the previous frame_id if you plan to reuse it).
222 //
223 // It is required by a remote jitter buffer, and is the same as
224 // EncodedFrame::id::picture_id.
225 //
226 // This data must be opaque to the media transport, and media transport should
227 // itself not make any assumptions about what it is and its uniqueness.
228 int64_t frame_id_;
229
230 // A single frame might depend on other frames. This is set of identifiers on
231 // which the current frame depends.
232 std::vector<int64_t> referenced_frame_ids_;
233};
234
235// Interface for receiving encoded video frames from MediaTransportInterface
236// implementations.
237class MediaTransportVideoSinkInterface {
238 public:
239 virtual ~MediaTransportVideoSinkInterface() = default;
240
241 // Called when new encoded video frame is received.
242 virtual void OnData(uint64_t channel_id,
243 MediaTransportEncodedVideoFrame frame) = 0;
244
Niels Möllerd8a1b7a2018-12-06 13:00:27 +0100245 // TODO(bugs.webrtc.org/9719): Belongs on send side, not receive side.
246 RTC_DEPRECATED virtual void OnKeyFrameRequested(uint64_t channel_id) {}
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700247};
248
Niels Möller1c7f5f62018-12-10 11:06:02 +0100249// Interface for video sender to be notified of received key frame request.
250class MediaTransportKeyFrameRequestCallback {
251 public:
252 virtual ~MediaTransportKeyFrameRequestCallback() = default;
253
254 // Called when a key frame request is received on the transport.
255 virtual void OnKeyFrameRequested(uint64_t channel_id) = 0;
256};
257
Bjorn Mellemc78b0ea2018-10-29 15:21:31 -0700258// State of the media transport. Media transport begins in the pending state.
259// It transitions to writable when it is ready to send media. It may transition
260// back to pending if the connection is blocked. It may transition to closed at
261// any time. Closed is terminal: a transport will never re-open once closed.
262enum class MediaTransportState {
263 kPending,
264 kWritable,
265 kClosed,
266};
267
268// Callback invoked whenever the state of the media transport changes.
269class MediaTransportStateCallback {
270 public:
271 virtual ~MediaTransportStateCallback() = default;
272
273 // Invoked whenever the state of the media transport changes.
274 virtual void OnStateChanged(MediaTransportState state) = 0;
275};
276
Niels Möller46879152019-01-07 15:54:47 +0100277// Callback for RTT measurements on the receive side.
278// TODO(nisse): Related interfaces: CallStatsObserver and RtcpRttStats. It's
279// somewhat unclear what type of measurement is needed. It's used to configure
280// NACK generation and playout buffer. Either raw measurement values or recent
281// maximum would make sense for this use. Need consolidation of RTT signalling.
282class MediaTransportRttObserver {
283 public:
284 virtual ~MediaTransportRttObserver() = default;
285
286 // Invoked when a new RTT measurement is available, typically once per ACK.
287 virtual void OnRttUpdated(int64_t rtt_ms) = 0;
288};
289
Bjorn Mellem1f6aa9f2018-10-30 15:15:00 -0700290// Supported types of application data messages.
291enum class DataMessageType {
292 // Application data buffer with the binary bit unset.
293 kText,
294
295 // Application data buffer with the binary bit set.
296 kBinary,
297
298 // Transport-agnostic control messages, such as open or open-ack messages.
299 kControl,
300};
301
302// Parameters for sending data. The parameters may change from message to
303// message, even within a single channel. For example, control messages may be
304// sent reliably and in-order, even if the data channel is configured for
305// unreliable delivery.
306struct SendDataParams {
307 SendDataParams();
Niels Möllere0446cb2018-11-30 09:35:52 +0100308 SendDataParams(const SendDataParams&);
Bjorn Mellem1f6aa9f2018-10-30 15:15:00 -0700309
310 DataMessageType type = DataMessageType::kText;
311
312 // Whether to deliver the message in order with respect to other ordered
313 // messages with the same channel_id.
314 bool ordered = false;
315
316 // If set, the maximum number of times this message may be
317 // retransmitted by the transport before it is dropped.
318 // Setting this value to zero disables retransmission.
319 // Must be non-negative. |max_rtx_count| and |max_rtx_ms| may not be set
320 // simultaneously.
321 absl::optional<int> max_rtx_count;
322
323 // If set, the maximum number of milliseconds for which the transport
324 // may retransmit this message before it is dropped.
325 // Setting this value to zero disables retransmission.
326 // Must be non-negative. |max_rtx_count| and |max_rtx_ms| may not be set
327 // simultaneously.
328 absl::optional<int> max_rtx_ms;
329};
330
331// Sink for callbacks related to a data channel.
332class DataChannelSink {
333 public:
334 virtual ~DataChannelSink() = default;
335
336 // Callback issued when data is received by the transport.
337 virtual void OnDataReceived(int channel_id,
338 DataMessageType type,
339 const rtc::CopyOnWriteBuffer& buffer) = 0;
340
341 // Callback issued when a remote data channel begins the closing procedure.
342 // Messages sent after the closing procedure begins will not be transmitted.
343 virtual void OnChannelClosing(int channel_id) = 0;
344
345 // Callback issued when a (remote or local) data channel completes the closing
346 // procedure. Closing channels become closed after all pending data has been
347 // transmitted.
348 virtual void OnChannelClosed(int channel_id) = 0;
349};
350
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400351// Media transport interface for sending / receiving encoded audio/video frames
352// and receiving bandwidth estimate update from congestion control.
353class MediaTransportInterface {
354 public:
355 virtual ~MediaTransportInterface() = default;
356
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700357 // Start asynchronous send of audio frame. The status returned by this method
358 // only pertains to the synchronous operations (e.g.
359 // serialization/packetization), not to the asynchronous operation.
360
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400361 virtual RTCError SendAudioFrame(uint64_t channel_id,
362 MediaTransportEncodedAudioFrame frame) = 0;
363
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700364 // Start asynchronous send of video frame. The status returned by this method
365 // only pertains to the synchronous operations (e.g.
366 // serialization/packetization), not to the asynchronous operation.
367 virtual RTCError SendVideoFrame(
368 uint64_t channel_id,
369 const MediaTransportEncodedVideoFrame& frame) = 0;
370
Niels Möller1c7f5f62018-12-10 11:06:02 +0100371 // Used by video sender to be notified on key frame requests.
372 virtual void SetKeyFrameRequestCallback(
373 MediaTransportKeyFrameRequestCallback* callback);
374
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700375 // Requests a keyframe for the particular channel (stream). The caller should
376 // check that the keyframe is not present in a jitter buffer already (i.e.
377 // don't request a keyframe if there is one that you will get from the jitter
378 // buffer in a moment).
379 virtual RTCError RequestKeyFrame(uint64_t channel_id) = 0;
380
381 // Sets audio sink. Sink must be unset by calling SetReceiveAudioSink(nullptr)
382 // before the media transport is destroyed or before new sink is set.
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400383 virtual void SetReceiveAudioSink(MediaTransportAudioSinkInterface* sink) = 0;
384
Piotr (Peter) Slatalae804f922018-09-25 08:40:30 -0700385 // Registers a video sink. Before destruction of media transport, you must
386 // pass a nullptr.
387 virtual void SetReceiveVideoSink(MediaTransportVideoSinkInterface* sink) = 0;
388
Piotr (Peter) Slatalaada077f2018-11-08 07:43:31 -0800389 // Adds a target bitrate observer. Before media transport is destructed
390 // the observer must be unregistered (by calling
391 // RemoveTargetTransferRateObserver).
392 // A newly registered observer will be called back with the latest recorded
393 // target rate, if available.
394 virtual void AddTargetTransferRateObserver(
Niels Möller46879152019-01-07 15:54:47 +0100395 TargetTransferRateObserver* observer);
Piotr (Peter) Slatalaada077f2018-11-08 07:43:31 -0800396
397 // Removes an existing |observer| from observers. If observer was never
398 // registered, an error is logged and method does nothing.
399 virtual void RemoveTargetTransferRateObserver(
Niels Möller46879152019-01-07 15:54:47 +0100400 TargetTransferRateObserver* observer);
401
402 // Intended for receive side. AddRttObserver registers an observer to be
403 // called for each RTT measurement, typically once per ACK. Before media
404 // transport is destructed the observer must be unregistered.
405 virtual void AddRttObserver(MediaTransportRttObserver* observer);
406 virtual void RemoveRttObserver(MediaTransportRttObserver* observer);
Piotr (Peter) Slatalaada077f2018-11-08 07:43:31 -0800407
408 // Returns the last known target transfer rate as reported to the above
409 // observers.
410 virtual absl::optional<TargetTransferRate> GetLatestTargetTransferRate();
411
412 // Gets the audio packet overhead in bytes. Returned overhead does not include
413 // transport overhead (ipv4/6, turn channeldata, tcp/udp, etc.).
414 // If the transport is capable of fusing packets together, this overhead
415 // might not be a very accurate number.
416 virtual size_t GetAudioPacketOverhead() const;
417
418 // Sets an observer for network change events. If the network route is already
419 // established when the callback is set, |callback| will be called immediately
420 // with the current network route.
421 // Before media transport is destroyed, the callback must be unregistered by
422 // setting it to nullptr.
423 virtual void SetNetworkChangeCallback(
424 MediaTransportNetworkChangeCallback* callback);
Piotr (Peter) Slatala6b9d8232018-10-26 07:59:46 -0700425
Bjorn Mellemc78b0ea2018-10-29 15:21:31 -0700426 // Sets a state observer callback. Before media transport is destroyed, the
427 // callback must be unregistered by setting it to nullptr.
428 // A newly registered callback will be called with the current state.
429 // Media transport does not invoke this callback concurrently.
Bjorn Mellemc78b0ea2018-10-29 15:21:31 -0700430 virtual void SetMediaTransportStateCallback(
Bjorn Mellemeb2c6412018-10-31 15:25:32 -0700431 MediaTransportStateCallback* callback) = 0;
Bjorn Mellemc78b0ea2018-10-29 15:21:31 -0700432
Bjorn Mellem1f6aa9f2018-10-30 15:15:00 -0700433 // Sends a data buffer to the remote endpoint using the given send parameters.
434 // |buffer| may not be larger than 256 KiB. Returns an error if the send
435 // fails.
Bjorn Mellem1f6aa9f2018-10-30 15:15:00 -0700436 virtual RTCError SendData(int channel_id,
437 const SendDataParams& params,
Bjorn Mellemeb2c6412018-10-31 15:25:32 -0700438 const rtc::CopyOnWriteBuffer& buffer) = 0;
Bjorn Mellem1f6aa9f2018-10-30 15:15:00 -0700439
440 // Closes |channel_id| gracefully. Returns an error if |channel_id| is not
441 // open. Data sent after the closing procedure begins will not be
442 // transmitted. The channel becomes closed after pending data is transmitted.
Bjorn Mellemeb2c6412018-10-31 15:25:32 -0700443 virtual RTCError CloseChannel(int channel_id) = 0;
Bjorn Mellem1f6aa9f2018-10-30 15:15:00 -0700444
445 // Sets a sink for data messages and channel state callbacks. Before media
446 // transport is destroyed, the sink must be unregistered by setting it to
447 // nullptr.
Bjorn Mellemeb2c6412018-10-31 15:25:32 -0700448 virtual void SetDataSink(DataChannelSink* sink) = 0;
Bjorn Mellem1f6aa9f2018-10-30 15:15:00 -0700449
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400450 // TODO(sukhanov): RtcEventLogs.
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400451};
452
453// If media transport factory is set in peer connection factory, it will be
454// used to create media transport for sending/receiving encoded frames and
455// this transport will be used instead of default RTP/SRTP transport.
456//
457// Currently Media Transport negotiation is not supported in SDP.
458// If application is using media transport, it must negotiate it before
459// setting media transport factory in peer connection.
460class MediaTransportFactory {
461 public:
462 virtual ~MediaTransportFactory() = default;
463
464 // Creates media transport.
465 // - Does not take ownership of packet_transport or network_thread.
466 // - Does not support group calls, in 1:1 call one side must set
467 // is_caller = true and another is_caller = false.
Piotr (Peter) Slatalaa0677d12018-10-29 07:31:42 -0700468 // TODO(bugs.webrtc.org/9938) This constructor will be removed and replaced
469 // with the one below.
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400470 virtual RTCErrorOr<std::unique_ptr<MediaTransportInterface>>
471 CreateMediaTransport(rtc::PacketTransportInternal* packet_transport,
472 rtc::Thread* network_thread,
Piotr (Peter) Slatalaa0677d12018-10-29 07:31:42 -0700473 bool is_caller);
474
475 // Creates media transport.
476 // - Does not take ownership of packet_transport or network_thread.
477 // TODO(bugs.webrtc.org/9938): remove default implementation once all children
478 // override it.
479 virtual RTCErrorOr<std::unique_ptr<MediaTransportInterface>>
480 CreateMediaTransport(rtc::PacketTransportInternal* packet_transport,
481 rtc::Thread* network_thread,
Piotr (Peter) Slatalaed7b8b12018-10-29 10:43:16 -0700482 const MediaTransportSettings& settings);
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400483};
484
485} // namespace webrtc
Anton Sukhanovf60bd4b2018-09-05 13:41:46 -0400486#endif // API_MEDIA_TRANSPORT_INTERFACE_H_