Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: webrtc/modules/video_coding/generic_encoder.cc

Issue 2995953002: Revert of Add a flags field to video timing extension. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } else if (codec_specific->codecType == kVideoCodecVP8) { 224 } else if (codec_specific->codecType == kVideoCodecVP8) {
225 simulcast_svc_idx = codec_specific->codecSpecific.VP8.simulcastIdx; 225 simulcast_svc_idx = codec_specific->codecSpecific.VP8.simulcastIdx;
226 } else if (codec_specific->codecType == kVideoCodecGeneric) { 226 } else if (codec_specific->codecType == kVideoCodecGeneric) {
227 simulcast_svc_idx = codec_specific->codecSpecific.generic.simulcast_idx; 227 simulcast_svc_idx = codec_specific->codecSpecific.generic.simulcast_idx;
228 } else if (codec_specific->codecType == kVideoCodecH264) { 228 } else if (codec_specific->codecType == kVideoCodecH264) {
229 // TODO(ilnik): When h264 simulcast is landed, extract simulcast idx here. 229 // TODO(ilnik): When h264 simulcast is landed, extract simulcast idx here.
230 } 230 }
231 231
232 rtc::Optional<size_t> outlier_frame_size; 232 rtc::Optional<size_t> outlier_frame_size;
233 rtc::Optional<int64_t> encode_start_ms; 233 rtc::Optional<int64_t> encode_start_ms;
234 uint8_t timing_flags = TimingFrameFlags::kInvalid; 234 bool is_timing_frame = false;
235 { 235 {
236 rtc::CritScope crit(&timing_params_lock_); 236 rtc::CritScope crit(&timing_params_lock_);
237 237
238 // Encoders with internal sources do not call OnEncodeStarted and 238 // Encoders with internal sources do not call OnEncodeStarted and
239 // OnFrameRateChanged. |timing_frames_info_| may be not filled here. 239 // OnFrameRateChanged. |timing_frames_info_| may be not filled here.
240 if (simulcast_svc_idx < timing_frames_info_.size()) { 240 if (simulcast_svc_idx < timing_frames_info_.size()) {
241 auto encode_start_map = 241 auto encode_start_map =
242 &timing_frames_info_[simulcast_svc_idx].encode_start_time_ms; 242 &timing_frames_info_[simulcast_svc_idx].encode_start_time_ms;
243 auto it = encode_start_map->find(encoded_image.capture_time_ms_); 243 auto it = encode_start_map->find(encoded_image.capture_time_ms_);
244 if (it != encode_start_map->end()) { 244 if (it != encode_start_map->end()) {
(...skipping 22 matching lines...) Expand all
267 267
268 // Check if it's time to send a timing frame. 268 // Check if it's time to send a timing frame.
269 int64_t timing_frame_delay_ms = 269 int64_t timing_frame_delay_ms =
270 encoded_image.capture_time_ms_ - last_timing_frame_time_ms_; 270 encoded_image.capture_time_ms_ - last_timing_frame_time_ms_;
271 // Trigger threshold if it's a first frame, too long passed since the last 271 // Trigger threshold if it's a first frame, too long passed since the last
272 // timing frame, or we already sent timing frame on a different simulcast 272 // timing frame, or we already sent timing frame on a different simulcast
273 // stream with the same capture time. 273 // stream with the same capture time.
274 if (last_timing_frame_time_ms_ == -1 || 274 if (last_timing_frame_time_ms_ == -1 ||
275 timing_frame_delay_ms >= timing_frames_thresholds_.delay_ms || 275 timing_frame_delay_ms >= timing_frames_thresholds_.delay_ms ||
276 timing_frame_delay_ms == 0) { 276 timing_frame_delay_ms == 0) {
277 timing_flags = TimingFrameFlags::kTriggeredByTimer; 277 is_timing_frame = true;
278 last_timing_frame_time_ms_ = encoded_image.capture_time_ms_; 278 last_timing_frame_time_ms_ = encoded_image.capture_time_ms_;
279 } 279 }
280 280
281 // Outliers trigger timing frames, but do not affect scheduled timing 281 // Outliers trigger timing frames, but do not affect scheduled timing
282 // frames. 282 // frames.
283 if (outlier_frame_size && encoded_image._length >= *outlier_frame_size) { 283 if (outlier_frame_size && encoded_image._length >= *outlier_frame_size) {
284 if (timing_flags == TimingFrameFlags::kInvalid) 284 is_timing_frame = true;
285 timing_flags = 0;
286 timing_flags |= TimingFrameFlags::kTriggeredBySize;
287 } 285 }
288 } 286 }
289 287
290 // If encode start is not available that means that encoder uses internal 288 // If encode start is not available that means that encoder uses internal
291 // source. In that case capture timestamp may be from a different clock with a 289 // source. In that case capture timestamp may be from a different clock with a
292 // drift relative to rtc::TimeMillis(). We can't use it for Timing frames, 290 // drift relative to rtc::TimeMillis(). We can't use it for Timing frames,
293 // because to being sent in the network capture time required to be less than 291 // because to being sent in the network capture time required to be less than
294 // all the other timestamps. 292 // all the other timestamps.
295 if (timing_flags != TimingFrameFlags::kInvalid && encode_start_ms) { 293 if (is_timing_frame && encode_start_ms) {
296 encoded_image.SetEncodeTime(*encode_start_ms, rtc::TimeMillis()); 294 encoded_image.SetEncodeTime(*encode_start_ms, rtc::TimeMillis());
297 } 295 }
298 encoded_image.timing_.flags = timing_flags;
299 296
300 Result result = post_encode_callback_->OnEncodedImage( 297 Result result = post_encode_callback_->OnEncodedImage(
301 encoded_image, codec_specific, fragmentation_header); 298 encoded_image, codec_specific, fragmentation_header);
302 if (result.error != Result::OK) 299 if (result.error != Result::OK)
303 return result; 300 return result;
304 301
305 if (media_opt_) { 302 if (media_opt_) {
306 media_opt_->UpdateWithEncodedData(encoded_image); 303 media_opt_->UpdateWithEncodedData(encoded_image);
307 if (internal_source_) { 304 if (internal_source_) {
308 // Signal to encoder to drop next frame. 305 // Signal to encoder to drop next frame.
309 result.drop_next_frame = media_opt_->DropFrame(); 306 result.drop_next_frame = media_opt_->DropFrame();
310 } 307 }
311 } 308 }
312 return result; 309 return result;
313 } 310 }
314 311
315 } // namespace webrtc 312 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/generic_decoder.cc ('k') | webrtc/modules/video_coding/generic_encoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698