Add tool package to separate testsuite binary
[platform/core/multimedia/libmm-streamrecorder.git] / src / mm_streamrecorder_attribute.c
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 /*=======================================================================================
23 |  INCLUDE FILES                                                                        |
24 =======================================================================================*/
25 #include <mm_error.h>
26
27 #include "mm_streamrecorder_util.h"
28 #include "mm_streamrecorder_attribute.h"
29 #include "mm_streamrecorder_gstdispatch.h"
30
31 /*-----------------------------------------------------------------------
32 |    MACRO DEFINITIONS:                                                 |
33 -----------------------------------------------------------------------*/
34 #define MM_STREAMRECORDER_ATTRIBUTE_MAX_VALUE  15
35 #define MM_STREAMRECORDER_RESOLUTION_MAX_VALUE 4080
36
37 /*---------------------------------------------------------------------------------------
38 |    GLOBAL VARIABLE DEFINITIONS for internal                                           |
39 ---------------------------------------------------------------------------------------*/
40
41 /* basic attributes' info */
42 mm_streamrecorder_attr_construct_info stream_attrs_const_info[] = {
43         /* 0 */
44         {
45          MM_STR_VIDEO_BUFFER_TYPE,      /* ID */
46          (char *)"videobuffer-type",            /* Name */
47          MM_ATTRS_TYPE_INT,             /* Type */
48          MM_ATTRS_FLAG_RW,                      /* Flag */
49          {(void *)MM_STREAMRECORDER_VIDEO_TYPE_TBM_BO}, /* Default value */
50          MM_ATTRS_VALID_TYPE_INT_RANGE, /* Validity type */
51          {.int_min = MM_STREAMRECORDER_VIDEO_TYPE_TBM_BO},      /* Validity val1 (min, *array,...) */
52          {.int_max = MM_STREAMRECORDER_VIDEO_TYPE_NORMAL_BUFFER},       /* Validity val2 (max, count, ...) */
53          NULL,                                          /* Runtime setting function of the attribute */
54          },
55         /* 1  */
56         {MM_STR_VIDEO_FORMAT,
57          (char *)"videosource-format",
58          MM_ATTRS_TYPE_INT,
59          MM_ATTRS_FLAG_RW,
60          {(void *)MM_STREAMRECORDER_INPUT_FORMAT_NV12},
61          MM_ATTRS_VALID_TYPE_INT_RANGE,
62          {.int_min = MM_STREAMRECORDER_INPUT_FORMAT_INVALID},
63          {.int_max = MM_STREAMRECORDER_INPUT_FORMAT_NUM},
64          NULL,
65          },
66         /* 2  */
67         {
68          MM_STR_VIDEO_FRAMERATE,
69          (char *)"video-framerate",
70          MM_ATTRS_TYPE_INT,
71          MM_ATTRS_FLAG_RW,
72          {(void *)0},
73          MM_ATTRS_VALID_TYPE_INT_RANGE,
74          {.int_min = 0},
75          {.int_max = _MMSTREAMRECORDER_MAX_INT},
76          NULL,
77          },
78         /* 3  */
79         {
80          MM_STR_VIDEO_ENCODER_BITRATE,
81          (char *)"video-bitrate",
82          MM_ATTRS_TYPE_INT,
83          MM_ATTRS_FLAG_RW,
84          {(void *)0},
85          MM_ATTRS_VALID_TYPE_INT_RANGE,
86          {.int_min = 0},
87          {.int_max = _MMSTREAMRECORDER_MAX_INT},
88          NULL,    /*_mmstreamrecorder_commit_video_bitrate, */
89          },
90         /* 4  */
91         {
92          MM_STR_VIDEO_RESOLUTION_WIDTH,
93          (char *)"video-resolution-width",
94          MM_ATTRS_TYPE_INT,
95          MM_ATTRS_FLAG_RW,
96          {(void *)0},
97          MM_ATTRS_VALID_TYPE_INT_ARRAY,
98          {.int_array = NULL},
99          {.count = 0},
100          NULL,
101          },
102         /* 5  */
103         {
104          MM_STR_VIDEO_RESOLUTION_HEIGHT,
105          (char *)"video-resolution-height",
106          MM_ATTRS_TYPE_INT,
107          MM_ATTRS_FLAG_RW,
108          {(void *)0},
109          MM_ATTRS_VALID_TYPE_INT_ARRAY,
110          {.int_array = NULL},
111          {.count = 0},
112          NULL,
113          },
114         /* 6  */
115         {
116          MM_STR_AUDIO_FORMAT,
117          (char *)"audio-source-format",
118          MM_ATTRS_TYPE_INT,
119          MM_ATTRS_FLAG_RW,
120          {(void *)MM_STREAMRECORDER_AUDIO_FORMAT_PCM_S16_LE},
121          MM_ATTRS_VALID_TYPE_INT_RANGE,
122          {.int_min = MM_STREAMRECORDER_AUDIO_FORMAT_PCM_U8},
123          {.int_max = MM_STREAMRECORDER_AUDIO_FORMAT_PCM_S16_LE},
124          _mmstreamrecorder_commit_audio_bitformat,
125          },
126         /* 7  */
127         {
128          MM_STR_AUDIO_ENCODER_BITRATE,
129          (char *)"audio-bitrate",
130          MM_ATTRS_TYPE_INT,
131          MM_ATTRS_FLAG_RW,
132          {(void *)128000},
133          MM_ATTRS_VALID_TYPE_INT_RANGE,
134          {.int_min = 0},
135          {.int_max = _MMSTREAMRECORDER_MAX_INT},
136          _mmstreamrecorder_commit_audio_bitrate,
137          },
138         /* 8  */
139         {
140          MM_STR_AUDIO_SAMPLERATE,
141          (char *)"audio-samplerate",
142          MM_ATTRS_TYPE_INT,
143          MM_ATTRS_FLAG_RW,
144          {(void *)0},
145          MM_ATTRS_VALID_TYPE_INT_RANGE,
146          {.int_min = 0},
147          {.int_max = _MMSTREAMRECORDER_MAX_INT},
148          _mmstreamrecorder_commit_audio_samplingrate,
149          },
150         /* 9  */
151         {
152          MM_STR_VIDEO_ENCODER,
153          (char *)"video-encoder",
154          MM_ATTRS_TYPE_INT,
155          MM_ATTRS_FLAG_RW,
156          {(void *)0},
157          MM_ATTRS_VALID_TYPE_INT_ARRAY,
158          {.int_array = NULL},
159          {.count = 0},
160          _mmstreamrecorder_commit_video_encoder,
161          },
162         /* 10  */
163         {
164          MM_STR_AUDIO_ENCODER,
165          (char *)"audio-encoder",
166          MM_ATTRS_TYPE_INT,
167          MM_ATTRS_FLAG_RW,
168          {(void *)0},
169          MM_ATTRS_VALID_TYPE_INT_ARRAY,
170          {.int_array = NULL},
171          {.count = 0},
172          _mmstreamrecorder_commit_audio_encoder,
173          },
174         /* 11  */
175         {
176          MM_STR_AUDIO_CHENNEL_COUNT,
177          (char *)"audio-channel-count",
178          MM_ATTRS_TYPE_INT,
179          MM_ATTRS_FLAG_RW,
180          {(void *)2},
181          MM_ATTRS_VALID_TYPE_INT_RANGE,
182          {.int_min = 0},
183          {.int_max = _MMSTREAMRECORDER_MAX_INT},
184          _mmstreamrecorder_commit_audio_channel,
185          },
186         /* 12  */
187         {
188          MM_STR_FILE_FORMAT,
189          (char *)"file-format",
190          MM_ATTRS_TYPE_INT,
191          MM_ATTRS_FLAG_RW,
192          {(void *)0},
193          MM_ATTRS_VALID_TYPE_INT_ARRAY,
194          {.int_array = NULL},
195          {.count = 0},
196          NULL,
197          },
198         /* 13  */
199         {
200          MM_STR_TARGET_FILE_NAME,
201          (char *)"filename",
202          MM_ATTRS_TYPE_STRING,
203          MM_ATTRS_FLAG_RW,
204          {NULL},
205          MM_ATTRS_VALID_TYPE_NONE,
206          {0},
207          {0},
208          NULL,
209          },
210         /* 14  */
211         {
212          MM_STR_VIDEO_ENABLE,
213          (char *)"video-enable",
214          MM_ATTRS_TYPE_INT,
215          MM_ATTRS_FLAG_RW,
216          {(void *)FALSE},
217          MM_ATTRS_VALID_TYPE_NONE,
218          {0},
219          {_MMSTREAMRECORDER_MAX_INT},
220          _mmstreamrecorder_commit_video_enable,
221          },
222         /* 15  */
223         {
224          MM_STR_AUDIO_ENABLE,
225          (char *)"audio-enable",
226          MM_ATTRS_TYPE_INT,
227          MM_ATTRS_FLAG_RW,
228          {(void *)FALSE},
229          MM_ATTRS_VALID_TYPE_NONE,
230          {0},
231          {_MMSTREAMRECORDER_MAX_INT},
232          _mmstreamrecorder_commit_audio_enable,
233          },
234         /* 16 */
235         {
236          MM_STR_MODE,
237          (char *)"recorder-mode",
238          MM_ATTRS_TYPE_INT,
239          MM_ATTRS_FLAG_RW,
240          {(void *)MM_STREAMRECORDER_MODE_STREAM_BUFFER},
241          MM_ATTRS_VALID_TYPE_NONE,
242          {0},
243          {_MMSTREAMRECORDER_MAX_INT},
244          NULL,
245          },
246         /*17*/
247         {
248          MM_STR_TARGET_MAX_SIZE,
249          (char *)"target-max-size",
250          MM_ATTRS_TYPE_INT,
251          MM_ATTRS_FLAG_RW,
252          {(void *)0},
253          MM_ATTRS_VALID_TYPE_INT_RANGE,
254          {.int_min = 0},
255          {.int_max = _MMSTREAMRECORDER_MAX_INT},
256          NULL,
257         },
258         /*18*/
259         {
260          MM_STR_TARGET_TIME_LIMIT,
261          (char *)"target-time-limit",
262          MM_ATTRS_TYPE_INT,
263          MM_ATTRS_FLAG_RW,
264          {(void *)0},
265          MM_ATTRS_VALID_TYPE_INT_RANGE,
266          {.int_min = 0},
267          {.int_max = _MMSTREAMRECORDER_MAX_INT},
268          NULL,
269         },
270
271 };
272
273 /*-----------------------------------------------------------------------
274 |    LOCAL VARIABLE DEFINITIONS for internal                            |
275 -----------------------------------------------------------------------*/
276
277 /*-----------------------------------------------------------------------
278 |    LOCAL FUNCTION PROTOTYPES:                                         |
279 -----------------------------------------------------------------------*/
280 int _mmstreamrecorder_get_available_format(MMHandleType handle, int type, int ** format);
281
282
283 /* STATIC INTERNAL FUNCTION */
284 static int __mmstreamrecorder_set_conf_to_valid_info(MMHandleType handle)
285 {
286         int *format = NULL;
287         int total_count = 0;
288
289         /* Video width */
290         total_count = _mmstreamrecorder_get_available_format(handle, KEYWORD_VIDEO_WIDTH, &format);
291         stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value_1.int_array = format;
292         stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value_2.count = total_count;
293
294         /* Video height */
295         total_count = _mmstreamrecorder_get_available_format(handle, KEYWORD_VIDEO_HEIGHT,  &format);
296         stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value_1.int_array = format;
297         stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value_2.count = total_count;
298
299         /* Audio encoder */
300         total_count = _mmstreamrecorder_get_available_format(handle, KEYWORD_AUDIO_ENCODERS, &format);
301         stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value_1.int_array = format;
302         stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value_2.count = total_count;
303
304         /*Video encoder*/
305         total_count = _mmstreamrecorder_get_available_format(handle, KEYWORD_VIDEO_ENCODERS, &format);
306         stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value_1.int_array = format;
307         stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value_2.count = total_count;
308
309         /* File Format */
310         total_count = _mmstreamrecorder_get_available_format(handle, KEYWORD_FILE_FORMATS, &format);
311         stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value_1.int_array = format;
312         stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value_2.count = total_count;
313
314         return MM_ERROR_NONE;
315 }
316
317 static int __mmstreamrecorder_release_conf_valid_info(MMHandleType handle)
318 {
319         int *allocated_memory = NULL;
320
321         _mmstreamrec_dbg_log("START");
322
323         allocated_memory = (int *)(stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value_1.int_array);
324         if (allocated_memory) {
325                 free(allocated_memory);
326                 stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value_1.int_array = NULL;
327                 stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_WIDTH].validity_value_2.count = 0;
328         }
329
330         allocated_memory = (int *)(stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value_1.int_array);
331         if (allocated_memory) {
332                 free(allocated_memory);
333                 stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value_1.int_array = NULL;
334                 stream_attrs_const_info[MM_STR_VIDEO_RESOLUTION_HEIGHT].validity_value_2.count = 0;
335         }
336
337         allocated_memory = (int *)(stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value_1.int_array);
338         if (allocated_memory) {
339                 free(allocated_memory);
340                 stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value_1.int_array = NULL;
341                 stream_attrs_const_info[MM_STR_AUDIO_ENCODER].validity_value_2.count = 0;
342         }
343
344         allocated_memory = (int *)(stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value_1.int_array);
345         if (allocated_memory) {
346                 free(allocated_memory);
347                 stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value_1.int_array = NULL;
348                 stream_attrs_const_info[MM_STR_VIDEO_ENCODER].validity_value_2.count = 0;
349         }
350
351         allocated_memory = (int *)(stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value_1.int_array);
352         if (allocated_memory) {
353                 free(allocated_memory);
354                 stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value_1.int_array = NULL;
355                 stream_attrs_const_info[MM_STR_FILE_FORMAT].validity_value_2.count = 0;
356         }
357         _mmstreamrec_dbg_log("DONE");
358
359         return MM_ERROR_NONE;
360 }
361
362 #if 0
363 static bool __mmstreamrecorder_attrs_is_supported(MMHandleType handle, int idx)
364 {
365         int flag;
366
367         if (mm_attrs_get_flags(handle, idx, &flag) == MM_ERROR_NONE) {
368                 if (flag == MM_ATTRS_FLAG_NONE)
369                         return FALSE;
370         } else {
371                 return FALSE;
372         }
373
374         if (mm_attrs_get_valid_type(handle, idx) == MM_ATTRS_VALID_TYPE_INT_RANGE) {
375                 int min, max;
376                 mm_attrs_get_valid_range(handle, idx, &min, &max);
377                 if (max < min)
378                         return FALSE;
379         } else if (mm_attrs_get_valid_type(handle, idx) == MM_ATTRS_VALID_TYPE_INT_ARRAY) {
380                 int count;
381                 int *array;
382                 mm_attrs_get_valid_array(handle, idx, &count, &array);
383                 if (count == 0)
384                         return FALSE;
385         }
386
387         return TRUE;
388 }
389 #endif
390 static int __mmstreamrecorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
391 {
392 #define INIT_VALUE            -1
393 #define CHECK_COUNT           2
394 #define CAPTURE_RESOLUTION    1
395
396         mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle);
397         MMHandleType attrs = 0;
398
399         int ret = MM_ERROR_NONE;
400         int i = 0, j = 0;
401         const char *name = NULL;
402         const char *check_pair_name[2][3] = {
403                 {MMSTR_VIDEO_RESOLUTION_WIDTH, MMSTR_VIDEO_RESOLUTION_HEIGHT, "MMSTR_VIDEO_RESOLUTION_WIDTH and HEIGHT"},
404                 {NULL, NULL, NULL}
405         };
406
407         int check_pair_value[2][2] = {
408                 {INIT_VALUE, INIT_VALUE},
409                 {INIT_VALUE, INIT_VALUE},
410         };
411
412         if (hstreamrecorder == NULL || attribute_name == NULL) {
413                 _mmstreamrec_dbg_warn("handle[%p] or attribute_name[%p] is NULL.", hstreamrecorder, attribute_name);
414                 return MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT;
415         }
416
417         if (err_attr_name)
418                 *err_attr_name = NULL;
419
420         /* _mmstreamrec_dbg_log( "ENTER" ); */
421
422         attrs = MMF_STREAMRECORDER_ATTRS(handle);
423
424         name = attribute_name;
425
426         while (name) {
427                 int idx = -1;
428                 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
429
430                 /*_mmstreamrec_dbg_log( "NAME : %s", name );*/
431
432                 /* attribute name check */
433                 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
434                         if (err_attr_name)
435                                 *err_attr_name = strdup(name);
436
437                         if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
438                                 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
439                         else
440                                 return ret;
441                 }
442
443                 /* type check */
444                 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
445                         return ret;
446
447                 switch (attr_type) {
448                 case MM_ATTRS_TYPE_INT:
449                         {
450                                 va_arg((var_args), int);
451                                 break;
452                         }
453                 case MM_ATTRS_TYPE_DOUBLE:
454                         va_arg((var_args), double);
455                         break;
456                 case MM_ATTRS_TYPE_STRING:
457                         va_arg((var_args), char *);     /* string */
458                         va_arg((var_args), int);        /* size */
459                         break;
460                 case MM_ATTRS_TYPE_DATA:
461                         va_arg((var_args), void *);     /* data */
462                         va_arg((var_args), int);        /* size */
463                         break;
464                 case MM_ATTRS_TYPE_INVALID:
465                 default:
466                         _mmstreamrec_dbg_err("Not supported attribute type(%d, name:%s)", attr_type, name);
467                         if (err_attr_name)
468                                 *err_attr_name = strdup(name);
469                         return MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT;
470                 }
471
472                 /* next name */
473                 name = va_arg(var_args, char *);
474         }
475
476         for (i = 0; i < CHECK_COUNT; i++) {
477                 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
478                         gboolean check_result = FALSE;
479                         char *err_name = NULL;
480                         MMStreamRecorderAttrsInfo attr_info_0, attr_info_1;
481
482                         if (check_pair_value[i][0] == INIT_VALUE) {
483                                 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
484                                 err_name = strdup(check_pair_name[i][1]);
485                         } else if (check_pair_value[i][1] == INIT_VALUE) {
486                                 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
487                                 err_name = strdup(check_pair_name[i][0]);
488                         } else {
489                                 err_name = strdup(check_pair_name[i][2]);
490                         }
491
492                         mm_streamrecorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
493                         mm_streamrecorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
494
495                         check_result = FALSE;
496
497                         for (j = 0; j < attr_info_0.int_array.count; j++) {
498                                 if (attr_info_0.int_array.array[j] == check_pair_value[i][0]
499                                         && attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
500                                         _mmstreamrec_dbg_log("Valid Pair[%s,%s] existed %dx%d[index:%d]", check_pair_name[i][0], check_pair_name[i][1], check_pair_value[i][0], check_pair_value[i][1], i);
501                                         check_result = TRUE;
502                                         break;
503                                 }
504                         }
505
506                         if (check_result == FALSE) {
507                                 _mmstreamrec_dbg_err("INVALID pair[%s,%s] %dx%d", check_pair_name[i][0], check_pair_name[i][1], check_pair_value[i][0], check_pair_value[i][1]);
508                                 if (err_attr_name)
509                                         *err_attr_name = err_name;
510
511                                 return MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT;
512                         }
513
514                         if (err_name) {
515                                 free(err_name);
516                                 err_name = NULL;
517                         }
518                 }
519         }
520
521         /*_mmstreamrec_dbg_log("DONE");*/
522
523         return MM_ERROR_NONE;
524 }
525
526 /* attribute commiter */
527 void __mmstreamrecorder_print_attrs(const char *attr_name, const MMAttrsValue * value, const char *cmt_way)
528 {
529         switch (value->type) {
530         case MM_ATTRS_TYPE_INT:
531                 _mmstreamrec_dbg_log("%s :(%s:%d)", cmt_way, attr_name, value->value.i_val);
532                 break;
533         case MM_ATTRS_TYPE_DOUBLE:
534                 _mmstreamrec_dbg_log("%s :(%s:%f)", cmt_way, attr_name, value->value.d_val);
535                 break;
536         case MM_ATTRS_TYPE_STRING:
537                 _mmstreamrec_dbg_log("%s :(%s:%s)", cmt_way, attr_name, value->value.s_val);
538                 break;
539         case MM_ATTRS_TYPE_DATA:
540                 _mmstreamrec_dbg_log("%s :(%s:%p)", cmt_way, attr_name, value->value.p_val);
541                 break;
542         default:
543                 break;
544         }
545
546         return;
547 }
548
549 int _mmstreamrecorder_get_audio_codec_format(MMHandleType handle, const char *name)
550 {
551         int codec_index = MM_AUDIO_CODEC_INVALID;
552
553         if (!name) {
554                 _mmstreamrec_dbg_err("name is NULL");
555                 return MM_AUDIO_CODEC_INVALID;
556         }
557
558         if (!strcmp(name, "AMR"))
559                 codec_index = MM_AUDIO_CODEC_AMR;
560         else if (!strcmp(name, "AAC"))
561                 codec_index = MM_AUDIO_CODEC_AAC;
562         else if (!strcmp(name, "PCM"))
563                 codec_index = MM_AUDIO_CODEC_WAVE;
564         else if (!strcmp(name, "VORBIS"))
565                 codec_index = MM_AUDIO_CODEC_VORBIS;
566
567         return codec_index;
568 }
569
570 int _mmstreamrecorder_get_video_codec_format(MMHandleType handle, const char *name)
571 {
572         int codec_index = MM_VIDEO_CODEC_INVALID;
573
574         if (!name) {
575                 _mmstreamrec_dbg_err("name is NULL");
576                 return MM_VIDEO_CODEC_INVALID;
577         }
578
579         if (!strcmp(name, "H263"))
580                 codec_index = MM_VIDEO_CODEC_H263;
581         else if (!strcmp(name, "H264"))
582                 codec_index = MM_VIDEO_CODEC_H264;
583         else if (!strcmp(name, "MPEG4"))
584                 codec_index = MM_VIDEO_CODEC_MPEG4;
585
586         return codec_index;
587 }
588
589
590 int _mmstreamrecorder_get_mux_format(MMHandleType handle, const char *name)
591 {
592         int mux_index = MM_FILE_FORMAT_INVALID;
593
594         if (!name) {
595                 _mmstreamrec_dbg_err("name is NULL");
596                 return MM_FILE_FORMAT_INVALID;
597         }
598
599         if (!strcmp(name, "3GP"))
600                 mux_index = MM_FILE_FORMAT_3GP;
601         else if (!strcmp(name, "AMR"))
602                 mux_index = MM_FILE_FORMAT_AMR;
603         else if (!strcmp(name, "MP4"))
604                 mux_index = MM_FILE_FORMAT_MP4;
605         else if (!strcmp(name, "WAV"))
606                 mux_index = MM_FILE_FORMAT_WAV;
607         return mux_index;
608 }
609
610
611 int _mmstreamrecorder_get_format(MMHandleType handle , int category, const char *name)
612 {
613         int fmt = -1;
614
615         mmf_return_val_if_fail(name, -1);
616
617         switch (category) {
618         case KEYWORD_AUDIO_ENCODERS:
619                 fmt = _mmstreamrecorder_get_audio_codec_format(handle, name);
620                 break;
621         case KEYWORD_VIDEO_ENCODERS:
622                 fmt = _mmstreamrecorder_get_video_codec_format(handle, name);
623                 break;
624         case KEYWORD_FILE_FORMATS:
625                 fmt = _mmstreamrecorder_get_mux_format(handle, name);
626                 break;
627         default:
628                 break;
629         }
630         return fmt;
631 }
632
633 int _mmstreamrecorder_get_type_count(MMHandleType handle, int type)
634 {
635         mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle);
636
637         int count = 0;
638         int i = 0;
639         if (type == KEYWORD_VIDEO_WIDTH) {
640                 while (hstreamrecorder->ini.supported_video_width[i++])
641                         count++;
642         } else if (type == KEYWORD_VIDEO_HEIGHT) {
643                 while (hstreamrecorder->ini.supported_video_height[i++])
644                         count++;
645         } else if (type == KEYWORD_AUDIO_ENCODERS) {
646                 while (hstreamrecorder->ini.supported_audio_encoders[i++][0])
647                         count++;
648         } else if (type == KEYWORD_VIDEO_ENCODERS) {
649                 while (hstreamrecorder->ini.supported_video_encoders[i++][0])
650                         count++;
651         } else if (type == KEYWORD_FILE_FORMATS) {
652                 while (hstreamrecorder->ini.supported_file_formats[i++][0])
653                         count++;
654         }
655         return count;
656 }
657
658 void __mmstreamrecorder_get_supported_name(MMHandleType handle, int type , char **str, int i)
659 {
660         mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle);
661         if (type == KEYWORD_AUDIO_ENCODERS) {
662                 *str = hstreamrecorder->ini.supported_audio_encoders[i];
663                 return;
664         } else if (type == KEYWORD_VIDEO_ENCODERS) {
665                 *str = hstreamrecorder->ini.supported_video_encoders[i];
666                 return;
667         } else if (type == KEYWORD_FILE_FORMATS) {
668                 *str = hstreamrecorder->ini.supported_file_formats[i];
669                 return;
670         } else {
671                 *str = NULL;
672                 return;
673         }
674 }
675
676 int __mmstreamrecorder_get_supported_value(MMHandleType handle, int type, int i)
677 {
678         mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle);
679
680         if (type == KEYWORD_VIDEO_WIDTH)
681                 return hstreamrecorder->ini.supported_video_width[i];
682         else if (type == KEYWORD_VIDEO_HEIGHT)
683                 return hstreamrecorder->ini.supported_video_height[i];
684         else
685                 return -1;
686 }
687
688 int
689 _mmstreamrecorder_get_available_format(MMHandleType handle, int type, int ** format)
690 {
691         mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle);
692         int *arr = NULL;
693         int total_count = 0;
694         int count = 0;
695         int i = 0;
696         int fmt = 0;
697         char *name = NULL;
698
699         mmf_return_val_if_fail(hstreamrecorder, 0);
700
701         count = _mmstreamrecorder_get_type_count(handle, type);
702
703         if (count <= 0)
704                 return -1;
705
706         arr = (int*) g_malloc0(count * sizeof(int));
707         if (arr == NULL) {
708                 _mmstreamrec_dbg_err("malloc failed : %zu", count * sizeof(int));
709                 return -1;
710         }
711
712         if (type == KEYWORD_VIDEO_WIDTH || type == KEYWORD_VIDEO_HEIGHT) {
713                 for (i = 0 ; i < count ; i++) {
714                         fmt = __mmstreamrecorder_get_supported_value(handle, type, i);
715                         if (fmt >= 0)
716                                 arr[total_count++] = fmt;
717                 }
718         } else {
719                 for (i = 0 ; i < count ; i++) {
720                         __mmstreamrecorder_get_supported_name(handle, type, &name, i);
721                         fmt = _mmstreamrecorder_get_format(handle, type, name);
722                         if (fmt >= 0)
723                                 arr[total_count++] = fmt;
724                 }
725         }
726         *format = arr;
727         return total_count;
728 }
729
730 /*=======================================================================
731 |  FUNCTION DEFINITIONS                                                 |
732 =======================================================================*/
733 /*-----------------------------------------------------------------------
734 |    GLOBAL FUNCTION DEFINITIONS:                                       |
735 -----------------------------------------------------------------------*/
736 MMHandleType _mmstreamrecorder_alloc_attribute(MMHandleType handle)
737 {
738         _mmstreamrec_dbg_log("");
739
740         MMHandleType attrs = NULL;
741         MMAttrsConstructInfo *attrs_const_info = NULL;
742         unsigned int attr_count = 0;
743         unsigned int idx;
744         int ret = MM_ERROR_NONE;
745
746         /* Create attribute constructor */
747         _mmstreamrec_dbg_log("start");
748
749         /* alloc 'mm_attrs_construct_info_t' */
750         attr_count = ARRAY_SIZE(stream_attrs_const_info);
751         attrs_const_info = malloc(attr_count * sizeof(MMAttrsConstructInfo));
752
753         if (!attrs_const_info) {
754                 _mmstreamrec_dbg_err("Fail to alloc constructor.");
755                 return 0;
756         }
757
758         for (idx = 0; idx < attr_count; idx++) {
759                 /* attribute order check. This should be same. */
760                 if (idx != stream_attrs_const_info[idx].attrid) {
761                         _mmstreamrec_dbg_err("Please check attributes order. Is the idx same with enum val?");
762                         free(attrs_const_info);
763                         attrs_const_info = NULL;
764                         return 0;
765                 }
766
767                 attrs_const_info[idx].name = stream_attrs_const_info[idx].name;
768                 attrs_const_info[idx].value_type = stream_attrs_const_info[idx].value_type;
769                 attrs_const_info[idx].flags = stream_attrs_const_info[idx].flags;
770                 attrs_const_info[idx].default_value = stream_attrs_const_info[idx].default_value.value_void;
771         }
772
773         _mmstreamrec_dbg_log("Create Streamrecorder Attributes[%p, %d]", attrs_const_info, attr_count);
774
775         ret = mm_attrs_new(attrs_const_info, attr_count, "Streamrecorder_Attributes", _mmstreamrecorder_commit_streamrecorder_attrs, (void *)handle, &attrs);
776
777         free(attrs_const_info);
778         attrs_const_info = NULL;
779
780         if (ret != MM_ERROR_NONE) {
781                 _mmstreamrec_dbg_err("Fail to alloc attribute handle");
782                 return 0;
783         }
784
785         __mmstreamrecorder_set_conf_to_valid_info(handle);
786
787         for (idx = 0; idx < attr_count; idx++) {
788                 mm_attrs_set_valid_type(attrs, idx, stream_attrs_const_info[idx].validity_type);
789
790                 switch (stream_attrs_const_info[idx].validity_type) {
791                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
792                         if (stream_attrs_const_info[idx].validity_value_1.int_array &&
793                                         stream_attrs_const_info[idx].validity_value_2.count > 0)
794                                 mm_attrs_set_valid_array(attrs, idx,
795                                                 (const int *)(stream_attrs_const_info[idx].validity_value_1.int_array),
796                                                 stream_attrs_const_info[idx].validity_value_2.count,
797                                                 stream_attrs_const_info[idx].default_value.value_int);
798                         break;
799                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
800                         mm_attrs_set_valid_range(attrs, idx,
801                                         stream_attrs_const_info[idx].validity_value_1.int_min,
802                                         stream_attrs_const_info[idx].validity_value_2.int_max,
803                                         stream_attrs_const_info[idx].default_value.value_int);
804                         break;
805                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
806                         if (stream_attrs_const_info[idx].validity_value_1.double_array &&
807                                         stream_attrs_const_info[idx].validity_value_2.count > 0)
808                                 mm_attrs_set_valid_double_array(attrs, idx,
809                                                 (const double *)(stream_attrs_const_info[idx].validity_value_1.double_array),
810                                                 stream_attrs_const_info[idx].validity_value_2.count,
811                                                 stream_attrs_const_info[idx].default_value.value_double);
812                         break;
813                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
814                         mm_attrs_set_valid_double_range(attrs, idx,
815                                         stream_attrs_const_info[idx].validity_value_1.double_min,
816                                         stream_attrs_const_info[idx].validity_value_2.double_max,
817                                         stream_attrs_const_info[idx].default_value.value_double);
818                         break;
819                 case MM_ATTRS_VALID_TYPE_NONE:
820                         break;
821                 case MM_ATTRS_VALID_TYPE_INVALID:
822                 default:
823                         _mmstreamrec_dbg_err("Valid type error.");
824                         break;
825                 }
826         }
827
828         __mmstreamrecorder_release_conf_valid_info(handle);
829
830         return attrs;
831 }
832
833 void _mmstreamrecorder_dealloc_attribute(MMHandleType attrs)
834 {
835         _mmstreamrec_dbg_log("");
836
837         if (attrs) {
838                 mm_attrs_free(attrs);
839
840                 _mmstreamrec_dbg_log("released attribute");
841         }
842 }
843
844 int _mmstreamrecorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
845 {
846         MMHandleType attrs = 0;
847         int ret = MM_ERROR_NONE;
848
849         mmf_return_val_if_fail(handle, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
850
851         attrs = MMF_STREAMRECORDER_ATTRS(handle);
852         mmf_return_val_if_fail(attrs, MM_ERROR_STREAMRECORDER_NOT_INITIALIZED);
853
854         ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
855
856         return ret;
857 }
858
859 int _mmstreamrecorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
860 {
861         MMHandleType attrs = 0;
862         int ret = MM_ERROR_NONE;
863         va_list var_args_copy;
864
865         mmf_return_val_if_fail(handle, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
866
867         attrs = MMF_STREAMRECORDER_ATTRS(handle);
868         if (!attrs) {
869                 _mmstreamrec_dbg_err("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
870                 return MM_ERROR_STREAMRECORDER_NOT_INITIALIZED;
871         }
872
873         /* copy var_args to keep original var_args */
874         va_copy(var_args_copy, var_args);
875
876         ret = __mmstreamrecorder_check_valid_pair(handle, err_attr_name, attribute_name, var_args);
877
878         _mmstreamrec_dbg_err("__mmstreamrecorder_check_valid_pair handle %p, attr name [%s] , ret = %d", handle, attribute_name, ret);
879
880         if (ret == MM_ERROR_NONE) {
881                 /* In 64bit environment, unexpected result is returned if var_args is used again. */
882                 ret = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, var_args_copy);
883         }
884         va_end(var_args_copy);
885
886         _mmstreamrec_dbg_err("mm_attrs_set_valist handle %p, attr name [%s] , ret = %d", handle, attribute_name, ret);
887         return ret;
888 }
889
890 int _mmstreamrecorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMStreamRecorderAttrsInfo * info)
891 {
892         MMHandleType attrs = 0;
893         MMAttrsInfo attrinfo;
894         int ret = MM_ERROR_NONE;
895
896         mmf_return_val_if_fail(handle, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
897         mmf_return_val_if_fail(attr_name, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
898         mmf_return_val_if_fail(info, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
899
900         attrs = MMF_STREAMRECORDER_ATTRS(handle);
901         mmf_return_val_if_fail(attrs, MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT);
902
903         ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo *) & attrinfo);
904
905         if (ret == MM_ERROR_NONE) {
906                 memset(info, 0x00, sizeof(MMStreamRecorderAttrsInfo));
907                 info->type = attrinfo.type;
908                 info->flag = attrinfo.flag;
909                 info->validity_type = attrinfo.validity_type;
910
911                 switch (attrinfo.validity_type) {
912                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
913                         info->int_array.array = attrinfo.int_array.array;
914                         info->int_array.count = attrinfo.int_array.count;
915                         info->int_array.def = attrinfo.int_array.dval;
916                         break;
917                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
918                         info->int_range.min = attrinfo.int_range.min;
919                         info->int_range.max = attrinfo.int_range.max;
920                         info->int_range.def = attrinfo.int_range.dval;
921                         break;
922                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
923                         info->double_array.array = attrinfo.double_array.array;
924                         info->double_array.count = attrinfo.double_array.count;
925                         info->double_array.def = attrinfo.double_array.dval;
926                         break;
927                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
928                         info->double_range.min = attrinfo.double_range.min;
929                         info->double_range.max = attrinfo.double_range.max;
930                         info->double_range.def = attrinfo.double_range.dval;
931                         break;
932                 case MM_ATTRS_VALID_TYPE_NONE:
933                         break;
934                 case MM_ATTRS_VALID_TYPE_INVALID:
935                 default:
936                         break;
937                 }
938         }
939
940         return ret;
941 }
942
943 bool _mmstreamrecorder_commit_streamrecorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue * value, void *commit_param)
944 {
945         bool bret = FALSE;
946
947         mmf_return_val_if_fail(commit_param, FALSE);
948         mmf_return_val_if_fail(attr_idx >= 0, FALSE);
949         mmf_return_val_if_fail(attr_name, FALSE);
950         mmf_return_val_if_fail(value, FALSE);
951
952         if (stream_attrs_const_info[attr_idx].attr_commit) {
953                 /* _mmstreamrec_dbg_log("Dynamic commit:(%s)", attr_name); */
954                 __mmstreamrecorder_print_attrs(attr_name, value, "Dynamic");
955                 bret = stream_attrs_const_info[attr_idx].attr_commit((MMHandleType) commit_param, attr_idx, value);
956         } else {
957                 /* _mmstreamrec_dbg_log("Static commit:(%s)", attr_name); */
958                 __mmstreamrecorder_print_attrs(attr_name, value, "Static");
959                 bret = TRUE;
960         }
961
962         return bret;
963 }
964
965 bool _mmstreamrecorder_commit_video_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
966 {
967         MMHandleType attr = 0;
968         /* mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); */
969         _MMStreamRecorderSubContext *sc = NULL;
970         _MMStreamRecorderVideoInfo *info = NULL;
971
972         mmf_return_val_if_fail(handle, FALSE);
973         attr = MMF_STREAMRECORDER_ATTRS(handle);
974         mmf_return_val_if_fail(attr, FALSE);
975         sc = MMF_STREAMRECORDER_SUBCONTEXT(handle);
976
977         _mmstreamrec_dbg_log("(%d)", attr_idx);
978
979         mmf_return_val_if_fail(sc, FALSE);
980
981         info = (_MMStreamRecorderVideoInfo *) sc->info_video;
982
983         if (info == NULL && value->value.i_val != 0) {
984                 if (_mmstreamrecorder_alloc_subcontext_videoinfo(handle))
985                         return FALSE;
986         }
987
988         return TRUE;
989 }
990
991 bool _mmstreamrecorder_commit_video_encoder(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
992 {
993         MMHandleType attr = 0;
994         _MMStreamRecorderSubContext *sc = NULL;
995         _MMStreamRecorderVideoInfo *info = NULL;
996
997         mmf_return_val_if_fail(handle, FALSE);
998         attr = MMF_STREAMRECORDER_ATTRS(handle);
999         mmf_return_val_if_fail(attr, FALSE);
1000         sc = MMF_STREAMRECORDER_SUBCONTEXT(handle);
1001         mmf_return_val_if_fail(sc, FALSE);
1002
1003         info = (_MMStreamRecorderVideoInfo *) sc->info_video;
1004         mmf_return_val_if_fail(info, FALSE);
1005
1006         _mmstreamrec_dbg_log("(%d)", attr_idx);
1007
1008         info->iVideoEncoder = value->value.i_val;
1009
1010         return TRUE;
1011 }
1012
1013 bool _mmstreamrecorder_commit_audio_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
1014 {
1015         MMHandleType attr = 0;
1016         /* mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle); */
1017         _MMStreamRecorderSubContext *sc = NULL;
1018         _MMStreamRecorderAudioInfo *info = NULL;
1019
1020         mmf_return_val_if_fail(handle, FALSE);
1021         attr = MMF_STREAMRECORDER_ATTRS(handle);
1022         mmf_return_val_if_fail(attr, FALSE);
1023         sc = MMF_STREAMRECORDER_SUBCONTEXT(handle);
1024         mmf_return_val_if_fail(sc, FALSE);
1025
1026         _mmstreamrec_dbg_log("(%d)", attr_idx);
1027
1028         info = (_MMStreamRecorderAudioInfo *) sc->info_audio;
1029
1030         if (info == NULL && value->value.i_val != 0) {
1031                 if (_mmstreamrecorder_alloc_subcontext_audioinfo(handle))
1032                         return FALSE;
1033         }
1034
1035         return TRUE;
1036 }
1037
1038 bool _mmstreamrecorder_commit_audio_encoder(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
1039 {
1040         MMHandleType attr = 0;
1041         _MMStreamRecorderSubContext *sc = NULL;
1042         _MMStreamRecorderAudioInfo *info = NULL;
1043
1044         mmf_return_val_if_fail(handle, FALSE);
1045         attr = MMF_STREAMRECORDER_ATTRS(handle);
1046         mmf_return_val_if_fail(attr, FALSE);
1047         sc = MMF_STREAMRECORDER_SUBCONTEXT(handle);
1048         mmf_return_val_if_fail(sc, FALSE);
1049
1050         info = (_MMStreamRecorderAudioInfo *) sc->info_audio;
1051         mmf_return_val_if_fail(info, FALSE);
1052
1053         _mmstreamrec_dbg_log("(%d)", attr_idx);
1054
1055         info->iAudioEncoder = value->value.i_val;
1056
1057         return TRUE;
1058 }
1059
1060 bool _mmstreamrecorder_commit_audio_samplingrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
1061 {
1062         MMHandleType attr = 0;
1063         _MMStreamRecorderSubContext *sc = NULL;
1064         _MMStreamRecorderAudioInfo *info = NULL;
1065
1066         mmf_return_val_if_fail(handle, FALSE);
1067         attr = MMF_STREAMRECORDER_ATTRS(handle);
1068         mmf_return_val_if_fail(attr, FALSE);
1069         sc = MMF_STREAMRECORDER_SUBCONTEXT(handle);
1070         mmf_return_val_if_fail(sc, FALSE);
1071
1072         info = (_MMStreamRecorderAudioInfo *) sc->info_audio;
1073         mmf_return_val_if_fail(info, FALSE);
1074
1075         _mmstreamrec_dbg_log("(%d)", attr_idx);
1076
1077         info->iSamplingRate = value->value.i_val;
1078
1079         return TRUE;
1080 }
1081
1082 bool _mmstreamrecorder_commit_audio_bitformat(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
1083 {
1084         MMHandleType attr = 0;
1085         _MMStreamRecorderSubContext *sc = NULL;
1086         _MMStreamRecorderAudioInfo *info = NULL;
1087
1088         mmf_return_val_if_fail(handle, FALSE);
1089         attr = MMF_STREAMRECORDER_ATTRS(handle);
1090         mmf_return_val_if_fail(attr, FALSE);
1091         sc = MMF_STREAMRECORDER_SUBCONTEXT(handle);
1092         mmf_return_val_if_fail(sc, FALSE);
1093
1094         info = (_MMStreamRecorderAudioInfo *) sc->info_audio;
1095         mmf_return_val_if_fail(info, FALSE);
1096
1097         _mmstreamrec_dbg_log("(%d)", attr_idx);
1098
1099         if (value->value.i_val == MM_STREAMRECORDER_AUDIO_FORMAT_PCM_U8)
1100                 info->audio_encode_depth = 16;
1101         else
1102                 info->audio_encode_depth = 8;
1103
1104         return TRUE;
1105 }
1106
1107 bool _mmstreamrecorder_commit_video_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
1108 {
1109         MMHandleType attr = 0;
1110         _MMStreamRecorderSubContext *sc = NULL;
1111         int v_bitrate;
1112
1113         mmf_return_val_if_fail(handle, FALSE);
1114         attr = MMF_STREAMRECORDER_ATTRS(handle);
1115         mmf_return_val_if_fail(attr, FALSE);
1116         sc = MMF_STREAMRECORDER_SUBCONTEXT(handle);
1117         mmf_return_val_if_fail(sc, FALSE);
1118
1119         v_bitrate = value->value.i_val;
1120
1121         if (sc->encode_element[_MMSTREAMRECORDER_ENCSINK_VENC].gst) {
1122                 MMSTREAMRECORDER_G_OBJECT_SET(sc->encode_element[_MMSTREAMRECORDER_ENCSINK_VENC].gst, "bitrate", v_bitrate);
1123                 _mmstreamrec_dbg_log("video bitrate set to encoder success = %d", v_bitrate);
1124         } else {
1125                 _mmstreamrec_dbg_log("_MMSTREAMRECORDER_ENCSINK_VENC is null %d", attr_idx);
1126         }
1127         return TRUE;
1128 }
1129
1130 bool _mmstreamrecorder_commit_audio_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
1131 {
1132         MMHandleType attr = 0;
1133         _MMStreamRecorderSubContext *sc = NULL;
1134         _MMStreamRecorderAudioInfo *info = NULL;
1135
1136         mmf_return_val_if_fail(handle, FALSE);
1137         attr = MMF_STREAMRECORDER_ATTRS(handle);
1138         mmf_return_val_if_fail(attr, FALSE);
1139         sc = MMF_STREAMRECORDER_SUBCONTEXT(handle);
1140         mmf_return_val_if_fail(sc, FALSE);
1141
1142         info = (_MMStreamRecorderAudioInfo *) sc->info_audio;
1143         mmf_return_val_if_fail(info, FALSE);
1144
1145         _mmstreamrec_dbg_log("(%d)", attr_idx);
1146
1147         info->iBitrate = value->value.i_val;
1148
1149         return TRUE;
1150 }
1151
1152 bool _mmstreamrecorder_commit_audio_channel(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
1153 {
1154         MMHandleType attr = 0;
1155         _MMStreamRecorderSubContext *sc = NULL;
1156         _MMStreamRecorderAudioInfo *info = NULL;
1157
1158         mmf_return_val_if_fail(handle, FALSE);
1159         attr = MMF_STREAMRECORDER_ATTRS(handle);
1160         mmf_return_val_if_fail(attr, FALSE);
1161         sc = MMF_STREAMRECORDER_SUBCONTEXT(handle);
1162         mmf_return_val_if_fail(sc, FALSE);
1163
1164         info = (_MMStreamRecorderAudioInfo *) sc->info_audio;
1165         mmf_return_val_if_fail(info, FALSE);
1166
1167         _mmstreamrec_dbg_log("(%d)", attr_idx);
1168
1169         info->iChannels = value->value.i_val;
1170
1171         return TRUE;
1172 }