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

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

Issue 1419673014: Remove frame time scheduing in IncomingVideoStream (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Method A: pass the flag through constructor Created 5 years, 1 month 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 14 matching lines...) Expand all
25 #include "webrtc/common_video/video_render_frames.h" 25 #include "webrtc/common_video/video_render_frames.h"
26 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 26 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
27 #include "webrtc/system_wrappers/include/event_wrapper.h" 27 #include "webrtc/system_wrappers/include/event_wrapper.h"
28 #include "webrtc/system_wrappers/include/thread_wrapper.h" 28 #include "webrtc/system_wrappers/include/thread_wrapper.h"
29 #include "webrtc/system_wrappers/include/tick_util.h" 29 #include "webrtc/system_wrappers/include/tick_util.h"
30 #include "webrtc/system_wrappers/include/trace.h" 30 #include "webrtc/system_wrappers/include/trace.h"
31 31
32 namespace webrtc { 32 namespace webrtc {
33 33
34 IncomingVideoStream::IncomingVideoStream(uint32_t stream_id) 34 IncomingVideoStream::IncomingVideoStream(uint32_t stream_id)
35 : IncomingVideoStream(stream_id, false) {}
36
37 IncomingVideoStream::IncomingVideoStream(uint32_t stream_id,
38 bool renderer_has_timing)
35 : stream_id_(stream_id), 39 : stream_id_(stream_id),
40 renderer_has_timing_(renderer_has_timing),
36 stream_critsect_(CriticalSectionWrapper::CreateCriticalSection()), 41 stream_critsect_(CriticalSectionWrapper::CreateCriticalSection()),
37 thread_critsect_(CriticalSectionWrapper::CreateCriticalSection()), 42 thread_critsect_(CriticalSectionWrapper::CreateCriticalSection()),
38 buffer_critsect_(CriticalSectionWrapper::CreateCriticalSection()), 43 buffer_critsect_(CriticalSectionWrapper::CreateCriticalSection()),
39 incoming_render_thread_(), 44 incoming_render_thread_(),
40 deliver_buffer_event_(EventTimerWrapper::Create()), 45 deliver_buffer_event_(EventTimerWrapper::Create()),
41 running_(false), 46 running_(false),
42 external_callback_(nullptr), 47 external_callback_(nullptr),
43 render_callback_(nullptr), 48 render_callback_(nullptr),
44 render_buffers_(new VideoRenderFrames()), 49 render_buffers_(new VideoRenderFrames()),
45 incoming_rate_(0), 50 incoming_rate_(0),
46 last_rate_calculation_time_ms_(0), 51 last_rate_calculation_time_ms_(0),
47 num_frames_since_last_calculation_(0), 52 num_frames_since_last_calculation_(0),
48 last_render_time_ms_(0), 53 last_render_time_ms_(0),
49 temp_frame_(), 54 temp_frame_(),
50 start_image_(), 55 start_image_(),
51 timeout_image_(), 56 timeout_image_(),
52 timeout_time_() { 57 timeout_time_() {}
53 }
54 58
55 IncomingVideoStream::~IncomingVideoStream() { 59 IncomingVideoStream::~IncomingVideoStream() {
56 Stop(); 60 Stop();
57 } 61 }
58 62
59 VideoRenderCallback* IncomingVideoStream::ModuleCallback() { 63 VideoRenderCallback* IncomingVideoStream::ModuleCallback() {
60 CriticalSectionScoped cs(stream_critsect_.get()); 64 CriticalSectionScoped cs(stream_critsect_.get());
61 return this; 65 return this;
62 } 66 }
63 67
(...skipping 11 matching lines...) Expand all
75 if (now_ms >= last_rate_calculation_time_ms_ + kFrameRatePeriodMs) { 79 if (now_ms >= last_rate_calculation_time_ms_ + kFrameRatePeriodMs) {
76 incoming_rate_ = 80 incoming_rate_ =
77 static_cast<uint32_t>(1000 * num_frames_since_last_calculation_ / 81 static_cast<uint32_t>(1000 * num_frames_since_last_calculation_ /
78 (now_ms - last_rate_calculation_time_ms_)); 82 (now_ms - last_rate_calculation_time_ms_));
79 num_frames_since_last_calculation_ = 0; 83 num_frames_since_last_calculation_ = 0;
80 last_rate_calculation_time_ms_ = now_ms; 84 last_rate_calculation_time_ms_ = now_ms;
81 } 85 }
82 86
83 // Insert frame. 87 // Insert frame.
84 CriticalSectionScoped csB(buffer_critsect_.get()); 88 CriticalSectionScoped csB(buffer_critsect_.get());
85 if (render_buffers_->AddFrame(video_frame) == 1) 89 if (render_buffers_->AddFrame(video_frame) == 1 || renderer_has_timing_)
86 deliver_buffer_event_->Set(); 90 deliver_buffer_event_->Set();
87 91
88 return 0; 92 return 0;
89 } 93 }
90 94
91 int32_t IncomingVideoStream::SetStartImage(const VideoFrame& video_frame) { 95 int32_t IncomingVideoStream::SetStartImage(const VideoFrame& video_frame) {
92 CriticalSectionScoped csS(thread_critsect_.get()); 96 CriticalSectionScoped csS(thread_critsect_.get());
93 return start_image_.CopyFrame(video_frame); 97 return start_image_.CopyFrame(video_frame);
94 } 98 }
95 99
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 211 }
208 // Get a new frame to render and the time for the frame after this one. 212 // Get a new frame to render and the time for the frame after this one.
209 VideoFrame frame_to_render; 213 VideoFrame frame_to_render;
210 uint32_t wait_time; 214 uint32_t wait_time;
211 { 215 {
212 CriticalSectionScoped cs(buffer_critsect_.get()); 216 CriticalSectionScoped cs(buffer_critsect_.get());
213 frame_to_render = render_buffers_->FrameToRender(); 217 frame_to_render = render_buffers_->FrameToRender();
214 wait_time = render_buffers_->TimeToNextFrameRelease(); 218 wait_time = render_buffers_->TimeToNextFrameRelease();
215 } 219 }
216 220
217 // Set timer for next frame to render. 221 if (!renderer_has_timing_) {
218 if (wait_time > kEventMaxWaitTimeMs) { 222 // Set timer for next frame to render.
219 wait_time = kEventMaxWaitTimeMs; 223 if (wait_time > kEventMaxWaitTimeMs) {
224 wait_time = kEventMaxWaitTimeMs;
225 }
226 deliver_buffer_event_->StartTimer(false, wait_time);
220 } 227 }
221 deliver_buffer_event_->StartTimer(false, wait_time);
222 228
223 if (frame_to_render.IsZeroSize()) { 229 if (frame_to_render.IsZeroSize()) {
224 if (render_callback_) { 230 if (render_callback_) {
225 if (last_render_time_ms_ == 0 && !start_image_.IsZeroSize()) { 231 if (last_render_time_ms_ == 0 && !start_image_.IsZeroSize()) {
226 // We have not rendered anything and have a start image. 232 // We have not rendered anything and have a start image.
227 temp_frame_.CopyFrame(start_image_); 233 temp_frame_.CopyFrame(start_image_);
228 render_callback_->RenderFrame(stream_id_, temp_frame_); 234 render_callback_->RenderFrame(stream_id_, temp_frame_);
229 } else if (!timeout_image_.IsZeroSize() && 235 } else if (!timeout_image_.IsZeroSize() &&
230 last_render_time_ms_ + timeout_time_ < 236 last_render_time_ms_ + timeout_time_ <
231 TickTime::MillisecondTimestamp()) { 237 TickTime::MillisecondTimestamp()) {
(...skipping 15 matching lines...) Expand all
247 } 253 }
248 254
249 // We're done with this frame. 255 // We're done with this frame.
250 if (!frame_to_render.IsZeroSize()) 256 if (!frame_to_render.IsZeroSize())
251 last_render_time_ms_ = frame_to_render.render_time_ms(); 257 last_render_time_ms_ = frame_to_render.render_time_ms();
252 } 258 }
253 return true; 259 return true;
254 } 260 }
255 261
256 } // namespace webrtc 262 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698