Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [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 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef PC_CHANNEL_INTERFACE_H_ |
| 12 | #define PC_CHANNEL_INTERFACE_H_ |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 13 | |
| 14 | #include <string> |
Amit Hilbuch | bcd39d4 | 2019-01-25 17:13:56 -0800 | [diff] [blame] | 15 | #include <vector> |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 16 | |
Tomas Gunnarsson | 94f0194 | 2022-01-03 14:59:12 +0000 | [diff] [blame^] | 17 | #include "absl/strings/string_view.h" |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 18 | #include "api/jsep.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 19 | #include "api/media_types.h" |
| 20 | #include "media/base/media_channel.h" |
| 21 | #include "pc/rtp_transport_internal.h" |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 22 | |
| 23 | namespace cricket { |
| 24 | |
| 25 | class MediaContentDescription; |
| 26 | |
| 27 | // ChannelInterface contains methods common to voice, video and data channels. |
| 28 | // As more methods are added to BaseChannel, they should be included in the |
| 29 | // interface as well. |
| 30 | class ChannelInterface { |
| 31 | public: |
| 32 | virtual cricket::MediaType media_type() const = 0; |
| 33 | |
| 34 | virtual MediaChannel* media_channel() const = 0; |
| 35 | |
Tomas Gunnarsson | 94f0194 | 2022-01-03 14:59:12 +0000 | [diff] [blame^] | 36 | // Returns a string view for the transport name. Fetching the transport name |
| 37 | // must be done on the network thread only and note that the lifetime of |
| 38 | // the returned object should be assumed to only be the calling scope. |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 39 | // TODO(deadbeef): This is redundant; remove this. |
Tomas Gunnarsson | 94f0194 | 2022-01-03 14:59:12 +0000 | [diff] [blame^] | 40 | virtual absl::string_view transport_name() const = 0; |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 41 | |
| 42 | virtual const std::string& content_name() const = 0; |
| 43 | |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 44 | // Enables or disables this channel |
Tommi | 1959f8f | 2021-04-26 10:20:19 +0200 | [diff] [blame] | 45 | virtual void Enable(bool enable) = 0; |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 46 | |
| 47 | // Used for latency measurements. |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 48 | virtual void SetFirstPacketReceivedCallback( |
| 49 | std::function<void()> callback) = 0; |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 50 | |
| 51 | // Channel control |
| 52 | virtual bool SetLocalContent(const MediaContentDescription* content, |
| 53 | webrtc::SdpType type, |
| 54 | std::string* error_desc) = 0; |
| 55 | virtual bool SetRemoteContent(const MediaContentDescription* content, |
| 56 | webrtc::SdpType type, |
| 57 | std::string* error_desc) = 0; |
Taylor Brandstetter | d0acbd8 | 2021-01-25 13:44:55 -0800 | [diff] [blame] | 58 | virtual bool SetPayloadTypeDemuxingEnabled(bool enabled) = 0; |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 59 | |
Amit Hilbuch | bcd39d4 | 2019-01-25 17:13:56 -0800 | [diff] [blame] | 60 | // Access to the local and remote streams that were set on the channel. |
| 61 | virtual const std::vector<StreamParams>& local_streams() const = 0; |
| 62 | virtual const std::vector<StreamParams>& remote_streams() const = 0; |
| 63 | |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 64 | // Set an RTP level transport. |
| 65 | // Some examples: |
| 66 | // * An RtpTransport without encryption. |
| 67 | // * An SrtpTransport for SDES. |
| 68 | // * A DtlsSrtpTransport for DTLS-SRTP. |
| 69 | virtual bool SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport) = 0; |
| 70 | |
| 71 | protected: |
| 72 | virtual ~ChannelInterface() = default; |
| 73 | }; |
| 74 | |
| 75 | } // namespace cricket |
| 76 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 77 | #endif // PC_CHANNEL_INTERFACE_H_ |