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

Unified Diff: content/renderer/media/webrtc/media_stream_remote_video_source.cc

Issue 1320183003: Preliminary change for new rtc rendering algorithm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Consider capture buffer contention Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/media/webmediaplayer_ms.cc ('k') | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc/media_stream_remote_video_source.cc
diff --git a/content/renderer/media/webrtc/media_stream_remote_video_source.cc b/content/renderer/media/webrtc/media_stream_remote_video_source.cc
index e81b37701de15df10019bdf517c105cdc50cffef..e325f797f6dee470e8e9c5c5b84e194b5d43716d 100644
--- a/content/renderer/media/webrtc/media_stream_remote_video_source.cc
+++ b/content/renderer/media/webrtc/media_stream_remote_video_source.cc
@@ -14,6 +14,7 @@
#include "media/base/video_frame.h"
#include "media/base/video_util.h"
#include "third_party/libjingle/source/talk/media/base/videoframe.h"
+#include "third_party/webrtc/system_wrappers/interface/tick_util.h"
namespace content {
@@ -47,6 +48,9 @@ class MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate
// |frame_callback_| is accessed on the IO thread.
VideoCaptureDeliverFrameCB frame_callback_;
+
+ // WebRTC Chromium timestamp diff
+ int64_t time_diff_us_;
};
MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::
@@ -54,6 +58,12 @@ MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
const VideoCaptureDeliverFrameCB& new_frame_callback)
: io_task_runner_(io_task_runner), frame_callback_(new_frame_callback) {
+ // TODO(qiangchen): There can be two differences between clocks: 1)
+ // the offset, 2) the rate (i.e., one clock runs faster than the other).
+ // See http://crbug/516700
+ time_diff_us_ =
+ (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds() -
+ webrtc::TickTime::MicrosecondTimestamp();
}
MediaStreamRemoteVideoSource::
@@ -62,7 +72,14 @@ RemoteVideoSourceDelegate::~RemoteVideoSourceDelegate() {
void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::RenderFrame(
const cricket::VideoFrame* incoming_frame) {
- TRACE_EVENT0("webrtc", "RemoteVideoSourceDelegate::RenderFrame");
+ base::TimeTicks render_time =
+ base::TimeTicks() +
+ base::TimeDelta::FromMicroseconds(incoming_frame->GetTimeStamp() / 1000 +
+ time_diff_us_);
+
+ TRACE_EVENT1("webrtc", "RemoteVideoSourceDelegate::RenderFrame",
+ "Ideal Render Instant", render_time.ToInternalValue());
+
base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds(
incoming_frame->GetElapsedTime() / rtc::kNumNanosecsPerMicrosec);
@@ -96,6 +113,9 @@ void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::RenderFrame(
base::Bind(&base::DeletePointer<cricket::VideoFrame>, frame->Copy()));
}
+ video_frame->metadata()->SetTimeTicks(
+ media::VideoFrameMetadata::REFERENCE_TIME, render_time);
+
io_task_runner_->PostTask(
FROM_HERE, base::Bind(&RemoteVideoSourceDelegate::DoRenderFrameOnIOThread,
this, video_frame));
« no previous file with comments | « content/renderer/media/webmediaplayer_ms.cc ('k') | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698