1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #ifndef PC_CHANNEL_INTERFACE_H_ 12*d9f75844SAndroid Build Coastguard Worker #define PC_CHANNEL_INTERFACE_H_ 13*d9f75844SAndroid Build Coastguard Worker 14*d9f75844SAndroid Build Coastguard Worker #include <memory> 15*d9f75844SAndroid Build Coastguard Worker #include <string> 16*d9f75844SAndroid Build Coastguard Worker #include <vector> 17*d9f75844SAndroid Build Coastguard Worker 18*d9f75844SAndroid Build Coastguard Worker #include "absl/strings/string_view.h" 19*d9f75844SAndroid Build Coastguard Worker #include "api/jsep.h" 20*d9f75844SAndroid Build Coastguard Worker #include "api/media_types.h" 21*d9f75844SAndroid Build Coastguard Worker #include "media/base/media_channel.h" 22*d9f75844SAndroid Build Coastguard Worker #include "pc/rtp_transport_internal.h" 23*d9f75844SAndroid Build Coastguard Worker 24*d9f75844SAndroid Build Coastguard Worker namespace webrtc { 25*d9f75844SAndroid Build Coastguard Worker class Call; 26*d9f75844SAndroid Build Coastguard Worker class VideoBitrateAllocatorFactory; 27*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc 28*d9f75844SAndroid Build Coastguard Worker 29*d9f75844SAndroid Build Coastguard Worker namespace cricket { 30*d9f75844SAndroid Build Coastguard Worker 31*d9f75844SAndroid Build Coastguard Worker class MediaContentDescription; 32*d9f75844SAndroid Build Coastguard Worker struct MediaConfig; 33*d9f75844SAndroid Build Coastguard Worker 34*d9f75844SAndroid Build Coastguard Worker // A Channel is a construct that groups media streams of the same type 35*d9f75844SAndroid Build Coastguard Worker // (audio or video), both outgoing and incoming. 36*d9f75844SAndroid Build Coastguard Worker // When the PeerConnection API is used, a Channel corresponds one to one 37*d9f75844SAndroid Build Coastguard Worker // to an RtpTransceiver. 38*d9f75844SAndroid Build Coastguard Worker // When Unified Plan is used, there can only be at most one outgoing and 39*d9f75844SAndroid Build Coastguard Worker // one incoming stream. With Plan B, there can be more than one. 40*d9f75844SAndroid Build Coastguard Worker 41*d9f75844SAndroid Build Coastguard Worker // ChannelInterface contains methods common to voice and video channels. 42*d9f75844SAndroid Build Coastguard Worker // As more methods are added to BaseChannel, they should be included in the 43*d9f75844SAndroid Build Coastguard Worker // interface as well. 44*d9f75844SAndroid Build Coastguard Worker // TODO(bugs.webrtc.org/13931): Merge this class into RtpTransceiver. 45*d9f75844SAndroid Build Coastguard Worker class ChannelInterface { 46*d9f75844SAndroid Build Coastguard Worker public: 47*d9f75844SAndroid Build Coastguard Worker virtual ~ChannelInterface() = default; 48*d9f75844SAndroid Build Coastguard Worker virtual cricket::MediaType media_type() const = 0; 49*d9f75844SAndroid Build Coastguard Worker 50*d9f75844SAndroid Build Coastguard Worker virtual MediaChannel* media_channel() const = 0; 51*d9f75844SAndroid Build Coastguard Worker // Typecasts of media_channel(). Will cause an exception if the 52*d9f75844SAndroid Build Coastguard Worker // channel is of the wrong type. 53*d9f75844SAndroid Build Coastguard Worker virtual VideoMediaChannel* video_media_channel() const = 0; 54*d9f75844SAndroid Build Coastguard Worker virtual VoiceMediaChannel* voice_media_channel() const = 0; 55*d9f75844SAndroid Build Coastguard Worker 56*d9f75844SAndroid Build Coastguard Worker // Returns a string view for the transport name. Fetching the transport name 57*d9f75844SAndroid Build Coastguard Worker // must be done on the network thread only and note that the lifetime of 58*d9f75844SAndroid Build Coastguard Worker // the returned object should be assumed to only be the calling scope. 59*d9f75844SAndroid Build Coastguard Worker // TODO(deadbeef): This is redundant; remove this. 60*d9f75844SAndroid Build Coastguard Worker virtual absl::string_view transport_name() const = 0; 61*d9f75844SAndroid Build Coastguard Worker 62*d9f75844SAndroid Build Coastguard Worker // TODO(tommi): Change return type to string_view. 63*d9f75844SAndroid Build Coastguard Worker virtual const std::string& mid() const = 0; 64*d9f75844SAndroid Build Coastguard Worker 65*d9f75844SAndroid Build Coastguard Worker // Enables or disables this channel 66*d9f75844SAndroid Build Coastguard Worker virtual void Enable(bool enable) = 0; 67*d9f75844SAndroid Build Coastguard Worker 68*d9f75844SAndroid Build Coastguard Worker // Used for latency measurements. 69*d9f75844SAndroid Build Coastguard Worker virtual void SetFirstPacketReceivedCallback( 70*d9f75844SAndroid Build Coastguard Worker std::function<void()> callback) = 0; 71*d9f75844SAndroid Build Coastguard Worker 72*d9f75844SAndroid Build Coastguard Worker // Channel control 73*d9f75844SAndroid Build Coastguard Worker virtual bool SetLocalContent(const MediaContentDescription* content, 74*d9f75844SAndroid Build Coastguard Worker webrtc::SdpType type, 75*d9f75844SAndroid Build Coastguard Worker std::string& error_desc) = 0; 76*d9f75844SAndroid Build Coastguard Worker virtual bool SetRemoteContent(const MediaContentDescription* content, 77*d9f75844SAndroid Build Coastguard Worker webrtc::SdpType type, 78*d9f75844SAndroid Build Coastguard Worker std::string& error_desc) = 0; 79*d9f75844SAndroid Build Coastguard Worker virtual bool SetPayloadTypeDemuxingEnabled(bool enabled) = 0; 80*d9f75844SAndroid Build Coastguard Worker 81*d9f75844SAndroid Build Coastguard Worker // Access to the local and remote streams that were set on the channel. 82*d9f75844SAndroid Build Coastguard Worker virtual const std::vector<StreamParams>& local_streams() const = 0; 83*d9f75844SAndroid Build Coastguard Worker virtual const std::vector<StreamParams>& remote_streams() const = 0; 84*d9f75844SAndroid Build Coastguard Worker 85*d9f75844SAndroid Build Coastguard Worker // Set an RTP level transport. 86*d9f75844SAndroid Build Coastguard Worker // Some examples: 87*d9f75844SAndroid Build Coastguard Worker // * An RtpTransport without encryption. 88*d9f75844SAndroid Build Coastguard Worker // * An SrtpTransport for SDES. 89*d9f75844SAndroid Build Coastguard Worker // * A DtlsSrtpTransport for DTLS-SRTP. 90*d9f75844SAndroid Build Coastguard Worker virtual bool SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport) = 0; 91*d9f75844SAndroid Build Coastguard Worker }; 92*d9f75844SAndroid Build Coastguard Worker 93*d9f75844SAndroid Build Coastguard Worker } // namespace cricket 94*d9f75844SAndroid Build Coastguard Worker 95*d9f75844SAndroid Build Coastguard Worker #endif // PC_CHANNEL_INTERFACE_H_ 96