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

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

Issue 2214533002: move //media/capture to //device/capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
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_CAPTURE_VIDEO_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ 5 #ifndef DEVICE_CAPTURE_VIDEO_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_
6 #define MEDIA_CAPTURE_VIDEO_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ 6 #define DEVICE_CAPTURE_VIDEO_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/macros.h" 12 #include "base/macros.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "media/capture/capture_export.h" 17 #include "device/capture/capture_export.h"
18 #include "media/capture/video/video_capture_device.h" 18 #include "device/capture/video/video_capture_device.h"
19 19
20 namespace tracked_objects { 20 namespace tracked_objects {
21 class Location; 21 class Location;
22 } // namespace tracked_ 22 } // namespace tracked_
23 23
24 namespace media { 24 namespace device {
25 25
26 // VideoCaptureDevice on Android. The VideoCaptureDevice API's are called 26 // VideoCaptureDevice on Android. The VideoCaptureDevice API's are called
27 // by VideoCaptureManager on its own thread, while OnFrameAvailable is called 27 // by VideoCaptureManager on its own thread, while OnFrameAvailable is called
28 // on JAVA thread (i.e., UI thread). Both will access |state_| and |client_|, 28 // on JAVA thread (i.e., UI thread). Both will access |state_| and |client_|,
29 // but only VideoCaptureManager would change their value. 29 // but only VideoCaptureManager would change their value.
30 class CAPTURE_EXPORT VideoCaptureDeviceAndroid : public VideoCaptureDevice { 30 class CAPTURE_EXPORT VideoCaptureDeviceAndroid : public VideoCaptureDevice {
31 public: 31 public:
32 // Automatically generated enum to interface with Java world. 32 // Automatically generated enum to interface with Java world.
33 // 33 //
34 // A Java counterpart will be generated for this enum. 34 // A Java counterpart will be generated for this enum.
35 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.media 35 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.device
36 enum AndroidImageFormat { 36 enum AndroidImageFormat {
37 // Android graphics ImageFormat mapping, see reference in: 37 // Android graphics ImageFormat mapping, see reference in:
38 // http://developer.android.com/reference/android/graphics/ImageFormat.html 38 // http://developer.android.com/reference/android/graphics/ImageFormat.html
39 ANDROID_IMAGE_FORMAT_NV21 = 17, 39 ANDROID_IMAGE_FORMAT_NV21 = 17,
40 ANDROID_IMAGE_FORMAT_YUV_420_888 = 35, 40 ANDROID_IMAGE_FORMAT_YUV_420_888 = 35,
41 ANDROID_IMAGE_FORMAT_YV12 = 842094169, 41 ANDROID_IMAGE_FORMAT_YV12 = 842094169,
42 ANDROID_IMAGE_FORMAT_UNKNOWN = 0, 42 ANDROID_IMAGE_FORMAT_UNKNOWN = 0,
43 }; 43 };
44 44
45 explicit VideoCaptureDeviceAndroid( 45 explicit VideoCaptureDeviceAndroid(
46 const VideoCaptureDeviceDescriptor& device_descriptor); 46 const VideoCaptureDeviceDescriptor& device_descriptor);
47 ~VideoCaptureDeviceAndroid() override; 47 ~VideoCaptureDeviceAndroid() override;
48 48
49 static VideoCaptureDevice* Create( 49 static VideoCaptureDevice* Create(
50 const VideoCaptureDeviceDescriptor& device_descriptor); 50 const VideoCaptureDeviceDescriptor& device_descriptor);
51 static bool RegisterVideoCaptureDevice(JNIEnv* env); 51 static bool RegisterVideoCaptureDevice(JNIEnv* env);
52 52
53 // Registers the Java VideoCaptureDevice pointer, used by the rest of the 53 // Registers the Java VideoCaptureDevice pointer, used by the rest of the
54 // methods of the class to operate the Java capture code. This method must be 54 // methods of the class to operate the Java capture code. This method must be
55 // called after the class constructor and before AllocateAndStart(). 55 // called after the class constructor and before AllocateAndStart().
56 bool Init(); 56 bool Init();
57 57
58 // VideoCaptureDevice implementation. 58 // VideoCaptureDevice implementation.
59 void AllocateAndStart(const VideoCaptureParams& params, 59 void AllocateAndStart(const VideoCaptureParams& params,
60 std::unique_ptr<Client> client) override; 60 std::unique_ptr<Client> client) override;
61 void StopAndDeAllocate() override; 61 void StopAndDeAllocate() override;
62 void GetPhotoCapabilities(GetPhotoCapabilitiesCallback callback) override; 62 void GetPhotoCapabilities(GetPhotoCapabilitiesCallback callback) override;
63 void SetPhotoOptions(mojom::PhotoSettingsPtr settings, 63 void SetPhotoOptions(media::mojom::PhotoSettingsPtr settings,
64 SetPhotoOptionsCallback callback) override; 64 SetPhotoOptionsCallback callback) override;
65 void TakePhoto(TakePhotoCallback callback) override; 65 void TakePhoto(TakePhotoCallback callback) override;
66 66
67 // Implement org.chromium.media.VideoCapture.nativeOnFrameAvailable. 67 // Implement org.chromium.device.VideoCapture.nativeOnFrameAvailable.
68 void OnFrameAvailable(JNIEnv* env, 68 void OnFrameAvailable(JNIEnv* env,
69 const base::android::JavaParamRef<jobject>& obj, 69 const base::android::JavaParamRef<jobject>& obj,
70 const base::android::JavaParamRef<jbyteArray>& data, 70 const base::android::JavaParamRef<jbyteArray>& data,
71 jint length, 71 jint length,
72 jint rotation); 72 jint rotation);
73 73
74 // Implement org.chromium.media.VideoCapture.nativeOnI420FrameAvailable. 74 // Implement org.chromium.device.VideoCapture.nativeOnI420FrameAvailable.
75 void OnI420FrameAvailable(JNIEnv* env, 75 void OnI420FrameAvailable(JNIEnv* env,
76 jobject obj, 76 jobject obj,
77 jobject y_buffer, 77 jobject y_buffer,
78 jint y_stride, 78 jint y_stride,
79 jobject u_buffer, 79 jobject u_buffer,
80 jobject v_buffer, 80 jobject v_buffer,
81 jint uv_row_stride, 81 jint uv_row_stride,
82 jint uv_pixel_stride, 82 jint uv_pixel_stride,
83 jint width, 83 jint width,
84 jint height, 84 jint height,
85 jint rotation); 85 jint rotation);
86 86
87 // Implement org.chromium.media.VideoCapture.nativeOnError. 87 // Implement org.chromium.device.VideoCapture.nativeOnError.
88 void OnError(JNIEnv* env, 88 void OnError(JNIEnv* env,
89 const base::android::JavaParamRef<jobject>& obj, 89 const base::android::JavaParamRef<jobject>& obj,
90 const base::android::JavaParamRef<jstring>& message); 90 const base::android::JavaParamRef<jstring>& message);
91 91
92 // Implement org.chromium.media.VideoCapture.nativeOnPhotoTaken. 92 // Implement org.chromium.device.VideoCapture.nativeOnPhotoTaken.
93 void OnPhotoTaken(JNIEnv* env, 93 void OnPhotoTaken(JNIEnv* env,
94 const base::android::JavaParamRef<jobject>& obj, 94 const base::android::JavaParamRef<jobject>& obj,
95 jlong callback_id, 95 jlong callback_id,
96 const base::android::JavaParamRef<jbyteArray>& data); 96 const base::android::JavaParamRef<jbyteArray>& data);
97 97
98 private: 98 private:
99 enum InternalState { 99 enum InternalState {
100 kIdle, // The device is opened but not in use. 100 kIdle, // The device is opened but not in use.
101 kCapturing, // Video is being captured. 101 kCapturing, // Video is being captured.
102 kError // Hit error. User needs to recover by destroying the object. 102 kError // Hit error. User needs to recover by destroying the object.
(...skipping 24 matching lines...) Expand all
127 127
128 const VideoCaptureDeviceDescriptor device_descriptor_; 128 const VideoCaptureDeviceDescriptor device_descriptor_;
129 VideoCaptureFormat capture_format_; 129 VideoCaptureFormat capture_format_;
130 130
131 // Java VideoCaptureAndroid instance. 131 // Java VideoCaptureAndroid instance.
132 base::android::ScopedJavaLocalRef<jobject> j_capture_; 132 base::android::ScopedJavaLocalRef<jobject> j_capture_;
133 133
134 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceAndroid); 134 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceAndroid);
135 }; 135 };
136 136
137 } // namespace media 137 } // namespace device
138 138
139 #endif // MEDIA_CAPTURE_VIDEO_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ 139 #endif // DEVICE_CAPTURE_VIDEO_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_
OLDNEW
« no previous file with comments | « device/capture/video/android/photo_capabilities.cc ('k') | device/capture/video/android/video_capture_device_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698