Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(840)

Unified Diff: media/capture/content/screen_capture_device_core.cc

Issue 2364413002: Screen Video Capture: Implement suspend optimization. (Closed)
Patch Set: Unwind ScreenCaptureMachineAndroid changes. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/capture/content/screen_capture_device_core.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/capture/content/screen_capture_device_core.cc
diff --git a/media/capture/content/screen_capture_device_core.cc b/media/capture/content/screen_capture_device_core.cc
index 0f06dfa51c5d59f4d73c3539873558ceaeb81452..f65ea591741117b68c4a1cc5b9487d896e5b083e 100644
--- a/media/capture/content/screen_capture_device_core.cc
+++ b/media/capture/content/screen_capture_device_core.cc
@@ -69,7 +69,7 @@ void ScreenCaptureDeviceCore::AllocateAndStart(
void ScreenCaptureDeviceCore::RequestRefreshFrame() {
DCHECK(thread_checker_.CalledOnValidThread());
- if (state_ != kCapturing)
+ if (state_ != kCapturing && state_ != kSuspended)
return;
if (oracle_proxy_->AttemptPassiveRefresh())
@@ -77,12 +77,34 @@ void ScreenCaptureDeviceCore::RequestRefreshFrame() {
capture_machine_->MaybeCaptureForRefresh();
}
-void ScreenCaptureDeviceCore::StopAndDeAllocate() {
+void ScreenCaptureDeviceCore::Suspend() {
DCHECK(thread_checker_.CalledOnValidThread());
if (state_ != kCapturing)
return;
+ TransitionStateTo(kSuspended);
+
+ capture_machine_->Suspend();
+}
+
+void ScreenCaptureDeviceCore::Resume() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ if (state_ != kSuspended)
+ return;
+
+ TransitionStateTo(kCapturing);
+
+ capture_machine_->Resume();
+}
+
+void ScreenCaptureDeviceCore::StopAndDeAllocate() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ if (state_ != kCapturing && state_ != kSuspended)
+ return;
+
oracle_proxy_->Stop();
oracle_proxy_ = NULL;
@@ -105,7 +127,7 @@ ScreenCaptureDeviceCore::ScreenCaptureDeviceCore(
ScreenCaptureDeviceCore::~ScreenCaptureDeviceCore() {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK_NE(state_, kCapturing);
+ DCHECK(state_ != kCapturing && state_ != kSuspended);
if (capture_machine_) {
capture_machine_->Stop(
base::Bind(&DeleteCaptureMachine, base::Passed(&capture_machine_)));
@@ -117,7 +139,8 @@ void ScreenCaptureDeviceCore::TransitionStateTo(State next_state) {
DCHECK(thread_checker_.CalledOnValidThread());
#ifndef NDEBUG
- static const char* kStateNames[] = {"Idle", "Capturing", "Error"};
+ static const char* kStateNames[] = {"Idle", "Capturing", "Suspended",
+ "Error"};
static_assert(arraysize(kStateNames) == kLastCaptureState,
"Different number of states and textual descriptions");
DVLOG(1) << "State change: " << kStateNames[state_] << " --> "
« no previous file with comments | « media/capture/content/screen_capture_device_core.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698