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

Side by Side Diff: talk/app/webrtc/rtpsender.cc

Issue 1631703002: Make WebRtcVideoChannel2::WebRtcVideoSendStream implement rtc::VideoRendererInterface. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix PropagatesInputFrameTimestamp and ProducesIncreasingTimestampsWithResetInputSources. Created 4 years, 10 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 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 LOG(LS_ERROR) << "SetTrack can't be called on a stopped RtpSender."; 261 LOG(LS_ERROR) << "SetTrack can't be called on a stopped RtpSender.";
262 return false; 262 return false;
263 } 263 }
264 if (track && track->kind() != MediaStreamTrackInterface::kVideoKind) { 264 if (track && track->kind() != MediaStreamTrackInterface::kVideoKind) {
265 LOG(LS_ERROR) << "SetTrack called on video RtpSender with " << track->kind() 265 LOG(LS_ERROR) << "SetTrack called on video RtpSender with " << track->kind()
266 << " track."; 266 << " track.";
267 return false; 267 return false;
268 } 268 }
269 VideoTrackInterface* video_track = static_cast<VideoTrackInterface*>(track); 269 VideoTrackInterface* video_track = static_cast<VideoTrackInterface*>(track);
270 270
271 // TODO(nisse): To make code a little simpler, ensure that
272 // GetSink(0) returns NULL, and that AddSink and RemoveSink with
273 // NULL is safe.
274 rtc::VideoSinkInterface<cricket::VideoFrame>* sink =
275 provider_->GetSink(ssrc_);
276
271 // Detach from old track. 277 // Detach from old track.
272 if (track_) { 278 if (track_) {
273 track_->UnregisterObserver(this); 279 track_->UnregisterObserver(this);
280 if (sink)
281 track_->RemoveSink(sink);
274 } 282 }
275 283
276 // Attach to new track. 284 // Attach to new track.
277 bool prev_can_send_track = can_send_track(); 285 bool prev_can_send_track = can_send_track();
278 track_ = video_track; 286 track_ = video_track;
279 if (track_) { 287 if (track_) {
280 cached_track_enabled_ = track_->enabled(); 288 cached_track_enabled_ = track_->enabled();
281 track_->RegisterObserver(this); 289 track_->RegisterObserver(this);
290 if (sink)
291 video_track->AddSink(sink);
282 } 292 }
283 293
284 // Update video provider. 294 // Update video provider.
285 if (can_send_track()) { 295 if (can_send_track()) {
286 VideoSourceInterface* source = track_->GetSource(); 296 VideoSourceInterface* source = track_->GetSource();
287 // TODO(deadbeef): If SetTrack is called with a disabled track, and the 297 // TODO(deadbeef): If SetTrack is called with a disabled track, and the
288 // previous track was enabled, this could cause a frame from the new track 298 // previous track was enabled, this could cause a frame from the new track
289 // to slip out. Really, what we need is for SetCaptureDevice and 299 // to slip out. Really, what we need is for SetCaptureDevice and
290 // SetVideoSend 300 // SetVideoSend
291 // to be combined into one atomic operation, all the way down to 301 // to be combined into one atomic operation, all the way down to
(...skipping 26 matching lines...) Expand all
318 } 328 }
319 } 329 }
320 330
321 void VideoRtpSender::Stop() { 331 void VideoRtpSender::Stop() {
322 // TODO(deadbeef): Need to do more here to fully stop sending packets. 332 // TODO(deadbeef): Need to do more here to fully stop sending packets.
323 if (stopped_) { 333 if (stopped_) {
324 return; 334 return;
325 } 335 }
326 if (track_) { 336 if (track_) {
327 track_->UnregisterObserver(this); 337 track_->UnregisterObserver(this);
338
339 rtc::VideoSinkInterface<cricket::VideoFrame>* sink =
340 provider_->GetSink(ssrc_);
341 if (sink)
342 track_->RemoveSink(sink);
343 else
344 LOG(LS_ERROR)
345 << "VideoRtpSender::Stop called with a NULL sink. Too late???";
perkj_webrtc 2016/01/26 15:40:56 Is there ever a case when this is fine? If not- I
nisse-webrtc 2016/01/28 08:24:53 I think track_->RemoveSink(nullptr) will succeed a
328 } 346 }
329 if (can_send_track()) { 347 if (can_send_track()) {
330 provider_->SetCaptureDevice(ssrc_, nullptr); 348 provider_->SetCaptureDevice(ssrc_, nullptr);
331 provider_->SetVideoSend(ssrc_, false, nullptr); 349 provider_->SetVideoSend(ssrc_, false, nullptr);
332 } 350 }
333 stopped_ = true; 351 stopped_ = true;
334 } 352 }
335 353
336 void VideoRtpSender::SetVideoSend() { 354 void VideoRtpSender::SetVideoSend() {
337 RTC_DCHECK(!stopped_ && can_send_track()); 355 RTC_DCHECK(!stopped_ && can_send_track());
338 const cricket::VideoOptions* options = nullptr; 356 const cricket::VideoOptions* options = nullptr;
339 VideoSourceInterface* source = track_->GetSource(); 357 VideoSourceInterface* source = track_->GetSource();
340 if (track_->enabled() && source) { 358 if (track_->enabled() && source) {
341 options = source->options(); 359 options = source->options();
342 } 360 }
343 provider_->SetVideoSend(ssrc_, track_->enabled(), options); 361 provider_->SetVideoSend(ssrc_, track_->enabled(), options);
344 } 362 }
345 363
346 } // namespace webrtc 364 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698