deadbeef | 6979b02 | 2015-09-24 16:47:53 -0700 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
deadbeef | 6979b02 | 2015-09-24 16:47:53 -0700 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 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. |
deadbeef | 6979b02 | 2015-09-24 16:47:53 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "pc/rtpsender.h" |
deadbeef | 6979b02 | 2015-09-24 16:47:53 -0700 | [diff] [blame] | 12 | |
Steve Anton | 36b29d1 | 2017-10-30 09:57:42 -0700 | [diff] [blame] | 13 | #include <vector> |
| 14 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 15 | #include "api/mediastreaminterface.h" |
| 16 | #include "pc/localaudiosource.h" |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 17 | #include "pc/statscollector.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "rtc_base/checks.h" |
| 19 | #include "rtc_base/helpers.h" |
| 20 | #include "rtc_base/trace_event.h" |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
Harald Alvestrand | c72af93 | 2018-01-11 17:18:19 +0100 | [diff] [blame] | 24 | namespace { |
| 25 | |
| 26 | // This function is only expected to be called on the signalling thread. |
| 27 | int GenerateUniqueId() { |
| 28 | static int g_unique_id = 0; |
| 29 | |
| 30 | return ++g_unique_id; |
| 31 | } |
| 32 | |
Seth Hampson | 2d2c888 | 2018-05-16 16:02:32 -0700 | [diff] [blame] | 33 | // Returns an true if any RtpEncodingParameters member that isn't implemented |
| 34 | // contains a value. |
| 35 | bool UnimplementedRtpEncodingParameterHasValue( |
| 36 | const RtpEncodingParameters& encoding_params) { |
| 37 | if (encoding_params.codec_payload_type.has_value() || |
| 38 | encoding_params.fec.has_value() || encoding_params.rtx.has_value() || |
| 39 | encoding_params.dtx.has_value() || encoding_params.ptime.has_value() || |
| 40 | encoding_params.max_framerate.has_value() || |
| 41 | !encoding_params.rid.empty() || |
| 42 | encoding_params.scale_resolution_down_by.has_value() || |
| 43 | encoding_params.scale_framerate_down_by.has_value() || |
| 44 | !encoding_params.dependency_rids.empty()) { |
| 45 | return true; |
| 46 | } |
| 47 | return false; |
| 48 | } |
| 49 | |
| 50 | // Returns true if a "per-sender" encoding parameter contains a value that isn't |
| 51 | // its default. Currently max_bitrate_bps and bitrate_priority both are |
| 52 | // implemented "per-sender," meaning that these encoding parameters |
| 53 | // are used for the RtpSender as a whole, not for a specific encoding layer. |
| 54 | // This is done by setting these encoding parameters at index 0 of |
| 55 | // RtpParameters.encodings. This function can be used to check if these |
| 56 | // parameters are set at any index other than 0 of RtpParameters.encodings, |
| 57 | // because they are currently unimplemented to be used for a specific encoding |
| 58 | // layer. |
| 59 | bool PerSenderRtpEncodingParameterHasValue( |
| 60 | const RtpEncodingParameters& encoding_params) { |
Åsa Persson | 5565981 | 2018-06-18 17:51:32 +0200 | [diff] [blame] | 61 | if (encoding_params.bitrate_priority != kDefaultBitratePriority) { |
Seth Hampson | 2d2c888 | 2018-05-16 16:02:32 -0700 | [diff] [blame] | 62 | return true; |
| 63 | } |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | // Returns true if any RtpParameters member that isn't implemented contains a |
| 68 | // value. |
| 69 | bool UnimplementedRtpParameterHasValue(const RtpParameters& parameters) { |
Florent Castelli | 87b3c51 | 2018-07-18 16:00:28 +0200 | [diff] [blame^] | 70 | if (!parameters.mid.empty()) { |
Seth Hampson | 2d2c888 | 2018-05-16 16:02:32 -0700 | [diff] [blame] | 71 | return true; |
| 72 | } |
| 73 | for (size_t i = 0; i < parameters.encodings.size(); ++i) { |
| 74 | if (UnimplementedRtpEncodingParameterHasValue(parameters.encodings[i])) { |
| 75 | return true; |
| 76 | } |
| 77 | // Encoding parameters that are per-sender should only contain value at |
| 78 | // index 0. |
| 79 | if (i != 0 && |
| 80 | PerSenderRtpEncodingParameterHasValue(parameters.encodings[i])) { |
| 81 | return true; |
| 82 | } |
| 83 | } |
| 84 | return false; |
| 85 | } |
| 86 | |
Harald Alvestrand | c72af93 | 2018-01-11 17:18:19 +0100 | [diff] [blame] | 87 | } // namespace |
| 88 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 89 | LocalAudioSinkAdapter::LocalAudioSinkAdapter() : sink_(nullptr) {} |
| 90 | |
| 91 | LocalAudioSinkAdapter::~LocalAudioSinkAdapter() { |
| 92 | rtc::CritScope lock(&lock_); |
| 93 | if (sink_) |
| 94 | sink_->OnClose(); |
| 95 | } |
| 96 | |
| 97 | void LocalAudioSinkAdapter::OnData(const void* audio_data, |
| 98 | int bits_per_sample, |
| 99 | int sample_rate, |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 100 | size_t number_of_channels, |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 101 | size_t number_of_frames) { |
| 102 | rtc::CritScope lock(&lock_); |
| 103 | if (sink_) { |
| 104 | sink_->OnData(audio_data, bits_per_sample, sample_rate, number_of_channels, |
| 105 | number_of_frames); |
| 106 | } |
| 107 | } |
| 108 | |
Taylor Brandstetter | 1a018dc | 2016-03-08 12:37:39 -0800 | [diff] [blame] | 109 | void LocalAudioSinkAdapter::SetSink(cricket::AudioSource::Sink* sink) { |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 110 | rtc::CritScope lock(&lock_); |
nisse | ede5da4 | 2017-01-12 05:15:36 -0800 | [diff] [blame] | 111 | RTC_DCHECK(!sink || !sink_); |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 112 | sink_ = sink; |
| 113 | } |
| 114 | |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 115 | AudioRtpSender::AudioRtpSender(rtc::Thread* worker_thread, |
Steve Anton | 111fdfd | 2018-06-25 13:03:36 -0700 | [diff] [blame] | 116 | const std::string& id, |
deadbeef | e1f9d83 | 2016-01-14 15:35:42 -0800 | [diff] [blame] | 117 | StatsCollector* stats) |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 118 | : worker_thread_(worker_thread), |
Steve Anton | 111fdfd | 2018-06-25 13:03:36 -0700 | [diff] [blame] | 119 | id_(id), |
deadbeef | e1f9d83 | 2016-01-14 15:35:42 -0800 | [diff] [blame] | 120 | stats_(stats), |
Steve Anton | 02ee47c | 2018-01-10 16:26:06 -0800 | [diff] [blame] | 121 | dtmf_sender_proxy_(DtmfSenderProxy::Create( |
| 122 | rtc::Thread::Current(), |
Steve Anton | b983bae | 2018-06-20 11:16:53 -0700 | [diff] [blame] | 123 | DtmfSender::Create(rtc::Thread::Current(), this))), |
Steve Anton | 111fdfd | 2018-06-25 13:03:36 -0700 | [diff] [blame] | 124 | sink_adapter_(new LocalAudioSinkAdapter()) { |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 125 | RTC_DCHECK(worker_thread); |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 126 | } |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 127 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 128 | AudioRtpSender::~AudioRtpSender() { |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 129 | // For DtmfSender. |
| 130 | SignalDestroyed(); |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 131 | Stop(); |
| 132 | } |
| 133 | |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 134 | bool AudioRtpSender::CanInsertDtmf() { |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 135 | if (!media_channel_) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 136 | RTC_LOG(LS_ERROR) << "CanInsertDtmf: No audio channel exists."; |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 137 | return false; |
| 138 | } |
| 139 | // Check that this RTP sender is active (description has been applied that |
| 140 | // matches an SSRC to its ID). |
| 141 | if (!ssrc_) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 142 | RTC_LOG(LS_ERROR) << "CanInsertDtmf: Sender does not have SSRC."; |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 143 | return false; |
| 144 | } |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 145 | return worker_thread_->Invoke<bool>( |
| 146 | RTC_FROM_HERE, [&] { return media_channel_->CanInsertDtmf(); }); |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | bool AudioRtpSender::InsertDtmf(int code, int duration) { |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 150 | if (!media_channel_) { |
Jonas Olsson | 45cc890 | 2018-02-13 10:37:07 +0100 | [diff] [blame] | 151 | RTC_LOG(LS_ERROR) << "InsertDtmf: No audio channel exists."; |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 152 | return false; |
| 153 | } |
| 154 | if (!ssrc_) { |
Jonas Olsson | 45cc890 | 2018-02-13 10:37:07 +0100 | [diff] [blame] | 155 | RTC_LOG(LS_ERROR) << "InsertDtmf: Sender does not have SSRC."; |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 156 | return false; |
| 157 | } |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 158 | bool success = worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] { |
| 159 | return media_channel_->InsertDtmf(ssrc_, code, duration); |
| 160 | }); |
| 161 | if (!success) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 162 | RTC_LOG(LS_ERROR) << "Failed to insert DTMF to channel."; |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 163 | } |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 164 | return success; |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | sigslot::signal0<>* AudioRtpSender::GetOnDestroyedSignal() { |
| 168 | return &SignalDestroyed; |
| 169 | } |
| 170 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 171 | void AudioRtpSender::OnChanged() { |
Peter Boström | dabc944 | 2016-04-11 11:45:14 +0200 | [diff] [blame] | 172 | TRACE_EVENT0("webrtc", "AudioRtpSender::OnChanged"); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 173 | RTC_DCHECK(!stopped_); |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 174 | if (cached_track_enabled_ != track_->enabled()) { |
| 175 | cached_track_enabled_ = track_->enabled(); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 176 | if (can_send_track()) { |
| 177 | SetAudioSend(); |
| 178 | } |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 179 | } |
| 180 | } |
| 181 | |
| 182 | bool AudioRtpSender::SetTrack(MediaStreamTrackInterface* track) { |
Peter Boström | dabc944 | 2016-04-11 11:45:14 +0200 | [diff] [blame] | 183 | TRACE_EVENT0("webrtc", "AudioRtpSender::SetTrack"); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 184 | if (stopped_) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 185 | RTC_LOG(LS_ERROR) << "SetTrack can't be called on a stopped RtpSender."; |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 186 | return false; |
| 187 | } |
| 188 | if (track && track->kind() != MediaStreamTrackInterface::kAudioKind) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 189 | RTC_LOG(LS_ERROR) << "SetTrack called on audio RtpSender with " |
| 190 | << track->kind() << " track."; |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 191 | return false; |
| 192 | } |
| 193 | AudioTrackInterface* audio_track = static_cast<AudioTrackInterface*>(track); |
| 194 | |
| 195 | // Detach from old track. |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 196 | if (track_) { |
| 197 | track_->RemoveSink(sink_adapter_.get()); |
| 198 | track_->UnregisterObserver(this); |
| 199 | } |
| 200 | |
| 201 | if (can_send_track() && stats_) { |
| 202 | stats_->RemoveLocalAudioTrack(track_.get(), ssrc_); |
| 203 | } |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 204 | |
| 205 | // Attach to new track. |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 206 | bool prev_can_send_track = can_send_track(); |
deadbeef | 5dd42fd | 2016-05-02 16:20:01 -0700 | [diff] [blame] | 207 | // Keep a reference to the old track to keep it alive until we call |
| 208 | // SetAudioSend. |
| 209 | rtc::scoped_refptr<AudioTrackInterface> old_track = track_; |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 210 | track_ = audio_track; |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 211 | if (track_) { |
| 212 | cached_track_enabled_ = track_->enabled(); |
| 213 | track_->RegisterObserver(this); |
| 214 | track_->AddSink(sink_adapter_.get()); |
| 215 | } |
| 216 | |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 217 | // Update audio channel. |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 218 | if (can_send_track()) { |
| 219 | SetAudioSend(); |
| 220 | if (stats_) { |
| 221 | stats_->AddLocalAudioTrack(track_.get(), ssrc_); |
| 222 | } |
| 223 | } else if (prev_can_send_track) { |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 224 | ClearAudioSend(); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 225 | } |
Steve Anton | 111fdfd | 2018-06-25 13:03:36 -0700 | [diff] [blame] | 226 | attachment_id_ = (track_ ? GenerateUniqueId() : 0); |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 227 | return true; |
| 228 | } |
| 229 | |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 230 | RtpParameters AudioRtpSender::GetParameters() { |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 231 | if (!media_channel_ || stopped_) { |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 232 | return RtpParameters(); |
| 233 | } |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 234 | return worker_thread_->Invoke<RtpParameters>(RTC_FROM_HERE, [&] { |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 235 | RtpParameters result = media_channel_->GetRtpSendParameters(ssrc_); |
| 236 | last_transaction_id_ = rtc::CreateRandomUuid(); |
| 237 | result.transaction_id = last_transaction_id_.value(); |
| 238 | return result; |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 239 | }); |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Zach Stein | ba37b4b | 2018-01-23 15:02:36 -0800 | [diff] [blame] | 242 | RTCError AudioRtpSender::SetParameters(const RtpParameters& parameters) { |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 243 | TRACE_EVENT0("webrtc", "AudioRtpSender::SetParameters"); |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 244 | if (!media_channel_ || stopped_) { |
Zach Stein | ba37b4b | 2018-01-23 15:02:36 -0800 | [diff] [blame] | 245 | return RTCError(RTCErrorType::INVALID_STATE); |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 246 | } |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 247 | if (!last_transaction_id_) { |
| 248 | LOG_AND_RETURN_ERROR( |
| 249 | RTCErrorType::INVALID_STATE, |
| 250 | "Failed to set parameters since getParameters() has never been called" |
| 251 | " on this sender"); |
| 252 | } |
| 253 | if (last_transaction_id_ != parameters.transaction_id) { |
| 254 | LOG_AND_RETURN_ERROR( |
| 255 | RTCErrorType::INVALID_MODIFICATION, |
| 256 | "Failed to set parameters since the transaction_id doesn't match" |
| 257 | " the last value returned from getParameters()"); |
| 258 | } |
| 259 | |
Seth Hampson | 2d2c888 | 2018-05-16 16:02:32 -0700 | [diff] [blame] | 260 | if (UnimplementedRtpParameterHasValue(parameters)) { |
| 261 | LOG_AND_RETURN_ERROR( |
| 262 | RTCErrorType::UNSUPPORTED_PARAMETER, |
| 263 | "Attempted to set an unimplemented parameter of RtpParameters."); |
| 264 | } |
Zach Stein | ba37b4b | 2018-01-23 15:02:36 -0800 | [diff] [blame] | 265 | return worker_thread_->Invoke<RTCError>(RTC_FROM_HERE, [&] { |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 266 | RTCError result = media_channel_->SetRtpSendParameters(ssrc_, parameters); |
| 267 | last_transaction_id_.reset(); |
| 268 | return result; |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 269 | }); |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 270 | } |
| 271 | |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 272 | rtc::scoped_refptr<DtmfSenderInterface> AudioRtpSender::GetDtmfSender() const { |
| 273 | return dtmf_sender_proxy_; |
| 274 | } |
| 275 | |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 276 | void AudioRtpSender::SetSsrc(uint32_t ssrc) { |
Peter Boström | dabc944 | 2016-04-11 11:45:14 +0200 | [diff] [blame] | 277 | TRACE_EVENT0("webrtc", "AudioRtpSender::SetSsrc"); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 278 | if (stopped_ || ssrc == ssrc_) { |
| 279 | return; |
| 280 | } |
| 281 | // If we are already sending with a particular SSRC, stop sending. |
| 282 | if (can_send_track()) { |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 283 | ClearAudioSend(); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 284 | if (stats_) { |
| 285 | stats_->RemoveLocalAudioTrack(track_.get(), ssrc_); |
| 286 | } |
| 287 | } |
| 288 | ssrc_ = ssrc; |
| 289 | if (can_send_track()) { |
| 290 | SetAudioSend(); |
| 291 | if (stats_) { |
| 292 | stats_->AddLocalAudioTrack(track_.get(), ssrc_); |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 297 | void AudioRtpSender::Stop() { |
Peter Boström | dabc944 | 2016-04-11 11:45:14 +0200 | [diff] [blame] | 298 | TRACE_EVENT0("webrtc", "AudioRtpSender::Stop"); |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 299 | // TODO(deadbeef): Need to do more here to fully stop sending packets. |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 300 | if (stopped_) { |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 301 | return; |
| 302 | } |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 303 | if (track_) { |
| 304 | track_->RemoveSink(sink_adapter_.get()); |
| 305 | track_->UnregisterObserver(this); |
| 306 | } |
| 307 | if (can_send_track()) { |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 308 | ClearAudioSend(); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 309 | if (stats_) { |
| 310 | stats_->RemoveLocalAudioTrack(track_.get(), ssrc_); |
| 311 | } |
| 312 | } |
Harald Alvestrand | 3d976f6 | 2018-03-19 19:05:06 +0100 | [diff] [blame] | 313 | media_channel_ = nullptr; |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 314 | stopped_ = true; |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 315 | } |
| 316 | |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 317 | void AudioRtpSender::SetAudioSend() { |
kwiberg | ee89e78 | 2017-08-09 17:22:01 -0700 | [diff] [blame] | 318 | RTC_DCHECK(!stopped_); |
| 319 | RTC_DCHECK(can_send_track()); |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 320 | if (!media_channel_) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 321 | RTC_LOG(LS_ERROR) << "SetAudioSend: No audio channel exists."; |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 322 | return; |
| 323 | } |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 324 | cricket::AudioOptions options; |
agouaillard | b11fb25 | 2017-02-03 06:37:05 -0800 | [diff] [blame] | 325 | #if !defined(WEBRTC_CHROMIUM_BUILD) && !defined(WEBRTC_WEBKIT_BUILD) |
Tommi | 3c16978 | 2016-01-21 16:12:17 +0100 | [diff] [blame] | 326 | // TODO(tommi): Remove this hack when we move CreateAudioSource out of |
| 327 | // PeerConnection. This is a bit of a strange way to apply local audio |
| 328 | // options since it is also applied to all streams/channels, local or remote. |
tommi | 6eca7e3 | 2015-12-15 04:27:11 -0800 | [diff] [blame] | 329 | if (track_->enabled() && track_->GetSource() && |
| 330 | !track_->GetSource()->remote()) { |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 331 | // TODO(xians): Remove this static_cast since we should be able to connect |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 332 | // a remote audio track to a peer connection. |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 333 | options = static_cast<LocalAudioSource*>(track_->GetSource())->options(); |
| 334 | } |
Tommi | 3c16978 | 2016-01-21 16:12:17 +0100 | [diff] [blame] | 335 | #endif |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 336 | |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 337 | // |track_->enabled()| hops to the signaling thread, so call it before we hop |
| 338 | // to the worker thread or else it will deadlock. |
| 339 | bool track_enabled = track_->enabled(); |
| 340 | bool success = worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] { |
| 341 | return media_channel_->SetAudioSend(ssrc_, track_enabled, &options, |
| 342 | sink_adapter_.get()); |
| 343 | }); |
| 344 | if (!success) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 345 | RTC_LOG(LS_ERROR) << "SetAudioSend: ssrc is incorrect: " << ssrc_; |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 346 | } |
| 347 | } |
| 348 | |
| 349 | void AudioRtpSender::ClearAudioSend() { |
| 350 | RTC_DCHECK(ssrc_ != 0); |
| 351 | RTC_DCHECK(!stopped_); |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 352 | if (!media_channel_) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 353 | RTC_LOG(LS_WARNING) << "ClearAudioSend: No audio channel exists."; |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 354 | return; |
| 355 | } |
| 356 | cricket::AudioOptions options; |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 357 | bool success = worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] { |
| 358 | return media_channel_->SetAudioSend(ssrc_, false, &options, nullptr); |
| 359 | }); |
| 360 | if (!success) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 361 | RTC_LOG(LS_WARNING) << "ClearAudioSend: ssrc is incorrect: " << ssrc_; |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 362 | } |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 363 | } |
| 364 | |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 365 | VideoRtpSender::VideoRtpSender(rtc::Thread* worker_thread, |
Steve Anton | 111fdfd | 2018-06-25 13:03:36 -0700 | [diff] [blame] | 366 | const std::string& id) |
| 367 | : worker_thread_(worker_thread), id_(id) { |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 368 | RTC_DCHECK(worker_thread); |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 369 | } |
| 370 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 371 | VideoRtpSender::~VideoRtpSender() { |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 372 | Stop(); |
| 373 | } |
| 374 | |
| 375 | void VideoRtpSender::OnChanged() { |
Peter Boström | dabc944 | 2016-04-11 11:45:14 +0200 | [diff] [blame] | 376 | TRACE_EVENT0("webrtc", "VideoRtpSender::OnChanged"); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 377 | RTC_DCHECK(!stopped_); |
Niels Möller | ff40b14 | 2018-04-09 08:49:14 +0200 | [diff] [blame] | 378 | if (cached_track_content_hint_ != track_->content_hint()) { |
pbos | 5214a0a | 2016-12-16 15:39:11 -0800 | [diff] [blame] | 379 | cached_track_content_hint_ = track_->content_hint(); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 380 | if (can_send_track()) { |
| 381 | SetVideoSend(); |
| 382 | } |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 383 | } |
| 384 | } |
| 385 | |
| 386 | bool VideoRtpSender::SetTrack(MediaStreamTrackInterface* track) { |
Peter Boström | dabc944 | 2016-04-11 11:45:14 +0200 | [diff] [blame] | 387 | TRACE_EVENT0("webrtc", "VideoRtpSender::SetTrack"); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 388 | if (stopped_) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 389 | RTC_LOG(LS_ERROR) << "SetTrack can't be called on a stopped RtpSender."; |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 390 | return false; |
| 391 | } |
| 392 | if (track && track->kind() != MediaStreamTrackInterface::kVideoKind) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 393 | RTC_LOG(LS_ERROR) << "SetTrack called on video RtpSender with " |
| 394 | << track->kind() << " track."; |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 395 | return false; |
| 396 | } |
| 397 | VideoTrackInterface* video_track = static_cast<VideoTrackInterface*>(track); |
| 398 | |
| 399 | // Detach from old track. |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 400 | if (track_) { |
| 401 | track_->UnregisterObserver(this); |
| 402 | } |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 403 | |
| 404 | // Attach to new track. |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 405 | bool prev_can_send_track = can_send_track(); |
deadbeef | 5dd42fd | 2016-05-02 16:20:01 -0700 | [diff] [blame] | 406 | // Keep a reference to the old track to keep it alive until we call |
deadbeef | 5a4a75a | 2016-06-02 16:23:38 -0700 | [diff] [blame] | 407 | // SetVideoSend. |
deadbeef | 5dd42fd | 2016-05-02 16:20:01 -0700 | [diff] [blame] | 408 | rtc::scoped_refptr<VideoTrackInterface> old_track = track_; |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 409 | track_ = video_track; |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 410 | if (track_) { |
pbos | 5214a0a | 2016-12-16 15:39:11 -0800 | [diff] [blame] | 411 | cached_track_content_hint_ = track_->content_hint(); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 412 | track_->RegisterObserver(this); |
| 413 | } |
| 414 | |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 415 | // Update video channel. |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 416 | if (can_send_track()) { |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 417 | SetVideoSend(); |
| 418 | } else if (prev_can_send_track) { |
deadbeef | 5a4a75a | 2016-06-02 16:23:38 -0700 | [diff] [blame] | 419 | ClearVideoSend(); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 420 | } |
Steve Anton | 111fdfd | 2018-06-25 13:03:36 -0700 | [diff] [blame] | 421 | attachment_id_ = (track_ ? GenerateUniqueId() : 0); |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 422 | return true; |
| 423 | } |
| 424 | |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 425 | RtpParameters VideoRtpSender::GetParameters() { |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 426 | if (!media_channel_ || stopped_) { |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 427 | return RtpParameters(); |
| 428 | } |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 429 | return worker_thread_->Invoke<RtpParameters>(RTC_FROM_HERE, [&] { |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 430 | RtpParameters result = media_channel_->GetRtpSendParameters(ssrc_); |
| 431 | last_transaction_id_ = rtc::CreateRandomUuid(); |
| 432 | result.transaction_id = last_transaction_id_.value(); |
| 433 | return result; |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 434 | }); |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 435 | } |
| 436 | |
Zach Stein | ba37b4b | 2018-01-23 15:02:36 -0800 | [diff] [blame] | 437 | RTCError VideoRtpSender::SetParameters(const RtpParameters& parameters) { |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 438 | TRACE_EVENT0("webrtc", "VideoRtpSender::SetParameters"); |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 439 | if (!media_channel_ || stopped_) { |
Zach Stein | ba37b4b | 2018-01-23 15:02:36 -0800 | [diff] [blame] | 440 | return RTCError(RTCErrorType::INVALID_STATE); |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 441 | } |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 442 | if (!last_transaction_id_) { |
| 443 | LOG_AND_RETURN_ERROR( |
| 444 | RTCErrorType::INVALID_STATE, |
| 445 | "Failed to set parameters since getParameters() has never been called" |
| 446 | " on this sender"); |
| 447 | } |
| 448 | if (last_transaction_id_ != parameters.transaction_id) { |
| 449 | LOG_AND_RETURN_ERROR( |
| 450 | RTCErrorType::INVALID_MODIFICATION, |
| 451 | "Failed to set parameters since the transaction_id doesn't match" |
| 452 | " the last value returned from getParameters()"); |
| 453 | } |
| 454 | |
Seth Hampson | 2d2c888 | 2018-05-16 16:02:32 -0700 | [diff] [blame] | 455 | if (UnimplementedRtpParameterHasValue(parameters)) { |
| 456 | LOG_AND_RETURN_ERROR( |
| 457 | RTCErrorType::UNSUPPORTED_PARAMETER, |
| 458 | "Attempted to set an unimplemented parameter of RtpParameters."); |
| 459 | } |
Zach Stein | ba37b4b | 2018-01-23 15:02:36 -0800 | [diff] [blame] | 460 | return worker_thread_->Invoke<RTCError>(RTC_FROM_HERE, [&] { |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 461 | RTCError result = media_channel_->SetRtpSendParameters(ssrc_, parameters); |
| 462 | last_transaction_id_.reset(); |
| 463 | return result; |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 464 | }); |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 465 | } |
| 466 | |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 467 | rtc::scoped_refptr<DtmfSenderInterface> VideoRtpSender::GetDtmfSender() const { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 468 | RTC_LOG(LS_ERROR) << "Tried to get DTMF sender from video sender."; |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 469 | return nullptr; |
| 470 | } |
| 471 | |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 472 | void VideoRtpSender::SetSsrc(uint32_t ssrc) { |
Peter Boström | dabc944 | 2016-04-11 11:45:14 +0200 | [diff] [blame] | 473 | TRACE_EVENT0("webrtc", "VideoRtpSender::SetSsrc"); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 474 | if (stopped_ || ssrc == ssrc_) { |
| 475 | return; |
| 476 | } |
| 477 | // If we are already sending with a particular SSRC, stop sending. |
| 478 | if (can_send_track()) { |
deadbeef | 5a4a75a | 2016-06-02 16:23:38 -0700 | [diff] [blame] | 479 | ClearVideoSend(); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 480 | } |
| 481 | ssrc_ = ssrc; |
| 482 | if (can_send_track()) { |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 483 | SetVideoSend(); |
| 484 | } |
| 485 | } |
| 486 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 487 | void VideoRtpSender::Stop() { |
Peter Boström | dabc944 | 2016-04-11 11:45:14 +0200 | [diff] [blame] | 488 | TRACE_EVENT0("webrtc", "VideoRtpSender::Stop"); |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 489 | // TODO(deadbeef): Need to do more here to fully stop sending packets. |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 490 | if (stopped_) { |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 491 | return; |
| 492 | } |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 493 | if (track_) { |
| 494 | track_->UnregisterObserver(this); |
| 495 | } |
| 496 | if (can_send_track()) { |
deadbeef | 5a4a75a | 2016-06-02 16:23:38 -0700 | [diff] [blame] | 497 | ClearVideoSend(); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 498 | } |
Harald Alvestrand | 3d976f6 | 2018-03-19 19:05:06 +0100 | [diff] [blame] | 499 | media_channel_ = nullptr; |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 500 | stopped_ = true; |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 501 | } |
| 502 | |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 503 | void VideoRtpSender::SetVideoSend() { |
kwiberg | ee89e78 | 2017-08-09 17:22:01 -0700 | [diff] [blame] | 504 | RTC_DCHECK(!stopped_); |
| 505 | RTC_DCHECK(can_send_track()); |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 506 | if (!media_channel_) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 507 | RTC_LOG(LS_ERROR) << "SetVideoSend: No video channel exists."; |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 508 | return; |
| 509 | } |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 510 | cricket::VideoOptions options; |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 511 | VideoTrackSourceInterface* source = track_->GetSource(); |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 512 | if (source) { |
Oskar Sundbom | 36f8f3e | 2017-11-16 10:54:27 +0100 | [diff] [blame] | 513 | options.is_screencast = source->is_screencast(); |
Per | c0d31e9 | 2016-03-31 17:23:39 +0200 | [diff] [blame] | 514 | options.video_noise_reduction = source->needs_denoising(); |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 515 | } |
pbos | 5214a0a | 2016-12-16 15:39:11 -0800 | [diff] [blame] | 516 | switch (cached_track_content_hint_) { |
| 517 | case VideoTrackInterface::ContentHint::kNone: |
| 518 | break; |
| 519 | case VideoTrackInterface::ContentHint::kFluid: |
Oskar Sundbom | 36f8f3e | 2017-11-16 10:54:27 +0100 | [diff] [blame] | 520 | options.is_screencast = false; |
pbos | 5214a0a | 2016-12-16 15:39:11 -0800 | [diff] [blame] | 521 | break; |
| 522 | case VideoTrackInterface::ContentHint::kDetailed: |
Harald Alvestrand | c19ab07 | 2018-06-18 08:53:10 +0200 | [diff] [blame] | 523 | case VideoTrackInterface::ContentHint::kText: |
Oskar Sundbom | 36f8f3e | 2017-11-16 10:54:27 +0100 | [diff] [blame] | 524 | options.is_screencast = true; |
pbos | 5214a0a | 2016-12-16 15:39:11 -0800 | [diff] [blame] | 525 | break; |
| 526 | } |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 527 | bool success = worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] { |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 528 | return media_channel_->SetVideoSend(ssrc_, &options, track_); |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 529 | }); |
| 530 | RTC_DCHECK(success); |
deadbeef | 5a4a75a | 2016-06-02 16:23:38 -0700 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | void VideoRtpSender::ClearVideoSend() { |
| 534 | RTC_DCHECK(ssrc_ != 0); |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 535 | RTC_DCHECK(!stopped_); |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 536 | if (!media_channel_) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 537 | RTC_LOG(LS_WARNING) << "SetVideoSend: No video channel exists."; |
Taylor Brandstetter | ba29c6a | 2016-06-27 16:30:35 -0700 | [diff] [blame] | 538 | return; |
| 539 | } |
| 540 | // Allow SetVideoSend to fail since |enable| is false and |source| is null. |
| 541 | // This the normal case when the underlying media channel has already been |
| 542 | // deleted. |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 543 | worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] { |
Niels Möller | ff40b14 | 2018-04-09 08:49:14 +0200 | [diff] [blame] | 544 | return media_channel_->SetVideoSend(ssrc_, nullptr, nullptr); |
Steve Anton | 47136dd | 2018-01-12 10:49:35 -0800 | [diff] [blame] | 545 | }); |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | } // namespace webrtc |