2 * Copyright 2018 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef PC_CHANNEL_INTERFACE_H_
12 #define PC_CHANNEL_INTERFACE_H_
18 #include "absl/strings/string_view.h"
20 #include "api/media_types.h"
21 #include "media/base/media_channel.h"
22 #include "pc/rtp_transport_internal.h"
26 class VideoBitrateAllocatorFactory
;
34 class MediaContentDescription
;
37 // A Channel is a construct that groups media streams of the same type
38 // (audio or video), both outgoing and incoming.
39 // When the PeerConnection API is used, a Channel corresponds one to one
40 // to an RtpTransceiver.
41 // When Unified Plan is used, there can only be at most one outgoing and
42 // one incoming stream. With Plan B, there can be more than one.
44 // ChannelInterface contains methods common to voice and video channels.
45 // As more methods are added to BaseChannel, they should be included in the
47 // TODO(bugs.webrtc.org/13931): Merge this class into RtpTransceiver.
48 class ChannelInterface
{
50 virtual ~ChannelInterface() = default;
51 virtual cricket::MediaType
media_type() const = 0;
53 virtual VideoChannel
* AsVideoChannel() = 0;
54 virtual VoiceChannel
* AsVoiceChannel() = 0;
56 virtual MediaSendChannelInterface
* media_send_channel() = 0;
57 // Typecasts of media_channel(). Will cause an exception if the
58 // channel is of the wrong type.
59 virtual VideoMediaSendChannelInterface
* video_media_send_channel() = 0;
60 virtual VoiceMediaSendChannelInterface
* voice_media_send_channel() = 0;
61 virtual MediaReceiveChannelInterface
* media_receive_channel() = 0;
62 // Typecasts of media_channel(). Will cause an exception if the
63 // channel is of the wrong type.
64 virtual VideoMediaReceiveChannelInterface
* video_media_receive_channel() = 0;
65 virtual VoiceMediaReceiveChannelInterface
* voice_media_receive_channel() = 0;
67 // Returns a string view for the transport name. Fetching the transport name
68 // must be done on the network thread only and note that the lifetime of
69 // the returned object should be assumed to only be the calling scope.
70 // TODO(deadbeef): This is redundant; remove this.
71 virtual absl::string_view
transport_name() const = 0;
73 // TODO(tommi): Change return type to string_view.
74 virtual const std::string
& mid() const = 0;
76 // Enables or disables this channel
77 virtual void Enable(bool enable
) = 0;
79 // Used for latency measurements.
80 virtual void SetFirstPacketReceivedCallback(
81 std::function
<void()> callback
) = 0;
84 virtual bool SetLocalContent(const MediaContentDescription
* content
,
86 std::string
& error_desc
) = 0;
87 virtual bool SetRemoteContent(const MediaContentDescription
* content
,
89 std::string
& error_desc
) = 0;
90 virtual bool SetPayloadTypeDemuxingEnabled(bool enabled
) = 0;
92 // Access to the local and remote streams that were set on the channel.
93 virtual const std::vector
<StreamParams
>& local_streams() const = 0;
94 virtual const std::vector
<StreamParams
>& remote_streams() const = 0;
96 // Set an RTP level transport.
98 // * An RtpTransport without encryption.
99 // * An SrtpTransport for SDES.
100 // * A DtlsSrtpTransport for DTLS-SRTP.
101 virtual bool SetRtpTransport(webrtc::RtpTransportInternal
* rtp_transport
) = 0;
104 } // namespace cricket
106 #endif // PC_CHANNEL_INTERFACE_H_