Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: webrtc/api/rtpsender.cc

Issue 1838413002: Combining SetVideoSend and SetSource into one method. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 // Attach to new track. 269 // Attach to new track.
270 bool prev_can_send_track = can_send_track(); 270 bool prev_can_send_track = can_send_track();
271 track_ = video_track; 271 track_ = video_track;
272 if (track_) { 272 if (track_) {
273 cached_track_enabled_ = track_->enabled(); 273 cached_track_enabled_ = track_->enabled();
274 track_->RegisterObserver(this); 274 track_->RegisterObserver(this);
275 } 275 }
276 276
277 // Update video provider. 277 // Update video provider.
278 if (can_send_track()) { 278 if (can_send_track()) {
279 VideoTrackSourceInterface* source = track_->GetSource();
280 // TODO(deadbeef): If SetTrack is called with a disabled track, and the
281 // previous track was enabled, this could cause a frame from the new track
282 // to slip out. Really, what we need is for SetCaptureDevice and
283 // SetVideoSend
284 // to be combined into one atomic operation, all the way down to
285 // WebRtcVideoSendStream.
286 provider_->SetCaptureDevice(ssrc_,
287 source ? source->GetVideoCapturer() : nullptr);
288 SetVideoSend(); 279 SetVideoSend();
289 } else if (prev_can_send_track) { 280 } else if (prev_can_send_track) {
290 provider_->SetCaptureDevice(ssrc_, nullptr); 281 provider_->SetVideoSend(ssrc_, false, nullptr, nullptr);
291 provider_->SetVideoSend(ssrc_, false, nullptr);
292 } 282 }
293 return true; 283 return true;
294 } 284 }
295 285
296 void VideoRtpSender::SetSsrc(uint32_t ssrc) { 286 void VideoRtpSender::SetSsrc(uint32_t ssrc) {
297 if (stopped_ || ssrc == ssrc_) { 287 if (stopped_ || ssrc == ssrc_) {
298 return; 288 return;
299 } 289 }
300 // If we are already sending with a particular SSRC, stop sending. 290 // If we are already sending with a particular SSRC, stop sending.
301 if (can_send_track()) { 291 if (can_send_track()) {
302 provider_->SetCaptureDevice(ssrc_, nullptr); 292 provider_->SetVideoSend(ssrc_, false, nullptr, nullptr);
303 provider_->SetVideoSend(ssrc_, false, nullptr);
304 } 293 }
305 ssrc_ = ssrc; 294 ssrc_ = ssrc;
306 if (can_send_track()) { 295 if (can_send_track()) {
307 VideoTrackSourceInterface* source = track_->GetSource();
308 provider_->SetCaptureDevice(ssrc_,
309 source ? source->GetVideoCapturer() : nullptr);
310 SetVideoSend(); 296 SetVideoSend();
311 } 297 }
312 } 298 }
313 299
314 void VideoRtpSender::Stop() { 300 void VideoRtpSender::Stop() {
315 // TODO(deadbeef): Need to do more here to fully stop sending packets. 301 // TODO(deadbeef): Need to do more here to fully stop sending packets.
316 if (stopped_) { 302 if (stopped_) {
317 return; 303 return;
318 } 304 }
319 if (track_) { 305 if (track_) {
320 track_->UnregisterObserver(this); 306 track_->UnregisterObserver(this);
321 } 307 }
322 if (can_send_track()) { 308 if (can_send_track()) {
323 provider_->SetCaptureDevice(ssrc_, nullptr); 309 provider_->SetVideoSend(ssrc_, false, nullptr, nullptr);
324 provider_->SetVideoSend(ssrc_, false, nullptr);
325 } 310 }
326 stopped_ = true; 311 stopped_ = true;
327 } 312 }
328 313
329 void VideoRtpSender::SetVideoSend() { 314 void VideoRtpSender::SetVideoSend() {
330 RTC_DCHECK(!stopped_ && can_send_track()); 315 RTC_DCHECK(!stopped_ && can_send_track());
331 cricket::VideoOptions options; 316 cricket::VideoOptions options;
332 VideoTrackSourceInterface* source = track_->GetSource(); 317 VideoTrackSourceInterface* source = track_->GetSource();
333 if (source) { 318 if (source) {
334 options.is_screencast = rtc::Optional<bool>(source->is_screencast()); 319 options.is_screencast = rtc::Optional<bool>(source->is_screencast());
335 options.video_noise_reduction = 320 options.video_noise_reduction =
336 rtc::Optional<bool>(source->needs_denoising()); 321 rtc::Optional<bool>(source->needs_denoising());
337 } 322 }
338 provider_->SetVideoSend(ssrc_, track_->enabled(), &options); 323 provider_->SetVideoSend(ssrc_, track_->enabled(), &options,
324 source ? source->GetVideoCapturer() : nullptr);
339 } 325 }
340 326
341 RtpParameters VideoRtpSender::GetParameters() const { 327 RtpParameters VideoRtpSender::GetParameters() const {
342 return provider_->GetVideoRtpParameters(ssrc_); 328 return provider_->GetVideoRtpParameters(ssrc_);
343 } 329 }
344 330
345 bool VideoRtpSender::SetParameters(const RtpParameters& parameters) { 331 bool VideoRtpSender::SetParameters(const RtpParameters& parameters) {
346 return provider_->SetVideoRtpParameters(ssrc_, parameters); 332 return provider_->SetVideoRtpParameters(ssrc_, parameters);
347 } 333 }
348 334
349 } // namespace webrtc 335 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698