blob: 6033046b920b45b58c2387b63ff3cabe524bb074 [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
14#include <string>
Amit Hilbuchbcd39d42019-01-25 17:13:56 -080015#include <vector>
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080016
Tomas Gunnarsson94f01942022-01-03 14:59:12 +000017#include "absl/strings/string_view.h"
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080018#include "api/jsep.h"
Steve Anton10542f22019-01-11 09:11:00 -080019#include "api/media_types.h"
20#include "media/base/media_channel.h"
21#include "pc/rtp_transport_internal.h"
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080022
Tomas Gunnarsson5411b172022-01-24 08:45:26 +010023namespace webrtc {
24class Call;
25class VideoBitrateAllocatorFactory;
26} // namespace webrtc
27
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080028namespace cricket {
29
30class MediaContentDescription;
Tomas Gunnarsson5411b172022-01-24 08:45:26 +010031class VideoChannel;
32class VoiceChannel;
33struct MediaConfig;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080034
35// ChannelInterface contains methods common to voice, video and data channels.
36// As more methods are added to BaseChannel, they should be included in the
37// interface as well.
38class ChannelInterface {
39 public:
40 virtual cricket::MediaType media_type() const = 0;
41
42 virtual MediaChannel* media_channel() const = 0;
43
Tomas Gunnarsson94f01942022-01-03 14:59:12 +000044 // Returns a string view for the transport name. Fetching the transport name
45 // must be done on the network thread only and note that the lifetime of
46 // the returned object should be assumed to only be the calling scope.
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080047 // TODO(deadbeef): This is redundant; remove this.
Tomas Gunnarsson94f01942022-01-03 14:59:12 +000048 virtual absl::string_view transport_name() const = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080049
Tomas Gunnarsson5411b172022-01-24 08:45:26 +010050 // TODO(tommi): Change return type to string_view.
51 virtual const std::string& mid() const = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080052
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080053 // Enables or disables this channel
Tommi1959f8f2021-04-26 10:20:19 +020054 virtual void Enable(bool enable) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080055
56 // Used for latency measurements.
Tommi99c8a802021-04-27 15:00:00 +020057 virtual void SetFirstPacketReceivedCallback(
58 std::function<void()> callback) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080059
60 // Channel control
61 virtual bool SetLocalContent(const MediaContentDescription* content,
62 webrtc::SdpType type,
Tomas Gunnarssond908d742022-01-05 10:44:26 +000063 std::string& error_desc) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080064 virtual bool SetRemoteContent(const MediaContentDescription* content,
65 webrtc::SdpType type,
Tomas Gunnarssond908d742022-01-05 10:44:26 +000066 std::string& error_desc) = 0;
Taylor Brandstetterd0acbd82021-01-25 13:44:55 -080067 virtual bool SetPayloadTypeDemuxingEnabled(bool enabled) = 0;
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080068
Amit Hilbuchbcd39d42019-01-25 17:13:56 -080069 // Access to the local and remote streams that were set on the channel.
70 virtual const std::vector<StreamParams>& local_streams() const = 0;
71 virtual const std::vector<StreamParams>& remote_streams() const = 0;
72
Amit Hilbuchdd9390c2018-11-13 16:26:05 -080073 // Set an RTP level transport.
74 // Some examples:
75 // * An RtpTransport without encryption.
76 // * An SrtpTransport for SDES.
77 // * A DtlsSrtpTransport for DTLS-SRTP.
78 virtual bool SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport) = 0;
79
80 protected:
81 virtual ~ChannelInterface() = default;
82};
83
Tomas Gunnarsson5411b172022-01-24 08:45:26 +010084class ChannelFactoryInterface {
85 public:
86 virtual VideoChannel* CreateVideoChannel(
87 webrtc::Call* call,
88 const MediaConfig& media_config,
89 const std::string& mid,
90 bool srtp_required,
91 const webrtc::CryptoOptions& crypto_options,
92 const VideoOptions& options,
93 webrtc::VideoBitrateAllocatorFactory*
94 video_bitrate_allocator_factory) = 0;
95
96 virtual VoiceChannel* CreateVoiceChannel(
97 webrtc::Call* call,
98 const MediaConfig& media_config,
99 const std::string& mid,
100 bool srtp_required,
101 const webrtc::CryptoOptions& crypto_options,
102 const AudioOptions& options) = 0;
103
104 virtual void DestroyChannel(ChannelInterface* channel) = 0;
105
106 protected:
107 virtual ~ChannelFactoryInterface() = default;
108};
109
Amit Hilbuchdd9390c2018-11-13 16:26:05 -0800110} // namespace cricket
111
Steve Anton10542f22019-01-11 09:11:00 -0800112#endif // PC_CHANNEL_INTERFACE_H_