Use NTP time for video frame timestamp.

Add tracing for capture timestamps.

BUG=225209


Review URL: https://chromiumcodereview.appspot.com/13554003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192670 0039d316-1c4b-4281-b951-d872f2087c98
parent f5869d8b
......@@ -517,8 +517,9 @@ void CaptureOracle::DidCaptureFrame(
bool success) {
base::AutoLock guard(lock_);
TRACE_EVENT_ASYNC_END1("mirroring", "Capture", frame.get(),
"success", success);
TRACE_EVENT_ASYNC_END2("mirroring", "Capture", frame.get(),
"success", success,
"timestamp", timestamp.ToInternalValue());
if (!consumer_ || !is_started_)
return; // Capture is stopped.
......
......@@ -5,6 +5,7 @@
#include "content/renderer/media/rtc_video_capturer.h"
#include "base/bind.h"
#include "base/debug/trace_event.h"
namespace content {
......@@ -15,6 +16,17 @@ RtcVideoCapturer::RtcVideoCapturer(
: is_screencast_(is_screencast),
delegate_(new RtcVideoCaptureDelegate(id, vc_manager)),
state_(VIDEO_CAPTURE_STATE_STOPPED) {
base::Time::Exploded exploded = {};
exploded.year = 1900;
exploded.month = 1;
exploded.day_of_week = 0;
exploded.day_of_month = 1;
exploded.hour = 0;
exploded.minute = 0;
exploded.second = 0;
exploded.millisecond = 0;
DCHECK(exploded.HasValidValues());
ntp_epoch_ = base::Time::FromUTCExploded(exploded);
}
RtcVideoCapturer::~RtcVideoCapturer() {
......@@ -100,11 +112,20 @@ void RtcVideoCapturer::OnFrameCaptured(
// cricket::CapturedFrame time is in nanoseconds.
frame.elapsed_time = (buf.timestamp - start_time_).InMicroseconds() *
base::Time::kNanosecondsPerMicrosecond;
frame.time_stamp = frame.elapsed_time;
// Timestamp in NTP time (seconds since 0:00 UTC 1 January 1900) in ms.
frame.time_stamp = (buf.timestamp - ntp_epoch_).InMilliseconds();
frame.data = buf.memory_pointer;
frame.pixel_height = 1;
frame.pixel_width = 1;
TRACE_EVENT_INSTANT2("rtc_video_capturer",
"OnFrameCaptured",
TRACE_EVENT_SCOPE_THREAD,
"elapsed time",
frame.elapsed_time,
"timestamp",
frame.time_stamp);
// This signals to libJingle that a new VideoFrame is available.
// libJingle have no assumptions on what thread this signal come from.
SignalFrameCaptured(this, &frame);
......
......@@ -51,6 +51,7 @@ class RtcVideoCapturer
scoped_refptr<RtcVideoCaptureDelegate> delegate_;
VideoCaptureState state_;
base::Time start_time_;
base::Time ntp_epoch_;
DISALLOW_COPY_AND_ASSIGN(RtcVideoCapturer);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment