blob: 032bfad5e3bf00a918593040a6fccad169812575 [file] [log] [blame]
Amit Hilbuchdd9390c2018-11-13 16:26:05 -08001/*
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 Anton10542f22019-01-11 09:11:00 -080011#ifndef PC_CHANNEL_INTERFACE_H_
12#define PC_CHANNEL_INTERFACE_H_
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080013
Harald Alvestrand3af79d12022-04-29 15:04:58 +000014#include <memory>
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080015#include <string>
Amit Hilbuchbcd39d42019-01-25 17:13:56 -080016#include <vector>
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080017
Tomas Gunnarsson94f01942022-01-03 14:59:12 +000018#include "absl/strings/string_view.h"
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080019#include "api/jsep.h"
Steve Anton10542f22019-01-11 09:11:00 -080020#include "api/media_types.h"
21#include "media/base/media_channel.h"
22#include "pc/rtp_transport_internal.h"
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080023
Tomas Gunnarsson5411b172022-01-24 08:45:26 +010024namespace webrtc {
25class Call;
26class VideoBitrateAllocatorFactory;
27} // namespace webrtc
28
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080029namespace cricket {
30
31class MediaContentDescription;
Tomas Gunnarsson5411b172022-01-24 08:45:26 +010032struct MediaConfig;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080033
Harald Alvestrandd5f414c2022-01-24 09:11:23 +000034// 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.
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080042// As more methods are added to BaseChannel, they should be included in the
43// interface as well.
Harald Alvestrand3af79d12022-04-29 15:04:58 +000044// TODO(bugs.webrtc.org/13931): Merge this class into RtpTransceiver.
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080045class ChannelInterface {
46 public:
Harald Alvestrand3af79d12022-04-29 15:04:58 +000047 virtual ~ChannelInterface() = default;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080048 virtual cricket::MediaType media_type() const = 0;
49
Harald Alvestrand36fafc82022-12-08 08:47:42 +000050 virtual MediaSendChannelInterface* media_send_channel() const = 0;
Harald Alvestrand25adc8e2022-05-03 13:44:34 +000051 // Typecasts of media_channel(). Will cause an exception if the
52 // channel is of the wrong type.
Harald Alvestrand36fafc82022-12-08 08:47:42 +000053 virtual VideoMediaChannel* video_media_send_channel() const = 0;
54 virtual VoiceMediaChannel* voice_media_send_channel() const = 0;
55 virtual MediaReceiveChannelInterface* media_receive_channel() const = 0;
56 // Typecasts of media_channel(). Will cause an exception if the
57 // channel is of the wrong type.
58 virtual VideoMediaChannel* video_media_receive_channel() const = 0;
59 virtual VoiceMediaChannel* voice_media_receive_channel() const = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080060
Tomas Gunnarsson94f01942022-01-03 14:59:12 +000061 // Returns a string view for the transport name. Fetching the transport name
62 // must be done on the network thread only and note that the lifetime of
63 // the returned object should be assumed to only be the calling scope.
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080064 // TODO(deadbeef): This is redundant; remove this.
Tomas Gunnarsson94f01942022-01-03 14:59:12 +000065 virtual absl::string_view transport_name() const = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080066
Tomas Gunnarsson5411b172022-01-24 08:45:26 +010067 // TODO(tommi): Change return type to string_view.
68 virtual const std::string& mid() const = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080069
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080070 // Enables or disables this channel
Tommi1959f8f2021-04-26 10:20:19 +020071 virtual void Enable(bool enable) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080072
73 // Used for latency measurements.
Tommi99c8a802021-04-27 15:00:00 +020074 virtual void SetFirstPacketReceivedCallback(
75 std::function<void()> callback) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080076
77 // Channel control
78 virtual bool SetLocalContent(const MediaContentDescription* content,
79 webrtc::SdpType type,
Tomas Gunnarssond908d742022-01-05 10:44:26 +000080 std::string& error_desc) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080081 virtual bool SetRemoteContent(const MediaContentDescription* content,
82 webrtc::SdpType type,
Tomas Gunnarssond908d742022-01-05 10:44:26 +000083 std::string& error_desc) = 0;
Taylor Brandstetterd0acbd82021-01-25 13:44:55 -080084 virtual bool SetPayloadTypeDemuxingEnabled(bool enabled) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080085
Amit Hilbuchbcd39d42019-01-25 17:13:56 -080086 // Access to the local and remote streams that were set on the channel.
87 virtual const std::vector<StreamParams>& local_streams() const = 0;
88 virtual const std::vector<StreamParams>& remote_streams() const = 0;
89
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080090 // Set an RTP level transport.
91 // Some examples:
92 // * An RtpTransport without encryption.
93 // * An SrtpTransport for SDES.
94 // * A DtlsSrtpTransport for DTLS-SRTP.
95 virtual bool SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080096};
97
98} // namespace cricket
99
Steve Anton10542f22019-01-11 09:11:00 -0800100#endif // PC_CHANNEL_INTERFACE_H_