OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 for (size_t i = 0; i < next_frame_types_.size(); ++i) { | 335 for (size_t i = 0; i < next_frame_types_.size(); ++i) { |
336 // Check for equality (same requested as before encoding) to not | 336 // Check for equality (same requested as before encoding) to not |
337 // accidentally drop a keyframe request while encoding. | 337 // accidentally drop a keyframe request while encoding. |
338 if (next_frame_types[i] == next_frame_types_[i]) | 338 if (next_frame_types[i] == next_frame_types_[i]) |
339 next_frame_types_[i] = kVideoFrameDelta; | 339 next_frame_types_[i] = kVideoFrameDelta; |
340 } | 340 } |
341 } | 341 } |
342 return VCM_OK; | 342 return VCM_OK; |
343 } | 343 } |
344 | 344 |
345 int32_t VideoSender::IntraFrameRequest(int stream_index) { | 345 int32_t VideoSender::IntraFrameRequest(size_t stream_index) { |
346 { | 346 { |
347 rtc::CritScope lock(¶ms_crit_); | 347 rtc::CritScope lock(¶ms_crit_); |
348 if (stream_index < 0 || | 348 if (stream_index >= next_frame_types_.size()) { |
349 static_cast<size_t>(stream_index) >= next_frame_types_.size()) { | |
350 return -1; | 349 return -1; |
351 } | 350 } |
352 next_frame_types_[stream_index] = kVideoFrameKey; | 351 next_frame_types_[stream_index] = kVideoFrameKey; |
353 if (!encoder_has_internal_source_) | 352 if (!encoder_has_internal_source_) |
354 return VCM_OK; | 353 return VCM_OK; |
355 } | 354 } |
356 // TODO(pbos): Remove when InternalSource() is gone. Both locks have to be | 355 // TODO(pbos): Remove when InternalSource() is gone. Both locks have to be |
357 // held here for internal consistency, since _encoder could be removed while | 356 // held here for internal consistency, since _encoder could be removed while |
358 // not holding encoder_crit_. Checks have to be performed again since | 357 // not holding encoder_crit_. Checks have to be performed again since |
359 // params_crit_ was dropped to not cause lock-order inversions with | 358 // params_crit_ was dropped to not cause lock-order inversions with |
360 // encoder_crit_. | 359 // encoder_crit_. |
361 rtc::CritScope lock(&encoder_crit_); | 360 rtc::CritScope lock(&encoder_crit_); |
362 rtc::CritScope params_lock(¶ms_crit_); | 361 rtc::CritScope params_lock(¶ms_crit_); |
363 if (static_cast<size_t>(stream_index) >= next_frame_types_.size()) | 362 if (stream_index >= next_frame_types_.size()) |
364 return -1; | 363 return -1; |
365 if (_encoder != nullptr && _encoder->InternalSource()) { | 364 if (_encoder != nullptr && _encoder->InternalSource()) { |
366 // Try to request the frame if we have an external encoder with | 365 // Try to request the frame if we have an external encoder with |
367 // internal source since AddVideoFrame never will be called. | 366 // internal source since AddVideoFrame never will be called. |
368 if (_encoder->RequestFrame(next_frame_types_) == WEBRTC_VIDEO_CODEC_OK) { | 367 if (_encoder->RequestFrame(next_frame_types_) == WEBRTC_VIDEO_CODEC_OK) { |
369 // Try to remove just-performed keyframe request, if stream still exists. | 368 // Try to remove just-performed keyframe request, if stream still exists. |
370 next_frame_types_[stream_index] = kVideoFrameDelta; | 369 next_frame_types_[stream_index] = kVideoFrameDelta; |
371 } | 370 } |
372 } | 371 } |
373 return VCM_OK; | 372 return VCM_OK; |
(...skipping 18 matching lines...) Expand all Loading... |
392 // 10 kbps. | 391 // 10 kbps. |
393 int window_bps = std::max(threshold_bps / 10, 10000); | 392 int window_bps = std::max(threshold_bps / 10, 10000); |
394 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps); | 393 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps); |
395 } | 394 } |
396 | 395 |
397 bool VideoSender::VideoSuspended() const { | 396 bool VideoSender::VideoSuspended() const { |
398 return _mediaOpt.IsVideoSuspended(); | 397 return _mediaOpt.IsVideoSuspended(); |
399 } | 398 } |
400 } // namespace vcm | 399 } // namespace vcm |
401 } // namespace webrtc | 400 } // namespace webrtc |
OLD | NEW |