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

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

Issue 1888593004: Delete all use of tick_util.h. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 4 years, 7 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/include/incoming_video_stream.h" 11 #include "webrtc/common_video/include/incoming_video_stream.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 14
15 #if defined(_WIN32) 15 #if defined(_WIN32)
16 #include <windows.h> 16 #include <windows.h>
17 #elif defined(WEBRTC_LINUX) 17 #elif defined(WEBRTC_LINUX)
18 #include <sys/time.h> 18 #include <sys/time.h>
19 #include <time.h> 19 #include <time.h>
20 #else 20 #else
21 #include <sys/time.h> 21 #include <sys/time.h>
22 #endif 22 #endif
23 23
24 #include "webrtc/base/platform_thread.h" 24 #include "webrtc/base/platform_thread.h"
25 #include "webrtc/base/timeutils.h"
25 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 26 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
26 #include "webrtc/common_video/video_render_frames.h" 27 #include "webrtc/common_video/video_render_frames.h"
27 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 28 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
28 #include "webrtc/system_wrappers/include/event_wrapper.h" 29 #include "webrtc/system_wrappers/include/event_wrapper.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(bool disable_prerenderer_smoothing) 34 IncomingVideoStream::IncomingVideoStream(bool disable_prerenderer_smoothing)
35 : disable_prerenderer_smoothing_(disable_prerenderer_smoothing), 35 : disable_prerenderer_smoothing_(disable_prerenderer_smoothing),
36 incoming_render_thread_(), 36 incoming_render_thread_(),
37 deliver_buffer_event_(EventTimerWrapper::Create()), 37 deliver_buffer_event_(EventTimerWrapper::Create()),
38 running_(false), 38 running_(false),
39 external_callback_(nullptr), 39 external_callback_(nullptr),
40 render_callback_(nullptr), 40 render_callback_(nullptr),
41 render_buffers_(new VideoRenderFrames()), 41 render_buffers_(new VideoRenderFrames()),
42 incoming_rate_(0), 42 incoming_rate_(0),
43 last_rate_calculation_time_ms_(0), 43 last_rate_calculation_time_ms_(0),
44 num_frames_since_last_calculation_(0) {} 44 num_frames_since_last_calculation_(0) {}
45 45
46 IncomingVideoStream::~IncomingVideoStream() { 46 IncomingVideoStream::~IncomingVideoStream() {
47 Stop(); 47 Stop();
48 } 48 }
49 49
50 void IncomingVideoStream::OnFrame(const VideoFrame& video_frame) { 50 void IncomingVideoStream::OnFrame(const VideoFrame& video_frame) {
51 rtc::CritScope csS(&stream_critsect_); 51 rtc::CritScope csS(&stream_critsect_);
52 52
53 if (!running_) { 53 if (!running_) {
54 return; 54 return;
55 } 55 }
56 56
57 // Rate statistics. 57 // Rate statistics.
58 num_frames_since_last_calculation_++; 58 num_frames_since_last_calculation_++;
59 int64_t now_ms = TickTime::MillisecondTimestamp(); 59 int64_t now_ms = rtc::TimeMillis();
60 if (now_ms >= last_rate_calculation_time_ms_ + kFrameRatePeriodMs) { 60 if (now_ms >= last_rate_calculation_time_ms_ + kFrameRatePeriodMs) {
61 incoming_rate_ = 61 incoming_rate_ =
62 static_cast<uint32_t>(1000 * num_frames_since_last_calculation_ / 62 static_cast<uint32_t>(1000 * num_frames_since_last_calculation_ /
63 (now_ms - last_rate_calculation_time_ms_)); 63 (now_ms - last_rate_calculation_time_ms_));
64 num_frames_since_last_calculation_ = 0; 64 num_frames_since_last_calculation_ = 0;
65 last_rate_calculation_time_ms_ = now_ms; 65 last_rate_calculation_time_ms_ = now_ms;
66 } 66 }
67 67
68 // Hand over or insert frame. 68 // Hand over or insert frame.
69 if (disable_prerenderer_smoothing_) { 69 if (disable_prerenderer_smoothing_) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 // Send frame for rendering. 204 // Send frame for rendering.
205 if (external_callback_) { 205 if (external_callback_) {
206 external_callback_->OnFrame(video_frame); 206 external_callback_->OnFrame(video_frame);
207 } else if (render_callback_) { 207 } else if (render_callback_) {
208 render_callback_->OnFrame(video_frame); 208 render_callback_->OnFrame(video_frame);
209 } 209 }
210 } 210 }
211 211
212 } // namespace webrtc 212 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_audio/resampler/sinc_resampler_unittest.cc ('k') | webrtc/common_video/libyuv/libyuv_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698