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

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

Issue 2983473002: Android Tango depth camera capture support.
Patch Set: rename tango_api files to tango_client_api_glue Created 3 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 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 void OnPhotoTaken(JNIEnv* env, 99 void OnPhotoTaken(JNIEnv* env,
100 const base::android::JavaParamRef<jobject>& obj, 100 const base::android::JavaParamRef<jobject>& obj,
101 jlong callback_id, 101 jlong callback_id,
102 const base::android::JavaParamRef<jbyteArray>& data); 102 const base::android::JavaParamRef<jbyteArray>& data);
103 103
104 // Implement org.chromium.media.VideoCapture.nativeOnStarted. 104 // Implement org.chromium.media.VideoCapture.nativeOnStarted.
105 void OnStarted(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); 105 void OnStarted(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
106 106
107 void ConfigureForTesting(); 107 void ConfigureForTesting();
108 108
109 private: 109 protected:
110 enum InternalState { 110 enum InternalState {
111 kIdle, // The device is opened but not in use. 111 kIdle, // The device is opened but not in use.
112 kConfigured, // The device has been AllocateAndStart()ed. 112 kConfigured, // The device has been AllocateAndStart()ed.
113 kError // Hit error. User needs to recover by destroying the object. 113 kError // Hit error. User needs to recover by destroying the object.
114 }; 114 };
115 115
116 VideoPixelFormat GetColorspace(); 116 // Helper code executed when the frame is available; if it is the first frame,
117 // setup time fluctuation control and process any pending photo requests.
118 void ProcessFirstFrameAvailable(base::TimeTicks current_time);
119
120 // Check if there is client and if the state is valid.
121 bool IsClientConfiguredForIncomingData();
122
123 // Check if the incoming frame didn't arrived too, advance the next frame
124 // expectation time and return true;
125 bool AdvanceToNextFrameTime(base::TimeTicks current_time);
126 void SendIncomingDataToClient(const uint8_t* data,
127 int length,
128 int rotation,
129 base::TimeTicks reference_time,
130 base::TimeDelta timestamp);
117 void SetErrorState(const tracked_objects::Location& from_here, 131 void SetErrorState(const tracked_objects::Location& from_here,
118 const std::string& reason); 132 const std::string& reason);
119 133
134 VideoCaptureFormat capture_format_;
135 // Java VideoCaptureAndroid instance.
136 base::android::ScopedJavaLocalRef<jobject> j_capture_;
137
138 // |lock_| protects |state_|, |client_|, |got_first_frame_| and
139 // |photo_requests_queue_| from concurrent access.
140 base::Lock lock_;
141 InternalState state_ = kIdle;
142 std::unique_ptr<VideoCaptureDevice::Client> client_;
143 bool got_first_frame_ = false;
144 base::TimeDelta frame_interval_;
145
146 private:
147 VideoPixelFormat GetColorspace();
120 void DoGetPhotoState(GetPhotoStateCallback callback); 148 void DoGetPhotoState(GetPhotoStateCallback callback);
121 void DoSetPhotoOptions(mojom::PhotoSettingsPtr settings, 149 void DoSetPhotoOptions(mojom::PhotoSettingsPtr settings,
122 SetPhotoOptionsCallback callback); 150 SetPhotoOptionsCallback callback);
123 void DoTakePhoto(TakePhotoCallback callback); 151 void DoTakePhoto(TakePhotoCallback callback);
124 152
125 // Thread on which we are created. 153 // Thread on which we are created.
126 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 154 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
127 155
128 // |lock_| protects |state_|, |client_|, |got_first_frame_| and
129 // |photo_requests_queue_| from concurrent access.
130 base::Lock lock_;
131 InternalState state_;
132 std::unique_ptr<VideoCaptureDevice::Client> client_;
133 bool got_first_frame_;
134 // Photo-related requests waiting for |got_first_frame_| to be served. Android 156 // Photo-related requests waiting for |got_first_frame_| to be served. Android
135 // APIs need the device capturing or nearly-capturing to be fully oeprational. 157 // APIs need the device capturing or nearly-capturing to be fully oeprational.
136 std::list<base::Closure> photo_requests_queue_; 158 std::list<base::Closure> photo_requests_queue_;
137 159
138 base::TimeTicks expected_next_frame_time_; 160 base::TimeTicks expected_next_frame_time_;
139 base::TimeDelta frame_interval_;
140 161
141 // List of |photo_callbacks_| in flight, being served in Java side. 162 // List of |photo_callbacks_| in flight, being served in Java side.
142 base::Lock photo_callbacks_lock_; 163 base::Lock photo_callbacks_lock_;
143 std::list<std::unique_ptr<TakePhotoCallback>> photo_callbacks_; 164 std::list<std::unique_ptr<TakePhotoCallback>> photo_callbacks_;
144 165
145 const VideoCaptureDeviceDescriptor device_descriptor_; 166 const VideoCaptureDeviceDescriptor device_descriptor_;
146 VideoCaptureFormat capture_format_;
147
148 // Java VideoCaptureAndroid instance.
149 base::android::ScopedJavaLocalRef<jobject> j_capture_;
150 167
151 base::WeakPtrFactory<VideoCaptureDeviceAndroid> weak_ptr_factory_; 168 base::WeakPtrFactory<VideoCaptureDeviceAndroid> weak_ptr_factory_;
152 169
153 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceAndroid); 170 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceAndroid);
154 }; 171 };
155 172
156 } // namespace media 173 } // namespace media
157 174
158 #endif // MEDIA_CAPTURE_VIDEO_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ 175 #endif // MEDIA_CAPTURE_VIDEO_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_
OLDNEW
« no previous file with comments | « media/capture/video/android/tango_client_api_glue.cc ('k') | media/capture/video/android/video_capture_device_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698