Initial release
[adaptation/ap_samsung/gst-plugins-s5pc2xx.git] / camerasrc / src / include / gstcamerasrc.h
1 /*
2  * camerasrc
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jeongmo Yang <jm80.yang@samsung.com>
7  *
8  * This library is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Lesser General Public License as published by the
10  * Free Software Foundation; either version 2.1 of the License, or (at your option)
11  * any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
14  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; if not, write to the Free Software Foundation, Inc., 51
20  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23
24 #ifndef __GSTCAMERASRC_H__
25 #define __GSTCAMERASRC_H__
26
27 #include <gst/gst.h>
28 #include <gst/base/gstpushsrc.h>
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33
34 #include <gst/interfaces/colorbalance.h>
35 #include <gst/interfaces/cameracontrol.h>
36
37 #include "camerasrc.h"
38
39 #ifndef _SPEED_UP_RAW_CAPTURE
40 /* Disabled now
41 #define _SPEED_UP_RAW_CAPTURE
42 */
43 #endif /* _SPEED_UP_RAW_CAPTURE */
44
45 G_BEGIN_DECLS
46 #define GST_TYPE_CAMERA_SRC             (gst_camerasrc_get_type())
47 #define GST_CAMERA_SRC(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CAMERA_SRC,GstCameraSrc))
48 #define GST_CAMERA_SRC_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CAMERA_SRC,GstCameraSrcClass))
49 #define GST_IS_CAMERA_SRC(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CAMERA_SRC))
50 #define GST_IS_CAMERA_SRC_CLASS(obj)    (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CAMERA_SRC))
51
52
53 /**
54  * Quality.
55  */
56 typedef enum {
57         GST_CAMERASRC_QUALITY_LOW,   /**< Low quality */
58         GST_CAMERASRC_QUALITY_HIGH,  /**< High quality */
59 } GstCameraSrcQuality;
60
61 #define MAX_USR_BUFFER_NUM              12
62
63 typedef struct _GstCameraSrc GstCameraSrc;
64 typedef struct _GstCameraSrcClass GstCameraSrcClass;
65 typedef struct _GstCameraBuffer GstCameraBuffer;
66
67 /* global info */
68 struct _GstCameraBuffer {
69         GstBuffer buffer;
70         int v4l2_buffer_index;
71         GstCameraSrc *camerasrc;
72         gboolean is_alloc_data;
73 };
74
75 struct _GstCameraSrc
76 {
77         GstPushSrc element;
78
79         /*private*/
80         void *v4l2_handle;                      /**< video4linux2 handle */
81         int mode;
82         int sensor_mode;                        /**< sensor mode - camera or movie(camcorder) */
83         gboolean vflip;                         /**< flip camera input vertically */
84         gboolean hflip;                         /**< flip camera input horizontally */
85         gboolean firsttime;
86
87         int main_buf_sz;
88         int cap_count_current;                  /**< current capture count */
89         int cap_count_reverse;                  /**< current capture count (reverse counting) */
90         unsigned long cap_next_time;            /**< next shot time for capture */
91         GQueue *command_list;                   /**< Command list(Start capture, Stop capture) queue */
92
93         GCond *cond;
94         GMutex *mutex;
95
96         /*camera property*/
97         int width;                              /**< Width */
98         int height;                             /**< Height */
99         int fps;                                /**< Video source fps */
100
101         guint32 fourcc;                         /**< Four CC */
102         int pix_format;                         /**< Image format of video source */
103         int colorspace;                         /**< Colorspace of video source */
104         int high_speed_fps;                     /**< Video source fps for high speed recording */
105         gboolean fps_auto;                      /**< Auto Video source fps */
106
107         gboolean req_negotiation;               /**< Video source fps for high speed recording */
108         int camera_id;
109         int rotate;                             /**< Video source rotate */
110         gboolean use_rotate_caps;               /**< Use or not rotate value in caps */
111         int external_videofd;                   /**< video FD from external module */
112
113         GCond *buffer_cond;
114         GMutex *buffer_lock;
115         gboolean buffer_running;                /* with lock */
116         gint num_live_buffers;                  /* with lock */
117         guint buffer_count;
118         gboolean bfirst;                        /* temp */
119 #ifdef _SPEED_UP_RAW_CAPTURE
120         gboolean cap_stream_diff;               /* whether preview and capture streams are different each other */
121 #endif
122         GQueue *pad_alloc_list;
123         GMutex *pad_alloc_mutex;
124         gint current_buffer_data_index;
125         gboolean first_invokation;
126
127         GstBuffer *usr_buffer[MAX_USR_BUFFER_NUM];
128         gboolean use_pad_alloc;
129         guint num_alloc_buf;
130
131         /* Colorbalance , CameraControl interface */
132         GList *colors;
133         GList *camera_controls;
134
135
136         /*capture property*/
137         guint32 cap_fourcc;                     /**< gstreamer fourcc value(GST_MAKE_FOURCC format) for raw capturing */
138         GstCameraSrcQuality cap_quality;        /**< Capture quality */
139         int cap_width;                          /**< Capture width */
140         int cap_height;                         /**< Capture height */
141         int cap_interval;                       /**< Capture interval */
142         int cap_count;                          /**< Capture count */
143         int cap_jpg_quality;                    /**< Capture quality for jpg compress ratio */
144         gboolean cap_provide_exif;              /**< Is exif provided? */
145
146         /*etc property*/
147         gboolean signal_still_capture;          /**< enable still capture signal */
148         gboolean hold_af_after_capturing;       /**< Whether to hold af after capturing */
149         gboolean create_jpeg;
150         GMutex *jpg_mutex;
151 };
152
153 struct _GstCameraSrcClass {
154         GstPushSrcClass parent_class;
155         /* signals */
156         void (*still_capture) (GstElement *element, GstBuffer *main, GstBuffer *sub, GstBuffer *scrnl);
157         void (*nego_complete) (GstElement *element);
158         void (*register_trouble) (GstElement *element);
159 };
160
161 typedef enum {
162         INTERFACE_NONE,
163         INTERFACE_COLOR_BALANCE,
164         INTERFACE_CAMERA_CONTROL,
165 } GstInterfaceType;
166
167
168 void gst_camerasrc_set_capture_command(GstCameraSrc* camerasrc, GstCameraControlCaptureCommand cmd);
169
170
171 GType gst_camerasrc_get_type(void);
172
173 G_END_DECLS
174
175 #endif /* __GSTCAMERASRC_H__ */