| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 namespace webrtc { | 27 namespace webrtc { |
| 28 namespace vcm { | 28 namespace vcm { |
| 29 | 29 |
| 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 has_received_frame_(false), |
| 36 _encodedFrameCallback(post_encode_callback, &_mediaOpt), | 37 _encodedFrameCallback(post_encode_callback, &_mediaOpt), |
| 37 send_stats_callback_(send_stats_callback), | 38 send_stats_callback_(send_stats_callback), |
| 38 _codecDataBase(&_encodedFrameCallback), | 39 _codecDataBase(&_encodedFrameCallback), |
| 39 frame_dropper_enabled_(true), | 40 frame_dropper_enabled_(true), |
| 40 _sendStatsTimer(1000, clock_), | 41 _sendStatsTimer(VCMProcessTimer::kDefaultProcessIntervalMs, clock_), |
| 41 current_codec_(), | 42 current_codec_(), |
| 42 encoder_params_({BitrateAllocation(), 0, 0, 0}), | 43 encoder_params_({BitrateAllocation(), 0, 0, 0}), |
| 43 encoder_has_internal_source_(false), | 44 encoder_has_internal_source_(false), |
| 44 next_frame_types_(1, kVideoFrameDelta) { | 45 next_frame_types_(1, kVideoFrameDelta) { |
| 45 _mediaOpt.Reset(); | 46 _mediaOpt.Reset(); |
| 46 // Allow VideoSender to be created on one thread but used on another, post | 47 // 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 | 48 // construction. This is currently how this class is being used by at least |
| 48 // one external project (diffractor). | 49 // one external project (diffractor). |
| 49 sequenced_checker_.Detach(); | 50 sequenced_checker_.Detach(); |
| 50 } | 51 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 133 } |
| 133 | 134 |
| 134 LOG(LS_VERBOSE) << " max bitrate " << sendCodec->maxBitrate | 135 LOG(LS_VERBOSE) << " max bitrate " << sendCodec->maxBitrate |
| 135 << " start bitrate " << sendCodec->startBitrate | 136 << " start bitrate " << sendCodec->startBitrate |
| 136 << " max frame rate " << sendCodec->maxFramerate | 137 << " max frame rate " << sendCodec->maxFramerate |
| 137 << " max payload size " << maxPayloadSize; | 138 << " max payload size " << maxPayloadSize; |
| 138 _mediaOpt.SetEncodingData(sendCodec->maxBitrate * 1000, | 139 _mediaOpt.SetEncodingData(sendCodec->maxBitrate * 1000, |
| 139 sendCodec->startBitrate * 1000, sendCodec->width, | 140 sendCodec->startBitrate * 1000, sendCodec->width, |
| 140 sendCodec->height, sendCodec->maxFramerate, | 141 sendCodec->height, sendCodec->maxFramerate, |
| 141 numLayers, maxPayloadSize); | 142 numLayers, maxPayloadSize); |
| 143 has_received_frame_ = false; |
| 142 return VCM_OK; | 144 return VCM_OK; |
| 143 } | 145 } |
| 144 | 146 |
| 145 // Register an external decoder object. | 147 // Register an external decoder object. |
| 146 // This can not be used together with external decoder callbacks. | 148 // This can not be used together with external decoder callbacks. |
| 147 void VideoSender::RegisterExternalEncoder(VideoEncoder* externalEncoder, | 149 void VideoSender::RegisterExternalEncoder(VideoEncoder* externalEncoder, |
| 148 uint8_t payloadType, | 150 uint8_t payloadType, |
| 149 bool internalSource /*= false*/) { | 151 bool internalSource /*= false*/) { |
| 150 RTC_DCHECK(sequenced_checker_.CalledSequentially()); | 152 RTC_DCHECK(sequenced_checker_.CalledSequentially()); |
| 151 | 153 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 return 0; | 194 return 0; |
| 193 } | 195 } |
| 194 | 196 |
| 195 EncoderParameters VideoSender::UpdateEncoderParameters( | 197 EncoderParameters VideoSender::UpdateEncoderParameters( |
| 196 const EncoderParameters& params, | 198 const EncoderParameters& params, |
| 197 VideoBitrateAllocator* bitrate_allocator, | 199 VideoBitrateAllocator* bitrate_allocator, |
| 198 uint32_t target_bitrate_bps) { | 200 uint32_t target_bitrate_bps) { |
| 199 uint32_t video_target_rate_bps = _mediaOpt.SetTargetRates( | 201 uint32_t video_target_rate_bps = _mediaOpt.SetTargetRates( |
| 200 target_bitrate_bps, params.loss_rate, params.rtt); | 202 target_bitrate_bps, params.loss_rate, params.rtt); |
| 201 uint32_t input_frame_rate = _mediaOpt.InputFrameRate(); | 203 uint32_t input_frame_rate = _mediaOpt.InputFrameRate(); |
| 204 if (input_frame_rate > 0) { |
| 205 has_received_frame_ = true; |
| 206 } else if (input_frame_rate == 0 && !has_received_frame_) { |
| 207 input_frame_rate = current_codec_.maxFramerate; |
| 208 } |
| 209 |
| 202 BitrateAllocation bitrate_allocation; | 210 BitrateAllocation bitrate_allocation; |
| 203 if (bitrate_allocator) { | 211 if (bitrate_allocator) { |
| 204 bitrate_allocation = bitrate_allocator->GetAllocation(video_target_rate_bps, | 212 bitrate_allocation = bitrate_allocator->GetAllocation(video_target_rate_bps, |
| 205 input_frame_rate); | 213 input_frame_rate); |
| 206 } else { | 214 } else { |
| 207 DefaultVideoBitrateAllocator default_allocator(current_codec_); | 215 DefaultVideoBitrateAllocator default_allocator(current_codec_); |
| 208 bitrate_allocation = default_allocator.GetAllocation(video_target_rate_bps, | 216 bitrate_allocation = default_allocator.GetAllocation(video_target_rate_bps, |
| 209 input_frame_rate); | 217 input_frame_rate); |
| 210 } | 218 } |
| 211 | 219 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 } | 393 } |
| 386 | 394 |
| 387 int32_t VideoSender::EnableFrameDropper(bool enable) { | 395 int32_t VideoSender::EnableFrameDropper(bool enable) { |
| 388 rtc::CritScope lock(&encoder_crit_); | 396 rtc::CritScope lock(&encoder_crit_); |
| 389 frame_dropper_enabled_ = enable; | 397 frame_dropper_enabled_ = enable; |
| 390 _mediaOpt.EnableFrameDropper(enable); | 398 _mediaOpt.EnableFrameDropper(enable); |
| 391 return VCM_OK; | 399 return VCM_OK; |
| 392 } | 400 } |
| 393 } // namespace vcm | 401 } // namespace vcm |
| 394 } // namespace webrtc | 402 } // namespace webrtc |
| OLD | NEW |