Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 MEDIA_CAPTURE_VIDEO_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ |
| 6 #define MEDIA_CAPTURE_VIDEO_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ | 6 #define MEDIA_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 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 // but only VideoCaptureManager would change their value. | 34 // but only VideoCaptureManager would change their value. |
| 35 class CAPTURE_EXPORT VideoCaptureDeviceAndroid : public VideoCaptureDevice { | 35 class CAPTURE_EXPORT VideoCaptureDeviceAndroid : public VideoCaptureDevice { |
| 36 public: | 36 public: |
| 37 // Automatically generated enum to interface with Java world. | 37 // Automatically generated enum to interface with Java world. |
| 38 // | 38 // |
| 39 // A Java counterpart will be generated for this enum. | 39 // A Java counterpart will be generated for this enum. |
| 40 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.media | 40 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.media |
| 41 enum AndroidImageFormat { | 41 enum AndroidImageFormat { |
| 42 // Android graphics ImageFormat mapping, see reference in: | 42 // Android graphics ImageFormat mapping, see reference in: |
| 43 // http://developer.android.com/reference/android/graphics/ImageFormat.html | 43 // http://developer.android.com/reference/android/graphics/ImageFormat.html |
| 44 ANDROID_IMAGE_FORMAT_DEPTH16 = 0x44363159, | |
| 44 ANDROID_IMAGE_FORMAT_NV21 = 17, | 45 ANDROID_IMAGE_FORMAT_NV21 = 17, |
| 45 ANDROID_IMAGE_FORMAT_YUV_420_888 = 35, | 46 ANDROID_IMAGE_FORMAT_YUV_420_888 = 35, |
| 46 ANDROID_IMAGE_FORMAT_YV12 = 842094169, | 47 ANDROID_IMAGE_FORMAT_YV12 = 842094169, |
| 47 ANDROID_IMAGE_FORMAT_UNKNOWN = 0, | 48 ANDROID_IMAGE_FORMAT_UNKNOWN = 0, |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 explicit VideoCaptureDeviceAndroid( | 51 explicit VideoCaptureDeviceAndroid( |
| 51 const VideoCaptureDeviceDescriptor& device_descriptor); | 52 const VideoCaptureDeviceDescriptor& device_descriptor); |
| 52 ~VideoCaptureDeviceAndroid() override; | 53 ~VideoCaptureDeviceAndroid() override; |
| 53 | 54 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 83 jint y_stride, | 84 jint y_stride, |
| 84 jobject u_buffer, | 85 jobject u_buffer, |
| 85 jobject v_buffer, | 86 jobject v_buffer, |
| 86 jint uv_row_stride, | 87 jint uv_row_stride, |
| 87 jint uv_pixel_stride, | 88 jint uv_pixel_stride, |
| 88 jint width, | 89 jint width, |
| 89 jint height, | 90 jint height, |
| 90 jint rotation, | 91 jint rotation, |
| 91 jlong timestamp); | 92 jlong timestamp); |
| 92 | 93 |
| 94 // Implement org.chromium.media.VideoCapture.nativePointCloudAvailable. | |
| 95 virtual void OnPointCloudAvailable(JNIEnv* env, | |
| 96 jobject obj, | |
| 97 jobject points_buffer, | |
| 98 jint num_points, | |
| 99 jdouble timestamp); | |
| 100 | |
| 93 // Implement org.chromium.media.VideoCapture.nativeOnError. | 101 // Implement org.chromium.media.VideoCapture.nativeOnError. |
| 94 void OnError(JNIEnv* env, | 102 void OnError(JNIEnv* env, |
| 95 const base::android::JavaParamRef<jobject>& obj, | 103 const base::android::JavaParamRef<jobject>& obj, |
| 96 const base::android::JavaParamRef<jstring>& message); | 104 const base::android::JavaParamRef<jstring>& message); |
| 97 | 105 |
| 98 // Implement org.chromium.media.VideoCapture.nativeOnPhotoTaken. | 106 // Implement org.chromium.media.VideoCapture.nativeOnPhotoTaken. |
| 99 void OnPhotoTaken(JNIEnv* env, | 107 void OnPhotoTaken(JNIEnv* env, |
| 100 const base::android::JavaParamRef<jobject>& obj, | 108 const base::android::JavaParamRef<jobject>& obj, |
| 101 jlong callback_id, | 109 jlong callback_id, |
| 102 const base::android::JavaParamRef<jbyteArray>& data); | 110 const base::android::JavaParamRef<jbyteArray>& data); |
| 103 | 111 |
| 104 // Implement org.chromium.media.VideoCapture.nativeOnStarted. | 112 // Implement org.chromium.media.VideoCapture.nativeOnStarted. |
| 105 void OnStarted(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 113 void OnStarted(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
| 106 | 114 |
| 107 void ConfigureForTesting(); | 115 void ConfigureForTesting(); |
| 108 | 116 |
| 117 protected: | |
|
mcasas
2017/07/15 00:12:36
Can we make a CL just for these small extractions?
| |
| 118 // Helper code executed when the frame is available; if it is the first frame, | |
| 119 // setup time fluctuation control and process any pending photo requests. | |
| 120 void ProcessFirstFrameAvailable(base::TimeTicks current_time); | |
| 121 | |
| 122 // Check if there is client and if the state is valid. | |
| 123 bool IsClientConfiguredForIncomingData(); | |
| 124 | |
| 125 // Check if the incoming frame didn't arrived too, advance the next frame | |
| 126 // expectation time and return true; | |
| 127 bool AdvanceToNextFrameTime(base::TimeTicks current_time); | |
| 128 | |
| 129 void SendIncomingDataToClient(const uint8_t* data, | |
| 130 int length, | |
| 131 int rotation, | |
| 132 base::TimeTicks reference_time, | |
| 133 base::TimeDelta timestamp); | |
| 134 | |
| 135 VideoCaptureFormat capture_format_; | |
| 136 // Java VideoCaptureAndroid instance. | |
| 137 base::android::ScopedJavaLocalRef<jobject> j_capture_; | |
| 138 | |
| 109 private: | 139 private: |
| 110 enum InternalState { | 140 enum InternalState { |
| 111 kIdle, // The device is opened but not in use. | 141 kIdle, // The device is opened but not in use. |
| 112 kConfigured, // The device has been AllocateAndStart()ed. | 142 kConfigured, // The device has been AllocateAndStart()ed. |
| 113 kError // Hit error. User needs to recover by destroying the object. | 143 kError // Hit error. User needs to recover by destroying the object. |
| 114 }; | 144 }; |
| 115 | 145 |
| 116 VideoPixelFormat GetColorspace(); | 146 VideoPixelFormat GetColorspace(); |
| 117 void SetErrorState(const tracked_objects::Location& from_here, | 147 void SetErrorState(const tracked_objects::Location& from_here, |
| 118 const std::string& reason); | 148 const std::string& reason); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 136 std::list<base::Closure> photo_requests_queue_; | 166 std::list<base::Closure> photo_requests_queue_; |
| 137 | 167 |
| 138 base::TimeTicks expected_next_frame_time_; | 168 base::TimeTicks expected_next_frame_time_; |
| 139 base::TimeDelta frame_interval_; | 169 base::TimeDelta frame_interval_; |
| 140 | 170 |
| 141 // List of |photo_callbacks_| in flight, being served in Java side. | 171 // List of |photo_callbacks_| in flight, being served in Java side. |
| 142 base::Lock photo_callbacks_lock_; | 172 base::Lock photo_callbacks_lock_; |
| 143 std::list<std::unique_ptr<TakePhotoCallback>> photo_callbacks_; | 173 std::list<std::unique_ptr<TakePhotoCallback>> photo_callbacks_; |
| 144 | 174 |
| 145 const VideoCaptureDeviceDescriptor device_descriptor_; | 175 const VideoCaptureDeviceDescriptor device_descriptor_; |
| 146 VideoCaptureFormat capture_format_; | |
| 147 | |
| 148 // Java VideoCaptureAndroid instance. | |
| 149 base::android::ScopedJavaLocalRef<jobject> j_capture_; | |
| 150 | 176 |
| 151 base::WeakPtrFactory<VideoCaptureDeviceAndroid> weak_ptr_factory_; | 177 base::WeakPtrFactory<VideoCaptureDeviceAndroid> weak_ptr_factory_; |
| 152 | 178 |
| 153 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceAndroid); | 179 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceAndroid); |
| 154 }; | 180 }; |
| 155 | 181 |
| 156 } // namespace media | 182 } // namespace media |
| 157 | 183 |
| 158 #endif // MEDIA_CAPTURE_VIDEO_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ | 184 #endif // MEDIA_CAPTURE_VIDEO_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ |
| OLD | NEW |