Index: media/screen_capture/android/screen_capturer2_android.h |
diff --git a/media/screen_capture/android/screen_capturer2_android.h b/media/screen_capture/android/screen_capturer2_android.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9f3fc78176bcf35c7fba79e06ea82c78dcf3926a |
--- /dev/null |
+++ b/media/screen_capture/android/screen_capturer2_android.h |
@@ -0,0 +1,73 @@ |
+// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
mcasas
2015/05/22 02:30:59
Remove (c)
|
+// 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_CAPTURER2_ANDROID_H_ |
+#define MEDIA_SCREEN_CAPTURE_ANDROID_SCREEN_CAPTURER2_ANDROID_H_ |
+ |
+#include <jni.h> |
+#include <string> |
+ |
+#include "base/android/scoped_java_ref.h" |
+#include "base/synchronization/lock.h" |
+#include "base/threading/thread.h" |
+#include "base/time/time.h" |
+#include "media/base/media_export.h" |
+#include "media/video/capture/video_capture_device.h" |
+ |
+namespace media { |
+ |
+// ScreenCapturer2Android captures 32bit RGB using SurfaceFlinger. |
+class ScreenCapturer2Android : public VideoCaptureDevice { |
mcasas
2015/05/22 02:30:59
This class is very similar to VideoCaptureDeviceAn
|
+ public: |
+ explicit ScreenCapturer2Android(); |
+ virtual ~ScreenCapturer2Android(); |
+ |
+ static bool RegisterScreenCapturer2(JNIEnv* env); |
+ |
+ bool Init(); |
+ |
+ // Implement org.chromium.media.ScreenCapture.nativeOnFrameAvailable. |
+ void OnFrameAvailable( |
+ JNIEnv* env, |
+ jobject obj, |
+ jbyteArray data, |
+ jint length); |
+ |
+ // Implement org.chromium.media.ScreenCapture.nativeOnActivityResult. |
+ void OnActivityResult(JNIEnv* env, jobject obj, jint result); |
+ |
+ // VideoCaptureDevice implementation. |
+ void AllocateAndStart(const VideoCaptureParams& params, |
+ scoped_ptr<Client> client) override; |
+ void StopAndDeAllocate() override; |
+ |
+ private: |
+ enum InternalState { |
+ kIdle, // The device is opened but not in use. |
+ kCapturing, // Video is being captured. |
+ kError // Hit error. User needs to recover by destroying the object. |
+ }; |
+ |
+ void SetErrorState(const std::string& reason); |
+ |
+ // Prevent racing on accessing |state_| and |client_| since both could be |
+ // accessed from different threads. |
+ base::Lock lock_; |
+ InternalState state_; |
+ bool got_first_frame_; |
+ base::TimeTicks expected_next_frame_time_; |
+ base::TimeDelta frame_interval_; |
+ scoped_ptr<VideoCaptureDevice::Client> client_; |
+ |
+ VideoCaptureFormat capture_format_; |
+ |
+ // Java VideoCaptureAndroid instance. |
+ base::android::ScopedJavaLocalRef<jobject> j_capture_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ScreenCapturer2Android); |
+}; |
+ |
+} // namespace webrtc |
+ |
+#endif // MEDIA_SCREEN_CAPTURE_ANDROID_SCREEN_CAPTURER2_ANDROID_H_ |