| 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 |
| 11 #include "webrtc/common_types.h" | |
| 12 | 11 |
| 13 #include <algorithm> // std::max | 12 #include <algorithm> // std::max |
| 14 | 13 |
| 15 #include "webrtc/base/checks.h" | 14 #include "webrtc/base/checks.h" |
| 16 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
| 16 #include "webrtc/common_types.h" |
| 17 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 17 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
| 18 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 18 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
| 19 #include "webrtc/modules/video_coding/encoded_frame.h" | 19 #include "webrtc/modules/video_coding/encoded_frame.h" |
| 20 #include "webrtc/modules/video_coding/utility/quality_scaler.h" | 20 #include "webrtc/modules/video_coding/utility/quality_scaler.h" |
| 21 #include "webrtc/modules/video_coding/video_coding_impl.h" | 21 #include "webrtc/modules/video_coding/video_coding_impl.h" |
| 22 #include "webrtc/system_wrappers/include/clock.h" | 22 #include "webrtc/system_wrappers/include/clock.h" |
| 23 | 23 |
| 24 namespace webrtc { | 24 namespace webrtc { |
| 25 namespace vcm { | 25 namespace vcm { |
| 26 | 26 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 numLayers > 1 && sendCodec->mode == kScreensharing; | 119 numLayers > 1 && sendCodec->mode == kScreensharing; |
| 120 if (disable_frame_dropper) { | 120 if (disable_frame_dropper) { |
| 121 _mediaOpt.EnableFrameDropper(false); | 121 _mediaOpt.EnableFrameDropper(false); |
| 122 } else if (frame_dropper_enabled_) { | 122 } else if (frame_dropper_enabled_) { |
| 123 _mediaOpt.EnableFrameDropper(true); | 123 _mediaOpt.EnableFrameDropper(true); |
| 124 } | 124 } |
| 125 _nextFrameTypes.clear(); | 125 _nextFrameTypes.clear(); |
| 126 _nextFrameTypes.resize(VCM_MAX(sendCodec->numberOfSimulcastStreams, 1), | 126 _nextFrameTypes.resize(VCM_MAX(sendCodec->numberOfSimulcastStreams, 1), |
| 127 kVideoFrameDelta); | 127 kVideoFrameDelta); |
| 128 | 128 |
| 129 _mediaOpt.SetEncodingData(sendCodec->codecType, | 129 _mediaOpt.SetEncodingData(sendCodec->codecType, sendCodec->maxBitrate * 1000, |
| 130 sendCodec->maxBitrate * 1000, | 130 sendCodec->startBitrate * 1000, sendCodec->width, |
| 131 sendCodec->startBitrate * 1000, | 131 sendCodec->height, sendCodec->maxFramerate, |
| 132 sendCodec->width, | 132 numLayers, maxPayloadSize); |
| 133 sendCodec->height, | |
| 134 sendCodec->maxFramerate, | |
| 135 numLayers, | |
| 136 maxPayloadSize); | |
| 137 return VCM_OK; | 133 return VCM_OK; |
| 138 } | 134 } |
| 139 | 135 |
| 140 const VideoCodec& VideoSender::GetSendCodec() const { | 136 const VideoCodec& VideoSender::GetSendCodec() const { |
| 141 RTC_DCHECK(main_thread_.CalledOnValidThread()); | 137 RTC_DCHECK(main_thread_.CalledOnValidThread()); |
| 142 return current_codec_; | 138 return current_codec_; |
| 143 } | 139 } |
| 144 | 140 |
| 145 int32_t VideoSender::SendCodecBlocking(VideoCodec* currentSendCodec) const { | 141 int32_t VideoSender::SendCodecBlocking(VideoCodec* currentSendCodec) const { |
| 146 rtc::CritScope lock(&send_crit_); | 142 rtc::CritScope lock(&send_crit_); |
| 147 if (currentSendCodec == nullptr) { | 143 if (currentSendCodec == nullptr) { |
| 148 return VCM_PARAMETER_ERROR; | 144 return VCM_PARAMETER_ERROR; |
| 149 } | 145 } |
| 150 return _codecDataBase.SendCodec(currentSendCodec) ? 0 : -1; | 146 return _codecDataBase.SendCodec(currentSendCodec) ? 0 : -1; |
| 151 } | 147 } |
| 152 | 148 |
| 153 VideoCodecType VideoSender::SendCodecBlocking() const { | 149 VideoCodecType VideoSender::SendCodecBlocking() const { |
| 154 rtc::CritScope lock(&send_crit_); | 150 rtc::CritScope lock(&send_crit_); |
| 155 return _codecDataBase.SendCodec(); | 151 return _codecDataBase.SendCodec(); |
| 156 } | 152 } |
| 157 | 153 |
| 158 // Register an external decoder object. | 154 // Register an external decoder object. |
| 159 // This can not be used together with external decoder callbacks. | 155 // This can not be used together with external decoder callbacks. |
| 160 void VideoSender::RegisterExternalEncoder(VideoEncoder* externalEncoder, | 156 void VideoSender::RegisterExternalEncoder(VideoEncoder* externalEncoder, |
| 161 uint8_t payloadType, | 157 uint8_t payloadType, |
| 162 bool internalSource /*= false*/) { | 158 bool internalSource /*= false*/) { |
| 163 RTC_DCHECK(main_thread_.CalledOnValidThread()); | 159 RTC_DCHECK(main_thread_.CalledOnValidThread()); |
| 164 | 160 |
| 165 rtc::CritScope lock(&send_crit_); | 161 rtc::CritScope lock(&send_crit_); |
| 166 | 162 |
| 167 if (externalEncoder == nullptr) { | 163 if (externalEncoder == nullptr) { |
| 168 bool wasSendCodec = false; | 164 bool wasSendCodec = false; |
| 169 RTC_CHECK( | 165 RTC_CHECK( |
| 170 _codecDataBase.DeregisterExternalEncoder(payloadType, &wasSendCodec)); | 166 _codecDataBase.DeregisterExternalEncoder(payloadType, &wasSendCodec)); |
| 171 if (wasSendCodec) { | 167 if (wasSendCodec) { |
| 172 // Make sure the VCM doesn't use the de-registered codec | 168 // Make sure the VCM doesn't use the de-registered codec |
| 173 _encoder = nullptr; | 169 _encoder = nullptr; |
| 174 } | 170 } |
| 175 return; | 171 return; |
| 176 } | 172 } |
| 177 _codecDataBase.RegisterExternalEncoder( | 173 _codecDataBase.RegisterExternalEncoder(externalEncoder, payloadType, |
| 178 externalEncoder, payloadType, internalSource); | 174 internalSource); |
| 179 } | 175 } |
| 180 | 176 |
| 181 // Get encode bitrate | 177 // Get encode bitrate |
| 182 int VideoSender::Bitrate(unsigned int* bitrate) const { | 178 int VideoSender::Bitrate(unsigned int* bitrate) const { |
| 183 RTC_DCHECK(main_thread_.CalledOnValidThread()); | 179 RTC_DCHECK(main_thread_.CalledOnValidThread()); |
| 184 // Since we're running on the thread that's the only thread known to modify | 180 // Since we're running on the thread that's the only thread known to modify |
| 185 // the value of _encoder, we don't need to grab the lock here. | 181 // the value of _encoder, we don't need to grab the lock here. |
| 186 | 182 |
| 187 if (!_encoder) | 183 if (!_encoder) |
| 188 return VCM_UNINITIALIZED; | 184 return VCM_UNINITIALIZED; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 // 10 kbps. | 361 // 10 kbps. |
| 366 int window_bps = std::max(threshold_bps / 10, 10000); | 362 int window_bps = std::max(threshold_bps / 10, 10000); |
| 367 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps); | 363 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps); |
| 368 } | 364 } |
| 369 | 365 |
| 370 bool VideoSender::VideoSuspended() const { | 366 bool VideoSender::VideoSuspended() const { |
| 371 return _mediaOpt.IsVideoSuspended(); | 367 return _mediaOpt.IsVideoSuspended(); |
| 372 } | 368 } |
| 373 } // namespace vcm | 369 } // namespace vcm |
| 374 } // namespace webrtc | 370 } // namespace webrtc |
| OLD | NEW |