| OLD | NEW | 
|---|
| 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 273   VideoTrackInterface* video_track = static_cast<VideoTrackInterface*>(track); | 273   VideoTrackInterface* video_track = static_cast<VideoTrackInterface*>(track); | 
| 274 | 274 | 
| 275   // Detach from old track. | 275   // Detach from old track. | 
| 276   if (track_) { | 276   if (track_) { | 
| 277     track_->UnregisterObserver(this); | 277     track_->UnregisterObserver(this); | 
| 278   } | 278   } | 
| 279 | 279 | 
| 280   // Attach to new track. | 280   // Attach to new track. | 
| 281   bool prev_can_send_track = can_send_track(); | 281   bool prev_can_send_track = can_send_track(); | 
| 282   // Keep a reference to the old track to keep it alive until we call | 282   // Keep a reference to the old track to keep it alive until we call | 
| 283   // SetSource. | 283   // SetVideoSend. | 
| 284   rtc::scoped_refptr<VideoTrackInterface> old_track = track_; | 284   rtc::scoped_refptr<VideoTrackInterface> old_track = track_; | 
| 285   track_ = video_track; | 285   track_ = video_track; | 
| 286   if (track_) { | 286   if (track_) { | 
| 287     cached_track_enabled_ = track_->enabled(); | 287     cached_track_enabled_ = track_->enabled(); | 
| 288     track_->RegisterObserver(this); | 288     track_->RegisterObserver(this); | 
| 289   } | 289   } | 
| 290 | 290 | 
| 291   // Update video provider. | 291   // Update video provider. | 
| 292   if (can_send_track()) { | 292   if (can_send_track()) { | 
| 293     // TODO(deadbeef): If SetTrack is called with a disabled track, and the |  | 
| 294     // previous track was enabled, this could cause a frame from the new track |  | 
| 295     // to slip out. Really, what we need is for SetSource and SetVideoSend |  | 
| 296     // to be combined into one atomic operation, all the way down to |  | 
| 297     // WebRtcVideoSendStream. |  | 
| 298 |  | 
| 299     provider_->SetSource(ssrc_, track_); |  | 
| 300     SetVideoSend(); | 293     SetVideoSend(); | 
| 301   } else if (prev_can_send_track) { | 294   } else if (prev_can_send_track) { | 
| 302     provider_->SetSource(ssrc_, nullptr); | 295     provider_->SetVideoSend(ssrc_, false, nullptr, nullptr); | 
| 303     provider_->SetVideoSend(ssrc_, false, nullptr); |  | 
| 304   } | 296   } | 
| 305   return true; | 297   return true; | 
| 306 } | 298 } | 
| 307 | 299 | 
| 308 void VideoRtpSender::SetSsrc(uint32_t ssrc) { | 300 void VideoRtpSender::SetSsrc(uint32_t ssrc) { | 
| 309   TRACE_EVENT0("webrtc", "VideoRtpSender::SetSsrc"); | 301   TRACE_EVENT0("webrtc", "VideoRtpSender::SetSsrc"); | 
| 310   if (stopped_ || ssrc == ssrc_) { | 302   if (stopped_ || ssrc == ssrc_) { | 
| 311     return; | 303     return; | 
| 312   } | 304   } | 
| 313   // If we are already sending with a particular SSRC, stop sending. | 305   // If we are already sending with a particular SSRC, stop sending. | 
| 314   if (can_send_track()) { | 306   if (can_send_track()) { | 
| 315     provider_->SetSource(ssrc_, nullptr); | 307     provider_->SetVideoSend(ssrc_, false, nullptr, nullptr); | 
| 316     provider_->SetVideoSend(ssrc_, false, nullptr); |  | 
| 317   } | 308   } | 
| 318   ssrc_ = ssrc; | 309   ssrc_ = ssrc; | 
| 319   if (can_send_track()) { | 310   if (can_send_track()) { | 
| 320     provider_->SetSource(ssrc_, track_); |  | 
| 321     SetVideoSend(); | 311     SetVideoSend(); | 
| 322   } | 312   } | 
| 323 } | 313 } | 
| 324 | 314 | 
| 325 void VideoRtpSender::Stop() { | 315 void VideoRtpSender::Stop() { | 
| 326   TRACE_EVENT0("webrtc", "VideoRtpSender::Stop"); | 316   TRACE_EVENT0("webrtc", "VideoRtpSender::Stop"); | 
| 327   // TODO(deadbeef): Need to do more here to fully stop sending packets. | 317   // TODO(deadbeef): Need to do more here to fully stop sending packets. | 
| 328   if (stopped_) { | 318   if (stopped_) { | 
| 329     return; | 319     return; | 
| 330   } | 320   } | 
| 331   if (track_) { | 321   if (track_) { | 
| 332     track_->UnregisterObserver(this); | 322     track_->UnregisterObserver(this); | 
| 333   } | 323   } | 
| 334   if (can_send_track()) { | 324   if (can_send_track()) { | 
| 335     provider_->SetSource(ssrc_, nullptr); | 325     provider_->SetVideoSend(ssrc_, false, nullptr, nullptr); | 
| 336     provider_->SetVideoSend(ssrc_, false, nullptr); |  | 
| 337   } | 326   } | 
| 338   stopped_ = true; | 327   stopped_ = true; | 
| 339 } | 328 } | 
| 340 | 329 | 
| 341 void VideoRtpSender::SetVideoSend() { | 330 void VideoRtpSender::SetVideoSend() { | 
| 342   RTC_DCHECK(!stopped_ && can_send_track()); | 331   RTC_DCHECK(!stopped_ && can_send_track()); | 
| 343   cricket::VideoOptions options; | 332   cricket::VideoOptions options; | 
| 344   VideoTrackSourceInterface* source = track_->GetSource(); | 333   VideoTrackSourceInterface* source = track_->GetSource(); | 
| 345   if (source) { | 334   if (source) { | 
| 346     options.is_screencast = rtc::Optional<bool>(source->is_screencast()); | 335     options.is_screencast = rtc::Optional<bool>(source->is_screencast()); | 
| 347     options.video_noise_reduction = source->needs_denoising(); | 336     options.video_noise_reduction = source->needs_denoising(); | 
| 348   } | 337   } | 
| 349   provider_->SetVideoSend(ssrc_, track_->enabled(), &options); | 338   provider_->SetVideoSend(ssrc_, track_->enabled(), &options, track_); | 
| 350 } | 339 } | 
| 351 | 340 | 
| 352 RtpParameters VideoRtpSender::GetParameters() const { | 341 RtpParameters VideoRtpSender::GetParameters() const { | 
| 353   return provider_->GetVideoRtpParameters(ssrc_); | 342   return provider_->GetVideoRtpParameters(ssrc_); | 
| 354 } | 343 } | 
| 355 | 344 | 
| 356 bool VideoRtpSender::SetParameters(const RtpParameters& parameters) { | 345 bool VideoRtpSender::SetParameters(const RtpParameters& parameters) { | 
| 357   TRACE_EVENT0("webrtc", "VideoRtpSender::SetParameters"); | 346   TRACE_EVENT0("webrtc", "VideoRtpSender::SetParameters"); | 
| 358   return provider_->SetVideoRtpParameters(ssrc_, parameters); | 347   return provider_->SetVideoRtpParameters(ssrc_, parameters); | 
| 359 } | 348 } | 
| 360 | 349 | 
| 361 }  // namespace webrtc | 350 }  // namespace webrtc | 
| OLD | NEW | 
|---|