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

Side by Side Diff: webrtc/common_video/video_render_frames.cc

Issue 2035173002: Split IncomingVideoStream into two implementations, with smoothing and without. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase again Created 4 years, 6 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
11 #include "webrtc/common_video/video_render_frames.h" 11 #include "webrtc/common_video/video_render_frames.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 14
15 #include "webrtc/base/timeutils.h" 15 #include "webrtc/base/timeutils.h"
16 #include "webrtc/modules/include/module_common_types.h" 16 #include "webrtc/modules/include/module_common_types.h"
17 #include "webrtc/system_wrappers/include/trace.h" 17 #include "webrtc/system_wrappers/include/trace.h"
18 18
19 namespace webrtc { 19 namespace webrtc {
20 namespace {
20 21
21 const uint32_t KEventMaxWaitTimeMs = 200; 22 const uint32_t kEventMaxWaitTimeMs = 200;
22 const uint32_t kMinRenderDelayMs = 10; 23 const uint32_t kMinRenderDelayMs = 10;
23 const uint32_t kMaxRenderDelayMs = 500; 24 const uint32_t kMaxRenderDelayMs = 500;
24 25
25 VideoRenderFrames::VideoRenderFrames() 26 uint32_t EnsureValidRenderDelay(uint32_t render_delay) {
26 : render_delay_ms_(10) { 27 return (render_delay < kMinRenderDelayMs || render_delay > kMaxRenderDelayMs)
28 ? kMinRenderDelayMs
29 : render_delay;
27 } 30 }
31 } // namespace
32
33 VideoRenderFrames::VideoRenderFrames(uint32_t render_delay_ms)
34 : render_delay_ms_(EnsureValidRenderDelay(render_delay_ms)) {}
28 35
29 int32_t VideoRenderFrames::AddFrame(const VideoFrame& new_frame) { 36 int32_t VideoRenderFrames::AddFrame(const VideoFrame& new_frame) {
30 const int64_t time_now = rtc::TimeMillis(); 37 const int64_t time_now = rtc::TimeMillis();
31 38
32 // Drop old frames only when there are other frames in the queue, otherwise, a 39 // Drop old frames only when there are other frames in the queue, otherwise, a
33 // really slow system never renders any frames. 40 // really slow system never renders any frames.
34 if (!incoming_frames_.empty() && 41 if (!incoming_frames_.empty() &&
35 new_frame.render_time_ms() + KOldRenderTimestampMS < time_now) { 42 new_frame.render_time_ms() + KOldRenderTimestampMS < time_now) {
36 WEBRTC_TRACE(kTraceWarning, 43 WEBRTC_TRACE(kTraceWarning,
37 kTraceVideoRenderer, 44 kTraceVideoRenderer,
(...skipping 25 matching lines...) Expand all
63 return render_frame; 70 return render_frame;
64 } 71 }
65 72
66 int32_t VideoRenderFrames::ReleaseAllFrames() { 73 int32_t VideoRenderFrames::ReleaseAllFrames() {
67 incoming_frames_.clear(); 74 incoming_frames_.clear();
68 return 0; 75 return 0;
69 } 76 }
70 77
71 uint32_t VideoRenderFrames::TimeToNextFrameRelease() { 78 uint32_t VideoRenderFrames::TimeToNextFrameRelease() {
72 if (incoming_frames_.empty()) { 79 if (incoming_frames_.empty()) {
73 return KEventMaxWaitTimeMs; 80 return kEventMaxWaitTimeMs;
74 } 81 }
75 const int64_t time_to_release = incoming_frames_.front().render_time_ms() - 82 const int64_t time_to_release = incoming_frames_.front().render_time_ms() -
76 render_delay_ms_ - 83 render_delay_ms_ -
77 rtc::TimeMillis(); 84 rtc::TimeMillis();
78 return time_to_release < 0 ? 0u : static_cast<uint32_t>(time_to_release); 85 return time_to_release < 0 ? 0u : static_cast<uint32_t>(time_to_release);
79 } 86 }
80 87
81 int32_t VideoRenderFrames::SetRenderDelay(
82 const uint32_t render_delay) {
83 if (render_delay < kMinRenderDelayMs ||
84 render_delay > kMaxRenderDelayMs) {
85 WEBRTC_TRACE(kTraceWarning, kTraceVideoRenderer,
86 -1, "%s(%d): Invalid argument.", __FUNCTION__,
87 render_delay);
88 return -1;
89 }
90
91 render_delay_ms_ = render_delay;
92 return 0;
93 }
94
95 } // namespace webrtc 88 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698