summaryrefslogtreecommitdiffstats
path: root/remoting/host/screen_recorder.h
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-09 01:34:08 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-09 01:34:08 +0000
commit5bc7183a8a86f77d79187b545f4442c02b4b5da4 (patch)
tree5e8605f948381d4ee164ad3cf6b6c79fab37676f /remoting/host/screen_recorder.h
parent5484722ea6f8b25aeca90ec2c7bd85b30143ee52 (diff)
downloadchromium_src-5bc7183a8a86f77d79187b545f4442c02b4b5da4.zip
chromium_src-5bc7183a8a86f77d79187b545f4442c02b4b5da4.tar.gz
chromium_src-5bc7183a8a86f77d79187b545f4442c02b4b5da4.tar.bz2
Simplified frame rate control in the chromoting host.
Insted of keeping semi-fixed frame rate, now capturing rate is controlled by how fast we can send data to the client. Capturing of frame n is started only after frame n-2 is sent (while n-1 is being encoded). This guarantees that we don't clog the video channel buffers, and that we start capturing only if we know that the frame will not need to wait for too long in the buffer. TEST=None BUG=None Review URL: http://codereview.chromium.org/5634002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/screen_recorder.h')
-rw-r--r--remoting/host/screen_recorder.h51
1 files changed, 24 insertions, 27 deletions
diff --git a/remoting/host/screen_recorder.h b/remoting/host/screen_recorder.h
index 2cd02b1..3a844eb 100644
--- a/remoting/host/screen_recorder.h
+++ b/remoting/host/screen_recorder.h
@@ -11,7 +11,7 @@
#include "base/message_loop.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
-#include "base/time.h"
+#include "base/timer.h"
#include "remoting/base/encoder.h"
#include "remoting/host/capturer.h"
#include "remoting/proto/video.pb.h"
@@ -105,44 +105,39 @@ class ScreenRecorder : public base::RefCountedThreadSafe<ScreenRecorder> {
void DoStart();
void DoPause();
- void DoSetRate(double rate);
void DoSetMaxRate(double max_rate);
// Hepler method to schedule next capture using the current rate.
- void ScheduleNextCapture();
+ void StartCaptureTimer();
void DoCapture();
void CaptureDoneCallback(scoped_refptr<CaptureData> capture_data);
- void DoFinishEncode();
-
- void DoGetInitInfo(scoped_refptr<protocol::ConnectionToClient> client);
+ void DoFinishSend();
// Network thread -----------------------------------------------------------
- void DoStartRateControl();
- void DoPauseRateControl();
-
- // Helper method to schedule next rate regulation task.
- void ScheduleNextRateControl();
-
- void DoRateControl();
-
- // DoSendUpdate takes ownership of header and is responsible for deleting it.
+ // DoSendVideoPacket takes ownership of the |packet| and is responsible
+ // for deleting it.
void DoSendVideoPacket(VideoPacket* packet);
+
void DoSendInit(scoped_refptr<protocol::ConnectionToClient> connection,
int width, int height);
- void DoAddClient(scoped_refptr<protocol::ConnectionToClient> connection);
+ void DoAddConnection(scoped_refptr<protocol::ConnectionToClient> connection);
void DoRemoveClient(scoped_refptr<protocol::ConnectionToClient> connection);
void DoRemoveAllClients();
+ // Callback for the last packet in one update. Deletes |packet| and
+ // schedules next screen capture.
+ void OnFrameSent(VideoPacket* packet);
+
// Encoder thread -----------------------------------------------------------
void DoEncode(scoped_refptr<CaptureData> capture_data);
- // EncodeDataAvailableTask takes ownership of header and is responsible for
- // deleting it.
+ // EncodeDataAvailableTask takes ownership of |packet|.
void EncodeDataAvailableTask(VideoPacket* packet);
+ void SendVideoPacket(VideoPacket* packet);
// Message loops used by this class.
MessageLoop* capture_loop_;
@@ -166,18 +161,20 @@ class ScreenRecorder : public base::RefCountedThreadSafe<ScreenRecorder> {
ConnectionToClientList connections_;
// The following members are accessed on the capture thread.
- double rate_; // Number of captures to perform every second.
bool started_;
- base::Time last_capture_time_; // Saves the time last capture started.
- int recordings_; // Count the number of recordings
- // (i.e. capture or encode) happening.
- // The maximum rate is written on the capture thread and read on the network
- // thread.
- double max_rate_; // Number of captures to perform every second.
+ // Timer that calls DoCapture.
+ base::RepeatingTimer<ScreenRecorder> capture_timer_;
+
+ // Count the number of recordings (i.e. capture or encode) happening.
+ int recordings_;
+
+ // Set to true if we've skipped last capture because there are too
+ // many pending frames.
+ int frame_skipped_;
- // The following member is accessed on the network thread.
- bool rate_control_started_;
+ // Number of captures to perform every second. Written on the capture thread.
+ double max_rate_;
DISALLOW_COPY_AND_ASSIGN(ScreenRecorder);
};