Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 rtc::VideoSinkInterface<cricket::VideoFrame>* sink = | |
| 272 provider_->GetSink(ssrc_); | |
| 273 | |
|
perkj_webrtc
2016/01/28 13:45:16
if sinkptr != null. DCHECK(sinkptr ==provider_->G
nisse-webrtc
2016/01/29 07:48:29
I'm not sure exactly what you mean, but I did some
| |
| 271 // Detach from old track. | 274 // Detach from old track. |
| 272 if (track_) { | 275 if (track_) { |
| 273 track_->UnregisterObserver(this); | 276 track_->UnregisterObserver(this); |
| 277 track_->RemoveSink(sink); | |
| 274 } | 278 } |
| 275 | 279 |
| 276 // Attach to new track. | 280 // Attach to new track. |
| 277 bool prev_can_send_track = can_send_track(); | 281 bool prev_can_send_track = can_send_track(); |
| 278 track_ = video_track; | 282 track_ = video_track; |
| 279 if (track_) { | 283 if (track_) { |
| 280 cached_track_enabled_ = track_->enabled(); | 284 cached_track_enabled_ = track_->enabled(); |
| 281 track_->RegisterObserver(this); | 285 track_->RegisterObserver(this); |
| 286 video_track->AddSink(sink); | |
| 282 } | 287 } |
| 283 | 288 |
| 284 // Update video provider. | 289 // Update video provider. |
| 285 if (can_send_track()) { | 290 if (can_send_track()) { |
| 286 VideoSourceInterface* source = track_->GetSource(); | 291 VideoSourceInterface* source = track_->GetSource(); |
| 287 // TODO(deadbeef): If SetTrack is called with a disabled track, and the | 292 // 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 | 293 // 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 | 294 // to slip out. Really, what we need is for SetCaptureDevice and |
| 290 // SetVideoSend | 295 // SetVideoSend |
| 291 // to be combined into one atomic operation, all the way down to | 296 // to be combined into one atomic operation, all the way down to |
| 292 // WebRtcVideoSendStream. | 297 // WebRtcVideoSendStream. |
| 293 provider_->SetCaptureDevice(ssrc_, | 298 provider_->SetCaptureDevice(ssrc_, |
| 294 source ? source->GetVideoCapturer() : nullptr); | 299 source ? source->GetVideoCapturer() : nullptr); |
|
perkj_webrtc
2016/01/28 13:45:16
AddSink here and store the sink in sinkptr.
When
| |
| 295 SetVideoSend(); | 300 SetVideoSend(); |
| 296 } else if (prev_can_send_track) { | 301 } else if (prev_can_send_track) { |
| 297 provider_->SetCaptureDevice(ssrc_, nullptr); | 302 provider_->SetCaptureDevice(ssrc_, nullptr); |
| 298 provider_->SetVideoSend(ssrc_, false, nullptr); | 303 provider_->SetVideoSend(ssrc_, false, nullptr); |
| 299 } | 304 } |
| 300 return true; | 305 return true; |
| 301 } | 306 } |
| 302 | 307 |
| 303 void VideoRtpSender::SetSsrc(uint32_t ssrc) { | 308 void VideoRtpSender::SetSsrc(uint32_t ssrc) { |
| 304 if (stopped_ || ssrc == ssrc_) { | 309 if (stopped_ || ssrc == ssrc_) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 318 } | 323 } |
| 319 } | 324 } |
| 320 | 325 |
| 321 void VideoRtpSender::Stop() { | 326 void VideoRtpSender::Stop() { |
| 322 // TODO(deadbeef): Need to do more here to fully stop sending packets. | 327 // TODO(deadbeef): Need to do more here to fully stop sending packets. |
| 323 if (stopped_) { | 328 if (stopped_) { |
| 324 return; | 329 return; |
| 325 } | 330 } |
| 326 if (track_) { | 331 if (track_) { |
| 327 track_->UnregisterObserver(this); | 332 track_->UnregisterObserver(this); |
| 333 | |
| 334 rtc::VideoSinkInterface<cricket::VideoFrame>* sink = | |
|
perkj_webrtc
2016/01/28 13:45:16
dito
| |
| 335 provider_->GetSink(ssrc_); | |
| 336 if (sink) | |
| 337 track_->RemoveSink(sink); | |
| 338 else | |
| 339 LOG(LS_ERROR) | |
| 340 << "VideoRtpSender::Stop called with a NULL sink. Too late???"; | |
| 328 } | 341 } |
| 329 if (can_send_track()) { | 342 if (can_send_track()) { |
| 330 provider_->SetCaptureDevice(ssrc_, nullptr); | 343 provider_->SetCaptureDevice(ssrc_, nullptr); |
| 331 provider_->SetVideoSend(ssrc_, false, nullptr); | 344 provider_->SetVideoSend(ssrc_, false, nullptr); |
| 332 } | 345 } |
| 333 stopped_ = true; | 346 stopped_ = true; |
| 334 } | 347 } |
| 335 | 348 |
| 336 void VideoRtpSender::SetVideoSend() { | 349 void VideoRtpSender::SetVideoSend() { |
| 337 RTC_DCHECK(!stopped_ && can_send_track()); | 350 RTC_DCHECK(!stopped_ && can_send_track()); |
| 338 const cricket::VideoOptions* options = nullptr; | 351 const cricket::VideoOptions* options = nullptr; |
| 339 VideoSourceInterface* source = track_->GetSource(); | 352 VideoSourceInterface* source = track_->GetSource(); |
| 340 if (track_->enabled() && source) { | 353 if (track_->enabled() && source) { |
| 341 options = source->options(); | 354 options = source->options(); |
| 342 } | 355 } |
| 343 provider_->SetVideoSend(ssrc_, track_->enabled(), options); | 356 provider_->SetVideoSend(ssrc_, track_->enabled(), options); |
| 344 } | 357 } |
| 345 | 358 |
| 346 } // namespace webrtc | 359 } // namespace webrtc |
| OLD | NEW |