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

Side by Side Diff: content/renderer/media/rtc_video_capturer.cc

Issue 13554003: Use NTP time for video frame timestamp. Add tracing for timestamps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/media/rtc_video_capturer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/rtc_video_capturer.h" 5 #include "content/renderer/media/rtc_video_capturer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h"
8 9
9 namespace content { 10 namespace content {
10 11
11 RtcVideoCapturer::RtcVideoCapturer( 12 RtcVideoCapturer::RtcVideoCapturer(
12 const media::VideoCaptureSessionId id, 13 const media::VideoCaptureSessionId id,
13 VideoCaptureImplManager* vc_manager, 14 VideoCaptureImplManager* vc_manager,
14 bool is_screencast) 15 bool is_screencast)
15 : is_screencast_(is_screencast), 16 : is_screencast_(is_screencast),
16 delegate_(new RtcVideoCaptureDelegate(id, vc_manager)), 17 delegate_(new RtcVideoCaptureDelegate(id, vc_manager)),
17 state_(VIDEO_CAPTURE_STATE_STOPPED) { 18 state_(VIDEO_CAPTURE_STATE_STOPPED) {
19 base::Time::Exploded exploded;
no longer working on chromium 2013/04/05 08:56:34 nit, initialize the value to {}
justinlin 2013/04/05 19:03:42 Done.
20 exploded.year = 1900;
21 exploded.month = 1;
22 exploded.day_of_week = 0;
23 exploded.day_of_month = 1;
24 exploded.hour = 0;
25 exploded.minute = 0;
26 exploded.second = 0;
27 exploded.millisecond = 0;
28 ntp_epoch_ = base::Time::FromUTCExploded(exploded);
18 } 29 }
19 30
20 RtcVideoCapturer::~RtcVideoCapturer() { 31 RtcVideoCapturer::~RtcVideoCapturer() {
21 DCHECK(VIDEO_CAPTURE_STATE_STOPPED); 32 DCHECK(VIDEO_CAPTURE_STATE_STOPPED);
22 DVLOG(3) << " RtcVideoCapturer::dtor"; 33 DVLOG(3) << " RtcVideoCapturer::dtor";
23 } 34 }
24 35
25 cricket::CaptureState RtcVideoCapturer::Start( 36 cricket::CaptureState RtcVideoCapturer::Start(
26 const cricket::VideoFormat& capture_format) { 37 const cricket::VideoFormat& capture_format) {
27 DVLOG(3) << " RtcVideoCapturer::Start "; 38 DVLOG(3) << " RtcVideoCapturer::Start ";
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const media::VideoCapture::VideoFrameBuffer& buf) { 104 const media::VideoCapture::VideoFrameBuffer& buf) {
94 // Currently, |fourcc| is always I420. 105 // Currently, |fourcc| is always I420.
95 cricket::CapturedFrame frame; 106 cricket::CapturedFrame frame;
96 frame.width = buf.width; 107 frame.width = buf.width;
97 frame.height = buf.height; 108 frame.height = buf.height;
98 frame.fourcc = cricket::FOURCC_I420; 109 frame.fourcc = cricket::FOURCC_I420;
99 frame.data_size = buf.buffer_size; 110 frame.data_size = buf.buffer_size;
100 // cricket::CapturedFrame time is in nanoseconds. 111 // cricket::CapturedFrame time is in nanoseconds.
101 frame.elapsed_time = (buf.timestamp - start_time_).InMicroseconds() * 112 frame.elapsed_time = (buf.timestamp - start_time_).InMicroseconds() *
102 base::Time::kNanosecondsPerMicrosecond; 113 base::Time::kNanosecondsPerMicrosecond;
103 frame.time_stamp = frame.elapsed_time; 114 // Timestamp in NTP time (seconds since 0:00 UTC 1 January 1900) in ms.
115 frame.time_stamp = (buf.timestamp - ntp_epoch_).InMilliseconds();
104 frame.data = buf.memory_pointer; 116 frame.data = buf.memory_pointer;
105 frame.pixel_height = 1; 117 frame.pixel_height = 1;
106 frame.pixel_width = 1; 118 frame.pixel_width = 1;
107 119
120 TRACE_EVENT_INSTANT2("rtc_video_capturer",
121 "OnFrameCaptured",
122 TRACE_EVENT_SCOPE_THREAD,
123 "elapsed time",
124 frame.elapsed_time,
125 "timestamp",
126 frame.time_stamp);
127
108 // This signals to libJingle that a new VideoFrame is available. 128 // This signals to libJingle that a new VideoFrame is available.
109 // libJingle have no assumptions on what thread this signal come from. 129 // libJingle have no assumptions on what thread this signal come from.
110 SignalFrameCaptured(this, &frame); 130 SignalFrameCaptured(this, &frame);
111 } 131 }
112 132
113 void RtcVideoCapturer::OnStateChange( 133 void RtcVideoCapturer::OnStateChange(
114 RtcVideoCaptureDelegate::CaptureState state) { 134 RtcVideoCaptureDelegate::CaptureState state) {
115 cricket::CaptureState converted_state = cricket::CS_FAILED; 135 cricket::CaptureState converted_state = cricket::CS_FAILED;
116 switch (state) { 136 switch (state) {
117 case RtcVideoCaptureDelegate::CAPTURE_STOPPED: 137 case RtcVideoCaptureDelegate::CAPTURE_STOPPED:
118 converted_state = cricket::CS_STOPPED; 138 converted_state = cricket::CS_STOPPED;
119 break; 139 break;
120 case RtcVideoCaptureDelegate::CAPTURE_RUNNING: 140 case RtcVideoCaptureDelegate::CAPTURE_RUNNING:
121 converted_state = cricket::CS_RUNNING; 141 converted_state = cricket::CS_RUNNING;
122 break; 142 break;
123 case RtcVideoCaptureDelegate::CAPTURE_FAILED: 143 case RtcVideoCaptureDelegate::CAPTURE_FAILED:
124 converted_state = cricket::CS_FAILED; 144 converted_state = cricket::CS_FAILED;
125 break; 145 break;
126 default: 146 default:
127 NOTREACHED(); 147 NOTREACHED();
128 break; 148 break;
129 } 149 }
130 SignalStateChange(this, converted_state); 150 SignalStateChange(this, converted_state);
131 } 151 }
132 152
133 } // namespace content 153 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_video_capturer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698