| 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 |
| 11 | #ifndef PC_CHANNEL_INTERFACE_H_ |
| 12 | #define PC_CHANNEL_INTERFACE_H_ |
| 13 |
| 14 | #include <memory> |
| 15 | #include <string> |
| 16 | #include <vector> |
| 17 |
| 18 | #include "absl/strings/string_view.h" |
| 19 | #include "api/jsep.h" |
| 20 | #include "api/media_types.h" |
| 21 | #include "media/base/media_channel.h" |
| 22 | #include "pc/rtp_transport_internal.h" |
| 23 |
| 24 | namespace webrtc { |
| 25 | class Call; |
| 26 | class VideoBitrateAllocatorFactory; |
| 27 | } // namespace webrtc |
| 28 |
| 29 | namespace cricket { |
| 30 |
| 31 | class VoiceChannel; |
| 32 | class VideoChannel; |
| 33 | class MediaContentDescription; |
| 34 | struct MediaConfig; |
| 35 |
| 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. |
| 44 | // As more methods are added to BaseChannel, they should be included in the |
| 45 | // interface as well. |
| 46 | // TODO(bugs.webrtc.org/13931): Merge this class into RtpTransceiver. |
| 47 | class ChannelInterface { |
| 48 | public: |
| 49 | virtual ~ChannelInterface() = default; |
| 50 | virtual cricket::MediaType media_type() const = 0; |
| 51 |
| 52 | virtual VideoChannel* AsVideoChannel() = 0; |
| 53 | virtual VoiceChannel* AsVoiceChannel() = 0; |
| 54 |
| 55 | virtual MediaSendChannelInterface* media_send_channel() = 0; |
| 56 | // Typecasts of media_channel(). Will cause an exception if the |
| 57 | // channel is of the wrong type. |
| 58 | virtual VideoMediaSendChannelInterface* video_media_send_channel() = 0; |
| 59 | virtual VoiceMediaSendChannelInterface* voice_media_send_channel() = 0; |
| 60 | virtual MediaReceiveChannelInterface* media_receive_channel() = 0; |
| 61 | // Typecasts of media_channel(). Will cause an exception if the |
| 62 | // channel is of the wrong type. |
| 63 | virtual VideoMediaReceiveChannelInterface* video_media_receive_channel() = 0; |
| 64 | virtual VoiceMediaReceiveChannelInterface* voice_media_receive_channel() = 0; |
| 65 |
| 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. |
| 69 | // TODO(deadbeef): This is redundant; remove this. |
| 70 | virtual absl::string_view transport_name() const = 0; |
| 71 |
| 72 | // TODO(tommi): Change return type to string_view. |
| 73 | virtual const std::string& mid() const = 0; |
| 74 |
| 75 | // Enables or disables this channel |
| 76 | virtual void Enable(bool enable) = 0; |
| 77 |
| 78 | // Used for latency measurements. |
| 79 | virtual void SetFirstPacketReceivedCallback( |
| 80 | std::function<void()> callback) = 0; |
| 81 |
| 82 | // Channel control |
| 83 | virtual bool SetLocalContent(const MediaContentDescription* content, |
| 84 | webrtc::SdpType type, |
| 85 | std::string& error_desc) = 0; |
| 86 | virtual bool SetRemoteContent(const MediaContentDescription* content, |
| 87 | webrtc::SdpType type, |
| 88 | std::string& error_desc) = 0; |
| 89 | virtual bool SetPayloadTypeDemuxingEnabled(bool enabled) = 0; |
| 90 |
| 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 |
| 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; |
| 101 | }; |
| 102 |
| 103 | } // namespace cricket |
| 104 |
| 105 | #endif // PC_CHANNEL_INTERFACE_H_ |
| 106 |