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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
pbos-webrtc
2016/03/31 14:14:31
Can this fit on one line now?
nisse-webrtc
2016/04/01 09:35:39
Done.
| |
283 // SetVideoSend | 282 // SetVideoSend |
284 // to be combined into one atomic operation, all the way down to | 283 // to be combined into one atomic operation, all the way down to |
285 // WebRtcVideoSendStream. | 284 // WebRtcVideoSendStream. |
286 provider_->SetCaptureDevice(ssrc_, | 285 |
287 source ? source->GetVideoCapturer() : nullptr); | 286 provider_->SetSource(ssrc_, track_); |
288 SetVideoSend(); | 287 SetVideoSend(); |
289 } else if (prev_can_send_track) { | 288 } else if (prev_can_send_track) { |
290 provider_->SetCaptureDevice(ssrc_, nullptr); | 289 provider_->SetSource(ssrc_, nullptr); |
291 provider_->SetVideoSend(ssrc_, false, nullptr); | 290 provider_->SetVideoSend(ssrc_, false, nullptr); |
292 } | 291 } |
293 return true; | 292 return true; |
294 } | 293 } |
295 | 294 |
296 void VideoRtpSender::SetSsrc(uint32_t ssrc) { | 295 void VideoRtpSender::SetSsrc(uint32_t ssrc) { |
297 if (stopped_ || ssrc == ssrc_) { | 296 if (stopped_ || ssrc == ssrc_) { |
298 return; | 297 return; |
299 } | 298 } |
300 // If we are already sending with a particular SSRC, stop sending. | 299 // If we are already sending with a particular SSRC, stop sending. |
301 if (can_send_track()) { | 300 if (can_send_track()) { |
302 provider_->SetCaptureDevice(ssrc_, nullptr); | 301 provider_->SetSource(ssrc_, nullptr); |
303 provider_->SetVideoSend(ssrc_, false, nullptr); | 302 provider_->SetVideoSend(ssrc_, false, nullptr); |
304 } | 303 } |
305 ssrc_ = ssrc; | 304 ssrc_ = ssrc; |
306 if (can_send_track()) { | 305 if (can_send_track()) { |
307 VideoTrackSourceInterface* source = track_->GetSource(); | 306 provider_->SetSource(ssrc_, track_); |
308 provider_->SetCaptureDevice(ssrc_, | |
309 source ? source->GetVideoCapturer() : nullptr); | |
310 SetVideoSend(); | 307 SetVideoSend(); |
311 } | 308 } |
312 } | 309 } |
313 | 310 |
314 void VideoRtpSender::Stop() { | 311 void VideoRtpSender::Stop() { |
315 // TODO(deadbeef): Need to do more here to fully stop sending packets. | 312 // TODO(deadbeef): Need to do more here to fully stop sending packets. |
316 if (stopped_) { | 313 if (stopped_) { |
317 return; | 314 return; |
318 } | 315 } |
319 if (track_) { | 316 if (track_) { |
320 track_->UnregisterObserver(this); | 317 track_->UnregisterObserver(this); |
321 } | 318 } |
322 if (can_send_track()) { | 319 if (can_send_track()) { |
323 provider_->SetCaptureDevice(ssrc_, nullptr); | 320 provider_->SetSource(ssrc_, nullptr); |
324 provider_->SetVideoSend(ssrc_, false, nullptr); | 321 provider_->SetVideoSend(ssrc_, false, nullptr); |
325 } | 322 } |
326 stopped_ = true; | 323 stopped_ = true; |
327 } | 324 } |
328 | 325 |
329 void VideoRtpSender::SetVideoSend() { | 326 void VideoRtpSender::SetVideoSend() { |
330 RTC_DCHECK(!stopped_ && can_send_track()); | 327 RTC_DCHECK(!stopped_ && can_send_track()); |
331 cricket::VideoOptions options; | 328 cricket::VideoOptions options; |
332 VideoTrackSourceInterface* source = track_->GetSource(); | 329 VideoTrackSourceInterface* source = track_->GetSource(); |
333 if (source) { | 330 if (source) { |
334 options.is_screencast = rtc::Optional<bool>(source->is_screencast()); | 331 options.is_screencast = rtc::Optional<bool>(source->is_screencast()); |
335 options.video_noise_reduction = | 332 options.video_noise_reduction = |
336 rtc::Optional<bool>(source->needs_denoising()); | 333 rtc::Optional<bool>(source->needs_denoising()); |
337 } | 334 } |
338 provider_->SetVideoSend(ssrc_, track_->enabled(), &options); | 335 provider_->SetVideoSend(ssrc_, track_->enabled(), &options); |
339 } | 336 } |
340 | 337 |
341 RtpParameters VideoRtpSender::GetParameters() const { | 338 RtpParameters VideoRtpSender::GetParameters() const { |
342 return provider_->GetVideoRtpParameters(ssrc_); | 339 return provider_->GetVideoRtpParameters(ssrc_); |
343 } | 340 } |
344 | 341 |
345 bool VideoRtpSender::SetParameters(const RtpParameters& parameters) { | 342 bool VideoRtpSender::SetParameters(const RtpParameters& parameters) { |
346 return provider_->SetVideoRtpParameters(ssrc_, parameters); | 343 return provider_->SetVideoRtpParameters(ssrc_, parameters); |
347 } | 344 } |
348 | 345 |
349 } // namespace webrtc | 346 } // namespace webrtc |
OLD | NEW |