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_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/capture/video/video_capture_device.h" | 16 #include "media/capture/video/video_capture_device.h" |
17 | 17 |
| 18 namespace tracked_objects { |
| 19 class Location; |
| 20 } // namespace tracked_ |
| 21 |
18 namespace media { | 22 namespace media { |
19 | 23 |
20 // VideoCaptureDevice on Android. The VideoCaptureDevice API's are called | 24 // VideoCaptureDevice on Android. The VideoCaptureDevice API's are called |
21 // by VideoCaptureManager on its own thread, while OnFrameAvailable is called | 25 // by VideoCaptureManager on its own thread, while OnFrameAvailable is called |
22 // on JAVA thread (i.e., UI thread). Both will access |state_| and |client_|, | 26 // on JAVA thread (i.e., UI thread). Both will access |state_| and |client_|, |
23 // but only VideoCaptureManager would change their value. | 27 // but only VideoCaptureManager would change their value. |
24 class MEDIA_EXPORT VideoCaptureDeviceAndroid : public VideoCaptureDevice { | 28 class MEDIA_EXPORT VideoCaptureDeviceAndroid : public VideoCaptureDevice { |
25 public: | 29 public: |
26 // Automatically generated enum to interface with Java world. | 30 // Automatically generated enum to interface with Java world. |
27 // | 31 // |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 void OnError(JNIEnv* env, jobject obj, jstring message); | 67 void OnError(JNIEnv* env, jobject obj, jstring message); |
64 | 68 |
65 private: | 69 private: |
66 enum InternalState { | 70 enum InternalState { |
67 kIdle, // The device is opened but not in use. | 71 kIdle, // The device is opened but not in use. |
68 kCapturing, // Video is being captured. | 72 kCapturing, // Video is being captured. |
69 kError // Hit error. User needs to recover by destroying the object. | 73 kError // Hit error. User needs to recover by destroying the object. |
70 }; | 74 }; |
71 | 75 |
72 VideoPixelFormat GetColorspace(); | 76 VideoPixelFormat GetColorspace(); |
73 void SetErrorState(const std::string& reason); | 77 void SetErrorState(const tracked_objects::Location& from_here, |
| 78 const std::string& reason); |
74 | 79 |
75 // Prevent racing on accessing |state_| and |client_| since both could be | 80 // Prevent racing on accessing |state_| and |client_| since both could be |
76 // accessed from different threads. | 81 // accessed from different threads. |
77 base::Lock lock_; | 82 base::Lock lock_; |
78 InternalState state_; | 83 InternalState state_; |
79 bool got_first_frame_; | 84 bool got_first_frame_; |
80 base::TimeTicks expected_next_frame_time_; | 85 base::TimeTicks expected_next_frame_time_; |
81 base::TimeDelta frame_interval_; | 86 base::TimeDelta frame_interval_; |
82 scoped_ptr<VideoCaptureDevice::Client> client_; | 87 scoped_ptr<VideoCaptureDevice::Client> client_; |
83 | 88 |
84 Name device_name_; | 89 Name device_name_; |
85 VideoCaptureFormat capture_format_; | 90 VideoCaptureFormat capture_format_; |
86 | 91 |
87 // Java VideoCaptureAndroid instance. | 92 // Java VideoCaptureAndroid instance. |
88 base::android::ScopedJavaLocalRef<jobject> j_capture_; | 93 base::android::ScopedJavaLocalRef<jobject> j_capture_; |
89 | 94 |
90 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceAndroid); | 95 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceAndroid); |
91 }; | 96 }; |
92 | 97 |
93 } // namespace media | 98 } // namespace media |
94 | 99 |
95 #endif // MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ | 100 #endif // MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_ |
OLD | NEW |