OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
mcasas
2015/05/22 02:30:59
Remove (c)
| |
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_CAPTURER2_ANDROID_H_ | |
6 #define MEDIA_SCREEN_CAPTURE_ANDROID_SCREEN_CAPTURER2_ANDROID_H_ | |
7 | |
8 #include <jni.h> | |
9 #include <string> | |
10 | |
11 #include "base/android/scoped_java_ref.h" | |
12 #include "base/synchronization/lock.h" | |
13 #include "base/threading/thread.h" | |
14 #include "base/time/time.h" | |
15 #include "media/base/media_export.h" | |
16 #include "media/video/capture/video_capture_device.h" | |
17 | |
18 namespace media { | |
19 | |
20 // ScreenCapturer2Android captures 32bit RGB using SurfaceFlinger. | |
21 class ScreenCapturer2Android : public VideoCaptureDevice { | |
mcasas
2015/05/22 02:30:59
This class is very similar to VideoCaptureDeviceAn
| |
22 public: | |
23 explicit ScreenCapturer2Android(); | |
24 virtual ~ScreenCapturer2Android(); | |
25 | |
26 static bool RegisterScreenCapturer2(JNIEnv* env); | |
27 | |
28 bool Init(); | |
29 | |
30 // Implement org.chromium.media.ScreenCapture.nativeOnFrameAvailable. | |
31 void OnFrameAvailable( | |
32 JNIEnv* env, | |
33 jobject obj, | |
34 jbyteArray data, | |
35 jint length); | |
36 | |
37 // Implement org.chromium.media.ScreenCapture.nativeOnActivityResult. | |
38 void OnActivityResult(JNIEnv* env, jobject obj, jint result); | |
39 | |
40 // VideoCaptureDevice implementation. | |
41 void AllocateAndStart(const VideoCaptureParams& params, | |
42 scoped_ptr<Client> client) override; | |
43 void StopAndDeAllocate() override; | |
44 | |
45 private: | |
46 enum InternalState { | |
47 kIdle, // The device is opened but not in use. | |
48 kCapturing, // Video is being captured. | |
49 kError // Hit error. User needs to recover by destroying the object. | |
50 }; | |
51 | |
52 void SetErrorState(const std::string& reason); | |
53 | |
54 // Prevent racing on accessing |state_| and |client_| since both could be | |
55 // accessed from different threads. | |
56 base::Lock lock_; | |
57 InternalState state_; | |
58 bool got_first_frame_; | |
59 base::TimeTicks expected_next_frame_time_; | |
60 base::TimeDelta frame_interval_; | |
61 scoped_ptr<VideoCaptureDevice::Client> client_; | |
62 | |
63 VideoCaptureFormat capture_format_; | |
64 | |
65 // Java VideoCaptureAndroid instance. | |
66 base::android::ScopedJavaLocalRef<jobject> j_capture_; | |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(ScreenCapturer2Android); | |
69 }; | |
70 | |
71 } // namespace webrtc | |
72 | |
73 #endif // MEDIA_SCREEN_CAPTURE_ANDROID_SCREEN_CAPTURER2_ANDROID_H_ | |
OLD | NEW |