Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 1 | /* |
| 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 Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 11 | #ifndef PC_CHANNEL_INTERFACE_H_ |
| 12 | #define PC_CHANNEL_INTERFACE_H_ |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 13 | |
Harald Alvestrand | 3af79d1 | 2022-04-29 15:04:58 | [diff] [blame] | 14 | #include <memory> |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 15 | #include <string> |
Amit Hilbuch | bcd39d4 | 2019-01-26 01:13:56 | [diff] [blame] | 16 | #include <vector> |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 17 | |
Tomas Gunnarsson | 94f0194 | 2022-01-03 14:59:12 | [diff] [blame] | 18 | #include "absl/strings/string_view.h" |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 19 | #include "api/jsep.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 20 | #include "api/media_types.h" |
| 21 | #include "media/base/media_channel.h" |
| 22 | #include "pc/rtp_transport_internal.h" |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 23 | |
Tomas Gunnarsson | 5411b17 | 2022-01-24 07:45:26 | [diff] [blame] | 24 | namespace webrtc { |
| 25 | class Call; |
| 26 | class VideoBitrateAllocatorFactory; |
| 27 | } // namespace webrtc |
| 28 | |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 29 | namespace cricket { |
| 30 | |
Harald Alvestrand | 1251c64 | 2023-01-04 12:42:56 | [diff] [blame] | 31 | class VoiceChannel; |
| 32 | class VideoChannel; |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 33 | class MediaContentDescription; |
Tomas Gunnarsson | 5411b17 | 2022-01-24 07:45:26 | [diff] [blame] | 34 | struct MediaConfig; |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 35 | |
Harald Alvestrand | d5f414c | 2022-01-24 09:11:23 | [diff] [blame] | 36 | // 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 Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 44 | // As more methods are added to BaseChannel, they should be included in the |
| 45 | // interface as well. |
Harald Alvestrand | 3af79d1 | 2022-04-29 15:04:58 | [diff] [blame] | 46 | // TODO(bugs.webrtc.org/13931): Merge this class into RtpTransceiver. |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 47 | class ChannelInterface { |
| 48 | public: |
Harald Alvestrand | 3af79d1 | 2022-04-29 15:04:58 | [diff] [blame] | 49 | virtual ~ChannelInterface() = default; |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 50 | virtual cricket::MediaType media_type() const = 0; |
| 51 | |
Harald Alvestrand | 1251c64 | 2023-01-04 12:42:56 | [diff] [blame] | 52 | virtual VideoChannel* AsVideoChannel() = 0; |
| 53 | virtual VoiceChannel* AsVoiceChannel() = 0; |
| 54 | |
Harald Alvestrand | 50454ef | 2022-12-15 16:49:13 | [diff] [blame] | 55 | virtual MediaSendChannelInterface* media_send_channel() = 0; |
Harald Alvestrand | 25adc8e | 2022-05-03 13:44:34 | [diff] [blame] | 56 | // Typecasts of media_channel(). Will cause an exception if the |
| 57 | // channel is of the wrong type. |
Harald Alvestrand | 50454ef | 2022-12-15 16:49:13 | [diff] [blame] | 58 | virtual VideoMediaSendChannelInterface* video_media_send_channel() = 0; |
| 59 | virtual VoiceMediaSendChannelInterface* voice_media_send_channel() = 0; |
| 60 | virtual MediaReceiveChannelInterface* media_receive_channel() = 0; |
Harald Alvestrand | 36fafc8 | 2022-12-08 08:47:42 | [diff] [blame] | 61 | // Typecasts of media_channel(). Will cause an exception if the |
| 62 | // channel is of the wrong type. |
Harald Alvestrand | 50454ef | 2022-12-15 16:49:13 | [diff] [blame] | 63 | virtual VideoMediaReceiveChannelInterface* video_media_receive_channel() = 0; |
| 64 | virtual VoiceMediaReceiveChannelInterface* voice_media_receive_channel() = 0; |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 65 | |
Tomas Gunnarsson | 94f0194 | 2022-01-03 14:59:12 | [diff] [blame] | 66 | // 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 Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 69 | // TODO(deadbeef): This is redundant; remove this. |
Tomas Gunnarsson | 94f0194 | 2022-01-03 14:59:12 | [diff] [blame] | 70 | virtual absl::string_view transport_name() const = 0; |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 71 | |
Tomas Gunnarsson | 5411b17 | 2022-01-24 07:45:26 | [diff] [blame] | 72 | // TODO(tommi): Change return type to string_view. |
| 73 | virtual const std::string& mid() const = 0; |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 74 | |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 75 | // Enables or disables this channel |
Tommi | 1959f8f | 2021-04-26 08:20:19 | [diff] [blame] | 76 | virtual void Enable(bool enable) = 0; |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 77 | |
| 78 | // Used for latency measurements. |
Tommi | 99c8a80 | 2021-04-27 13:00:00 | [diff] [blame] | 79 | virtual void SetFirstPacketReceivedCallback( |
| 80 | std::function<void()> callback) = 0; |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 81 | |
| 82 | // Channel control |
| 83 | virtual bool SetLocalContent(const MediaContentDescription* content, |
| 84 | webrtc::SdpType type, |
Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 85 | std::string& error_desc) = 0; |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 86 | virtual bool SetRemoteContent(const MediaContentDescription* content, |
| 87 | webrtc::SdpType type, |
Tomas Gunnarsson | d908d74 | 2022-01-05 10:44:26 | [diff] [blame] | 88 | std::string& error_desc) = 0; |
Taylor Brandstetter | d0acbd8 | 2021-01-25 21:44:55 | [diff] [blame] | 89 | virtual bool SetPayloadTypeDemuxingEnabled(bool enabled) = 0; |
Amit Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 90 | |
Amit Hilbuch | bcd39d4 | 2019-01-26 01:13:56 | [diff] [blame] | 91 | // 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 Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 95 | // 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 Hilbuch | dd9390c | 2018-11-14 00:26:05 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | } // namespace cricket |
| 104 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 105 | #endif // PC_CHANNEL_INTERFACE_H_ |