| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 encoder_params_ = encoder_params; | 212 encoder_params_ = encoder_params; |
| 213 encoder_has_internal_source = encoder_has_internal_source_; | 213 encoder_has_internal_source = encoder_has_internal_source_; |
| 214 } | 214 } |
| 215 | 215 |
| 216 // For encoders with internal sources, we need to tell the encoder directly, | 216 // For encoders with internal sources, we need to tell the encoder directly, |
| 217 // instead of waiting for an AddVideoFrame that will never come (internal | 217 // instead of waiting for an AddVideoFrame that will never come (internal |
| 218 // source encoders don't get input frames). | 218 // source encoders don't get input frames). |
| 219 if (encoder_has_internal_source) { | 219 if (encoder_has_internal_source) { |
| 220 rtc::CritScope cs(&encoder_crit_); | 220 rtc::CritScope cs(&encoder_crit_); |
| 221 if (_encoder) { | 221 if (_encoder) { |
| 222 SetEncoderParameters(encoder_params); | 222 SetEncoderParameters(encoder_params, encoder_has_internal_source); |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 | 225 |
| 226 return VCM_OK; | 226 return VCM_OK; |
| 227 } | 227 } |
| 228 | 228 |
| 229 void VideoSender::SetEncoderParameters(EncoderParameters params) { | 229 void VideoSender::SetEncoderParameters(EncoderParameters params, |
| 230 bool has_internal_source) { |
| 230 // |target_bitrate == 0 | means that the network is down or the send pacer is | 231 // |target_bitrate == 0 | means that the network is down or the send pacer is |
| 231 // full. | 232 // full. We currently only report this if the encoder has an internal source. |
| 232 // TODO(perkj): Consider setting |target_bitrate| == 0 to the encoders. | 233 // If the encoder does not have an internal source, higher levels are expected |
| 233 // Especially if |encoder_has_internal_source_ | == true. | 234 // to not call AddVideoFrame. We do this since its unclear how current |
| 234 if (params.target_bitrate == 0) | 235 // encoder implementations behave when given a zero target bitrate. |
| 236 // TODO(perkj): Make sure all known encoder implementations handle zero |
| 237 // target bitrate and remove this check. |
| 238 if (!has_internal_source && params.target_bitrate == 0) |
| 235 return; | 239 return; |
| 236 | 240 |
| 237 if (params.input_frame_rate == 0) { | 241 if (params.input_frame_rate == 0) { |
| 238 // No frame rate estimate available, use default. | 242 // No frame rate estimate available, use default. |
| 239 params.input_frame_rate = current_codec_.maxFramerate; | 243 params.input_frame_rate = current_codec_.maxFramerate; |
| 240 } | 244 } |
| 241 if (_encoder != nullptr) | 245 if (_encoder != nullptr) |
| 242 _encoder->SetEncoderParameters(params); | 246 _encoder->SetEncoderParameters(params); |
| 243 } | 247 } |
| 244 | 248 |
| 245 // Deprecated: | 249 // Deprecated: |
| 246 // TODO(perkj): Remove once no projects call this method. It currently do | 250 // TODO(perkj): Remove once no projects call this method. It currently do |
| 247 // nothing. | 251 // nothing. |
| 248 int32_t VideoSender::RegisterProtectionCallback( | 252 int32_t VideoSender::RegisterProtectionCallback( |
| 249 VCMProtectionCallback* protection_callback) { | 253 VCMProtectionCallback* protection_callback) { |
| 250 // Deprecated: | 254 // Deprecated: |
| 251 // TODO(perkj): Remove once no projects call this method. It currently do | 255 // TODO(perkj): Remove once no projects call this method. It currently do |
| 252 // nothing. | 256 // nothing. |
| 253 return VCM_OK; | 257 return VCM_OK; |
| 254 } | 258 } |
| 255 | 259 |
| 256 // Add one raw video frame to the encoder, blocking. | 260 // Add one raw video frame to the encoder, blocking. |
| 257 int32_t VideoSender::AddVideoFrame(const VideoFrame& videoFrame, | 261 int32_t VideoSender::AddVideoFrame(const VideoFrame& videoFrame, |
| 258 const CodecSpecificInfo* codecSpecificInfo) { | 262 const CodecSpecificInfo* codecSpecificInfo) { |
| 259 EncoderParameters encoder_params; | 263 EncoderParameters encoder_params; |
| 260 std::vector<FrameType> next_frame_types; | 264 std::vector<FrameType> next_frame_types; |
| 265 bool encoder_has_internal_source = false; |
| 261 { | 266 { |
| 262 rtc::CritScope lock(¶ms_crit_); | 267 rtc::CritScope lock(¶ms_crit_); |
| 263 encoder_params = encoder_params_; | 268 encoder_params = encoder_params_; |
| 264 next_frame_types = next_frame_types_; | 269 next_frame_types = next_frame_types_; |
| 270 encoder_has_internal_source = encoder_has_internal_source_; |
| 265 } | 271 } |
| 266 rtc::CritScope lock(&encoder_crit_); | 272 rtc::CritScope lock(&encoder_crit_); |
| 267 if (_encoder == nullptr) | 273 if (_encoder == nullptr) |
| 268 return VCM_UNINITIALIZED; | 274 return VCM_UNINITIALIZED; |
| 269 SetEncoderParameters(encoder_params); | 275 SetEncoderParameters(encoder_params, encoder_has_internal_source); |
| 270 if (_mediaOpt.DropFrame()) { | 276 if (_mediaOpt.DropFrame()) { |
| 271 LOG(LS_VERBOSE) << "Drop Frame " | 277 LOG(LS_VERBOSE) << "Drop Frame " |
| 272 << "target bitrate " << encoder_params.target_bitrate | 278 << "target bitrate " << encoder_params.target_bitrate |
| 273 << " loss rate " << encoder_params.loss_rate << " rtt " | 279 << " loss rate " << encoder_params.loss_rate << " rtt " |
| 274 << encoder_params.rtt << " input frame rate " | 280 << encoder_params.rtt << " input frame rate " |
| 275 << encoder_params.input_frame_rate; | 281 << encoder_params.input_frame_rate; |
| 276 _encoder->OnDroppedFrame(); | 282 _encoder->OnDroppedFrame(); |
| 277 return VCM_OK; | 283 return VCM_OK; |
| 278 } | 284 } |
| 279 // TODO(pbos): Make sure setting send codec is synchronized with video | 285 // TODO(pbos): Make sure setting send codec is synchronized with video |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 // 10 kbps. | 369 // 10 kbps. |
| 364 int window_bps = std::max(threshold_bps / 10, 10000); | 370 int window_bps = std::max(threshold_bps / 10, 10000); |
| 365 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps); | 371 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps); |
| 366 } | 372 } |
| 367 | 373 |
| 368 bool VideoSender::VideoSuspended() const { | 374 bool VideoSender::VideoSuspended() const { |
| 369 return _mediaOpt.IsVideoSuspended(); | 375 return _mediaOpt.IsVideoSuspended(); |
| 370 } | 376 } |
| 371 } // namespace vcm | 377 } // namespace vcm |
| 372 } // namespace webrtc | 378 } // namespace webrtc |
| OLD | NEW |