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