summaryrefslogtreecommitdiffstats
path: root/remoting/host/video_frame_capturer_win.cc
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/host/video_frame_capturer_win.cc
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/host/video_frame_capturer_win.cc')
-rw-r--r--remoting/host/video_frame_capturer_win.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/remoting/host/video_frame_capturer_win.cc b/remoting/host/video_frame_capturer_win.cc
index ffb8aee..65a3c19 100644
--- a/remoting/host/video_frame_capturer_win.cc
+++ b/remoting/host/video_frame_capturer_win.cc
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/scoped_native_library.h"
+#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "base/win/scoped_gdi_object.h"
#include "base/win/scoped_hdc.h"
@@ -93,7 +94,8 @@ class VideoFrameCapturerWin : public VideoFrameCapturer {
// Creates a CaptureData instance wrapping the current framebuffer and
// notifies |delegate_|.
- void CaptureRegion(const SkRegion& region);
+ void CaptureRegion(const SkRegion& region,
+ const base::Time& capture_start_time);
// Captures the current screen contents into the current buffer.
void CaptureImage();
@@ -240,6 +242,8 @@ void VideoFrameCapturerWin::InvalidateRegion(const SkRegion& invalid_region) {
}
void VideoFrameCapturerWin::CaptureFrame() {
+ base::Time capture_start_time = base::Time::Now();
+
// Force the system to power-up display hardware, if it has been suspended.
SetThreadExecutionState(ES_DISPLAY_REQUIRED);
@@ -278,7 +282,7 @@ void VideoFrameCapturerWin::CaptureFrame() {
// the completion callback.
SkRegion invalid_region;
helper_.SwapInvalidRegion(&invalid_region);
- CaptureRegion(invalid_region);
+ CaptureRegion(invalid_region, capture_start_time);
// Check for cursor shape update.
CaptureCursor();
@@ -363,7 +367,9 @@ void VideoFrameCapturerWin::PrepareCaptureResources() {
}
}
-void VideoFrameCapturerWin::CaptureRegion(const SkRegion& region) {
+void VideoFrameCapturerWin::CaptureRegion(
+ const SkRegion& region,
+ const base::Time& capture_start_time) {
const VideoFrame* current_buffer = queue_.current_frame();
DataPlanes planes;
@@ -379,6 +385,9 @@ void VideoFrameCapturerWin::CaptureRegion(const SkRegion& region) {
helper_.set_size_most_recent(data->size());
queue_.DoneWithCurrentFrame();
+
+ data->set_capture_time_ms(
+ (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp());
delegate_->OnCaptureCompleted(data);
}