Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: media/video/capture/android/video_capture_device_android.h

Issue 135213005: Add GetDeviceSupportedFormats to Android VideoCapture.java. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wjia@s comments Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ 5 #ifndef MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_
6 #define MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ 6 #define MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <string> 9 #include <string>
10 10
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "media/base/media_export.h" 15 #include "media/base/media_export.h"
16 #include "media/video/capture/video_capture_device.h" 16 #include "media/video/capture/video_capture_device.h"
17 17
18 namespace media { 18 namespace media {
19 19
20 // VideoCaptureDevice on Android. The VideoCaptureDevice API's are called 20 // VideoCaptureDevice on Android. The VideoCaptureDevice API's are called
21 // by VideoCaptureManager on its own thread, while OnFrameAvailable is called 21 // by VideoCaptureManager on its own thread, while OnFrameAvailable is called
22 // on JAVA thread (i.e., UI thread). Both will access |state_| and |client_|, 22 // on JAVA thread (i.e., UI thread). Both will access |state_| and |client_|,
23 // but only VideoCaptureManager would change their value. 23 // but only VideoCaptureManager would change their value.
24 class MEDIA_EXPORT VideoCaptureDeviceAndroid : public VideoCaptureDevice { 24 class MEDIA_EXPORT VideoCaptureDeviceAndroid : public VideoCaptureDevice {
25 public: 25 public:
26 // Automatically generated enum to interface with Java world.
27 enum AndroidImageFormat {
28 #define DEFINE_ANDROID_IMAGEFORMAT(name, value) name = value,
29 #include "media/video/capture/android/imageformat_list.h"
30 #undef DEFINE_ANDROID_IMAGEFORMAT
31 };
32
26 virtual ~VideoCaptureDeviceAndroid(); 33 virtual ~VideoCaptureDeviceAndroid();
27 34
28 static VideoCaptureDevice* Create(const Name& device_name); 35 static VideoCaptureDevice* Create(const Name& device_name);
29 static bool RegisterVideoCaptureDevice(JNIEnv* env); 36 static bool RegisterVideoCaptureDevice(JNIEnv* env);
30 37
31 // VideoCaptureDevice implementation. 38 // VideoCaptureDevice implementation.
32 virtual void AllocateAndStart(const VideoCaptureParams& params, 39 virtual void AllocateAndStart(const VideoCaptureParams& params,
33 scoped_ptr<Client> client) OVERRIDE; 40 scoped_ptr<Client> client) OVERRIDE;
34 virtual void StopAndDeAllocate() OVERRIDE; 41 virtual void StopAndDeAllocate() OVERRIDE;
35 42
36 // Implement org.chromium.media.VideoCapture.nativeOnFrameAvailable. 43 // Implement org.chromium.media.VideoCapture.nativeOnFrameAvailable.
37 void OnFrameAvailable( 44 void OnFrameAvailable(
38 JNIEnv* env, 45 JNIEnv* env,
39 jobject obj, 46 jobject obj,
40 jbyteArray data, 47 jbyteArray data,
41 jint length, 48 jint length,
42 jint rotation); 49 jint rotation);
43 50
44 private: 51 private:
45 enum InternalState { 52 enum InternalState {
46 kIdle, // The device is opened but not in use. 53 kIdle, // The device is opened but not in use.
47 kCapturing, // Video is being captured. 54 kCapturing, // Video is being captured.
48 kError // Hit error. User needs to recover by destroying the object. 55 kError // Hit error. User needs to recover by destroying the object.
49 }; 56 };
50 57
51 // Automatically generated enum to interface with Java world.
52 enum AndroidImageFormat {
53 #define DEFINE_ANDROID_IMAGEFORMAT(name, value) name = value,
54 #include "media/video/capture/android/imageformat_list.h"
55 #undef DEFINE_ANDROID_IMAGEFORMAT
56 };
57
58 explicit VideoCaptureDeviceAndroid(const Name& device_name); 58 explicit VideoCaptureDeviceAndroid(const Name& device_name);
59 bool Init(); 59 bool Init();
60 VideoPixelFormat GetColorspace(); 60 VideoPixelFormat GetColorspace();
61 void SetErrorState(const std::string& reason); 61 void SetErrorState(const std::string& reason);
62 62
63 // Prevent racing on accessing |state_| and |client_| since both could be 63 // Prevent racing on accessing |state_| and |client_| since both could be
64 // accessed from different threads. 64 // accessed from different threads.
65 base::Lock lock_; 65 base::Lock lock_;
66 InternalState state_; 66 InternalState state_;
67 bool got_first_frame_; 67 bool got_first_frame_;
68 base::TimeTicks expected_next_frame_time_; 68 base::TimeTicks expected_next_frame_time_;
69 base::TimeDelta frame_interval_; 69 base::TimeDelta frame_interval_;
70 scoped_ptr<VideoCaptureDevice::Client> client_; 70 scoped_ptr<VideoCaptureDevice::Client> client_;
71 71
72 Name device_name_; 72 Name device_name_;
73 VideoCaptureFormat capture_format_; 73 VideoCaptureFormat capture_format_;
74 74
75 // Java VideoCaptureAndroid instance. 75 // Java VideoCaptureAndroid instance.
76 base::android::ScopedJavaGlobalRef<jobject> j_capture_; 76 base::android::ScopedJavaGlobalRef<jobject> j_capture_;
77 77
78 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceAndroid); 78 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceAndroid);
79 }; 79 };
80 80
81 } // namespace media 81 } // namespace media
82 82
83 #endif // MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ 83 #endif // MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698