blob: c11b2bd7d372a117ef761b3f4a48f77cff427f5f [file] [log] [blame]
ossu7bb87ee2017-01-23 12:56:251/*
2 * Copyright 2015 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
11// This file contains classes that implement RtpSenderInterface.
12// An RtpSender associates a MediaStreamTrackInterface with an underlying
13// transport (provided by AudioProviderInterface/VideoProviderInterface)
14
Steve Anton10542f22019-01-11 17:11:0015#ifndef PC_RTP_SENDER_H_
16#define PC_RTP_SENDER_H_
ossu7bb87ee2017-01-23 12:56:2517
Harald Alvestrand5761e7b2021-01-29 14:45:0818#include <stddef.h>
19#include <stdint.h>
Harald Alvestrandc24a2182022-02-23 13:44:5920
ossu7bb87ee2017-01-23 12:56:2521#include <memory>
22#include <string>
Steve Anton36b29d12017-10-30 16:57:4223#include <vector>
ossu7bb87ee2017-01-23 12:56:2524
Harald Alvestrand5761e7b2021-01-29 14:45:0825#include "absl/types/optional.h"
26#include "api/crypto/frame_encryptor_interface.h"
27#include "api/dtls_transport_interface.h"
28#include "api/dtmf_sender_interface.h"
29#include "api/frame_transformer_interface.h"
Steve Anton10542f22019-01-11 17:11:0030#include "api/media_stream_interface.h"
Harald Alvestrand5761e7b2021-01-29 14:45:0831#include "api/media_types.h"
32#include "api/rtc_error.h"
33#include "api/rtp_parameters.h"
Steve Anton10542f22019-01-11 17:11:0034#include "api/rtp_sender_interface.h"
Harald Alvestrand5761e7b2021-01-29 14:45:0835#include "api/scoped_refptr.h"
Harald Alvestrandc24a2182022-02-23 13:44:5936#include "api/sequence_checker.h"
Steve Anton10542f22019-01-11 17:11:0037#include "media/base/audio_source.h"
38#include "media/base/media_channel.h"
39#include "pc/dtmf_sender.h"
Henrik Boströmf7859892022-07-04 12:36:3740#include "pc/legacy_stats_collector_interface.h"
Harald Alvestrandc24a2182022-02-23 13:44:5941#include "rtc_base/checks.h"
Markus Handell6fcd0f82020-07-07 17:08:5342#include "rtc_base/synchronization/mutex.h"
Harald Alvestrand5761e7b2021-01-29 14:45:0843#include "rtc_base/thread.h"
Harald Alvestrandc24a2182022-02-23 13:44:5944#include "rtc_base/thread_annotations.h"
ossu7bb87ee2017-01-23 12:56:2545
46namespace webrtc {
47
Florent Castelli892acf02018-10-01 20:47:2048bool UnimplementedRtpParameterHasValue(const RtpParameters& parameters);
49
ossu7bb87ee2017-01-23 12:56:2550// Internal interface used by PeerConnection.
51class RtpSenderInternal : public RtpSenderInterface {
52 public:
Steve Anton57858b32018-02-15 23:19:5053 // Sets the underlying MediaEngine channel associated with this RtpSender.
Amit Hilbuchdd9390c2018-11-14 00:26:0554 // A VoiceMediaChannel should be used for audio RtpSenders and
55 // a VideoMediaChannel should be used for video RtpSenders.
56 // Must call SetMediaChannel(nullptr) before the media channel is destroyed.
57 virtual void SetMediaChannel(cricket::MediaChannel* media_channel) = 0;
Steve Anton57858b32018-02-15 23:19:5058
ossu7bb87ee2017-01-23 12:56:2559 // Used to set the SSRC of the sender, once a local description has been set.
Artem Titov880fa812021-07-30 20:30:2360 // If `ssrc` is 0, this indiates that the sender should disconnect from the
ossu7bb87ee2017-01-23 12:56:2561 // underlying transport (this occurs if the sender isn't seen in a local
62 // description).
63 virtual void SetSsrc(uint32_t ssrc) = 0;
64
Henrik Andreasssoncc189172019-05-20 09:01:3865 virtual void set_stream_ids(const std::vector<std::string>& stream_ids) = 0;
Florent Castelli892acf02018-10-01 20:47:2066 virtual void set_init_send_encodings(
67 const std::vector<RtpEncodingParameters>& init_send_encodings) = 0;
Harald Alvestrand4a7b3ac2019-01-17 09:39:4068 virtual void set_transport(
69 rtc::scoped_refptr<DtlsTransportInterface> dtls_transport) = 0;
ossu7bb87ee2017-01-23 12:56:2570
71 virtual void Stop() = 0;
Steve Anton57858b32018-02-15 23:19:5072
Artem Titov880fa812021-07-30 20:30:2373 // `GetParameters` and `SetParameters` operate with a transactional model.
Amit Hilbuch619b2942019-02-26 23:55:1974 // Allow access to get/set parameters without invalidating transaction id.
75 virtual RtpParameters GetParametersInternal() const = 0;
Florent Castelliacabb362022-10-18 15:05:1676 virtual void SetParametersInternal(const RtpParameters& parameters,
77 SetParametersCallback,
78 bool blocking) = 0;
Amit Hilbuch619b2942019-02-26 23:55:1979
Harald Alvestrand0166be82022-08-25 11:31:0180 // GetParameters and SetParameters will remove deactivated simulcast layers
81 // and restore them on SetParameters. This is probably a Bad Idea, but we
82 // do not know who depends on this behavior
83 virtual RtpParameters GetParametersInternalWithAllLayers() const = 0;
84 virtual RTCError SetParametersInternalWithAllLayers(
85 const RtpParameters& parameters) = 0;
86
Florent Castelli725ee242022-10-18 15:05:5887 // Additional checks that are specific to the Sender type
88 virtual RTCError CheckSVCParameters(const RtpParameters& parameters) {
89 return webrtc::RTCError::OK();
90 }
91
Steve Anton57858b32018-02-15 23:19:5092 // Returns an ID that changes every time SetTrack() is called, but
93 // otherwise remains constant. Used to generate IDs for stats.
94 // The special value zero means that no track is attached.
95 virtual int AttachmentId() const = 0;
Amit Hilbuch2297d332019-02-19 20:49:2296
97 // Disables the layers identified by the specified RIDs.
98 // If the specified list is empty, this is a no-op.
99 virtual RTCError DisableEncodingLayers(
100 const std::vector<std::string>& rid) = 0;
Harald Alvestrand6060df52020-08-11 07:54:02101
102 virtual void SetTransceiverAsStopped() = 0;
Florent Castelli725ee242022-10-18 15:05:58103
104 // Used by the owning transceiver to inform the sender on the currently
105 // selected codecs.
106 virtual void SetVideoCodecPreferences(
107 std::vector<cricket::VideoCodec> codec_preferences) = 0;
ossu7bb87ee2017-01-23 12:56:25108};
109
Amit Hilbuchea7ef2a2019-02-19 23:20:21110// Shared implementation for RtpSenderInternal interface.
111class RtpSenderBase : public RtpSenderInternal, public ObserverInterface {
112 public:
Guido Urdaneta1ff16c82019-05-20 17:31:53113 class SetStreamsObserver {
114 public:
115 virtual ~SetStreamsObserver() = default;
116 virtual void OnSetStreams() = 0;
117 };
118
Amit Hilbuchea7ef2a2019-02-19 23:20:21119 // Sets the underlying MediaEngine channel associated with this RtpSender.
120 // A VoiceMediaChannel should be used for audio RtpSenders and
121 // a VideoMediaChannel should be used for video RtpSenders.
122 // Must call SetMediaChannel(nullptr) before the media channel is destroyed.
123 void SetMediaChannel(cricket::MediaChannel* media_channel) override;
124
125 bool SetTrack(MediaStreamTrackInterface* track) override;
126 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
Tomas Gunnarssonfe328ca2022-02-16 19:02:12127 // This method is currently called from the worker thread by
128 // RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n.
129 // RTC_DCHECK_RUN_ON(signaling_thread_);
Amit Hilbuchea7ef2a2019-02-19 23:20:21130 return track_;
131 }
132
133 RtpParameters GetParameters() const override;
134 RTCError SetParameters(const RtpParameters& parameters) override;
Florent Castelliacabb362022-10-18 15:05:16135 void SetParametersAsync(const RtpParameters& parameters,
136 SetParametersCallback callback) override;
Amit Hilbuchea7ef2a2019-02-19 23:20:21137
Artem Titov880fa812021-07-30 20:30:23138 // `GetParameters` and `SetParameters` operate with a transactional model.
Amit Hilbuch619b2942019-02-26 23:55:19139 // Allow access to get/set parameters without invalidating transaction id.
140 RtpParameters GetParametersInternal() const override;
Florent Castelliacabb362022-10-18 15:05:16141 void SetParametersInternal(const RtpParameters& parameters,
142 SetParametersCallback callback = nullptr,
143 bool blocking = true) override;
144 RTCError CheckSetParameters(const RtpParameters& parameters);
Harald Alvestrand0166be82022-08-25 11:31:01145 RtpParameters GetParametersInternalWithAllLayers() const override;
146 RTCError SetParametersInternalWithAllLayers(
147 const RtpParameters& parameters) override;
Amit Hilbuch619b2942019-02-26 23:55:19148
Amit Hilbuchea7ef2a2019-02-19 23:20:21149 // Used to set the SSRC of the sender, once a local description has been set.
Artem Titov880fa812021-07-30 20:30:23150 // If `ssrc` is 0, this indiates that the sender should disconnect from the
Amit Hilbuchea7ef2a2019-02-19 23:20:21151 // underlying transport (this occurs if the sender isn't seen in a local
152 // description).
153 void SetSsrc(uint32_t ssrc) override;
Tomas Gunnarssonfe328ca2022-02-16 19:02:12154 uint32_t ssrc() const override {
155 // This method is currently called from the worker thread by
156 // RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n.
157 // RTC_DCHECK_RUN_ON(signaling_thread_);
158 return ssrc_;
159 }
Amit Hilbuchea7ef2a2019-02-19 23:20:21160
Tomas Gunnarssonfe328ca2022-02-16 19:02:12161 std::vector<std::string> stream_ids() const override {
162 RTC_DCHECK_RUN_ON(signaling_thread_);
163 return stream_ids_;
164 }
Henrik Andreasssoncc189172019-05-20 09:01:38165 void set_stream_ids(const std::vector<std::string>& stream_ids) override {
166 stream_ids_ = stream_ids;
167 }
Guido Urdaneta1ff16c82019-05-20 17:31:53168 void SetStreams(const std::vector<std::string>& stream_ids) override;
Amit Hilbuchea7ef2a2019-02-19 23:20:21169
170 std::string id() const override { return id_; }
171
172 void set_init_send_encodings(
173 const std::vector<RtpEncodingParameters>& init_send_encodings) override {
174 init_parameters_.encodings = init_send_encodings;
175 }
176 std::vector<RtpEncodingParameters> init_send_encodings() const override {
Tomas Gunnarssonfe328ca2022-02-16 19:02:12177 RTC_DCHECK_RUN_ON(signaling_thread_);
Amit Hilbuchea7ef2a2019-02-19 23:20:21178 return init_parameters_.encodings;
179 }
180
181 void set_transport(
182 rtc::scoped_refptr<DtlsTransportInterface> dtls_transport) override {
183 dtls_transport_ = dtls_transport;
184 }
185 rtc::scoped_refptr<DtlsTransportInterface> dtls_transport() const override {
Tomas Gunnarssonfe328ca2022-02-16 19:02:12186 RTC_DCHECK_RUN_ON(signaling_thread_);
Amit Hilbuchea7ef2a2019-02-19 23:20:21187 return dtls_transport_;
188 }
189
190 void SetFrameEncryptor(
191 rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor) override;
192
193 rtc::scoped_refptr<FrameEncryptorInterface> GetFrameEncryptor()
194 const override {
195 return frame_encryptor_;
196 }
197
198 void Stop() override;
199
200 // Returns an ID that changes every time SetTrack() is called, but
201 // otherwise remains constant. Used to generate IDs for stats.
202 // The special value zero means that no track is attached.
203 int AttachmentId() const override { return attachment_id_; }
204
205 // Disables the layers identified by the specified RIDs.
206 // If the specified list is empty, this is a no-op.
207 RTCError DisableEncodingLayers(const std::vector<std::string>& rid) override;
208
Marina Cioceae77912b2020-02-27 15:16:55209 void SetEncoderToPacketizerFrameTransformer(
210 rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) override;
211
Jonas Oreland65455162022-06-08 09:25:46212 void SetEncoderSelector(
213 std::unique_ptr<VideoEncoderFactory::EncoderSelectorInterface>
214 encoder_selector) override;
215
216 void SetEncoderSelectorOnChannel();
217
Tomas Gunnarssonfe328ca2022-02-16 19:02:12218 void SetTransceiverAsStopped() override {
219 RTC_DCHECK_RUN_ON(signaling_thread_);
220 is_transceiver_stopped_ = true;
221 }
Harald Alvestrand6060df52020-08-11 07:54:02222
Florent Castelli725ee242022-10-18 15:05:58223 void SetVideoCodecPreferences(
224 std::vector<cricket::VideoCodec> codec_preferences) override {
225 video_codec_preferences_ = codec_preferences;
226 }
227
Amit Hilbuchea7ef2a2019-02-19 23:20:21228 protected:
Artem Titov880fa812021-07-30 20:30:23229 // If `set_streams_observer` is not null, it is invoked when SetStreams()
230 // is called. `set_streams_observer` is not owned by this object. If not
Guido Urdaneta1ff16c82019-05-20 17:31:53231 // null, it must be valid at least until this sender becomes stopped.
232 RtpSenderBase(rtc::Thread* worker_thread,
233 const std::string& id,
234 SetStreamsObserver* set_streams_observer);
Niels Möllerb5b159d2022-07-05 07:59:27235 // TODO(bugs.webrtc.org/8694): Since SSRC == 0 is technically valid, figure
236 // out some other way to test if we have a valid SSRC.
Amit Hilbuchea7ef2a2019-02-19 23:20:21237 bool can_send_track() const { return track_ && ssrc_; }
238
239 virtual std::string track_kind() const = 0;
240
241 // Enable sending on the media channel.
242 virtual void SetSend() = 0;
243 // Disable sending on the media channel.
244 virtual void ClearSend() = 0;
245
246 // Template method pattern to allow subclasses to add custom behavior for
247 // when tracks are attached, detached, and for adding tracks to statistics.
248 virtual void AttachTrack() {}
249 virtual void DetachTrack() {}
250 virtual void AddTrackToStats() {}
251 virtual void RemoveTrackFromStats() {}
252
Tomas Gunnarssonfe328ca2022-02-16 19:02:12253 rtc::Thread* const signaling_thread_;
254 rtc::Thread* const worker_thread_;
Amit Hilbuchea7ef2a2019-02-19 23:20:21255 uint32_t ssrc_ = 0;
Tomas Gunnarssonfe328ca2022-02-16 19:02:12256 bool stopped_ RTC_GUARDED_BY(signaling_thread_) = false;
257 bool is_transceiver_stopped_ RTC_GUARDED_BY(signaling_thread_) = false;
Amit Hilbuchea7ef2a2019-02-19 23:20:21258 int attachment_id_ = 0;
259 const std::string id_;
260
261 std::vector<std::string> stream_ids_;
262 RtpParameters init_parameters_;
Florent Castelli725ee242022-10-18 15:05:58263 std::vector<cricket::VideoCodec> video_codec_preferences_;
Amit Hilbuchea7ef2a2019-02-19 23:20:21264
Tommi6589def2022-02-17 22:36:47265 // TODO(tommi): `media_channel_` and several other member variables in this
266 // class (ssrc_, stopped_, etc) are accessed from more than one thread without
267 // a guard or lock. Internally there are also several Invoke()s that we could
268 // remove since the upstream code may already be performing several operations
269 // on the worker thread.
Amit Hilbuchea7ef2a2019-02-19 23:20:21270 cricket::MediaChannel* media_channel_ = nullptr;
271 rtc::scoped_refptr<MediaStreamTrackInterface> track_;
272
273 rtc::scoped_refptr<DtlsTransportInterface> dtls_transport_;
274 rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor_;
Artem Titov880fa812021-07-30 20:30:23275 // `last_transaction_id_` is used to verify that `SetParameters` is receiving
276 // the parameters object that was last returned from `GetParameters`.
Amit Hilbuchea7ef2a2019-02-19 23:20:21277 // As such, it is used for internal verification and is not observable by the
Artem Titov880fa812021-07-30 20:30:23278 // the client. It is marked as mutable to enable `GetParameters` to be a
Amit Hilbuchea7ef2a2019-02-19 23:20:21279 // const method.
280 mutable absl::optional<std::string> last_transaction_id_;
281 std::vector<std::string> disabled_rids_;
Guido Urdaneta1ff16c82019-05-20 17:31:53282
283 SetStreamsObserver* set_streams_observer_ = nullptr;
Marina Cioceae77912b2020-02-27 15:16:55284
285 rtc::scoped_refptr<FrameTransformerInterface> frame_transformer_;
Jonas Oreland65455162022-06-08 09:25:46286 std::unique_ptr<VideoEncoderFactory::EncoderSelectorInterface>
287 encoder_selector_;
Amit Hilbuchea7ef2a2019-02-19 23:20:21288};
289
ossu7bb87ee2017-01-23 12:56:25290// LocalAudioSinkAdapter receives data callback as a sink to the local
291// AudioTrack, and passes the data to the sink of AudioSource.
292class LocalAudioSinkAdapter : public AudioTrackSinkInterface,
293 public cricket::AudioSource {
294 public:
295 LocalAudioSinkAdapter();
296 virtual ~LocalAudioSinkAdapter();
297
298 private:
299 // AudioSinkInterface implementation.
300 void OnData(const void* audio_data,
301 int bits_per_sample,
302 int sample_rate,
303 size_t number_of_channels,
Minyue Li99d6d812020-01-29 09:25:12304 size_t number_of_frames,
305 absl::optional<int64_t> absolute_capture_timestamp_ms) override;
306
307 // AudioSinkInterface implementation.
308 void OnData(const void* audio_data,
309 int bits_per_sample,
310 int sample_rate,
311 size_t number_of_channels,
312 size_t number_of_frames) override {
313 OnData(audio_data, bits_per_sample, sample_rate, number_of_channels,
314 number_of_frames,
315 /*absolute_capture_timestamp_ms=*/absl::nullopt);
316 }
ossu7bb87ee2017-01-23 12:56:25317
Gustaf Ullberg46ea5d72020-12-15 14:12:16318 // AudioSinkInterface implementation.
319 int NumPreferredChannels() const override { return num_preferred_channels_; }
320
ossu7bb87ee2017-01-23 12:56:25321 // cricket::AudioSource implementation.
322 void SetSink(cricket::AudioSource::Sink* sink) override;
323
324 cricket::AudioSource::Sink* sink_;
Artem Titov880fa812021-07-30 20:30:23325 // Critical section protecting `sink_`.
Markus Handell6fcd0f82020-07-07 17:08:53326 Mutex lock_;
Gustaf Ullberg46ea5d72020-12-15 14:12:16327 int num_preferred_channels_ = -1;
ossu7bb87ee2017-01-23 12:56:25328};
329
Amit Hilbuchea7ef2a2019-02-19 23:20:21330class AudioRtpSender : public DtmfProviderInterface, public RtpSenderBase {
ossu7bb87ee2017-01-23 12:56:25331 public:
Steve Anton111fdfd2018-06-25 20:03:36332 // Construct an RtpSender for audio with the given sender ID.
333 // The sender is initialized with no track to send and no associated streams.
Amit Hilbuchea7ef2a2019-02-19 23:20:21334 // StatsCollector provided so that Add/RemoveLocalAudioTrack can be called
335 // at the appropriate times.
Artem Titov880fa812021-07-30 20:30:23336 // If `set_streams_observer` is not null, it is invoked when SetStreams()
337 // is called. `set_streams_observer` is not owned by this object. If not
Guido Urdaneta1ff16c82019-05-20 17:31:53338 // null, it must be valid at least until this sender becomes stopped.
339 static rtc::scoped_refptr<AudioRtpSender> Create(
340 rtc::Thread* worker_thread,
341 const std::string& id,
Henrik Boströmf7859892022-07-04 12:36:37342 LegacyStatsCollectorInterface* stats,
Guido Urdaneta1ff16c82019-05-20 17:31:53343 SetStreamsObserver* set_streams_observer);
ossu7bb87ee2017-01-23 12:56:25344 virtual ~AudioRtpSender();
345
deadbeef20cb0c12017-02-02 04:27:00346 // DtmfSenderProvider implementation.
347 bool CanInsertDtmf() override;
348 bool InsertDtmf(int code, int duration) override;
deadbeef20cb0c12017-02-02 04:27:00349
350 // ObserverInterface implementation.
ossu7bb87ee2017-01-23 12:56:25351 void OnChanged() override;
352
ossu7bb87ee2017-01-23 12:56:25353 cricket::MediaType media_type() const override {
354 return cricket::MEDIA_TYPE_AUDIO;
355 }
Amit Hilbuchea7ef2a2019-02-19 23:20:21356 std::string track_kind() const override {
357 return MediaStreamTrackInterface::kAudioKind;
358 }
ossu7bb87ee2017-01-23 12:56:25359
deadbeef20cb0c12017-02-02 04:27:00360 rtc::scoped_refptr<DtmfSenderInterface> GetDtmfSender() const override;
Philipp Hanckea1b4eb22022-11-04 13:45:23361 RTCError GenerateKeyFrame(const std::vector<std::string>& rids) override;
deadbeef20cb0c12017-02-02 04:27:00362
Amit Hilbuchea7ef2a2019-02-19 23:20:21363 protected:
364 AudioRtpSender(rtc::Thread* worker_thread,
365 const std::string& id,
Henrik Boströmf7859892022-07-04 12:36:37366 LegacyStatsCollectorInterface* legacy_stats,
Guido Urdaneta1ff16c82019-05-20 17:31:53367 SetStreamsObserver* set_streams_observer);
Benjamin Wrightd81ac952018-08-30 00:02:10368
Amit Hilbuchea7ef2a2019-02-19 23:20:21369 void SetSend() override;
370 void ClearSend() override;
Benjamin Wrightd81ac952018-08-30 00:02:10371
Amit Hilbuchea7ef2a2019-02-19 23:20:21372 // Hooks to allow custom logic when tracks are attached and detached.
373 void AttachTrack() override;
374 void DetachTrack() override;
375 void AddTrackToStats() override;
376 void RemoveTrackFromStats() override;
Amit Hilbuch2297d332019-02-19 20:49:22377
ossu7bb87ee2017-01-23 12:56:25378 private:
Amit Hilbuchea7ef2a2019-02-19 23:20:21379 cricket::VoiceMediaChannel* voice_media_channel() {
380 return static_cast<cricket::VoiceMediaChannel*>(media_channel_);
381 }
382 rtc::scoped_refptr<AudioTrackInterface> audio_track() const {
383 return rtc::scoped_refptr<AudioTrackInterface>(
384 static_cast<AudioTrackInterface*>(track_.get()));
385 }
deadbeef20cb0c12017-02-02 04:27:00386
Henrik Boströmf7859892022-07-04 12:36:37387 LegacyStatsCollectorInterface* legacy_stats_ = nullptr;
Fredrik Solenbergda2afbd2022-08-03 10:07:51388 rtc::scoped_refptr<DtmfSender> dtmf_sender_;
deadbeef20cb0c12017-02-02 04:27:00389 rtc::scoped_refptr<DtmfSenderInterface> dtmf_sender_proxy_;
ossu7bb87ee2017-01-23 12:56:25390 bool cached_track_enabled_ = false;
ossu7bb87ee2017-01-23 12:56:25391
Artem Titov880fa812021-07-30 20:30:23392 // Used to pass the data callback from the `track_` to the other end of
ossu7bb87ee2017-01-23 12:56:25393 // cricket::AudioSource.
394 std::unique_ptr<LocalAudioSinkAdapter> sink_adapter_;
395};
396
Amit Hilbuchea7ef2a2019-02-19 23:20:21397class VideoRtpSender : public RtpSenderBase {
ossu7bb87ee2017-01-23 12:56:25398 public:
Steve Anton111fdfd2018-06-25 20:03:36399 // Construct an RtpSender for video with the given sender ID.
400 // The sender is initialized with no track to send and no associated streams.
Artem Titov880fa812021-07-30 20:30:23401 // If `set_streams_observer` is not null, it is invoked when SetStreams()
402 // is called. `set_streams_observer` is not owned by this object. If not
Guido Urdaneta1ff16c82019-05-20 17:31:53403 // null, it must be valid at least until this sender becomes stopped.
404 static rtc::scoped_refptr<VideoRtpSender> Create(
405 rtc::Thread* worker_thread,
406 const std::string& id,
407 SetStreamsObserver* set_streams_observer);
ossu7bb87ee2017-01-23 12:56:25408 virtual ~VideoRtpSender();
409
410 // ObserverInterface implementation
411 void OnChanged() override;
412
ossu7bb87ee2017-01-23 12:56:25413 cricket::MediaType media_type() const override {
414 return cricket::MEDIA_TYPE_VIDEO;
415 }
Amit Hilbuchea7ef2a2019-02-19 23:20:21416 std::string track_kind() const override {
417 return MediaStreamTrackInterface::kVideoKind;
Florent Castelli892acf02018-10-01 20:47:20418 }
ossu7bb87ee2017-01-23 12:56:25419
deadbeef20cb0c12017-02-02 04:27:00420 rtc::scoped_refptr<DtmfSenderInterface> GetDtmfSender() const override;
Philipp Hanckea1b4eb22022-11-04 13:45:23421 RTCError GenerateKeyFrame(const std::vector<std::string>& rids) override;
deadbeef20cb0c12017-02-02 04:27:00422
Florent Castelli725ee242022-10-18 15:05:58423 RTCError CheckSVCParameters(const RtpParameters& parameters) override;
424
Amit Hilbuchea7ef2a2019-02-19 23:20:21425 protected:
Guido Urdaneta1ff16c82019-05-20 17:31:53426 VideoRtpSender(rtc::Thread* worker_thread,
427 const std::string& id,
428 SetStreamsObserver* set_streams_observer);
Benjamin Wrightd81ac952018-08-30 00:02:10429
Amit Hilbuchea7ef2a2019-02-19 23:20:21430 void SetSend() override;
431 void ClearSend() override;
Benjamin Wrightd81ac952018-08-30 00:02:10432
Amit Hilbuchea7ef2a2019-02-19 23:20:21433 // Hook to allow custom logic when tracks are attached.
434 void AttachTrack() override;
Amit Hilbuch2297d332019-02-19 20:49:22435
ossu7bb87ee2017-01-23 12:56:25436 private:
Amit Hilbuchea7ef2a2019-02-19 23:20:21437 cricket::VideoMediaChannel* video_media_channel() {
438 return static_cast<cricket::VideoMediaChannel*>(media_channel_);
439 }
440 rtc::scoped_refptr<VideoTrackInterface> video_track() const {
441 return rtc::scoped_refptr<VideoTrackInterface>(
442 static_cast<VideoTrackInterface*>(track_.get()));
443 }
ossu7bb87ee2017-01-23 12:56:25444
ossu7bb87ee2017-01-23 12:56:25445 VideoTrackInterface::ContentHint cached_track_content_hint_ =
446 VideoTrackInterface::ContentHint::kNone;
ossu7bb87ee2017-01-23 12:56:25447};
448
449} // namespace webrtc
450
Steve Anton10542f22019-01-11 17:11:00451#endif // PC_RTP_SENDER_H_