Chromium Code Reviews| 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 29 matching lines...) Expand all Loading... | |
| 40 qm_settings_callback_(qm_settings_callback), | 40 qm_settings_callback_(qm_settings_callback), |
| 41 protection_callback_(nullptr), | 41 protection_callback_(nullptr), |
| 42 encoder_params_({0, 0, 0, 0}), | 42 encoder_params_({0, 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 // Allow VideoSender to be created on one thread but used on another, post | 45 // Allow VideoSender to be created on one thread but used on another, post |
| 46 // construction. This is currently how this class is being used by at least | 46 // construction. This is currently how this class is being used by at least |
| 47 // one external project (diffractor). | 47 // one external project (diffractor). |
| 48 _mediaOpt.EnableQM(qm_settings_callback_ != nullptr); | 48 _mediaOpt.EnableQM(qm_settings_callback_ != nullptr); |
| 49 _mediaOpt.Reset(); | 49 _mediaOpt.Reset(); |
| 50 _encodedFrameCallback.SetMediaOpt(&_mediaOpt); | |
| 50 main_thread_.DetachFromThread(); | 51 main_thread_.DetachFromThread(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 VideoSender::~VideoSender() {} | 54 VideoSender::~VideoSender() {} |
| 54 | 55 |
| 55 void VideoSender::Process() { | 56 void VideoSender::Process() { |
| 56 if (_sendStatsTimer.TimeUntilProcess() == 0) { | 57 if (_sendStatsTimer.TimeUntilProcess() == 0) { |
| 57 _sendStatsTimer.Processed(); | 58 _sendStatsTimer.Processed(); |
| 59 std::string implementation_name; | |
| 60 { | |
| 61 rtc::CritScope cs(&encoder_crit_); | |
|
pbos-webrtc
2016/04/20 13:48:26
I don't like that ::Process starts blocking on enc
| |
| 62 if (_encoder) { | |
| 63 implementation_name = _encoder->ImplementationName(); | |
| 64 } | |
| 65 } | |
| 58 rtc::CritScope cs(&process_crit_); | 66 rtc::CritScope cs(&process_crit_); |
| 59 if (_sendStatsCallback != nullptr) { | 67 if (_sendStatsCallback != nullptr) { |
| 60 uint32_t bitRate = _mediaOpt.SentBitRate(); | 68 uint32_t bitRate = _mediaOpt.SentBitRate(); |
| 61 uint32_t frameRate = _mediaOpt.SentFrameRate(); | 69 uint32_t frameRate = _mediaOpt.SentFrameRate(); |
| 62 _sendStatsCallback->SendStatistics(bitRate, frameRate); | 70 _sendStatsCallback->SendStatistics(bitRate, frameRate, |
| 71 std::move(implementation_name)); | |
| 63 } | 72 } |
| 64 } | 73 } |
| 65 | 74 |
| 66 { | 75 { |
| 67 rtc::CritScope cs(¶ms_crit_); | 76 rtc::CritScope cs(¶ms_crit_); |
| 68 // Force an encoder parameters update, so that incoming frame rate is | 77 // Force an encoder parameters update, so that incoming frame rate is |
| 69 // updated even if bandwidth hasn't changed. | 78 // updated even if bandwidth hasn't changed. |
| 70 encoder_params_.input_frame_rate = _mediaOpt.InputFrameRate(); | 79 encoder_params_.input_frame_rate = _mediaOpt.InputFrameRate(); |
| 71 } | 80 } |
| 72 } | 81 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 return; | 237 return; |
| 229 | 238 |
| 230 if (params.input_frame_rate == 0) { | 239 if (params.input_frame_rate == 0) { |
| 231 // No frame rate estimate available, use default. | 240 // No frame rate estimate available, use default. |
| 232 params.input_frame_rate = current_codec_.maxFramerate; | 241 params.input_frame_rate = current_codec_.maxFramerate; |
| 233 } | 242 } |
| 234 if (_encoder != nullptr) | 243 if (_encoder != nullptr) |
| 235 _encoder->SetEncoderParameters(params); | 244 _encoder->SetEncoderParameters(params); |
| 236 } | 245 } |
| 237 | 246 |
| 238 int32_t VideoSender::RegisterTransportCallback( | |
| 239 VCMPacketizationCallback* transport) { | |
| 240 rtc::CritScope lock(&encoder_crit_); | |
| 241 _encodedFrameCallback.SetMediaOpt(&_mediaOpt); | |
| 242 _encodedFrameCallback.SetTransportCallback(transport); | |
| 243 return VCM_OK; | |
| 244 } | |
| 245 | |
| 246 // Register video output information callback which will be called to deliver | 247 // Register video output information callback which will be called to deliver |
| 247 // information about the video stream produced by the encoder, for instance the | 248 // information about the video stream produced by the encoder, for instance the |
| 248 // average frame rate and bit rate. | 249 // average frame rate and bit rate. |
| 249 int32_t VideoSender::RegisterSendStatisticsCallback( | 250 int32_t VideoSender::RegisterSendStatisticsCallback( |
| 250 VCMSendStatisticsCallback* sendStats) { | 251 VCMSendStatisticsCallback* sendStats) { |
| 251 rtc::CritScope cs(&process_crit_); | 252 rtc::CritScope cs(&process_crit_); |
| 252 _sendStatsCallback = sendStats; | 253 _sendStatsCallback = sendStats; |
| 253 return VCM_OK; | 254 return VCM_OK; |
| 254 } | 255 } |
| 255 | 256 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 // 10 kbps. | 395 // 10 kbps. |
| 395 int window_bps = std::max(threshold_bps / 10, 10000); | 396 int window_bps = std::max(threshold_bps / 10, 10000); |
| 396 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps); | 397 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps); |
| 397 } | 398 } |
| 398 | 399 |
| 399 bool VideoSender::VideoSuspended() const { | 400 bool VideoSender::VideoSuspended() const { |
| 400 return _mediaOpt.IsVideoSuspended(); | 401 return _mediaOpt.IsVideoSuspended(); |
| 401 } | 402 } |
| 402 } // namespace vcm | 403 } // namespace vcm |
| 403 } // namespace webrtc | 404 } // namespace webrtc |
| OLD | NEW |