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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 VideoRtpSender::VideoRtpSender(VideoTrackInterface* track, | 239 VideoRtpSender::VideoRtpSender(VideoTrackInterface* track, |
240 const std::string& stream_id, | 240 const std::string& stream_id, |
241 cricket::VideoChannel* channel) | 241 cricket::VideoChannel* channel) |
242 : id_(track->id()), | 242 : id_(track->id()), |
243 stream_id_(stream_id), | 243 stream_id_(stream_id), |
244 channel_(channel), | 244 channel_(channel), |
245 track_(track), | 245 track_(track), |
246 cached_track_enabled_(track->enabled()) { | 246 cached_track_enabled_(track->enabled()), |
| 247 cached_track_content_hint_(track->content_hint()) { |
247 track_->RegisterObserver(this); | 248 track_->RegisterObserver(this); |
248 } | 249 } |
249 | 250 |
250 VideoRtpSender::VideoRtpSender(VideoTrackInterface* track, | 251 VideoRtpSender::VideoRtpSender(VideoTrackInterface* track, |
251 cricket::VideoChannel* channel) | 252 cricket::VideoChannel* channel) |
252 : id_(track->id()), | 253 : id_(track->id()), |
253 stream_id_(rtc::CreateRandomUuid()), | 254 stream_id_(rtc::CreateRandomUuid()), |
254 channel_(channel), | 255 channel_(channel), |
255 track_(track), | 256 track_(track), |
256 cached_track_enabled_(track->enabled()) { | 257 cached_track_enabled_(track->enabled()), |
| 258 cached_track_content_hint_(track->content_hint()) { |
257 track_->RegisterObserver(this); | 259 track_->RegisterObserver(this); |
258 } | 260 } |
259 | 261 |
260 VideoRtpSender::VideoRtpSender(cricket::VideoChannel* channel) | 262 VideoRtpSender::VideoRtpSender(cricket::VideoChannel* channel) |
261 : id_(rtc::CreateRandomUuid()), | 263 : id_(rtc::CreateRandomUuid()), |
262 stream_id_(rtc::CreateRandomUuid()), | 264 stream_id_(rtc::CreateRandomUuid()), |
263 channel_(channel) {} | 265 channel_(channel) {} |
264 | 266 |
265 VideoRtpSender::~VideoRtpSender() { | 267 VideoRtpSender::~VideoRtpSender() { |
266 Stop(); | 268 Stop(); |
267 } | 269 } |
268 | 270 |
269 void VideoRtpSender::OnChanged() { | 271 void VideoRtpSender::OnChanged() { |
270 TRACE_EVENT0("webrtc", "VideoRtpSender::OnChanged"); | 272 TRACE_EVENT0("webrtc", "VideoRtpSender::OnChanged"); |
271 RTC_DCHECK(!stopped_); | 273 RTC_DCHECK(!stopped_); |
272 if (cached_track_enabled_ != track_->enabled()) { | 274 if (cached_track_enabled_ != track_->enabled() || |
| 275 cached_track_content_hint_ != track_->content_hint()) { |
273 cached_track_enabled_ = track_->enabled(); | 276 cached_track_enabled_ = track_->enabled(); |
| 277 cached_track_content_hint_ = track_->content_hint(); |
274 if (can_send_track()) { | 278 if (can_send_track()) { |
275 SetVideoSend(); | 279 SetVideoSend(); |
276 } | 280 } |
277 } | 281 } |
278 } | 282 } |
279 | 283 |
280 bool VideoRtpSender::SetTrack(MediaStreamTrackInterface* track) { | 284 bool VideoRtpSender::SetTrack(MediaStreamTrackInterface* track) { |
281 TRACE_EVENT0("webrtc", "VideoRtpSender::SetTrack"); | 285 TRACE_EVENT0("webrtc", "VideoRtpSender::SetTrack"); |
282 if (stopped_) { | 286 if (stopped_) { |
283 LOG(LS_ERROR) << "SetTrack can't be called on a stopped RtpSender."; | 287 LOG(LS_ERROR) << "SetTrack can't be called on a stopped RtpSender."; |
(...skipping 12 matching lines...) Expand all Loading... |
296 } | 300 } |
297 | 301 |
298 // Attach to new track. | 302 // Attach to new track. |
299 bool prev_can_send_track = can_send_track(); | 303 bool prev_can_send_track = can_send_track(); |
300 // Keep a reference to the old track to keep it alive until we call | 304 // Keep a reference to the old track to keep it alive until we call |
301 // SetVideoSend. | 305 // SetVideoSend. |
302 rtc::scoped_refptr<VideoTrackInterface> old_track = track_; | 306 rtc::scoped_refptr<VideoTrackInterface> old_track = track_; |
303 track_ = video_track; | 307 track_ = video_track; |
304 if (track_) { | 308 if (track_) { |
305 cached_track_enabled_ = track_->enabled(); | 309 cached_track_enabled_ = track_->enabled(); |
| 310 cached_track_content_hint_ = track_->content_hint(); |
306 track_->RegisterObserver(this); | 311 track_->RegisterObserver(this); |
307 } | 312 } |
308 | 313 |
309 // Update video channel. | 314 // Update video channel. |
310 if (can_send_track()) { | 315 if (can_send_track()) { |
311 SetVideoSend(); | 316 SetVideoSend(); |
312 } else if (prev_can_send_track) { | 317 } else if (prev_can_send_track) { |
313 ClearVideoSend(); | 318 ClearVideoSend(); |
314 } | 319 } |
315 return true; | 320 return true; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 if (!channel_) { | 370 if (!channel_) { |
366 LOG(LS_ERROR) << "SetVideoSend: No video channel exists."; | 371 LOG(LS_ERROR) << "SetVideoSend: No video channel exists."; |
367 return; | 372 return; |
368 } | 373 } |
369 cricket::VideoOptions options; | 374 cricket::VideoOptions options; |
370 VideoTrackSourceInterface* source = track_->GetSource(); | 375 VideoTrackSourceInterface* source = track_->GetSource(); |
371 if (source) { | 376 if (source) { |
372 options.is_screencast = rtc::Optional<bool>(source->is_screencast()); | 377 options.is_screencast = rtc::Optional<bool>(source->is_screencast()); |
373 options.video_noise_reduction = source->needs_denoising(); | 378 options.video_noise_reduction = source->needs_denoising(); |
374 } | 379 } |
| 380 switch (cached_track_content_hint_) { |
| 381 case VideoTrackInterface::ContentHint::kNone: |
| 382 break; |
| 383 case VideoTrackInterface::ContentHint::kFluid: |
| 384 options.is_screencast = rtc::Optional<bool>(false); |
| 385 break; |
| 386 case VideoTrackInterface::ContentHint::kDetailed: |
| 387 options.is_screencast = rtc::Optional<bool>(true); |
| 388 break; |
| 389 } |
375 if (!channel_->SetVideoSend(ssrc_, track_->enabled(), &options, track_)) { | 390 if (!channel_->SetVideoSend(ssrc_, track_->enabled(), &options, track_)) { |
376 RTC_DCHECK(false); | 391 RTC_DCHECK(false); |
377 } | 392 } |
378 } | 393 } |
379 | 394 |
380 void VideoRtpSender::ClearVideoSend() { | 395 void VideoRtpSender::ClearVideoSend() { |
381 RTC_DCHECK(ssrc_ != 0); | 396 RTC_DCHECK(ssrc_ != 0); |
382 RTC_DCHECK(!stopped_); | 397 RTC_DCHECK(!stopped_); |
383 if (!channel_) { | 398 if (!channel_) { |
384 LOG(LS_WARNING) << "SetVideoSend: No video channel exists."; | 399 LOG(LS_WARNING) << "SetVideoSend: No video channel exists."; |
385 return; | 400 return; |
386 } | 401 } |
387 // Allow SetVideoSend to fail since |enable| is false and |source| is null. | 402 // Allow SetVideoSend to fail since |enable| is false and |source| is null. |
388 // This the normal case when the underlying media channel has already been | 403 // This the normal case when the underlying media channel has already been |
389 // deleted. | 404 // deleted. |
390 channel_->SetVideoSend(ssrc_, false, nullptr, nullptr); | 405 channel_->SetVideoSend(ssrc_, false, nullptr, nullptr); |
391 } | 406 } |
392 | 407 |
393 } // namespace webrtc | 408 } // namespace webrtc |
OLD | NEW |