OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_SCREEN_CAPTURE_ANDROID_SCREEN_CAPTURE_MACHINE_ANDROID_H_ |
| 6 #define MEDIA_SCREEN_CAPTURE_ANDROID_SCREEN_CAPTURE_MACHINE_ANDROID_H_ |
| 7 |
| 8 #include <jni.h> |
| 9 |
| 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/browser/media/capture/content_video_capture_device_core.h" |
| 14 #include "content/public/browser/power_save_blocker.h" |
| 15 |
| 16 namespace media { |
| 17 |
| 18 // ScreenCaptureMachineAndroid captures 32bit RGB using SurfaceFlinger. |
| 19 class ScreenCaptureMachineAndroid |
| 20 : public content::VideoCaptureMachine, |
| 21 public base::SupportsWeakPtr<ScreenCaptureMachineAndroid> { |
| 22 public: |
| 23 ScreenCaptureMachineAndroid(); |
| 24 ~ScreenCaptureMachineAndroid() override; |
| 25 |
| 26 static bool RegisterScreenCaptureMachine(JNIEnv* env); |
| 27 |
| 28 // Implement org.chromium.media.ScreenCapture.nativeOnFrameAvailable. |
| 29 void OnFrameAvailable( |
| 30 JNIEnv* env, |
| 31 jobject obj, |
| 32 jbyteArray data, |
| 33 jint cropWidth, |
| 34 jint cropHeight, |
| 35 jlong timestamp); |
| 36 |
| 37 // Implement org.chromium.media.ScreenCapture.nativeOnActivityResult. |
| 38 void OnActivityResult(JNIEnv* env, jobject obj, jint result); |
| 39 |
| 40 // VideoCaptureMachine overrides. |
| 41 void Start( |
| 42 const scoped_refptr<content::ThreadSafeCaptureOracle>& oracle_proxy, |
| 43 const media::VideoCaptureParams& params, |
| 44 const base::Callback<void(bool)> callback) override; |
| 45 void Stop(const base::Closure& callback) override; |
| 46 |
| 47 private: |
| 48 // Makes all the decisions about which frames to copy, and how. |
| 49 scoped_refptr<content::ThreadSafeCaptureOracle> oracle_proxy_; |
| 50 |
| 51 VideoCaptureFormat capture_format_; |
| 52 |
| 53 // Java VideoCaptureAndroid instance. |
| 54 base::android::ScopedJavaLocalRef<jobject> j_capture_; |
| 55 |
| 56 // TODO(jiayl): Remove power_save_blocker_ when there is an API to keep the |
| 57 // screen from sleeping for the drive-by web. |
| 58 scoped_ptr<content::PowerSaveBlocker> power_save_blocker_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureMachineAndroid); |
| 61 }; |
| 62 |
| 63 } // namespace media |
| 64 |
| 65 #endif // MEDIA_SCREEN_CAPTURE_ANDROID_SCREEN_CAPTURE_MACHINE_ANDROID_H_ |
OLD | NEW |