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

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: Make SetSource tolerate unknown ssrc and source == NULL. Created 4 years, 9 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // Attach to new track. 261 // Attach to new track.
262 bool prev_can_send_track = can_send_track(); 262 bool prev_can_send_track = can_send_track();
263 track_ = video_track; 263 track_ = video_track;
264 if (track_) { 264 if (track_) {
265 cached_track_enabled_ = track_->enabled(); 265 cached_track_enabled_ = track_->enabled();
266 track_->RegisterObserver(this); 266 track_->RegisterObserver(this);
267 } 267 }
268 268
269 // Update video provider. 269 // Update video provider.
270 if (can_send_track()) { 270 if (can_send_track()) {
271 // TODO(nisse): GetSource should return a VideoTrackSource, which
272 // implements rtc::VideoSourceInterface, and can be passed
273 // directly to SetSource.
271 VideoSourceInterface* source = track_->GetSource(); 274 VideoSourceInterface* source = track_->GetSource();
272 // TODO(deadbeef): If SetTrack is called with a disabled track, and the 275 // TODO(deadbeef): If SetTrack is called with a disabled track, and the
273 // previous track was enabled, this could cause a frame from the new track 276 // previous track was enabled, this could cause a frame from the new track
274 // to slip out. Really, what we need is for SetCaptureDevice and 277 // to slip out. Really, what we need is for SetCaptureDevice and
275 // SetVideoSend 278 // SetVideoSend
276 // to be combined into one atomic operation, all the way down to 279 // to be combined into one atomic operation, all the way down to
277 // WebRtcVideoSendStream. 280 // WebRtcVideoSendStream.
278 provider_->SetCaptureDevice(ssrc_, 281 provider_->SetSource(ssrc_,
279 source ? source->GetVideoCapturer() : nullptr); 282 source ? source->GetVideoCapturer() : nullptr);
280 SetVideoSend(); 283 SetVideoSend();
281 } else if (prev_can_send_track) { 284 } else if (prev_can_send_track) {
282 provider_->SetCaptureDevice(ssrc_, nullptr); 285 provider_->SetSource(ssrc_, nullptr);
283 provider_->SetVideoSend(ssrc_, false, nullptr); 286 provider_->SetVideoSend(ssrc_, false, nullptr);
284 } 287 }
285 return true; 288 return true;
286 } 289 }
287 290
288 void VideoRtpSender::SetSsrc(uint32_t ssrc) { 291 void VideoRtpSender::SetSsrc(uint32_t ssrc) {
289 if (stopped_ || ssrc == ssrc_) { 292 if (stopped_ || ssrc == ssrc_) {
290 return; 293 return;
291 } 294 }
292 // If we are already sending with a particular SSRC, stop sending. 295 // If we are already sending with a particular SSRC, stop sending.
293 if (can_send_track()) { 296 if (can_send_track()) {
294 provider_->SetCaptureDevice(ssrc_, nullptr); 297 provider_->SetSource(ssrc_, nullptr);
295 provider_->SetVideoSend(ssrc_, false, nullptr); 298 provider_->SetVideoSend(ssrc_, false, nullptr);
296 } 299 }
297 ssrc_ = ssrc; 300 ssrc_ = ssrc;
298 if (can_send_track()) { 301 if (can_send_track()) {
299 VideoSourceInterface* source = track_->GetSource(); 302 VideoSourceInterface* source = track_->GetSource();
300 provider_->SetCaptureDevice(ssrc_, 303 provider_->SetSource(ssrc_,
301 source ? source->GetVideoCapturer() : nullptr); 304 source ? source->GetVideoCapturer() : nullptr);
302 SetVideoSend(); 305 SetVideoSend();
303 } 306 }
304 } 307 }
305 308
306 void VideoRtpSender::Stop() { 309 void VideoRtpSender::Stop() {
307 // TODO(deadbeef): Need to do more here to fully stop sending packets. 310 // TODO(deadbeef): Need to do more here to fully stop sending packets.
308 if (stopped_) { 311 if (stopped_) {
309 return; 312 return;
310 } 313 }
311 if (track_) { 314 if (track_) {
312 track_->UnregisterObserver(this); 315 track_->UnregisterObserver(this);
313 } 316 }
314 if (can_send_track()) { 317 if (can_send_track()) {
315 provider_->SetCaptureDevice(ssrc_, nullptr); 318 provider_->SetSource(ssrc_, nullptr);
316 provider_->SetVideoSend(ssrc_, false, nullptr); 319 provider_->SetVideoSend(ssrc_, false, nullptr);
317 } 320 }
318 stopped_ = true; 321 stopped_ = true;
319 } 322 }
320 323
321 void VideoRtpSender::SetVideoSend() { 324 void VideoRtpSender::SetVideoSend() {
322 RTC_DCHECK(!stopped_ && can_send_track()); 325 RTC_DCHECK(!stopped_ && can_send_track());
323 const cricket::VideoOptions* options = nullptr; 326 const cricket::VideoOptions* options = nullptr;
324 VideoSourceInterface* source = track_->GetSource(); 327 VideoSourceInterface* source = track_->GetSource();
325 if (track_->enabled() && source) { 328 if (track_->enabled() && source) {
326 options = source->options(); 329 options = source->options();
327 } 330 }
328 provider_->SetVideoSend(ssrc_, track_->enabled(), options); 331 provider_->SetVideoSend(ssrc_, track_->enabled(), options);
329 } 332 }
330 333
331 } // namespace webrtc 334 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698