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