Move files from gst-plugins-bad into the "subprojects/gst-plugins-bad/" subdir
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / gst / camerabin2 / gstcamerabin2.h
1 /* GStreamer
2  * Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 #ifndef _GST_CAMERA_BIN2_H_
20 #define _GST_CAMERA_BIN2_H_
21
22 #include <gst/gst.h>
23 #include <gst/pbutils/encoding-profile.h>
24
25 G_BEGIN_DECLS
26
27 /* to keep code mergeable */
28 #define GstCameraBin2 GstCameraBin
29 #define GstCameraBin2Class GstCameraBinClass
30
31 #define GST_TYPE_CAMERA_BIN2   (gst_camera_bin2_get_type())
32 #define GST_CAMERA_BIN2(obj)   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CAMERA_BIN2,GstCameraBin2))
33 #define GST_CAMERA_BIN2_CAST(obj)   ((GstCameraBin2 *) obj)
34 #define GST_CAMERA_BIN2_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CAMERA_BIN2,GstCameraBin2Class))
35 #define GST_IS_CAMERA_BIN2(obj)   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CAMERA_BIN2))
36 #define GST_IS_CAMERA_BIN2_CLASS(obj)   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CAMERA_BIN2))
37
38 typedef enum
39 {
40   /* matches GstEncFlags GST_ENC_FLAG_NO_AUDIO_CONVERSION in encodebin */
41   GST_CAM_FLAG_NO_AUDIO_CONVERSION = (1 << 0),
42   /* matches GstEncFlags GST_ENC_FLAG_NO_VIDEO_CONVERSION in encodebin */
43   GST_CAM_FLAG_NO_VIDEO_CONVERSION = (1 << 1),
44   /* maps to 'disable-converters' property in viewfinderbin */
45   GST_CAM_FLAG_NO_VIEWFINDER_CONVERSION = (1 << 2),
46   /* maps to GstEncFlags GST_ENC_FLAG_NO_VIDEO_CONVERSION in the image bin's
47    * encodebin */
48   GST_CAM_FLAG_NO_IMAGE_CONVERSION = (1 << 3)
49 } GstCamFlags;
50
51
52 typedef enum _GstCameraBinVideoState
53 {
54   GST_CAMERA_BIN_VIDEO_IDLE=0,
55   GST_CAMERA_BIN_VIDEO_STARTING=1,
56   GST_CAMERA_BIN_VIDEO_RECORDING=2,
57   GST_CAMERA_BIN_VIDEO_FINISHING=3
58 } GstCameraBinVideoState;
59
60 typedef struct _GstCameraBin2 GstCameraBin2;
61 typedef struct _GstCameraBin2Class GstCameraBin2Class;
62
63 struct _GstCameraBin2
64 {
65   GstPipeline pipeline;
66
67   GstElement *src;
68   GstElement *user_src;
69   gulong src_capture_notify_id;
70
71   GstElement *video_encodebin;
72   gulong video_encodebin_signal_id;
73   GstElement *videosink;
74   GstElement *videobin_capsfilter;
75
76   GstElement *viewfinderbin;
77   GstElement *viewfinderbin_queue;
78   GstElement *viewfinderbin_capsfilter;
79
80   GstElement *image_encodebin;
81   gulong image_encodebin_signal_id;
82   GstElement *imagesink;
83   GstElement *imagebin_capsfilter;
84
85   GstElement *video_filter;
86   GstElement *image_filter;
87   GstElement *viewfinder_filter;
88   GstElement *audio_filter;
89   GstElement *user_video_filter;
90   GstElement *user_image_filter;
91   GstElement *user_viewfinder_filter;
92   GstElement *user_audio_filter;
93
94   GstElement *audio_src;
95   GstElement *user_audio_src;
96   GstElement *audio_volume;
97   GstElement *audio_capsfilter;
98
99   gint processing_counter; /* atomic int */
100
101   /* Index of the auto incrementing file index for captures */
102   gint capture_index;
103
104   GMutex image_capture_mutex;
105   /* stores list of image locations to be pushed to the image sink
106    * as file location change notifications, they are pushed before
107    * each buffer capture */
108   GSList *image_location_list;
109   /* Store also tags and push them before each captured image */
110   GSList *image_tags_list;
111
112   /*
113    * Similar to above, but used for giving names to previews
114    *
115    * Need to protect with a mutex as this list is used when the
116    * camera-source posts a preview image. As we have no control
117    * on how the camera-source will behave (we can only tell how
118    * it should), the preview location list might be used in an
119    * inconsistent way.
120    * One example is the camera-source posting a preview image after
121    * camerabin2 was put to ready, when this preview list will be
122    * freed and set to NULL. Concurrent access might lead to crashes in
123    * this situation. (Concurrency from the state-change freeing the
124    * list and the message handling function looking at preview names)
125    */
126   GSList *preview_location_list;
127   GMutex preview_list_mutex;
128
129   gboolean video_profile_switch;
130   gboolean image_profile_switch;
131
132   gboolean audio_drop_eos;
133   gboolean audio_send_newseg;
134
135   GMutex video_capture_mutex;
136   GCond video_state_cond;
137   GstCameraBinVideoState video_state;
138
139   /* properties */
140   gint mode;
141   gchar *location;
142   gboolean post_previews;
143   GstCaps *preview_caps;
144   GstElement *preview_filter;
145   GstEncodingProfile *video_profile;
146   GstEncodingProfile *image_profile;
147   gfloat zoom;
148   gfloat max_zoom;
149   GstCamFlags flags;
150
151   gboolean elements_created;
152 };
153
154 struct _GstCameraBin2Class
155 {
156   GstPipelineClass pipeline_class;
157
158   /* Action signals */
159   void (*start_capture) (GstCameraBin2 * camera);
160   void (*stop_capture) (GstCameraBin2 * camera);
161 };
162
163 GType gst_camera_bin2_get_type (void);
164 GST_ELEMENT_REGISTER_DECLARE (camerabin);
165
166 G_END_DECLS
167
168 #endif