Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 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_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ | |
| 6 #define MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_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 "media/video/capture/video_capture_device.h" | |
| 15 | |
| 16 namespace media { | |
| 17 | |
| 18 class VideoCaptureDeviceAndroid : public VideoCaptureDevice { | |
| 19 public: | |
| 20 virtual ~VideoCaptureDeviceAndroid(); | |
| 21 | |
| 22 static VideoCaptureDevice* Create(const Name& device_name); | |
| 23 static bool RegisterVideoCaptureDevice(JNIEnv* env); | |
| 24 | |
| 25 // VideoCaptureDevice implementation. | |
| 26 virtual void Allocate(int width, int height, int frame_rate, | |
| 27 EventHandler* observer) OVERRIDE; | |
| 28 virtual void Start() OVERRIDE; | |
| 29 virtual void Stop() OVERRIDE; | |
| 30 virtual void DeAllocate() OVERRIDE; | |
| 31 virtual const Name& device_name() OVERRIDE; | |
| 32 | |
| 33 // Implement org.chromium.media.VideoCapture.nativeOnFrameAvailable. | |
| 34 void OnFrameAvailable(JNIEnv* env, jobject obj, | |
| 35 jbyteArray data, jint length, | |
|
Ami GONE FROM CHROMIUM
2013/01/30 19:46:23
nit: indent here is wrong (mixing styles again).
wjia(left Chromium)
2013/02/06 00:45:34
Done.
| |
| 36 jint rotation, jboolean flip_vert, jboolean flip_horiz); | |
| 37 | |
| 38 private: | |
| 39 enum InternalState { | |
| 40 kIdle, // The device is opened but not in use. | |
| 41 kAllocated, // All resouces have been allocated and camera can be started. | |
| 42 kCapturing, // Video is being captured. | |
| 43 kError // Hit error. User needs to recover by destroying the object. | |
| 44 }; | |
| 45 | |
| 46 explicit VideoCaptureDeviceAndroid(const Name& device_name); | |
| 47 bool Init(); | |
| 48 void SetErrorState(const std::string& reason); | |
| 49 | |
| 50 // Prevent racing on accessing |state_| and |observer_| since both could be | |
| 51 // accessed from different threads. | |
|
Ami GONE FROM CHROMIUM
2013/01/30 19:46:23
This is less useful than it could be. What threa
wjia(left Chromium)
2013/02/06 00:45:34
Added class-level explanation.
| |
| 52 base::Lock lock_; | |
| 53 InternalState state_; | |
| 54 VideoCaptureDevice::EventHandler* observer_; | |
|
Ami GONE FROM CHROMIUM
2013/01/30 19:46:23
add a blank line after this to separate the lock_-
wjia(left Chromium)
2013/02/06 00:45:34
Done.
| |
| 55 Name device_name_; | |
| 56 VideoCaptureCapability current_settings_; | |
| 57 scoped_ptr<uint8[]> rotation_buffer_; | |
| 58 int rotation_; | |
| 59 | |
| 60 // Java VideoCaptureAndroid instance. | |
| 61 base::android::ScopedJavaGlobalRef<jobject> j_capture_; | |
| 62 | |
| 63 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceAndroid); | |
| 64 }; | |
| 65 | |
| 66 } // namespace media | |
| 67 | |
| 68 #endif // MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ | |
| OLD | NEW |