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

Unified 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: catch only IOException 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/media.gyp ('k') | media/video/capture/android/video_capture_device_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/video/capture/android/video_capture_device_android.h
===================================================================
--- media/video/capture/android/video_capture_device_android.h (revision 0)
+++ media/video/capture/android/video_capture_device_android.h (revision 0)
@@ -0,0 +1,80 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_
+#define MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_
+
+#include <jni.h>
+#include <string>
+
+#include "base/android/scoped_java_ref.h"
+#include "base/synchronization/lock.h"
+#include "base/threading/thread.h"
+#include "media/video/capture/video_capture_device.h"
+
+namespace media {
+
+// VideoCaptureDevice on Android. The VideoCaptureDevice API's are called
+// by VideoCaptureManager on its own thread, while OnFrameAvailable is called
+// on JAVA thread (i.e., UI thread). Both will access |state_| and |observer_|,
+// but only VideoCaptureManager would change their value.
+class VideoCaptureDeviceAndroid : public VideoCaptureDevice {
+ public:
+ virtual ~VideoCaptureDeviceAndroid();
+
+ static VideoCaptureDevice* Create(const Name& device_name);
+ static bool RegisterVideoCaptureDevice(JNIEnv* env);
+
+ // VideoCaptureDevice implementation.
+ virtual void Allocate(int width,
+ int height,
+ int frame_rate,
+ EventHandler* observer) OVERRIDE;
+ virtual void Start() OVERRIDE;
+ virtual void Stop() OVERRIDE;
+ virtual void DeAllocate() OVERRIDE;
+ virtual const Name& device_name() OVERRIDE;
+
+ // Implement org.chromium.media.VideoCapture.nativeOnFrameAvailable.
+ void OnFrameAvailable(
+ JNIEnv* env,
+ jobject obj,
+ jbyteArray data,
+ jint length,
+ jint rotation,
+ jboolean flip_vert,
+ jboolean flip_horiz);
+
+ private:
+ enum InternalState {
+ kIdle, // The device is opened but not in use.
+ kAllocated, // All resouces have been allocated and camera can be started.
+ kCapturing, // Video is being captured.
+ kError // Hit error. User needs to recover by destroying the object.
+ };
+
+ explicit VideoCaptureDeviceAndroid(const Name& device_name);
+ bool Init();
+ void SetErrorState(const std::string& reason);
+
+ // Prevent racing on accessing |state_| and |observer_| since both could be
+ // accessed from different threads.
+ base::Lock lock_;
+ InternalState state_;
+ VideoCaptureDevice::EventHandler* observer_;
+
+ Name device_name_;
+ VideoCaptureCapability current_settings_;
+ scoped_ptr<uint8[]> rotation_buffer_;
+ int rotation_;
+
+ // Java VideoCaptureAndroid instance.
+ base::android::ScopedJavaGlobalRef<jobject> j_capture_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceAndroid);
+};
+
+} // namespace media
+
+#endif // MEDIA_VIDEO_CAPTURE_ANDROID_VIDEO_CAPTURE_DEVICE_ANDROID_H_
« no previous file with comments | « media/media.gyp ('k') | media/video/capture/android/video_capture_device_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698