1 // Copyright (c) 2012 The Samsung 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.
5 // Tizen specific implementation of VideoCaptureDevice.
6 // Tizen Core API is used to capture the video frames from the device.
8 #ifndef MEDIA_VIDEO_CAPTURE_TIZEN_VIDEO_CAPTURE_DEVICE_TIZEN_H_
9 #define MEDIA_VIDEO_CAPTURE_TIZEN_VIDEO_CAPTURE_DEVICE_TIZEN_H_
13 #include "base/threading/thread.h"
14 #include "media/capture/video/video_capture_device.h"
18 class VideoCaptureDeviceTizen : public VideoCaptureDevice {
20 const static std::string kFrontCameraName;
21 const static std::string kBackCameraName;
22 const static std::string kFrontCameraId;
23 const static std::string kBackCameraId;
25 explicit VideoCaptureDeviceTizen(const Name& device_name);
26 virtual ~VideoCaptureDeviceTizen() override;
28 virtual void AllocateAndStart(const VideoCaptureParams& params,
29 scoped_ptr<Client> client) override;
31 virtual void StopAndDeAllocate() override;
33 static camera_device_e DeviceNameToCameraId(
34 const VideoCaptureDevice::Name& device_name);
36 static std::string GetCameraErrorMessage(int err_code);
40 kIdle, // The device driver is opened but camera is not in use.
41 kCapturing, // Video is being captured.
42 kError // Error accessing HW functions.
43 // User needs to recover by destroying the object.
46 static void OnCameraCaptured(camera_preview_data_s* frame, void* data);
47 void OnAllocateAndStart(int width,
50 VideoPixelFormat format,
51 scoped_ptr<Client> client);
52 void OnStopAndDeAllocate();
54 bool AllocateVideoBuffers(int width, int height);
55 void DeAllocateVideoBuffers();
56 void SetErrorState(const std::string& reason);
59 scoped_ptr<VideoCaptureDevice::Client> client_;
61 base::Thread worker_; // Thread used for reading data from the device.
62 scoped_ptr<VideoCaptureDevice::Client::Buffer> buffer_;
64 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceTizen);
69 #endif // MEDIA_VIDEO_CAPTURE_TIZEN_VIDEO_CAPTURE_DEVICE_TIZEN_H_