summaryrefslogtreecommitdiffstats
path: root/remoting/codec
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-28 20:44:13 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-28 20:44:13 +0000
commit7969c007569a5676ea644ad462885d5150151f8b (patch)
tree42c91755618cb1dfd9e8ae98686c61cb84267e24 /remoting/codec
parent818d553bc8999feccd6ec6e1e9e2476d8d46a52d (diff)
downloadchromium_src-7969c007569a5676ea644ad462885d5150151f8b.zip
chromium_src-7969c007569a5676ea644ad462885d5150151f8b.tar.gz
chromium_src-7969c007569a5676ea644ad462885d5150151f8b.tar.bz2
Capturing and encoding time are now calculated by the thread doing the operation. This gives more accurate result in the case when multiple frames are scheduled for capturing/encoding simultaneously. The side effect is that the thread scheduling delays are not accounted for any more.
Review URL: https://chromiumcodereview.appspot.com/11280068 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170045 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/codec')
-rw-r--r--remoting/codec/video_encoder.h5
-rw-r--r--remoting/codec/video_encoder_verbatim.cc3
-rw-r--r--remoting/codec/video_encoder_verbatim.h2
-rw-r--r--remoting/codec/video_encoder_vp8.cc5
4 files changed, 12 insertions, 3 deletions
diff --git a/remoting/codec/video_encoder.h b/remoting/codec/video_encoder.h
index b9bee8b..5cc4c10 100644
--- a/remoting/codec/video_encoder.h
+++ b/remoting/codec/video_encoder.h
@@ -24,9 +24,8 @@ class VideoPacket;
class VideoEncoder {
public:
- // DataAvailableCallback is called as blocks of data are made available
- // from the encoder. Data made available by the encoder is in the form
- // of HostMessage to reduce the amount of memory copies.
+ // DataAvailableCallback is called one or more times, for each chunk the
+ // underlying video encoder generates.
typedef base::Callback<void(scoped_ptr<VideoPacket>)> DataAvailableCallback;
virtual ~VideoEncoder() {}
diff --git a/remoting/codec/video_encoder_verbatim.cc b/remoting/codec/video_encoder_verbatim.cc
index 25f2217..1352aa6 100644
--- a/remoting/codec/video_encoder_verbatim.cc
+++ b/remoting/codec/video_encoder_verbatim.cc
@@ -34,6 +34,7 @@ void VideoEncoderVerbatim::Encode(
<< capture_data->pixel_format();
capture_data_ = capture_data;
callback_ = data_available_callback;
+ encode_start_time_ = base::Time::Now();
const SkRegion& region = capture_data->dirty_region();
SkRegion::Iterator iter(region);
@@ -92,6 +93,8 @@ void VideoEncoderVerbatim::EncodeRect(const SkIRect& rect, bool last) {
packet->mutable_data()->resize(filled);
packet->set_flags(packet->flags() | VideoPacket::LAST_PACKET);
packet->set_capture_time_ms(capture_data_->capture_time_ms());
+ packet->set_encode_time_ms(
+ (base::Time::Now() - encode_start_time_).InMillisecondsRoundedUp());
packet->set_client_sequence_number(
capture_data_->client_sequence_number());
SkIPoint dpi(capture_data_->dpi());
diff --git a/remoting/codec/video_encoder_verbatim.h b/remoting/codec/video_encoder_verbatim.h
index 02c5814..6477b2a 100644
--- a/remoting/codec/video_encoder_verbatim.h
+++ b/remoting/codec/video_encoder_verbatim.h
@@ -5,6 +5,7 @@
#ifndef REMOTING_CODEC_VIDEO_ENCODER_VERBATIM_H_
#define REMOTING_CODEC_VIDEO_ENCODER_VERBATIM_H_
+#include "base/time.h"
#include "remoting/codec/video_encoder.h"
#include "remoting/proto/video.pb.h"
#include "third_party/skia/include/core/SkRect.h"
@@ -44,6 +45,7 @@ class VideoEncoderVerbatim : public VideoEncoder {
scoped_refptr<CaptureData> capture_data_;
DataAvailableCallback callback_;
+ base::Time encode_start_time_;
// The most recent screen size.
SkISize screen_size_;
diff --git a/remoting/codec/video_encoder_vp8.cc b/remoting/codec/video_encoder_vp8.cc
index e133113..5370549 100644
--- a/remoting/codec/video_encoder_vp8.cc
+++ b/remoting/codec/video_encoder_vp8.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "base/sys_info.h"
+#include "base/time.h"
#include "media/base/yuv_convert.h"
#include "remoting/base/capture_data.h"
#include "remoting/base/util.h"
@@ -220,6 +221,8 @@ void VideoEncoderVp8::Encode(
DCHECK_LE(32, capture_data->size().width());
DCHECK_LE(32, capture_data->size().height());
+ base::Time encode_start_time = base::Time::Now();
+
if (!initialized_ ||
(capture_data->size() != SkISize::Make(image_->w, image_->h))) {
bool ret = Init(capture_data->size());
@@ -288,6 +291,8 @@ void VideoEncoderVp8::Encode(
packet->mutable_format()->set_screen_width(capture_data->size().width());
packet->mutable_format()->set_screen_height(capture_data->size().height());
packet->set_capture_time_ms(capture_data->capture_time_ms());
+ packet->set_encode_time_ms(
+ (base::Time::Now() - encode_start_time).InMillisecondsRoundedUp());
packet->set_client_sequence_number(capture_data->client_sequence_number());
SkIPoint dpi(capture_data->dpi());
if (dpi.x())