blob: 783755e6fe6333d3c848194fc8e92a5a1b308b93 [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
Harald Alvestrandc0d44d92022-12-13 12:57:24 +000031class MediaChannel;
Harald Alvestrand1251c642023-01-04 12:42:56 +000032class VoiceChannel;
33class VideoChannel;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080034class MediaContentDescription;
Tomas Gunnarsson5411b172022-01-24 08:45:26 +010035struct MediaConfig;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080036
Harald Alvestrandd5f414c2022-01-24 09:11:23 +000037// 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.
43
44// ChannelInterface contains methods common to voice and video channels.
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080045// As more methods are added to BaseChannel, they should be included in the
46// interface as well.
Harald Alvestrand3af79d12022-04-29 15:04:58 +000047// TODO(bugs.webrtc.org/13931): Merge this class into RtpTransceiver.
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080048class ChannelInterface {
49 public:
Harald Alvestrand3af79d12022-04-29 15:04:58 +000050 virtual ~ChannelInterface() = default;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080051 virtual cricket::MediaType media_type() const = 0;
52
Harald Alvestrand1251c642023-01-04 12:42:56 +000053 virtual VideoChannel* AsVideoChannel() = 0;
54 virtual VoiceChannel* AsVoiceChannel() = 0;
55
Harald Alvestrandc0d44d92022-12-13 12:57:24 +000056 // Temporary fix while MediaChannel is being reconstructed
Harald Alvestrand50454ef2022-12-15 16:49:13 +000057 virtual MediaChannel* media_channel() = 0;
58 virtual MediaSendChannelInterface* media_send_channel() = 0;
Harald Alvestrand25adc8e2022-05-03 13:44:34 +000059 // Typecasts of media_channel(). Will cause an exception if the
60 // channel is of the wrong type.
Harald Alvestrand50454ef2022-12-15 16:49:13 +000061 virtual VideoMediaSendChannelInterface* video_media_send_channel() = 0;
62 virtual VoiceMediaSendChannelInterface* voice_media_send_channel() = 0;
63 virtual MediaReceiveChannelInterface* media_receive_channel() = 0;
Harald Alvestrand36fafc82022-12-08 08:47:42 +000064 // Typecasts of media_channel(). Will cause an exception if the
65 // channel is of the wrong type.
Harald Alvestrand50454ef2022-12-15 16:49:13 +000066 virtual VideoMediaReceiveChannelInterface* video_media_receive_channel() = 0;
67 virtual VoiceMediaReceiveChannelInterface* voice_media_receive_channel() = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080068
Tomas Gunnarsson94f01942022-01-03 14:59:12 +000069 // Returns a string view for the transport name. Fetching the transport name
70 // must be done on the network thread only and note that the lifetime of
71 // the returned object should be assumed to only be the calling scope.
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080072 // TODO(deadbeef): This is redundant; remove this.
Tomas Gunnarsson94f01942022-01-03 14:59:12 +000073 virtual absl::string_view transport_name() const = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080074
Tomas Gunnarsson5411b172022-01-24 08:45:26 +010075 // TODO(tommi): Change return type to string_view.
76 virtual const std::string& mid() const = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080077
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080078 // Enables or disables this channel
Tommi1959f8f2021-04-26 10:20:19 +020079 virtual void Enable(bool enable) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080080
81 // Used for latency measurements.
Tommi99c8a802021-04-27 15:00:00 +020082 virtual void SetFirstPacketReceivedCallback(
83 std::function<void()> callback) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080084
85 // Channel control
86 virtual bool SetLocalContent(const MediaContentDescription* content,
87 webrtc::SdpType type,
Tomas Gunnarssond908d742022-01-05 10:44:26 +000088 std::string& error_desc) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080089 virtual bool SetRemoteContent(const MediaContentDescription* content,
90 webrtc::SdpType type,
Tomas Gunnarssond908d742022-01-05 10:44:26 +000091 std::string& error_desc) = 0;
Taylor Brandstetterd0acbd82021-01-25 13:44:55 -080092 virtual bool SetPayloadTypeDemuxingEnabled(bool enabled) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080093
Amit Hilbuchbcd39d42019-01-25 17:13:56 -080094 // Access to the local and remote streams that were set on the channel.
95 virtual const std::vector<StreamParams>& local_streams() const = 0;
96 virtual const std::vector<StreamParams>& remote_streams() const = 0;
97
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080098 // Set an RTP level transport.
99 // Some examples:
100 // * An RtpTransport without encryption.
101 // * An SrtpTransport for SDES.
102 // * A DtlsSrtpTransport for DTLS-SRTP.
103 virtual bool SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -0800104};
105
106} // namespace cricket
107
Steve Anton10542f22019-01-11 09:11:00 -0800108#endif // PC_CHANNEL_INTERFACE_H_