| 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,65 @@
|
| +// 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();
|
| + virtual void OnFrameAvailable(uint8* buffer, int length, base::Time timestamp,
|
| + int rotation, bool flip_vert, bool 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_
|
|
|