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

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

Issue 1766653002: Replace SetCapturer and SetCaptureDevice by SetSource. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased, no longer any proxy object changes. 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
« no previous file with comments | « webrtc/api/objc/RTCAVFoundationVideoSource.mm ('k') | webrtc/api/rtpsenderreceiver_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 279 // 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 280 // 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 281 // to slip out. Really, what we need is for SetSource and SetVideoSend
283 // SetVideoSend
284 // to be combined into one atomic operation, all the way down to 282 // to be combined into one atomic operation, all the way down to
285 // WebRtcVideoSendStream. 283 // WebRtcVideoSendStream.
286 provider_->SetCaptureDevice(ssrc_, 284
287 source ? source->GetVideoCapturer() : nullptr); 285 provider_->SetSource(ssrc_, track_);
288 SetVideoSend(); 286 SetVideoSend();
289 } else if (prev_can_send_track) { 287 } else if (prev_can_send_track) {
290 provider_->SetCaptureDevice(ssrc_, nullptr); 288 provider_->SetSource(ssrc_, nullptr);
291 provider_->SetVideoSend(ssrc_, false, nullptr); 289 provider_->SetVideoSend(ssrc_, false, nullptr);
292 } 290 }
293 return true; 291 return true;
294 } 292 }
295 293
296 void VideoRtpSender::SetSsrc(uint32_t ssrc) { 294 void VideoRtpSender::SetSsrc(uint32_t ssrc) {
297 if (stopped_ || ssrc == ssrc_) { 295 if (stopped_ || ssrc == ssrc_) {
298 return; 296 return;
299 } 297 }
300 // If we are already sending with a particular SSRC, stop sending. 298 // If we are already sending with a particular SSRC, stop sending.
301 if (can_send_track()) { 299 if (can_send_track()) {
302 provider_->SetCaptureDevice(ssrc_, nullptr); 300 provider_->SetSource(ssrc_, nullptr);
303 provider_->SetVideoSend(ssrc_, false, nullptr); 301 provider_->SetVideoSend(ssrc_, false, nullptr);
304 } 302 }
305 ssrc_ = ssrc; 303 ssrc_ = ssrc;
306 if (can_send_track()) { 304 if (can_send_track()) {
307 VideoTrackSourceInterface* source = track_->GetSource(); 305 provider_->SetSource(ssrc_, track_);
308 provider_->SetCaptureDevice(ssrc_,
309 source ? source->GetVideoCapturer() : nullptr);
310 SetVideoSend(); 306 SetVideoSend();
311 } 307 }
312 } 308 }
313 309
314 void VideoRtpSender::Stop() { 310 void VideoRtpSender::Stop() {
315 // TODO(deadbeef): Need to do more here to fully stop sending packets. 311 // TODO(deadbeef): Need to do more here to fully stop sending packets.
316 if (stopped_) { 312 if (stopped_) {
317 return; 313 return;
318 } 314 }
319 if (track_) { 315 if (track_) {
320 track_->UnregisterObserver(this); 316 track_->UnregisterObserver(this);
321 } 317 }
322 if (can_send_track()) { 318 if (can_send_track()) {
323 provider_->SetCaptureDevice(ssrc_, nullptr); 319 provider_->SetSource(ssrc_, nullptr);
324 provider_->SetVideoSend(ssrc_, false, nullptr); 320 provider_->SetVideoSend(ssrc_, false, nullptr);
325 } 321 }
326 stopped_ = true; 322 stopped_ = true;
327 } 323 }
328 324
329 void VideoRtpSender::SetVideoSend() { 325 void VideoRtpSender::SetVideoSend() {
330 RTC_DCHECK(!stopped_ && can_send_track()); 326 RTC_DCHECK(!stopped_ && can_send_track());
331 cricket::VideoOptions options; 327 cricket::VideoOptions options;
332 VideoTrackSourceInterface* source = track_->GetSource(); 328 VideoTrackSourceInterface* source = track_->GetSource();
333 if (source) { 329 if (source) {
334 options.is_screencast = rtc::Optional<bool>(source->is_screencast()); 330 options.is_screencast = rtc::Optional<bool>(source->is_screencast());
335 options.video_noise_reduction = source->needs_denoising(); 331 options.video_noise_reduction = source->needs_denoising();
336 } 332 }
337 provider_->SetVideoSend(ssrc_, track_->enabled(), &options); 333 provider_->SetVideoSend(ssrc_, track_->enabled(), &options);
338 } 334 }
339 335
340 RtpParameters VideoRtpSender::GetParameters() const { 336 RtpParameters VideoRtpSender::GetParameters() const {
341 return provider_->GetVideoRtpParameters(ssrc_); 337 return provider_->GetVideoRtpParameters(ssrc_);
342 } 338 }
343 339
344 bool VideoRtpSender::SetParameters(const RtpParameters& parameters) { 340 bool VideoRtpSender::SetParameters(const RtpParameters& parameters) {
345 return provider_->SetVideoRtpParameters(ssrc_, parameters); 341 return provider_->SetVideoRtpParameters(ssrc_, parameters);
346 } 342 }
347 343
348 } // namespace webrtc 344 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/objc/RTCAVFoundationVideoSource.mm ('k') | webrtc/api/rtpsenderreceiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698