summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-26 22:34:56 +0000
committerhshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-26 22:34:56 +0000
commit301c42e35d015515d18e505e1918cf4e73aa6e7a (patch)
tree116a3c9f7c0fb4df65b5ca51a0987fc616c39aed
parent3ed0026a949b0f2c857db20d7fc1335ee658c0ec (diff)
downloadchromium_src-301c42e35d015515d18e505e1918cf4e73aa6e7a.zip
chromium_src-301c42e35d015515d18e505e1918cf4e73aa6e7a.tar.gz
chromium_src-301c42e35d015515d18e505e1918cf4e73aa6e7a.tar.bz2
RTCVideoEncoder should use webrtc timestamp for |capture_time_ms|.
Previously we were using the time delta between base::Time::Now() at BitstreamBufferReady() and a "time base", but this does not match the internal frame of timeticks used by the webrtc RTP sender. As a result the sender is comparing apples to oranges, and frequently pauses HW encoder when it incorrectly believes that sender queue is too large. The solution is to use the same webrtc timestamp routine to set the |capture_time_ms|. It is nearly impossible to replicate the exact timestamp using chromium's base::Time routines. TODO(hshi): we should ideally obtain the actual timestamp when capture occurs, and not in BitstreamBufferReady. This may introduce jitter in the stream. BUG=284783 TEST=observe that EncoderPaused events are eliminated in traces. R=fischman@chromium.org, juberti@chromium.org Review URL: https://codereview.chromium.org/24623002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225590 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/media/rtc_video_encoder.cc16
1 files changed, 6 insertions, 10 deletions
diff --git a/content/renderer/media/rtc_video_encoder.cc b/content/renderer/media/rtc_video_encoder.cc
index 29794dd..1ce4b4a 100644
--- a/content/renderer/media/rtc_video_encoder.cc
+++ b/content/renderer/media/rtc_video_encoder.cc
@@ -16,6 +16,7 @@
#include "media/base/video_util.h"
#include "media/filters/gpu_video_accelerator_factories.h"
#include "media/video/video_encode_accelerator.h"
+#include "third_party/webrtc/system_wrappers/interface/tick_util.h"
#define NOTIFY_ERROR(x) \
do { \
@@ -148,10 +149,6 @@ class RTCVideoEncoder::Impl
// we don't care about ordering.
std::vector<int> input_buffers_free_;
- // Timestamp of first frame returned from encoder. We calculate subsequent
- // capture times as deltas from this base.
- base::Time time_base_;
-
DISALLOW_COPY_AND_ASSIGN(Impl);
};
@@ -324,10 +321,9 @@ void RTCVideoEncoder::Impl::BitstreamBufferReady(int32 bitstream_buffer_id,
return;
}
- const base::Time now = base::Time::Now();
- if (time_base_.is_null())
- time_base_ = now;
- const base::TimeDelta delta = now - time_base_;
+ // Use webrtc timestamps to ensure correct RTP sender behavior.
+ // TODO(hshi): obtain timestamp from the capturer, see crbug.com/284783.
+ const int64 capture_time_ms = webrtc::TickTime::MillisecondTimestamp();
scoped_ptr<webrtc::EncodedImage> image(new webrtc::EncodedImage(
reinterpret_cast<uint8_t*>(output_buffer->memory()),
@@ -336,8 +332,8 @@ void RTCVideoEncoder::Impl::BitstreamBufferReady(int32 bitstream_buffer_id,
image->_encodedWidth = input_visible_size_.width();
image->_encodedHeight = input_visible_size_.height();
// Convert capture time to 90 kHz RTP timestamp.
- image->_timeStamp = (delta * 90000).InSeconds();
- image->capture_time_ms_ = delta.InMilliseconds();
+ image->_timeStamp = static_cast<uint32_t>(90 * capture_time_ms);
+ image->capture_time_ms_ = capture_time_ms;
image->_frameType = (key_frame ? webrtc::kKeyFrame : webrtc::kDeltaFrame);
image->_completeFrame = true;