blob: 8d6a9fe7454800e73339417b7ed8f24fbe9cff89 [file] [log] [blame]
Amit Hilbuchdd9390c2018-11-14 00:26:051/*
2 * Copyright 2018 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Steve Anton10542f22019-01-11 17:11:0011#ifndef PC_CHANNEL_INTERFACE_H_
12#define PC_CHANNEL_INTERFACE_H_
Amit Hilbuchdd9390c2018-11-14 00:26:0513
Harald Alvestrand3af79d12022-04-29 15:04:5814#include <memory>
Amit Hilbuchdd9390c2018-11-14 00:26:0515#include <string>
Amit Hilbuchbcd39d42019-01-26 01:13:5616#include <vector>
Amit Hilbuchdd9390c2018-11-14 00:26:0517
Tomas Gunnarsson94f01942022-01-03 14:59:1218#include "absl/strings/string_view.h"
Amit Hilbuchdd9390c2018-11-14 00:26:0519#include "api/jsep.h"
Steve Anton10542f22019-01-11 17:11:0020#include "api/media_types.h"
21#include "media/base/media_channel.h"
22#include "pc/rtp_transport_internal.h"
Amit Hilbuchdd9390c2018-11-14 00:26:0523
Tomas Gunnarsson5411b172022-01-24 07:45:2624namespace webrtc {
25class Call;
26class VideoBitrateAllocatorFactory;
27} // namespace webrtc
28
Amit Hilbuchdd9390c2018-11-14 00:26:0529namespace cricket {
30
Harald Alvestrand1251c642023-01-04 12:42:5631class VoiceChannel;
32class VideoChannel;
Amit Hilbuchdd9390c2018-11-14 00:26:0533class MediaContentDescription;
Tomas Gunnarsson5411b172022-01-24 07:45:2634struct MediaConfig;
Amit Hilbuchdd9390c2018-11-14 00:26:0535
Harald Alvestrandd5f414c2022-01-24 09:11:2336// A Channel is a construct that groups media streams of the same type
37// (audio or video), both outgoing and incoming.
38// When the PeerConnection API is used, a Channel corresponds one to one
39// to an RtpTransceiver.
40// When Unified Plan is used, there can only be at most one outgoing and
41// one incoming stream. With Plan B, there can be more than one.
42
43// ChannelInterface contains methods common to voice and video channels.
Amit Hilbuchdd9390c2018-11-14 00:26:0544// As more methods are added to BaseChannel, they should be included in the
45// interface as well.
Harald Alvestrand3af79d12022-04-29 15:04:5846// TODO(bugs.webrtc.org/13931): Merge this class into RtpTransceiver.
Amit Hilbuchdd9390c2018-11-14 00:26:0547class ChannelInterface {
48 public:
Harald Alvestrand3af79d12022-04-29 15:04:5849 virtual ~ChannelInterface() = default;
Amit Hilbuchdd9390c2018-11-14 00:26:0550 virtual cricket::MediaType media_type() const = 0;
51
Harald Alvestrand1251c642023-01-04 12:42:5652 virtual VideoChannel* AsVideoChannel() = 0;
53 virtual VoiceChannel* AsVoiceChannel() = 0;
54
Harald Alvestrand50454ef2022-12-15 16:49:1355 virtual MediaSendChannelInterface* media_send_channel() = 0;
Harald Alvestrand25adc8e2022-05-03 13:44:3456 // Typecasts of media_channel(). Will cause an exception if the
57 // channel is of the wrong type.
Harald Alvestrand50454ef2022-12-15 16:49:1358 virtual VideoMediaSendChannelInterface* video_media_send_channel() = 0;
59 virtual VoiceMediaSendChannelInterface* voice_media_send_channel() = 0;
60 virtual MediaReceiveChannelInterface* media_receive_channel() = 0;
Harald Alvestrand36fafc82022-12-08 08:47:4261 // Typecasts of media_channel(). Will cause an exception if the
62 // channel is of the wrong type.
Harald Alvestrand50454ef2022-12-15 16:49:1363 virtual VideoMediaReceiveChannelInterface* video_media_receive_channel() = 0;
64 virtual VoiceMediaReceiveChannelInterface* voice_media_receive_channel() = 0;
Amit Hilbuchdd9390c2018-11-14 00:26:0565
Tomas Gunnarsson94f01942022-01-03 14:59:1266 // Returns a string view for the transport name. Fetching the transport name
67 // must be done on the network thread only and note that the lifetime of
68 // the returned object should be assumed to only be the calling scope.
Amit Hilbuchdd9390c2018-11-14 00:26:0569 // TODO(deadbeef): This is redundant; remove this.
Tomas Gunnarsson94f01942022-01-03 14:59:1270 virtual absl::string_view transport_name() const = 0;
Amit Hilbuchdd9390c2018-11-14 00:26:0571
Tomas Gunnarsson5411b172022-01-24 07:45:2672 // TODO(tommi): Change return type to string_view.
73 virtual const std::string& mid() const = 0;
Amit Hilbuchdd9390c2018-11-14 00:26:0574
Amit Hilbuchdd9390c2018-11-14 00:26:0575 // Enables or disables this channel
Tommi1959f8f2021-04-26 08:20:1976 virtual void Enable(bool enable) = 0;
Amit Hilbuchdd9390c2018-11-14 00:26:0577
78 // Used for latency measurements.
Tommi99c8a802021-04-27 13:00:0079 virtual void SetFirstPacketReceivedCallback(
80 std::function<void()> callback) = 0;
Amit Hilbuchdd9390c2018-11-14 00:26:0581
82 // Channel control
83 virtual bool SetLocalContent(const MediaContentDescription* content,
84 webrtc::SdpType type,
Tomas Gunnarssond908d742022-01-05 10:44:2685 std::string& error_desc) = 0;
Amit Hilbuchdd9390c2018-11-14 00:26:0586 virtual bool SetRemoteContent(const MediaContentDescription* content,
87 webrtc::SdpType type,
Tomas Gunnarssond908d742022-01-05 10:44:2688 std::string& error_desc) = 0;
Taylor Brandstetterd0acbd82021-01-25 21:44:5589 virtual bool SetPayloadTypeDemuxingEnabled(bool enabled) = 0;
Amit Hilbuchdd9390c2018-11-14 00:26:0590
Amit Hilbuchbcd39d42019-01-26 01:13:5691 // Access to the local and remote streams that were set on the channel.
92 virtual const std::vector<StreamParams>& local_streams() const = 0;
93 virtual const std::vector<StreamParams>& remote_streams() const = 0;
94
Amit Hilbuchdd9390c2018-11-14 00:26:0595 // Set an RTP level transport.
96 // Some examples:
97 // * An RtpTransport without encryption.
98 // * An SrtpTransport for SDES.
99 // * A DtlsSrtpTransport for DTLS-SRTP.
100 virtual bool SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport) = 0;
Amit Hilbuchdd9390c2018-11-14 00:26:05101};
102
103} // namespace cricket
104
Steve Anton10542f22019-01-11 17:11:00105#endif // PC_CHANNEL_INTERFACE_H_