summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorronghuawu@chromium.org <ronghuawu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-10 01:46:17 +0000
committerronghuawu@chromium.org <ronghuawu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-10 01:46:17 +0000
commite7af1c094d8c9c202d751699f4382b90ee479f95 (patch)
tree0940b47258192beee8738a772379b899282dcf85
parent69fdff4ff3c57aa65f3f086459cf027615d1c544 (diff)
downloadchromium_src-e7af1c094d8c9c202d751699f4382b90ee479f95.zip
chromium_src-e7af1c094d8c9c202d751699f4382b90ee479f95.tar.gz
chromium_src-e7af1c094d8c9c202d751699f4382b90ee479f95.tar.bz2
* Pass the incoming frame's timestamp to the renderer.
* Adjust start_time_ for rtc video decoder so that the preroll in video renderer is correctly compensated. BUG=none test=peerconnection test Review URL: http://codereview.chromium.org/9301029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121371 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/media/rtc_video_decoder.cc30
-rw-r--r--content/renderer/media/rtc_video_decoder.h5
2 files changed, 27 insertions, 8 deletions
diff --git a/content/renderer/media/rtc_video_decoder.cc b/content/renderer/media/rtc_video_decoder.cc
index 3b3f86f..34d2ed8 100644
--- a/content/renderer/media/rtc_video_decoder.cc
+++ b/content/renderer/media/rtc_video_decoder.cc
@@ -1,9 +1,11 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/renderer/media/rtc_video_decoder.h"
+#include <algorithm>
+
#include "base/bind.h"
#include "base/callback.h"
#include "base/message_loop.h"
@@ -31,7 +33,8 @@ RTCVideoDecoder::RTCVideoDecoder(MessageLoop* message_loop,
: message_loop_(message_loop),
visible_size_(176, 144),
url_(url),
- state_(kUnInitialized) {
+ state_(kUnInitialized),
+ got_first_frame_(false) {
}
RTCVideoDecoder::~RTCVideoDecoder() {}
@@ -173,18 +176,30 @@ bool RTCVideoDecoder::RenderFrame(const cricket::VideoFrame* frame) {
// Called from libjingle thread.
DCHECK(frame);
- if (state_ != kNormal)
- return true;
+ base::TimeDelta timestamp = base::TimeDelta::FromMilliseconds(
+ frame->GetTimeStamp() / talk_base::kNumNanosecsPerMillisec);
ReadCB read_cb;
{
base::AutoLock auto_lock(lock_);
- if (read_cb_.is_null()) {
+ if (read_cb_.is_null() || state_ != kNormal) {
+ // TODO(ronghuawu): revisit TS adjustment when crbug.com/111672 is
+ // resolved.
+ if (got_first_frame_) {
+ start_time_ += timestamp - last_frame_timestamp_;
+ }
+ last_frame_timestamp_ = timestamp;
return true;
}
std::swap(read_cb, read_cb_);
}
+ // Rebase timestamp with zero as starting point.
+ if (!got_first_frame_) {
+ start_time_ = timestamp;
+ got_first_frame_ = true;
+ }
+
// Always allocate a new frame.
//
// TODO(scherkus): migrate this to proper buffer recycling.
@@ -192,8 +207,9 @@ bool RTCVideoDecoder::RenderFrame(const cricket::VideoFrame* frame) {
VideoFrame::CreateFrame(VideoFrame::YV12,
visible_size_.width(),
visible_size_.height(),
- host()->GetTime(),
- base::TimeDelta::FromMilliseconds(30));
+ timestamp - start_time_,
+ base::TimeDelta::FromMilliseconds(0));
+ last_frame_timestamp_ = timestamp;
// Aspect ratio unsupported; DCHECK when there are non-square pixels.
DCHECK_EQ(frame->GetPixelWidth(), 1u);
diff --git a/content/renderer/media/rtc_video_decoder.h b/content/renderer/media/rtc_video_decoder.h
index 35ec744..892a46d 100644
--- a/content/renderer/media/rtc_video_decoder.h
+++ b/content/renderer/media/rtc_video_decoder.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -70,6 +70,9 @@ class CONTENT_EXPORT RTCVideoDecoder
std::string url_;
DecoderState state_;
ReadCB read_cb_;
+ bool got_first_frame_;
+ base::TimeDelta last_frame_timestamp_;
+ base::TimeDelta start_time_;
// Used for accessing |read_cb_| from another thread.
base::Lock lock_;