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. |
pbos-webrtc
2016/06/16 13:16:28
Put a comment here instead to explain why we don't
perkj_webrtc
2016/06/16 18:42:17
Done.
| |
232 // TODO(perkj): Consider setting |target_bitrate| == 0 to the encoders. | 233 if (!has_internal_source && params.target_bitrate == 0) |
233 // Especially if |encoder_has_internal_source_ | == true. | |
234 if (params.target_bitrate == 0) | |
235 return; | 234 return; |
236 | 235 |
237 if (params.input_frame_rate == 0) { | 236 if (params.input_frame_rate == 0) { |
238 // No frame rate estimate available, use default. | 237 // No frame rate estimate available, use default. |
239 params.input_frame_rate = current_codec_.maxFramerate; | 238 params.input_frame_rate = current_codec_.maxFramerate; |
240 } | 239 } |
241 if (_encoder != nullptr) | 240 if (_encoder != nullptr) |
242 _encoder->SetEncoderParameters(params); | 241 _encoder->SetEncoderParameters(params); |
243 } | 242 } |
244 | 243 |
245 // Deprecated: | 244 // Deprecated: |
246 // TODO(perkj): Remove once no projects call this method. It currently do | 245 // TODO(perkj): Remove once no projects call this method. It currently do |
247 // nothing. | 246 // nothing. |
248 int32_t VideoSender::RegisterProtectionCallback( | 247 int32_t VideoSender::RegisterProtectionCallback( |
249 VCMProtectionCallback* protection_callback) { | 248 VCMProtectionCallback* protection_callback) { |
250 // Deprecated: | 249 // Deprecated: |
251 // 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 |
252 // nothing. | 251 // nothing. |
253 return VCM_OK; | 252 return VCM_OK; |
254 } | 253 } |
255 | 254 |
256 // Add one raw video frame to the encoder, blocking. | 255 // Add one raw video frame to the encoder, blocking. |
257 int32_t VideoSender::AddVideoFrame(const VideoFrame& videoFrame, | 256 int32_t VideoSender::AddVideoFrame(const VideoFrame& videoFrame, |
258 const CodecSpecificInfo* codecSpecificInfo) { | 257 const CodecSpecificInfo* codecSpecificInfo) { |
259 EncoderParameters encoder_params; | 258 EncoderParameters encoder_params; |
260 std::vector<FrameType> next_frame_types; | 259 std::vector<FrameType> next_frame_types; |
260 bool encoder_has_internal_source = false; | |
261 { | 261 { |
262 rtc::CritScope lock(¶ms_crit_); | 262 rtc::CritScope lock(¶ms_crit_); |
263 encoder_params = encoder_params_; | 263 encoder_params = encoder_params_; |
264 next_frame_types = next_frame_types_; | 264 next_frame_types = next_frame_types_; |
265 encoder_has_internal_source = encoder_has_internal_source_; | |
265 } | 266 } |
266 rtc::CritScope lock(&encoder_crit_); | 267 rtc::CritScope lock(&encoder_crit_); |
267 if (_encoder == nullptr) | 268 if (_encoder == nullptr) |
268 return VCM_UNINITIALIZED; | 269 return VCM_UNINITIALIZED; |
269 SetEncoderParameters(encoder_params); | 270 SetEncoderParameters(encoder_params, encoder_has_internal_source); |
270 if (_mediaOpt.DropFrame()) { | 271 if (_mediaOpt.DropFrame()) { |
271 LOG(LS_VERBOSE) << "Drop Frame " | 272 LOG(LS_VERBOSE) << "Drop Frame " |
272 << "target bitrate " << encoder_params.target_bitrate | 273 << "target bitrate " << encoder_params.target_bitrate |
273 << " loss rate " << encoder_params.loss_rate << " rtt " | 274 << " loss rate " << encoder_params.loss_rate << " rtt " |
274 << encoder_params.rtt << " input frame rate " | 275 << encoder_params.rtt << " input frame rate " |
275 << encoder_params.input_frame_rate; | 276 << encoder_params.input_frame_rate; |
276 _encoder->OnDroppedFrame(); | 277 _encoder->OnDroppedFrame(); |
277 return VCM_OK; | 278 return VCM_OK; |
278 } | 279 } |
279 // TODO(pbos): Make sure setting send codec is synchronized with video | 280 // 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. | 364 // 10 kbps. |
364 int window_bps = std::max(threshold_bps / 10, 10000); | 365 int window_bps = std::max(threshold_bps / 10, 10000); |
365 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps); | 366 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps); |
366 } | 367 } |
367 | 368 |
368 bool VideoSender::VideoSuspended() const { | 369 bool VideoSender::VideoSuspended() const { |
369 return _mediaOpt.IsVideoSuspended(); | 370 return _mediaOpt.IsVideoSuspended(); |
370 } | 371 } |
371 } // namespace vcm | 372 } // namespace vcm |
372 } // namespace webrtc | 373 } // namespace webrtc |
OLD | NEW |