Restore dev branch S_TRUNK_OWNERS
[platform/framework/web/chromium-efl.git] / tizen_src / chromium_impl / media / capture / video / tizen / video_capture_device_tizen.h
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.
4
5 // Tizen specific implementation of VideoCaptureDevice.
6 // Tizen Core API is used to capture the video frames from the device.
7
8 #ifndef MEDIA_VIDEO_CAPTURE_TIZEN_VIDEO_CAPTURE_DEVICE_TIZEN_H_
9 #define MEDIA_VIDEO_CAPTURE_TIZEN_VIDEO_CAPTURE_DEVICE_TIZEN_H_
10
11 #include <camera.h>
12
13 #include "base/threading/thread.h"
14 #include "media/capture/video/video_capture_device.h"
15
16 namespace media {
17
18 class VideoCaptureDeviceTizen : public VideoCaptureDevice {
19  public:
20   const static std::string kFrontCameraName;
21   const static std::string kBackCameraName;
22   const static std::string kFrontCameraId;
23   const static std::string kBackCameraId;
24
25   explicit VideoCaptureDeviceTizen(const Name& device_name);
26   virtual ~VideoCaptureDeviceTizen() override;
27
28   virtual void AllocateAndStart(const VideoCaptureParams& params,
29                                 scoped_ptr<Client> client) override;
30
31   virtual void StopAndDeAllocate() override;
32
33   static camera_device_e DeviceNameToCameraId(
34     const VideoCaptureDevice::Name& device_name);
35
36   static std::string GetCameraErrorMessage(int err_code);
37
38  private:
39   enum InternalState {
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.
44   };
45
46   static void OnCameraCaptured(camera_preview_data_s* frame, void* data);
47   void OnAllocateAndStart(int width,
48                           int height,
49                           int frame_rate,
50                           VideoPixelFormat format,
51                           scoped_ptr<Client> client);
52   void OnStopAndDeAllocate();
53
54   bool AllocateVideoBuffers(int width, int height);
55   void DeAllocateVideoBuffers();
56   void SetErrorState(const std::string& reason);
57
58   InternalState state_;
59   scoped_ptr<VideoCaptureDevice::Client> client_;
60   Name device_name_;
61   base::Thread worker_;  // Thread used for reading data from the device.
62   scoped_ptr<VideoCaptureDevice::Client::Buffer> buffer_;
63   camera_h camera_;
64   DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceTizen);
65 };
66
67 }  // namespace media
68
69 #endif  // MEDIA_VIDEO_CAPTURE_TIZEN_VIDEO_CAPTURE_DEVICE_TIZEN_H_