[libmm-streamrecorder] initial code for new feature of streamrecorder
[platform/core/multimedia/libmm-streamrecorder.git] / src / include / mm_streamrecorder_attribute.h
1 /*
2  * libmm-streamrecorder
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hyuntae Kim <ht1211.kim@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_STREAMRECORDER_ATTRIBUTE_H__
23 #define __MM_STREAMRECORDER_ATTRIBUTE_H__
24
25 /*=======================================================================================
26 | INCLUDE FILES                                                                         |
27 ========================================================================================*/
28 #include <mm_types.h>
29 #include <mm_attrs.h>
30 #include <mm_attrs_private.h>
31 #include <stdarg.h>
32 #include "mm_streamrecorder_internal.h"
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 /*=======================================================================================
39 | GLOBAL DEFINITIONS AND DECLARATIONS FOR STREAMRECORDER                                        |
40 ========================================================================================*/
41 /* Disabled
42 #define GET_AND_STORE_ATTRS_AFTER_SCENE_MODE
43 */
44
45 /*=======================================================================================
46 | MACRO DEFINITIONS                                                                     |
47 ========================================================================================*/
48 /**
49  * Caster of attributes handle
50  */
51 #define MMF_STREAMRECORDER_ATTRS(h) (((mmf_streamrecorder_t *)(h))->attributes)
52
53 /*=======================================================================================
54 | ENUM DEFINITIONS                                                                      |
55 ========================================================================================*/
56 /**
57  * Enumerations for streamrecorder attribute ID.
58  */
59 typedef enum {
60         MM_STR_VIDEO_BUFFER_TYPE,       /* 0 */
61         MM_STR_VIDEO_FORMAT,
62         MM_STR_VIDEO_FRAMERATE,
63         MM_STR_VIDEO_ENCODER_BITRATE,
64         MM_STR_VIDEO_RESOLUTION_WIDTH,
65         MM_STR_VIDEO_RESOLUTION_HEIGHT,
66         MM_STR_AUDIO_FORMAT,
67         MM_STR_AUDIO_ENCODER_BITRATE,
68         MM_STR_AUDIO_SAMPLERATE,
69         MM_STR_VIDEO_ENCODER,
70         MM_STR_AUDIO_ENCODER,   /* 10 */
71         MM_STR_AUDIO_CHENNEL_COUNT,
72         MM_STR_FILE_FORMAT,
73         MM_STR_TARGET_FILE_NAME,
74         MM_STR_VIDEO_ENABLE,
75         MM_STR_AUDIO_ENABLE,
76         MM_STR_MODE,
77         MM_STR_TARGET_MAX_SIZE,
78         MM_STR_TARGET_TIME_LIMIT,
79         MM_STR_NUM
80 } MMStreamRecorderAttrsID;
81
82
83 /*=======================================================================================
84 | TYPE DEFINITIONS                                                                      |
85 ========================================================================================*/
86 typedef bool(*mmf_streamrecorder_commit_func_t) (MMHandleType handle, int attr_idx, const mmf_value_t *value);
87
88 /*=======================================================================================
89 | STRUCTURE DEFINITIONS                                                                 |
90 ========================================================================================*/
91 typedef struct {
92         MMStreamRecorderAttrsID attrid;
93         const char *name;
94         int value_type;
95         int flags;
96         union {
97                 void *value_void;
98                 char *value_string;
99                 int value_int;
100                 double value_double;
101         } default_value;                /* default value */
102         MMStreamRecorderAttrsValidType validity_type;
103         int validity_value1;    /* can be int min, int *array, double *array, or cast to double min. */
104         int validity_value2;    /* can be int max, int count, int count, or cast to double max. */
105         mmf_streamrecorder_commit_func_t attr_commit;
106 } mm_streamrecorder_attr_construct_info;
107
108 /*=======================================================================================
109 | CONSTANT DEFINITIONS                                                                  |
110 ========================================================================================*/
111
112 /*=======================================================================================
113 | STATIC VARIABLES                                                                      |
114 ========================================================================================*/
115
116 /*=======================================================================================
117 | EXTERN GLOBAL VARIABLE                                                                |
118 ========================================================================================*/
119
120 /*=======================================================================================
121 | GLOBAL FUNCTION PROTOTYPES                                                            |
122 ========================================================================================*/
123 /**
124  * This function allocates structure of attributes and sets initial values.
125  *
126  * @param[in]   handle          Handle of streamrecorder.
127  * @param[in]   info            Preset information of streamrecorder.
128  * @return      This function returns allocated structure of attributes.
129  * @remarks
130  * @see         _mmstreamrecorder_dealloc_attribute()
131  *
132  */
133 MMHandleType _mmstreamrecorder_alloc_attribute(MMHandleType handle);
134
135 /**
136  * This function release structure of attributes.
137  *
138  * @param[in]   attrs           Handle of streamrecorder attribute.
139  * @return      void
140  * @remarks
141  * @see         _mmstreamrecorder_alloc_attribute()
142  *
143  */
144 void _mmstreamrecorder_dealloc_attribute(MMHandleType attrs);
145
146 /**
147  * This is a meta  function to get attributes of streamrecorder with given attribute names.
148  *
149  * @param[in]   handle          Handle of streamrecorder.
150  * @param[out]  err_attr_name   Specifies the name of attributes that made an error. If the function doesn't make an error, this will be null.
151  * @param[in]   attribute_name  attribute name that user want to get.
152  * @param[in]   var_args        Specifies variable arguments.
153  * @return      This function returns MM_ERROR_NONE on Success, minus on Failure.
154  * @remarks     You can retrieve multiple attributes at the same time.  @n
155  * @see         _mmstreamrecorder_set_attributes
156  */
157 int _mmstreamrecorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args);
158
159 /**
160  * This is a meta  function to set attributes of steamrecorder with given attribute names.
161  *
162  * @param[in]   handle          Handle of streamrecorder.
163  * @param[out]  err_attr_name   Specifies the name of attributes that made an error. If the function doesn't make an error, this will be null.
164  * @param[in]   attribute_name  attribute name that user want to set.
165  * @param[in]   var_args        Specifies variable arguments.
166  * @return      This function returns MM_ERROR_NONE on Success, minus on Failure.
167  * @remarks     You can put multiple attributes to streamrecorder at the same time.  @n
168  * @see         _mmstreamrecorder_get_attributes
169  */
170 int _mmstreamrecorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args);
171
172 /**
173  * This is a meta  function to get detail information of the attribute.
174  *
175  * @param[in]   handle          Handle of streamrecorder.
176  * @param[in]   attr_name       attribute name that user want to get information.
177  * @param[out]  info            a structure that holds information related with the attribute.
178  * @return      This function returns MM_ERROR_NONE on Success, minus on Failure.
179  * @remarks     If the function succeeds, 'info' holds detail information about the attribute, such as type, flag, validity_type, validity_values  @n
180  * @see         _mmstreamrecorder_get_attributes, _mmstreamrecorder_set_attributes
181  */
182 int _mmstreamrecorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMStreamRecorderAttrsInfo * info);
183
184 /*=======================================================================================
185 | STREAMRECORDER INTERNAL LOCAL                                                         |
186 ========================================================================================*/
187 /**
188  * A commit function to set streamrecorder attributes
189  * If the attribute needs actual setting, this function handles that activity.
190  * When application sets an attribute, setting function in MSL common calls this function.
191  * If this function fails, original value will not change.
192  *
193  * @param[in]   attr_idx        Attribute index of subcategory.
194  * @param[in]   attr_name       Attribute name.
195  * @param[in]   value           Handle of streamrecorder.
196  * @param[in]   commit_param    Allocation type of streamrecorder context.
197  * @return      This function returns TRUE on success, or FALSE on failure
198  * @remarks
199  * @see
200  *
201  */
202 bool _mmstreamrecorder_commit_streamrecorder_attrs(int attr_idx, const char *attr_name, const mmf_value_t *value, void *commit_param);
203
204 bool _mmstreamrecorder_commit_video_enable(MMHandleType handle, int attr_idx, const mmf_value_t *value);
205
206 bool _mmstreamrecorder_commit_video_encoder(MMHandleType handle, int attr_idx, const mmf_value_t *value);
207
208 bool _mmstreamrecorder_commit_audio_enable(MMHandleType handle, int attr_idx, const mmf_value_t *value);
209
210 bool _mmstreamrecorder_commit_audio_encoder(MMHandleType handle, int attr_idx, const mmf_value_t *value);
211
212 bool _mmstreamrecorder_commit_audio_samplingrate(MMHandleType handle, int attr_idx, const mmf_value_t *value);
213
214 bool _mmstreamrecorder_commit_audio_bitformat(MMHandleType handle, int attr_idx, const mmf_value_t *value);
215
216 bool _mmstreamrecorder_commit_audio_channel(MMHandleType handle, int attr_idx, const mmf_value_t *value);
217
218 bool _mmstreamrecorder_commit_audio_bitrate(MMHandleType handle, int attr_idx, const mmf_value_t *value);
219
220 /**
221  * check whether supported or not
222  *
223  * @param[in]   handle          Handle of streamrecorder.
224  * @param[in]   attr_index      index of attribute to check.
225  * @return      bool            TRUE if supported or FALSE
226  */
227 bool _mmstreamrecorder_check_supported_attribute(MMHandleType handle, int attr_index);
228
229 /**
230  *    mm_streamrecorder_get_attribute_info:\n
231  *  Get detail information of the attribute. To manager attributes, an user may want to know the exact character of the attribute,
232  *  such as type, flag, and validity. This is the function to provide such information.
233  *  Depending on the 'validity_type', validity union would be different. To know about the type of union, please refer 'MMStreamRecorderAttrsInfo'.
234  *
235  *      @param[in]      streamrecorder  Specifies the streamrecorder  handle.
236  *      @param[in]      attribute_name  attribute name that user want to get information.
237  *      @param[out]     info            a structure that holds information related with the attribute.
238  *      @return         This function returns zero(MM_ERROR_NONE) on success, or negative value with error code.\n
239  *                      Please refer 'mm_error.h' to know the exact meaning of the error.
240  *      @pre            None
241  *      @post           None
242  *      @remarks        If the function succeeds, 'info' holds detail information about the attribute, such as type,
243  *                      flag, validity_type, validity_values, and default values.
244  *      @see            mm_streamrecorder_get_attributes, mm_streamrecorder_set_attributes
245  */
246
247 int mm_streamrecorder_get_attribute_info(MMHandleType streamrecorder, const char *attribute_name, MMStreamRecorderAttrsInfo *info);
248
249 bool _mmstreamrecorder_commit_video_bitrate(MMHandleType handle, int attr_idx, const mmf_value_t *value);
250
251 #ifdef __cplusplus
252 }
253 #endif
254 #endif                                                  /* __MM_STREAMRECORDER_ATTRIBUTE_H__ */