OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_CAPTURE_CONTENT_ANDROID_SCREEN_CAPTURE_MACHINE_ANDROID_H_ |
| 6 #define MEDIA_CAPTURE_CONTENT_ANDROID_SCREEN_CAPTURE_MACHINE_ANDROID_H_ |
| 7 |
| 8 #include <jni.h> |
| 9 #include <memory> |
| 10 |
| 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "media/capture/content/screen_capture_device_core.h" |
| 13 |
| 14 namespace media { |
| 15 |
| 16 // ScreenCaptureMachineAndroid captures 32bit RGB or YUV420 triplanar. |
| 17 class MEDIA_EXPORT ScreenCaptureMachineAndroid |
| 18 : public media::VideoCaptureMachine { |
| 19 public: |
| 20 ScreenCaptureMachineAndroid(); |
| 21 ~ScreenCaptureMachineAndroid() override; |
| 22 |
| 23 static bool RegisterScreenCaptureMachine(JNIEnv* env); |
| 24 static base::android::ScopedJavaLocalRef<jobject> |
| 25 createScreenCaptureMachineAndroid(jlong nativeScreenCaptureMachineAndroid); |
| 26 |
| 27 // Implement org.chromium.media.ScreenCapture.nativeOnRGBAFrameAvailable. |
| 28 void OnRGBAFrameAvailable(JNIEnv* env, |
| 29 jobject obj, |
| 30 jobject buf, |
| 31 jint width, |
| 32 jint height, |
| 33 jint row_stride, |
| 34 jlong timestamp); |
| 35 // Implement org.chromium.media.ScreenCapture.nativeOnI420FrameAvailable. |
| 36 void OnI420FrameAvailable(JNIEnv* env, |
| 37 jobject obj, |
| 38 jobject y_buffer, |
| 39 jint y_Zde, |
| 40 jobject u_buffer, |
| 41 jobject v_buffer, |
| 42 jint uv_row_stride, |
| 43 jint uv_pixel_stride, |
| 44 jint width, |
| 45 jint height, |
| 46 jlong timestamp); |
| 47 |
| 48 // Implement org.chromium.media.ScreenCapture.nativeOnActivityResult. |
| 49 void OnActivityResult(JNIEnv* env, jobject obj, jboolean result); |
| 50 |
| 51 // VideoCaptureMachine overrides. |
| 52 void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, |
| 53 const media::VideoCaptureParams& params, |
| 54 const base::Callback<void(bool)> callback) override; |
| 55 void Stop(const base::Closure& callback) override; |
| 56 void MaybeCaptureForRefresh() override; |
| 57 |
| 58 private: |
| 59 void OnIncomingFrameAvailable(const uint8_t* y_src, |
| 60 int y_stride, |
| 61 const uint8_t* u_src, |
| 62 int u_stride, |
| 63 const uint8_t* v_src, |
| 64 int v_stride, |
| 65 int width, |
| 66 int height, |
| 67 int64_t timestamp); |
| 68 |
| 69 // Makes all the decisions about which frames to copy, and how. |
| 70 scoped_refptr<media::ThreadSafeCaptureOracle> oracle_proxy_; |
| 71 |
| 72 // Cache the last frame for possible refreshing. |
| 73 scoped_refptr<VideoFrame> lastFrame_; |
| 74 |
| 75 // Java VideoCaptureAndroid instance. |
| 76 base::android::ScopedJavaLocalRef<jobject> j_capture_; |
| 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureMachineAndroid); |
| 79 }; |
| 80 |
| 81 } // namespace media |
| 82 |
| 83 #endif // MEDIA_CAPTURE_CONTENT_ANDROID_SCREEN_CAPTURE_MACHINE_ANDROID_H_ |
OLD | NEW |