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 19 matching lines...) Expand all Loading... |
30 VideoSender::VideoSender(Clock* clock, | 30 VideoSender::VideoSender(Clock* clock, |
31 EncodedImageCallback* post_encode_callback, | 31 EncodedImageCallback* post_encode_callback, |
32 VCMSendStatisticsCallback* send_stats_callback) | 32 VCMSendStatisticsCallback* send_stats_callback) |
33 : clock_(clock), | 33 : clock_(clock), |
34 _encoder(nullptr), | 34 _encoder(nullptr), |
35 _mediaOpt(clock_), | 35 _mediaOpt(clock_), |
36 _encodedFrameCallback(post_encode_callback, &_mediaOpt), | 36 _encodedFrameCallback(post_encode_callback, &_mediaOpt), |
37 send_stats_callback_(send_stats_callback), | 37 send_stats_callback_(send_stats_callback), |
38 _codecDataBase(&_encodedFrameCallback), | 38 _codecDataBase(&_encodedFrameCallback), |
39 frame_dropper_enabled_(true), | 39 frame_dropper_enabled_(true), |
40 _sendStatsTimer(1000, clock_), | 40 _sendStatsTimer(VCMProcessTimer::kDefaultProcessIntervalMs, clock_), |
41 current_codec_(), | 41 current_codec_(), |
42 encoder_params_({BitrateAllocation(), 0, 0, 0}), | 42 encoder_params_({BitrateAllocation(), 0, 0, 0}), |
43 encoder_has_internal_source_(false), | 43 encoder_has_internal_source_(false), |
44 next_frame_types_(1, kVideoFrameDelta) { | 44 next_frame_types_(1, kVideoFrameDelta) { |
45 _mediaOpt.Reset(); | 45 _mediaOpt.Reset(); |
46 // Allow VideoSender to be created on one thread but used on another, post | 46 // Allow VideoSender to be created on one thread but used on another, post |
47 // construction. This is currently how this class is being used by at least | 47 // construction. This is currently how this class is being used by at least |
48 // one external project (diffractor). | 48 // one external project (diffractor). |
49 sequenced_checker_.Detach(); | 49 sequenced_checker_.Detach(); |
50 } | 50 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 return 0; | 192 return 0; |
193 } | 193 } |
194 | 194 |
195 EncoderParameters VideoSender::UpdateEncoderParameters( | 195 EncoderParameters VideoSender::UpdateEncoderParameters( |
196 const EncoderParameters& params, | 196 const EncoderParameters& params, |
197 VideoBitrateAllocator* bitrate_allocator, | 197 VideoBitrateAllocator* bitrate_allocator, |
198 uint32_t target_bitrate_bps) { | 198 uint32_t target_bitrate_bps) { |
199 uint32_t video_target_rate_bps = _mediaOpt.SetTargetRates( | 199 uint32_t video_target_rate_bps = _mediaOpt.SetTargetRates( |
200 target_bitrate_bps, params.loss_rate, params.rtt); | 200 target_bitrate_bps, params.loss_rate, params.rtt); |
201 uint32_t input_frame_rate = _mediaOpt.InputFrameRate(); | 201 uint32_t input_frame_rate = _mediaOpt.InputFrameRate(); |
| 202 if (input_frame_rate == 0) |
| 203 input_frame_rate = current_codec_.maxFramerate; |
| 204 |
202 BitrateAllocation bitrate_allocation; | 205 BitrateAllocation bitrate_allocation; |
203 if (bitrate_allocator) { | 206 if (bitrate_allocator) { |
204 bitrate_allocation = bitrate_allocator->GetAllocation(video_target_rate_bps, | 207 bitrate_allocation = bitrate_allocator->GetAllocation(video_target_rate_bps, |
205 input_frame_rate); | 208 input_frame_rate); |
206 } else { | 209 } else { |
207 DefaultVideoBitrateAllocator default_allocator(current_codec_); | 210 DefaultVideoBitrateAllocator default_allocator(current_codec_); |
208 bitrate_allocation = default_allocator.GetAllocation(video_target_rate_bps, | 211 bitrate_allocation = default_allocator.GetAllocation(video_target_rate_bps, |
209 input_frame_rate); | 212 input_frame_rate); |
210 } | 213 } |
211 | 214 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 } | 388 } |
386 | 389 |
387 int32_t VideoSender::EnableFrameDropper(bool enable) { | 390 int32_t VideoSender::EnableFrameDropper(bool enable) { |
388 rtc::CritScope lock(&encoder_crit_); | 391 rtc::CritScope lock(&encoder_crit_); |
389 frame_dropper_enabled_ = enable; | 392 frame_dropper_enabled_ = enable; |
390 _mediaOpt.EnableFrameDropper(enable); | 393 _mediaOpt.EnableFrameDropper(enable); |
391 return VCM_OK; | 394 return VCM_OK; |
392 } | 395 } |
393 } // namespace vcm | 396 } // namespace vcm |
394 } // namespace webrtc | 397 } // namespace webrtc |
OLD | NEW |