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

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: Created 7 years, 11 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
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,66 @@
+// 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 {
+
+class VideoCaptureDeviceAndroid : public VideoCaptureDevice {
+ public:
+ explicit VideoCaptureDeviceAndroid(const Name& device_name);
+ virtual ~VideoCaptureDeviceAndroid();
+
+ 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;
+
+ bool Init();
+ void OnFrameAvailable(JNIEnv* env, jobject obj,
+ jbyteArray data, jint length,
+ jint rotation, jboolean flip_vert, jboolean flip_horiz);
+
+ jobject java_capture_object() { return j_capture_.obj(); }
+
+ 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.
+ };
+
+ void SetErrorState(const std::string& reason);
+
+ 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_

Powered by Google App Engine
This is Rietveld 408576698