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 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 MediaContentDescription; 32 struct MediaConfig; 33 34 // A Channel is a construct that groups media streams of the same type 35 // (audio or video), both outgoing and incoming. 36 // When the PeerConnection API is used, a Channel corresponds one to one 37 // to an RtpTransceiver. 38 // When Unified Plan is used, there can only be at most one outgoing and 39 // one incoming stream. With Plan B, there can be more than one. 40 41 // ChannelInterface contains methods common to voice and video channels. 42 // As more methods are added to BaseChannel, they should be included in the 43 // interface as well. 44 // TODO(bugs.webrtc.org/13931): Merge this class into RtpTransceiver. 45 class ChannelInterface { 46 public: 47 virtual ~ChannelInterface() = default; 48 virtual cricket::MediaType media_type() const = 0; 49 50 virtual MediaChannel* media_channel() const = 0; 51 // Typecasts of media_channel(). Will cause an exception if the 52 // channel is of the wrong type. 53 virtual VideoMediaChannel* video_media_channel() const = 0; 54 virtual VoiceMediaChannel* voice_media_channel() const = 0; 55 56 // Returns a string view for the transport name. Fetching the transport name 57 // must be done on the network thread only and note that the lifetime of 58 // the returned object should be assumed to only be the calling scope. 59 // TODO(deadbeef): This is redundant; remove this. 60 virtual absl::string_view transport_name() const = 0; 61 62 // TODO(tommi): Change return type to string_view. 63 virtual const std::string& mid() const = 0; 64 65 // Enables or disables this channel 66 virtual void Enable(bool enable) = 0; 67 68 // Used for latency measurements. 69 virtual void SetFirstPacketReceivedCallback( 70 std::function<void()> callback) = 0; 71 72 // Channel control 73 virtual bool SetLocalContent(const MediaContentDescription* content, 74 webrtc::SdpType type, 75 std::string& error_desc) = 0; 76 virtual bool SetRemoteContent(const MediaContentDescription* content, 77 webrtc::SdpType type, 78 std::string& error_desc) = 0; 79 virtual bool SetPayloadTypeDemuxingEnabled(bool enabled) = 0; 80 81 // Access to the local and remote streams that were set on the channel. 82 virtual const std::vector<StreamParams>& local_streams() const = 0; 83 virtual const std::vector<StreamParams>& remote_streams() const = 0; 84 85 // Set an RTP level transport. 86 // Some examples: 87 // * An RtpTransport without encryption. 88 // * An SrtpTransport for SDES. 89 // * A DtlsSrtpTransport for DTLS-SRTP. 90 virtual bool SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport) = 0; 91 }; 92 93 } // namespace cricket 94 95 #endif // PC_CHANNEL_INTERFACE_H_ 96