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

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

Issue 11860002: Add video capture on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: code review and rebase Created 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_
6 #define MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_
7
8 #include <jni.h>
9 #include <string>
10
11 #include "base/android/scoped_java_ref.h"
12 #include "base/synchronization/lock.h"
13 #include "base/threading/thread.h"
14 #include "media/video/capture/video_capture_device.h"
15
16 namespace media {
17
18 class VideoCaptureDeviceAndroid : public VideoCaptureDevice {
19 public:
20 virtual ~VideoCaptureDeviceAndroid();
21
22 static VideoCaptureDevice* Create(const Name& device_name);
23 static bool RegisterVideoCaptureDevice(JNIEnv* env);
24
25 // VideoCaptureDevice implementation.
26 virtual void Allocate(int width, int height, int frame_rate,
27 EventHandler* observer) OVERRIDE;
28 virtual void Start() OVERRIDE;
29 virtual void Stop() OVERRIDE;
30 virtual void DeAllocate() OVERRIDE;
31 virtual const Name& device_name() OVERRIDE;
32
33 // Implement org.chromium.media.VideoCapture.nativeOnFrameAvailable.
34 void OnFrameAvailable(JNIEnv* env, jobject obj,
35 jbyteArray data, jint length,
Ami GONE FROM CHROMIUM 2013/01/30 19:46:23 nit: indent here is wrong (mixing styles again).
wjia(left Chromium) 2013/02/06 00:45:34 Done.
36 jint rotation, jboolean flip_vert, jboolean flip_horiz);
37
38 private:
39 enum InternalState {
40 kIdle, // The device is opened but not in use.
41 kAllocated, // All resouces have been allocated and camera can be started.
42 kCapturing, // Video is being captured.
43 kError // Hit error. User needs to recover by destroying the object.
44 };
45
46 explicit VideoCaptureDeviceAndroid(const Name& device_name);
47 bool Init();
48 void SetErrorState(const std::string& reason);
49
50 // Prevent racing on accessing |state_| and |observer_| since both could be
51 // accessed from different threads.
Ami GONE FROM CHROMIUM 2013/01/30 19:46:23 This is less useful than it could be. What threa
wjia(left Chromium) 2013/02/06 00:45:34 Added class-level explanation.
52 base::Lock lock_;
53 InternalState state_;
54 VideoCaptureDevice::EventHandler* observer_;
Ami GONE FROM CHROMIUM 2013/01/30 19:46:23 add a blank line after this to separate the lock_-
wjia(left Chromium) 2013/02/06 00:45:34 Done.
55 Name device_name_;
56 VideoCaptureCapability current_settings_;
57 scoped_ptr<uint8[]> rotation_buffer_;
58 int rotation_;
59
60 // Java VideoCaptureAndroid instance.
61 base::android::ScopedJavaGlobalRef<jobject> j_capture_;
62
63 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceAndroid);
64 };
65
66 } // namespace media
67
68 #endif // MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698