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

Unified Diff: media/screen_capture/android/screen_capture_machine_android.h

Issue 1140113002: Implement screen capture for android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ScreenCaptureMachineAndroid which inherited from content::VideoCaptureMachine Created 5 years, 7 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
Index: media/screen_capture/android/screen_capture_machine_android.h
diff --git a/media/screen_capture/android/screen_capture_machine_android.h b/media/screen_capture/android/screen_capture_machine_android.h
new file mode 100644
index 0000000000000000000000000000000000000000..877c26ba082e5c169aa4cd68321286c765ff85d5
--- /dev/null
+++ b/media/screen_capture/android/screen_capture_machine_android.h
@@ -0,0 +1,65 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_SCREEN_CAPTURE_ANDROID_SCREEN_CAPTURE_MACHINE_ANDROID_H_
+#define MEDIA_SCREEN_CAPTURE_ANDROID_SCREEN_CAPTURE_MACHINE_ANDROID_H_
+
+#include <jni.h>
+
+#include "base/android/scoped_java_ref.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "content/browser/media/capture/content_video_capture_device_core.h"
+#include "content/public/browser/power_save_blocker.h"
+
+namespace media {
+
+// ScreenCaptureMachineAndroid captures 32bit RGB using SurfaceFlinger.
+class ScreenCaptureMachineAndroid
+ : public content::VideoCaptureMachine,
+ public base::SupportsWeakPtr<ScreenCaptureMachineAndroid> {
+ public:
+ ScreenCaptureMachineAndroid();
+ ~ScreenCaptureMachineAndroid() override;
+
+ static bool RegisterScreenCaptureMachine(JNIEnv* env);
+
+ // Implement org.chromium.media.ScreenCapture.nativeOnFrameAvailable.
+ void OnFrameAvailable(
+ JNIEnv* env,
+ jobject obj,
+ jbyteArray data,
+ jint cropWidth,
+ jint cropHeight,
+ jlong timestamp);
+
+ // Implement org.chromium.media.ScreenCapture.nativeOnActivityResult.
+ void OnActivityResult(JNIEnv* env, jobject obj, jint result);
+
+ // VideoCaptureMachine overrides.
+ void Start(
+ const scoped_refptr<content::ThreadSafeCaptureOracle>& oracle_proxy,
+ const media::VideoCaptureParams& params,
+ const base::Callback<void(bool)> callback) override;
+ void Stop(const base::Closure& callback) override;
+
+ private:
+ // Makes all the decisions about which frames to copy, and how.
+ scoped_refptr<content::ThreadSafeCaptureOracle> oracle_proxy_;
+
+ VideoCaptureFormat capture_format_;
+
+ // Java VideoCaptureAndroid instance.
+ base::android::ScopedJavaLocalRef<jobject> j_capture_;
+
+ // TODO(jiayl): Remove power_save_blocker_ when there is an API to keep the
+ // screen from sleeping for the drive-by web.
+ scoped_ptr<content::PowerSaveBlocker> power_save_blocker_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScreenCaptureMachineAndroid);
+};
+
+} // namespace media
+
+#endif // MEDIA_SCREEN_CAPTURE_ANDROID_SCREEN_CAPTURE_MACHINE_ANDROID_H_

Powered by Google App Engine
This is Rietveld 408576698