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