[Release version 0.10.71] Update error handling for invalid state and pointer
[platform/core/multimedia/libmm-camcorder.git] / src / include / mm_camcorder_gstcommon.h
1 /*
2  * libmm-camcorder
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jeongmo Yang <jm80.yang@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __MM_CAMCORDER_GSTCOMMON_H__
23 #define __MM_CAMCORDER_GSTCOMMON_H__
24
25 /*=======================================================================================
26 | INCLUDE FILES                                                                         |
27 ========================================================================================*/
28 #include <mm_types.h>
29 #include "mm_camcorder_configure.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /*=======================================================================================
36 | GLOBAL DEFINITIONS AND DECLARATIONS FOR CAMCORDER                                     |
37 ========================================================================================*/
38
39 /*=======================================================================================
40 | MACRO DEFINITIONS                                                                     |
41 ========================================================================================*/
42
43 /*=======================================================================================
44 | ENUM DEFINITIONS                                                                      |
45 ========================================================================================*/
46 /**
47 * Enumerations for AMR bitrate
48 */
49 typedef enum _MMCamcorderAMRBitRate {
50         MM_CAMCORDER_MR475,     /**< MR475 : 4.75 kbit/s */
51         MM_CAMCORDER_MR515,     /**< MR515 : 5.15 kbit/s */
52         MM_CAMCORDER_MR59,      /**< MR59 : 5.90 kbit/s */
53         MM_CAMCORDER_MR67,      /**< MR67 : 6.70 kbit/s */
54         MM_CAMCORDER_MR74,      /**< MR74 : 7.40 kbit/s */
55         MM_CAMCORDER_MR795,     /**< MR795 : 7.95 kbit/s */
56         MM_CAMCORDER_MR102,     /**< MR102 : 10.20 kbit/s */
57         MM_CAMCORDER_MR122,     /**< MR122 : 12.20 kbit/s */
58         MM_CAMCORDER_MRDTX      /**< MRDTX */
59 } MMCamcorderAMRBitRate;
60
61 /**
62 * Encodebin profile
63 */
64 typedef enum _MMCamcorderEncodebinProfile {
65         MM_CAMCORDER_ENCBIN_PROFILE_VIDEO = 0,  /**< Video recording profile */
66         MM_CAMCORDER_ENCBIN_PROFILE_AUDIO,      /**< Audio recording profile */
67         MM_CAMCORDER_ENCBIN_PROFILE_IMAGE,      /**< Image capture profile */
68         MM_CAMCORDER_ENCBIN_PROFILE_NUM
69 } MMCamcorderEncodebinProfile;
70
71 /**
72 * Encoder Type
73 */
74 typedef enum _MMCamcorderEncoderType {
75         MM_CAMCORDER_ENCODER_TYPE_AUDIO,
76         MM_CAMCORDER_ENCODER_TYPE_VIDEO
77 } MMCamcorderEncoderType;
78
79 /*=======================================================================================
80 | STRUCTURE DEFINITIONS                                                                 |
81 ========================================================================================*/
82 /**
83  * Element name table.
84  * @note if name is NULL, not supported.
85  */
86 typedef struct {
87         unsigned int prof_id;           /**< id of mmcamcorder_profile_attrs_id */
88         unsigned int id;                /**< id of value id */
89         char *name;                     /**< gstreamer element name*/
90 } _MMCamcorderElementName;
91
92 /*=======================================================================================
93 | CONSTANT DEFINITIONS                                                                  |
94 ========================================================================================*/
95
96 /*=======================================================================================
97 | STATIC VARIABLES                                                                      |
98 ========================================================================================*/
99
100 /*=======================================================================================
101 | EXTERN GLOBAL VARIABLE                                                                |
102 ========================================================================================*/
103
104 /*=======================================================================================
105 | GLOBAL FUNCTION PROTOTYPES                                                            |
106 ========================================================================================*/
107 /* create pipeline */
108 /**
109  * This function creates bin of video source.
110  * Basically, main pipeline of camcorder is composed of several bin(a bundle
111  *  of elements). Each bin operates its own function. This bin has a roll
112  * inputting video data from camera.
113  *
114  * @param[in]   handle          Handle of camcorder context.
115  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
116  * @remarks
117  * @see         __mmcamcorder_create_preview_pipeline()
118  */
119 int _mmcamcorder_create_preview_elements(MMHandleType handle);
120
121 /**
122  * This function creates bin of audio source.
123  * Basically, main pipeline of camcorder is composed of several bin(a bundle
124  *  of elements). Each bin operates its own function. This bin has a roll
125  * inputting audio data from audio source(such as mike).
126  *
127  * @param[in]   handle          Handle of camcorder context.
128  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
129  * @remarks
130  * @see         __mmcamcorder_create_preview_pipeline()
131  */
132 int _mmcamcorder_create_audiosrc_bin(MMHandleType handle);
133
134 /**
135  * This function creates outputsink bin.
136  *
137  * @param[in]   handle          Handle of camcorder context.
138  * @param[in]   profile         profile of encodesinkbin.
139  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
140  * @remarks
141  * @see         __mmcamcorder_create_preview_pipeline()
142  */
143 int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebinProfile profile);
144
145 /**
146  * This function creates main pipeline of camcorder.
147  * Basically, main pipeline of camcorder is composed of several bin(a bundle
148  *  of elements). And if the appilcation wants to make pipeline working, the
149  * application assemble bin that is proper to that task.
150  * When this function is called, bins that is needed for preview will be composed.
151  *
152  * @param[in]   handle Handle of camcorder context.
153  * @return      This function returns MM_ERROR_NONE on success, or the other values on error.
154  * @remarks
155  * @see         _mmcamcorder_create_pipeline()
156  */
157 int _mmcamcorder_create_preview_pipeline(MMHandleType handle);
158
159 /* plug-in related */
160 void _mmcamcorder_ready_to_encode_callback(GstElement *element, guint size, gpointer handle);
161 bool _mmcamcorder_recreate_decoder_for_encoded_preview(MMHandleType handle);
162
163 /* etc */
164 int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element *VideosinkElement);
165 int _mmcamcorder_vframe_stablize(MMHandleType handle);
166 gboolean _mmcamcorder_get_device_info(MMHandleType handle);
167 int _mmcamcorder_get_eos_message(MMHandleType handle);
168 void _mmcamcorder_remove_element_handle(MMHandleType handle, void *element, int first_elem, int last_elem);
169 int _mmcamcorder_check_audiocodec_fileformat_compatibility(MMHandleType handle);
170 int _mmcamcorder_check_videocodec_fileformat_compatibility(MMHandleType handle);
171 bool _mmcamcorder_set_display_rotation(MMHandleType handle, int display_rotate, int videosink_index);
172 bool _mmcamcorder_set_display_flip(MMHandleType handle, int display_flip, int videosink_index);
173 bool _mmcamcorder_set_videosrc_rotation(MMHandleType handle, int videosrc_rotate);
174 bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, int width, int height, int fps, int rotate);
175 bool _mmcamcorder_set_videosrc_flip(MMHandleType handle, int viderosrc_flip);
176 bool _mmcamcorder_set_videosrc_anti_shake(MMHandleType handle, int anti_shake);
177 bool _mmcamcorder_set_videosrc_stabilization(MMHandleType handle, int stabilization);
178 bool _mmcamcorder_set_camera_resolution(MMHandleType handle, int width, int height);
179 bool _mmcamcorder_set_encoded_preview_bitrate(MMHandleType handle, int bitrate);
180 bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int gop);
181 bool _mmcamcorder_set_sound_stream_info(GstElement *element, char *stream_type, int stream_index);
182 void _mmcamcorder_set_encoder_bitrate(MMCamcorderEncoderType type, int codec, int bitrate, GstElement *element);
183 #ifdef __cplusplus
184 }
185 #endif
186 #endif /* __MM_CAMCORDER_GSTCOMMON_H__ */