Merge "Revert "use-tbm is set to true when the condition is true"" into tizen
[platform/core/multimedia/libmm-player.git] / src / mm_player_attrs.c
1 /*
2  * libmm-player
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
7  * YoungHwan An <younghwan_.an@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 /*===========================================================================================
24 |                                                                                                                                                                                       |
25 |  INCLUDE FILES                                                                                                                                                        |
26 |                                                                                                                                                                                       |
27 ========================================================================================== */
28 #include <dlog.h>
29 #include <mm_attrs.h>
30 #include "mm_player_utils.h"
31 #include "mm_player_priv.h"
32 #include "mm_player_attrs.h"
33
34 /*===========================================================================================
35 |                                                                                                                                                                                       |
36 |  LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE                                                                                        |
37 |                                                                                                                                                                                       |
38 ========================================================================================== */
39
40 /*-----------------------------------------------------------------------
41 |    LOCAL FUNCTION PROTOTYPES:                                         |
42 -----------------------------------------------------------------------*/
43 static bool __mmplayer_commit_gapless_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
44 static bool __mmplayer_commit_enable_video_decoded_cb(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
45 static bool __mmplayer_commit_audio_pitch_value(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
46
47 /*===========================================================================================
48 |                                                                                                                                                                                                               |
49 |  FUNCTION DEFINITIONS                                                                                                                                                                 |
50 |                                                                                                                                                                                                               |
51 ========================================================================================== */
52
53 static bool __mmplayer_commit_enable_video_decoded_cb(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
54 {
55         mmplayer_t *player = MM_PLAYER_CAST(handle);
56         mmplayer_gst_element_t *videobin = NULL;
57
58         MMPLAYER_FENTER();
59         MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
60
61         if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
62                 LOGD("will be applied when videosink is ready");
63                 return true;
64         }
65
66         if (!player->set_mode.video_export) {
67                 LOGW("there is no callback for enabling");
68                 return true;
69         }
70
71         videobin = player->pipeline->videobin;
72
73         LOGD("[update plugin][videosink] handoff %d", value->value.i_val);
74
75         g_object_set(videobin[MMPLAYER_V_SINK].gst,
76                                 "signal-handoffs", (value->value.i_val) ? TRUE : FALSE, NULL);
77
78         return true;
79 }
80
81 static bool __mmplayer_commit_gapless_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
82 {
83         mmplayer_t *player = MM_PLAYER_CAST(handle);
84         mmplayer_gst_element_t *videobin = NULL;
85
86         MMPLAYER_FENTER();
87         MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
88
89         if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
90                 LOGD("will be applied when videosink is ready");
91                 return true;
92         }
93
94         videobin = player->pipeline->videobin;
95
96         if (value->value.i_val > 0) {
97                 LOGD("[update plugin][videosink] disable last sample for gapless");
98                 g_object_set(videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
99         }
100
101         return true;
102 }
103
104 static bool __mmplayer_commit_audio_pitch_value(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
105 {
106         mmplayer_t *player = MM_PLAYER_CAST(handle);
107         mmplayer_pipeline_info_t *pipeline;
108         int pitch_control = 0;
109
110         MMPLAYER_FENTER();
111         MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
112         MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline && player->pipeline->mainbin, true);
113
114         pipeline = player->pipeline;
115         mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_PITCH_CONTROL, &pitch_control);
116
117         if (!pitch_control || !pipeline->audiobin[MMPLAYER_A_PITCH].gst) {
118                 LOGW("audio pitch is disabled");
119                 return true;
120         }
121
122         LOGD("[update plugin][pitch] value to %1.3f", value->value.d_val);
123         g_object_set(pipeline->audiobin[MMPLAYER_A_PITCH].gst, "pitch", (value->value.d_val), NULL);
124
125         return true;
126 }
127
128 static int __mmplayer_get_array_count(MMHandleType handle, int type)
129 {
130         mmplayer_t *player = (mmplayer_t *)handle;
131
132         int count = 0;
133         int i = 0;
134
135         if (type == KEYWORD_A_OFFLOAD_MEDIA_FORMAT) {
136                 while (player->ini.audio_offload_media_format[i++][0])
137                         count++;
138         } else if (type == KEYWORD_MEDIA_STREAM_IN_FORMAT) {
139                 while (player->ini.media_stream_input_format[i++][0])
140                         count++;
141         }
142         return count;
143 }
144
145 static media_format_mimetype_e __mmplayer_get_supported_format_mimetype(MMHandleType handle, int type, int i)
146 {
147         char *name = NULL;
148         media_format_mimetype_e format = MEDIA_FORMAT_MAX;
149
150         mmplayer_t *player = (mmplayer_t *)handle;
151
152         if (type == KEYWORD_A_OFFLOAD_MEDIA_FORMAT) {
153                 name = player->ini.audio_offload_media_format[i];
154         } else if (type == KEYWORD_MEDIA_STREAM_IN_FORMAT) {
155                 name = player->ini.media_stream_input_format[i];
156         } else {
157                 LOGE("invalid ini type");
158                 goto EXIT;
159         }
160
161         if (!strcmp(name, "MP3"))
162                 format = MEDIA_FORMAT_MP3;
163         else if (!strcmp(name, "AAC"))
164                 format = MEDIA_FORMAT_AAC;
165         else if (!strcmp(name, "H264_SP"))
166                 format = MEDIA_FORMAT_H264_SP;
167         else if (!strcmp(name, "H264_MP"))
168                 format = MEDIA_FORMAT_H264_MP;
169         else if (!strcmp(name, "H264_HP"))
170                 format = MEDIA_FORMAT_H264_HP;
171         else if (!strcmp(name, "PCM"))
172                 format = MEDIA_FORMAT_PCM;
173         else if (!strcmp(name, "PCM_S16LE"))
174                 format = MEDIA_FORMAT_PCM_S16LE;
175         else if (!strcmp(name, "PCM_S24LE"))
176                 format = MEDIA_FORMAT_PCM_S24LE;
177         else if (!strcmp(name, "PCM_S32LE"))
178                 format = MEDIA_FORMAT_PCM_S32LE;
179         else if (!strcmp(name, "PCM_S16BE"))
180                 format = MEDIA_FORMAT_PCM_S16BE;
181         else if (!strcmp(name, "PCM_S24BE"))
182                 format = MEDIA_FORMAT_PCM_S24BE;
183         else if (!strcmp(name, "PCM_S32BE"))
184                 format = MEDIA_FORMAT_PCM_S32BE;
185         else if (!strcmp(name, "PCM_F32LE"))
186                 format = MEDIA_FORMAT_PCM_F32LE;
187         else if (!strcmp(name, "PCM_F32BE"))
188                 format = MEDIA_FORMAT_PCM_F32BE;
189         else if (!strcmp(name, "PCM_S16LE"))
190                 format = MEDIA_FORMAT_PCM_U16LE;
191         else if (!strcmp(name, "PCM_U24LE"))
192                 format = MEDIA_FORMAT_PCM_U24LE;
193         else if (!strcmp(name, "PCM_U32LE"))
194                 format = MEDIA_FORMAT_PCM_U32LE;
195         else if (!strcmp(name, "PCM_U16BE"))
196                 format = MEDIA_FORMAT_PCM_U16BE;
197         else if (!strcmp(name, "PCM_U24BE"))
198                 format = MEDIA_FORMAT_PCM_U24BE;
199         else if (!strcmp(name, "PCM_U32BE"))
200                 format = MEDIA_FORMAT_PCM_U32BE;
201         else
202                 LOGE("FIXME: need to modify function to support more format");
203
204 EXIT:
205         LOGD("[%d type] supported format 0x%X(%s)", type, format, name);
206
207         return format;
208 }
209
210 static int __mmplayer_get_available_format(MMHandleType handle, int type, int **format)
211 {
212         int *arr = NULL;
213         int total_count = 0;
214         int count = 0;
215         int i = 0;
216         int fmt = 0;
217
218         MMPLAYER_RETURN_VAL_IF_FAIL(handle, -1);
219
220         count = __mmplayer_get_array_count(handle, type);
221
222         if (count <= 0)
223                 return -1;
224
225         arr = (int *) g_malloc0(count * sizeof(int));
226         for (i = 0 ; i < count ; i++) {
227                 fmt = __mmplayer_get_supported_format_mimetype(handle, type, i);
228                 if (fmt != MEDIA_FORMAT_MAX)
229                         arr[total_count++] = fmt;
230         }
231
232         if (total_count <= 0) {
233                 g_free(arr);
234                 return -1;
235         }
236
237         LOGD("[%d type] num of supported codec %d", type, total_count);
238
239         *format = arr;
240         return total_count;
241 }
242
243 static int __mmplayer_set_ini_to_valid_info(MMHandleType handle)
244 {
245         mmplayer_t *player = MM_PLAYER_CAST(handle);
246         int *format = NULL;
247         int total_count = 0;
248
249         /* supported format of audio offload */
250         total_count = __mmplayer_get_available_format(handle, KEYWORD_A_OFFLOAD_MEDIA_FORMAT, &format);
251         if (format && total_count > 0) {
252                 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = format;
253                 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = total_count;
254         }
255
256         /* supported format of media stream input */
257         total_count = __mmplayer_get_available_format(handle, KEYWORD_MEDIA_STREAM_IN_FORMAT, &format);
258         if (format && total_count > 0) {
259                 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = format;
260                 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = total_count;
261         }
262
263         return MM_ERROR_NONE;
264 }
265
266 static int __mmplayer_release_ini_info(MMHandleType handle)
267 {
268         mmplayer_t *player = MM_PLAYER_CAST(handle);
269         int *mem = NULL;
270
271         MMPLAYER_FENTER();
272
273         mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array);
274         g_free(mem);
275         player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = NULL;
276         player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = 0;
277
278         mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array);
279         g_free(mem);
280         player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = NULL;
281         player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = 0;
282
283         MMPLAYER_FLEAVE();
284         return MM_ERROR_NONE;
285 }
286
287 static void __mmplayer_print_attrs(const char *attr_name, const MMAttrsValue * value, const char *prefix)
288 {
289         switch (value->type) {
290         case MM_ATTRS_TYPE_INT:
291                 LOGD("[ %s : %s : %d ]", prefix, attr_name, value->value.i_val);
292                 break;
293         case MM_ATTRS_TYPE_DOUBLE:
294                 LOGD("[ %s : %s : %f ]", prefix, attr_name, value->value.d_val);
295                 break;
296         case MM_ATTRS_TYPE_STRING:
297                 LOGD("[ %s : %s : %s ]", prefix, attr_name, value->value.s_val);
298                 break;
299         case MM_ATTRS_TYPE_DATA:
300                 LOGD("[ %s : %s : %p ]", prefix, attr_name, value->value.p_val);
301                 break;
302         default:
303                 break;
304         }
305
306         return;
307 }
308
309 bool _mmplayer_commit_attribute(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
310 {
311         bool ret = false;
312         mmplayer_t *player = MM_PLAYER_CAST(commit_param);
313
314         MMPLAYER_RETURN_VAL_IF_FAIL(player && (attr_idx >= 0) && attr_name && value, false);
315
316         if (player->default_attrs[attr_idx].attr_commit) {
317                 __mmplayer_print_attrs(attr_name, value, "Dynamic");
318                 ret = player->default_attrs[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
319         } else {
320                 __mmplayer_print_attrs(attr_name, value, "Static");
321                 ret = true;
322         }
323
324         return ret;
325 }
326
327 int _mmplayer_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
328 {
329         int result = MM_ERROR_NONE;
330         MMHandleType attrs = NULL;
331
332         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
333         /* if it's not want to know it. */
334         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
335         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
336
337         attrs = MM_PLAYER_GET_ATTRS(handle);
338
339         result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
340
341         if (result != MM_ERROR_NONE)
342                 LOGE("failed to get %s attribute", attribute_name);
343
344         return result;
345 }
346
347 int __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
348 {
349         mmplayer_t *player = NULL;
350
351         MMPLAYER_FENTER();
352         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
353         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
354
355         player = MM_PLAYER_CAST(handle);
356
357         /* apply display attr value to player handle */
358         if (!g_strrstr(attribute_name, "display"))
359                 return MM_ERROR_NONE;
360
361         if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
362                 LOGD("will be applied when videosink is ready");
363                 return MM_ERROR_NONE;
364         }
365
366         if (_mmplayer_update_video_overlay_param(player, attribute_name) != MM_ERROR_NONE) {
367                 LOGW("not supported video param %s", attribute_name);
368                 return MM_ERROR_NONE;
369         }
370
371         return MM_ERROR_NONE;
372 }
373
374 int _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
375 {
376         int result = MM_ERROR_NONE;
377         MMHandleType attrs = NULL;
378
379         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
380         /* if it's not want to know it. */
381         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
382         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
383
384         attrs = MM_PLAYER_GET_ATTRS(handle);
385
386         /* set attributes and commit them */
387         result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
388         if (result != MM_ERROR_NONE) {
389                 LOGE("failed to set %s attribute", attribute_name);
390                 return result;
391         }
392
393         /* Note: 'attr_commit' function is called before committing the new value to attr struct.
394                  so if there is a value to apply after committing, it should be added below function. */
395         result = __mmplayer_apply_attribute(handle, attribute_name);
396         if (result != MM_ERROR_NONE) {
397                 LOGE("failed to apply attributes");
398                 return result;
399         }
400
401         return MM_ERROR_NONE;
402 }
403
404 int _mmplayer_get_attributes_info(MMHandleType handle,  const char *attribute_name, mmplayer_attrs_info_t *dst_info)
405 {
406         int result = MM_ERROR_NONE;
407         MMHandleType attrs = NULL;
408         MMAttrsInfo src_info = {0, };
409
410         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
411         MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
412         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
413
414         attrs = MM_PLAYER_GET_ATTRS(handle);
415
416         result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
417
418         if (result != MM_ERROR_NONE) {
419                 LOGE("failed to get attribute info");
420                 return result;
421         }
422
423         memset(dst_info, 0x00, sizeof(mmplayer_attrs_info_t));
424
425         dst_info->type = src_info.type;
426         dst_info->flag = src_info.flag;
427         dst_info->validity_type = src_info.validity_type;
428
429         switch (src_info.validity_type) {
430         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
431                 dst_info->int_array.array = src_info.int_array.array;
432                 dst_info->int_array.count = src_info.int_array.count;
433                 dst_info->int_array.d_val = src_info.int_array.dval;
434                 break;
435
436         case MM_ATTRS_VALID_TYPE_INT_RANGE:
437                 dst_info->int_range.min = src_info.int_range.min;
438                 dst_info->int_range.max = src_info.int_range.max;
439                 dst_info->int_range.d_val = src_info.int_range.dval;
440                 break;
441
442         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
443                 dst_info->double_array.array = src_info.double_array.array;
444                 dst_info->double_array.count = src_info.double_array.count;
445                 dst_info->double_array.d_val = src_info.double_array.dval;
446                 break;
447
448         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
449                 dst_info->double_range.min = src_info.double_range.min;
450                 dst_info->double_range.max = src_info.double_range.max;
451                 dst_info->double_range.d_val = src_info.double_range.dval;
452                 break;
453
454         default:
455                 break;
456         }
457
458         return result;
459 }
460
461 MMHandleType _mmplayer_construct_attribute(MMHandleType handle)
462 {
463         mmplayer_t *player = MM_PLAYER_CAST(handle);
464         int result = MM_ERROR_NONE;
465         int idx = 0;
466         MMHandleType attrs = NULL;
467         int num_of_attrs = 0;
468         MMAttrsConstructInfo *base = NULL;
469
470         mmplayer_attrs_spec_t player_attrs[] = {
471                 {
472                         MMPLAYER_ATTRS_PROFILE_URI,                /* ID */
473                         (char *)"profile_uri",                             /* Name */
474                         MM_ATTRS_TYPE_STRING,                              /* Value Type */
475                         MM_ATTRS_FLAG_RW,                                          /* Flag */
476                         {(void *)NULL},                                            /* default value */
477                         MM_ATTRS_VALID_TYPE_NONE,                          /* validity type */
478                         {0},                                                               /* validity min value */
479                         {0},                                                               /* validity max value */
480                         NULL,                                                              /* Runtime setting function of the attribute */
481                 },
482                 {
483                         MMPLAYER_ATTRS_PROFILE_USER_PARAM,
484                         (char *)"profile_user_param",
485                         MM_ATTRS_TYPE_DATA,
486                         MM_ATTRS_FLAG_RW,
487                         {(void *)NULL},
488                         MM_ATTRS_VALID_TYPE_NONE,
489                         {0},
490                         {0},
491                         NULL,
492                 },
493                 {
494                         MMPLAYER_ATTRS_PROFILE_PLAY_COUNT,
495                         (char *)"profile_play_count",
496                         MM_ATTRS_TYPE_INT,
497                         MM_ATTRS_FLAG_RW,
498                         {(void *)1},                                            /* -1 : repeat continually */
499                         MM_ATTRS_VALID_TYPE_INT_RANGE,
500                         {.int_min = -1},
501                         {.int_max = 1},
502                         NULL,
503                 },
504                 {
505                         MMPLAYER_ATTRS_PROFILE_PREPARE_ASYNC,
506                         (char *)"profile_prepare_async",
507                         MM_ATTRS_TYPE_INT,
508                         MM_ATTRS_FLAG_RW,
509                         {(void *)0},
510                         MM_ATTRS_VALID_TYPE_INT_RANGE,
511                         {.int_min = 0},
512                         {.int_max = 1},
513                         NULL,
514                 },
515                 {
516                         MMPLAYER_ATTRS_STREAMING_USER_AGENT,
517                         (char *)"streaming_user_agent",
518                         MM_ATTRS_TYPE_STRING,
519                         MM_ATTRS_FLAG_RW,
520                         {(void *)NULL},
521                         MM_ATTRS_VALID_TYPE_NONE,
522                         {0},
523                         {0},
524                         NULL,
525                 },
526                 {
527                         MMPLAYER_ATTRS_STREAMING_COOKIE,
528                         (char *)"streaming_cookie",
529                         MM_ATTRS_TYPE_STRING,
530                         MM_ATTRS_FLAG_RW,
531                         {(void *)NULL},
532                         MM_ATTRS_VALID_TYPE_NONE,
533                         {0},
534                         {0},
535                         NULL,
536                 },
537                 {
538                         MMPLAYER_ATTRS_SUBTITLE_URI,
539                         (char *)"subtitle_uri",
540                         MM_ATTRS_TYPE_STRING,
541                         MM_ATTRS_FLAG_RW,
542                         {(void *)NULL},
543                         MM_ATTRS_VALID_TYPE_NONE,
544                         {0},
545                         {0},
546                         NULL,
547                 },
548                 {
549                         MMPLAYER_ATTRS_CONTENT_BITRATE,
550                         (char *)"content_bitrate",
551                         MM_ATTRS_TYPE_INT,
552                         MM_ATTRS_FLAG_RW,
553                         {(void *)0},
554                         MM_ATTRS_VALID_TYPE_INT_RANGE,
555                         {.int_min = 0},
556                         {.int_max = MMPLAYER_MAX_INT},
557                         NULL,
558                 },
559                 {
560                         MMPLAYER_ATTRS_CONTENT_MAX_BITRATE,
561                         (char *)"content_max_bitrate",
562                         MM_ATTRS_TYPE_INT,
563                         MM_ATTRS_FLAG_RW,
564                         {(void *)0},
565                         MM_ATTRS_VALID_TYPE_INT_RANGE,
566                         {.int_min = 0},
567                         {.int_max = MMPLAYER_MAX_INT},
568                         NULL,
569                 },
570                 {
571                         MMPLAYER_ATTRS_CONTENT_VIDEO_FOUND,
572                         (char *)"content_video_found",
573                         MM_ATTRS_TYPE_INT,
574                         MM_ATTRS_FLAG_RW,
575                         {(void *)0},
576                         MM_ATTRS_VALID_TYPE_INT_RANGE,
577                         {.int_min = 0},
578                         {.int_max = 1},
579                         NULL,
580                 },
581                 {
582                         MMPLAYER_ATTRS_CONTENT_VIDEO_CODEC,
583                         (char *)"content_video_codec",
584                         MM_ATTRS_TYPE_STRING,
585                         MM_ATTRS_FLAG_RW,
586                         {(void *)NULL},
587                         MM_ATTRS_VALID_TYPE_NONE,
588                         {0},
589                         {0},
590                         NULL,
591                 },
592                 {
593                         MMPLAYER_ATTRS_CONTENT_VIDEO_BITRATE,
594                         (char *)"content_video_bitrate",
595                         MM_ATTRS_TYPE_INT,
596                         MM_ATTRS_FLAG_RW,
597                         {(void *)0},
598                         MM_ATTRS_VALID_TYPE_INT_RANGE,
599                         {.int_min = 0},
600                         {.int_max = MMPLAYER_MAX_INT},
601                         NULL,
602                 },
603                 {
604                         MMPLAYER_ATTRS_CONTENT_VIDEO_FPS,
605                         (char *)"content_video_fps",
606                         MM_ATTRS_TYPE_INT,
607                         MM_ATTRS_FLAG_RW,
608                         {(void *)0},
609                         MM_ATTRS_VALID_TYPE_INT_RANGE,
610                         {.int_min = 0},
611                         {.int_max = MMPLAYER_MAX_INT},
612                         NULL,
613                 },
614                 {
615                         MMPLAYER_ATTRS_CONTENT_VIDEO_WIDTH,
616                         (char *)"content_video_width",
617                         MM_ATTRS_TYPE_INT,
618                         MM_ATTRS_FLAG_RW,
619                         {(void *)0},
620                         MM_ATTRS_VALID_TYPE_INT_RANGE,
621                         {.int_min = 0},
622                         {.int_max = MMPLAYER_MAX_INT},
623                         NULL,
624                 },
625                 {
626                         MMPLAYER_ATTRS_CONTENT_VIDEO_HEIGHT,
627                         (char *)"content_video_height",
628                         MM_ATTRS_TYPE_INT,
629                         MM_ATTRS_FLAG_RW,
630                         {(void *)0},
631                         MM_ATTRS_VALID_TYPE_INT_RANGE,
632                         {.int_min = 0},
633                         {.int_max = MMPLAYER_MAX_INT},
634                         NULL,
635                 },
636                 {
637                         MMPLAYER_ATTRS_CONTENT_VIDEO_ORIENTATION,
638                         (char *)"content_video_orientation",   /* orientation of video content */
639                         MM_ATTRS_TYPE_STRING,
640                         MM_ATTRS_FLAG_RW,
641                         {(void *)NULL},
642                         MM_ATTRS_VALID_TYPE_NONE,
643                         {0},
644                         {0},
645                         NULL,
646                 },
647                 {
648                         MMPLAYER_ATTRS_CONTENT_VIDEO_IS_SPHERICAL,
649                         (char *)"content_video_is_spherical",
650                         MM_ATTRS_TYPE_INT,
651                         MM_ATTRS_FLAG_RW,
652                         {(void *)-1},
653                         MM_ATTRS_VALID_TYPE_INT_RANGE,
654                         {.int_min = -1},
655                         {.int_max = MMPLAYER_MAX_INT},
656                         NULL,
657                 },
658                 {
659                         MMPLAYER_ATTRS_CONTENT_AUDIO_CODEC,
660                         (char *)"content_audio_codec",
661                         MM_ATTRS_TYPE_STRING,
662                         MM_ATTRS_FLAG_RW,
663                         {(void *)NULL},
664                         MM_ATTRS_VALID_TYPE_NONE,
665                         {0},
666                         {0},
667                         NULL,
668                 },
669                 {
670                         MMPLAYER_ATTRS_CONTENT_AUDIO_BITRATE,
671                         (char *)"content_audio_bitrate",
672                         MM_ATTRS_TYPE_INT,
673                         MM_ATTRS_FLAG_RW,
674                         {(void *)0},
675                         MM_ATTRS_VALID_TYPE_INT_RANGE,
676                         {.int_min = 0},
677                         {.int_max = MMPLAYER_MAX_INT},
678                         NULL,
679                 },
680                 {
681                         MMPLAYER_ATTRS_CONTENT_AUDIO_CHANNELS,
682                         (char *)"content_audio_channels",
683                         MM_ATTRS_TYPE_INT,
684                         MM_ATTRS_FLAG_RW,
685                         {(void *)0},
686                         MM_ATTRS_VALID_TYPE_INT_RANGE,
687                         {.int_min = 0},
688                         {.int_max = MMPLAYER_MAX_INT},
689                         NULL,
690                 },
691                 {
692                         MMPLAYER_ATTRS_CONTENT_AUDIO_SAMPLERATE,
693                         (char *)"content_audio_samplerate",
694                         MM_ATTRS_TYPE_INT,
695                         MM_ATTRS_FLAG_RW,
696                         {(void *)0},
697                         MM_ATTRS_VALID_TYPE_INT_RANGE,
698                         {.int_min = 0},
699                         {.int_max = MMPLAYER_MAX_INT},
700                         NULL,
701                 },
702                 {
703                         MMPLAYER_ATTRS_CONTENT_AUDIO_FORMAT,
704                         (char *)"content_audio_format",
705                         MM_ATTRS_TYPE_STRING,
706                         MM_ATTRS_FLAG_RW,
707                         {(void *)NULL},
708                         MM_ATTRS_VALID_TYPE_NONE,
709                         {0},
710                         {0},
711                         NULL,
712                 },
713                 {
714                         MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_NUM,
715                         (char *)"content_text_track_num",
716                         MM_ATTRS_TYPE_INT,
717                         MM_ATTRS_FLAG_RW,
718                         {(void *)0},
719                         MM_ATTRS_VALID_TYPE_INT_RANGE,
720                         {.int_min = 0},
721                         {.int_max = MMPLAYER_MAX_INT},
722                         NULL,
723                 },
724                 {
725                         MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_INDEX,
726                         (char *)"current_text_track_index",
727                         MM_ATTRS_TYPE_INT,
728                         MM_ATTRS_FLAG_RW,
729                         {(void *)-1},
730                         MM_ATTRS_VALID_TYPE_INT_RANGE,
731                         {.int_min = -1},
732                         {.int_max = MMPLAYER_MAX_INT},
733                         NULL,
734                 },
735                 {
736                         MMPLAYER_ATTRS_TAG_ARTIST,
737                         (char *)"tag_artist",
738                         MM_ATTRS_TYPE_STRING,
739                         MM_ATTRS_FLAG_RW,
740                         {(void *)NULL},
741                         MM_ATTRS_VALID_TYPE_NONE,
742                         {0},
743                         {0},
744                         NULL,
745                 },
746                 {
747                         MMPLAYER_ATTRS_TAG_TITLE,
748                         (char *)"tag_title",
749                         MM_ATTRS_TYPE_STRING,
750                         MM_ATTRS_FLAG_RW,
751                         {(void *)NULL},
752                         MM_ATTRS_VALID_TYPE_NONE,
753                         {0},
754                         {0},
755                         NULL,
756                 },
757                 {
758                         MMPLAYER_ATTRS_TAG_ALBUM,
759                         (char *)"tag_album",
760                         MM_ATTRS_TYPE_STRING,
761                         MM_ATTRS_FLAG_RW,
762                         {(void *)NULL},
763                         MM_ATTRS_VALID_TYPE_NONE,
764                         {0},
765                         {0},
766                         NULL,
767                 },
768                 {
769                         MMPLAYER_ATTRS_TAG_GENRE,
770                         (char *)"tag_genre",
771                         MM_ATTRS_TYPE_STRING,
772                         MM_ATTRS_FLAG_RW,
773                         {(void *)NULL},
774                         MM_ATTRS_VALID_TYPE_NONE,
775                         {0},
776                         {0},
777                         NULL,
778                 },
779                 {
780                         MMPLAYER_ATTRS_TAG_AUTHOR,
781                         (char *)"tag_author",
782                         MM_ATTRS_TYPE_STRING,
783                         MM_ATTRS_FLAG_RW,
784                         {(void *)NULL},
785                         MM_ATTRS_VALID_TYPE_NONE,
786                         {0},
787                         {0},
788                         NULL,
789                 },
790                 {
791                         MMPLAYER_ATTRS_TAG_COPYRIGHT,
792                         (char *)"tag_copyright",
793                         MM_ATTRS_TYPE_STRING,
794                         MM_ATTRS_FLAG_RW,
795                         {(void *)NULL},
796                         MM_ATTRS_VALID_TYPE_NONE,
797                         {0},
798                         {0},
799                         NULL,
800                 },
801                 {
802                         MMPLAYER_ATTRS_TAG_DATE,
803                         (char *)"tag_date",
804                         MM_ATTRS_TYPE_STRING,
805                         MM_ATTRS_FLAG_RW,
806                         {(void *)NULL},
807                         MM_ATTRS_VALID_TYPE_NONE,
808                         {0},
809                         {0},
810                         NULL,
811                 },
812                 {
813                         MMPLAYER_ATTRS_TAG_DESCRIPTION,
814                         (char *)"tag_description",
815                         MM_ATTRS_TYPE_STRING,
816                         MM_ATTRS_FLAG_RW,
817                         {(void *)NULL},
818                         MM_ATTRS_VALID_TYPE_NONE,
819                         {0},
820                         {0},
821                         NULL,
822                 },
823                 {
824                         MMPLAYER_ATTRS_TAG_TRACK_NUM,
825                         (char *)"tag_track_num",
826                         MM_ATTRS_TYPE_INT,
827                         MM_ATTRS_FLAG_RW,
828                         {(void *)0},
829                         MM_ATTRS_VALID_TYPE_INT_RANGE,
830                         {.int_min = 0},
831                         {.int_max = MMPLAYER_MAX_INT},
832                         NULL,
833                 },
834                 {
835                         MMPLAYER_ATTRS_TAG_ALBUM_COVER,
836                         (char *)"tag_album_cover",
837                         MM_ATTRS_TYPE_DATA,
838                         MM_ATTRS_FLAG_RW,
839                         {(void *)NULL},
840                         MM_ATTRS_VALID_TYPE_NONE,
841                         {0},
842                         {0},
843                         NULL,
844                 },
845                 {
846                         MMPLAYER_ATTRS_DISPLAY_ROTATION,
847                         (char *)"display_rotation",
848                         MM_ATTRS_TYPE_INT,
849                         MM_ATTRS_FLAG_RW,
850                         {(void *)MM_DISPLAY_ROTATION_NONE},
851                         MM_ATTRS_VALID_TYPE_INT_RANGE,
852                         {.int_min = MM_DISPLAY_ROTATION_NONE},
853                         {.int_max = MM_DISPLAY_ROTATION_270},
854                         NULL,
855                 },
856                 {
857                         MMPLAYER_ATTRS_DISPLAY_VISIBLE,
858                         (char *)"display_visible",
859                         MM_ATTRS_TYPE_INT,
860                         MM_ATTRS_FLAG_RW,
861                         {(void *)FALSE},
862                         MM_ATTRS_VALID_TYPE_INT_RANGE,
863                         {.int_min = FALSE},
864                         {.int_max = TRUE},
865                         NULL,
866                 },
867                 {
868                         MMPLAYER_ATTRS_DISPLAY_METHOD,
869                         (char *)"display_method",
870                         MM_ATTRS_TYPE_INT,
871                         MM_ATTRS_FLAG_RW,
872                         {(void *)MM_DISPLAY_METHOD_LETTER_BOX},
873                         MM_ATTRS_VALID_TYPE_INT_RANGE,
874                         {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
875                         {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
876                         NULL,
877                 },
878                 {
879                         MMPLAYER_ATTRS_DISPLAY_OVERLAY,
880                         (char *)"display_overlay",
881                         MM_ATTRS_TYPE_INT,
882                         MM_ATTRS_FLAG_RW,
883                         {(void *)0},
884                         MM_ATTRS_VALID_TYPE_INT_RANGE,
885                         {.int_min = 0},
886                         {.int_max = MMPLAYER_MAX_INT},
887                         NULL,
888                 },
889                 {
890                         MMPLAYER_ATTRS_DISPLAY_WIN_ROI_X,
891                         (char *)"display_win_roi_x",
892                         MM_ATTRS_TYPE_INT,
893                         MM_ATTRS_FLAG_RW,
894                         {(void *)0},
895                         MM_ATTRS_VALID_TYPE_INT_RANGE,
896                         {.int_min = MMPLAYER_MIN_INT},
897                         {.int_max = MMPLAYER_MAX_INT},
898                         NULL,
899                 },
900                 {
901                         MMPLAYER_ATTRS_DISPLAY_WIN_ROI_Y,
902                         (char *)"display_win_roi_y",
903                         MM_ATTRS_TYPE_INT,
904                         MM_ATTRS_FLAG_RW,
905                         {(void *)0},
906                         MM_ATTRS_VALID_TYPE_INT_RANGE,
907                         {.int_min = MMPLAYER_MIN_INT},
908                         {.int_max = MMPLAYER_MAX_INT},
909                         NULL,
910                 },
911                 {
912                         MMPLAYER_ATTRS_DISPLAY_WIN_ROI_WIDTH,
913                         (char *)"display_win_roi_width",
914                         MM_ATTRS_TYPE_INT,
915                         MM_ATTRS_FLAG_RW,
916                         {(void *)0},
917                         MM_ATTRS_VALID_TYPE_INT_RANGE,
918                         {.int_min = 0},
919                         {.int_max = MMPLAYER_MAX_INT},
920                         NULL,
921                 },
922                 {
923                         MMPLAYER_ATTRS_DISPLAY_WIN_ROI_HEIGHT,
924                         (char *)"display_win_roi_height",
925                         MM_ATTRS_TYPE_INT,
926                         MM_ATTRS_FLAG_RW,
927                         {(void *)0},
928                         MM_ATTRS_VALID_TYPE_INT_RANGE,
929                         {.int_min = 0},
930                         {.int_max = MMPLAYER_MAX_INT},
931                         NULL,
932                 },
933                 {
934                         MMPLAYER_ATTRS_DISPLAY_SURFACE_TYPE,
935                         (char *)"display_surface_type",
936                         MM_ATTRS_TYPE_INT,
937                         MM_ATTRS_FLAG_RW,
938                         {(void *)MM_DISPLAY_SURFACE_NULL},
939                         MM_ATTRS_VALID_TYPE_INT_RANGE,
940                         {.int_min = MM_DISPLAY_SURFACE_OVERLAY},
941                         {.int_max = MM_DISPLAY_SURFACE_NUM - 1},
942                         NULL,
943                 },
944                 {
945                         MMPLAYER_ATTRS_SOUND_STREAM_TYPE,
946                         (char *)"sound_stream_type",
947                         MM_ATTRS_TYPE_STRING,
948                         MM_ATTRS_FLAG_RW,
949                         {(void *)NULL},
950                         MM_ATTRS_VALID_TYPE_NONE,
951                         {0},
952                         {0},
953                         NULL,
954                 },
955                 {
956                         MMPLAYER_ATTRS_SOUND_STREAM_INDEX,
957                         (char *)"sound_stream_index",
958                         MM_ATTRS_TYPE_INT,
959                         MM_ATTRS_FLAG_RW,
960                         {(void *)0},
961                         MM_ATTRS_VALID_TYPE_INT_RANGE,
962                         {.int_min = -1},
963                         {.int_max = MMPLAYER_MAX_INT},
964                         NULL,
965                 },
966                 {
967                         MMPLAYER_ATTRS_SOUND_LATENCY_MODE,
968                         (char *)"sound_latency_mode",
969                         MM_ATTRS_TYPE_INT,
970                         MM_ATTRS_FLAG_RW,
971                         {(void *)1},                                             /* 0: low latency, 1: middle latency 2: high latency */
972                         MM_ATTRS_VALID_TYPE_INT_RANGE,
973                         {.int_min = 0},
974                         {.int_max = 2},
975                         NULL,
976                 },
977                 {
978                         MMPLAYER_ATTRS_PCM_EXTRACTION_SAMPLERATE,
979                         (char *)"pcm_extraction_samplerate", /* set samplerate for pcm extraction */
980                         MM_ATTRS_TYPE_INT,
981                         MM_ATTRS_FLAG_RW,
982                         {(void *)44100},
983                         MM_ATTRS_VALID_TYPE_INT_RANGE,
984                         {.int_min = 0},
985                         {.int_max = MMPLAYER_MAX_INT},
986                         NULL,
987                 },
988                 {
989                         MMPLAYER_ATTRS_PCM_EXTRACTION_CHANNELS,
990                         (char *)"pcm_extraction_channels",       /* set channels for pcm extraction */
991                         MM_ATTRS_TYPE_INT,
992                         MM_ATTRS_FLAG_RW,
993                         {(void *)1},
994                         MM_ATTRS_VALID_TYPE_INT_RANGE,
995                         {.int_min = 0},
996                         {.int_max = MMPLAYER_MAX_INT},
997                         NULL,
998                 },
999                 {
1000                         MMPLAYER_ATTRS_ACCURATE_SEEK,
1001                         (char *)"accurate_seek",
1002                         MM_ATTRS_TYPE_INT,
1003                         MM_ATTRS_FLAG_RW,
1004                         {(void *)0},
1005                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1006                         {.int_min = 0},
1007                         {.int_max = 1},
1008                         NULL,
1009                 },
1010                 {
1011                         MMPLAYER_ATTRS_PCM_EXTRACTION_FORMAT,
1012                         (char *)"pcm_extraction_format",
1013                         MM_ATTRS_TYPE_STRING,
1014                         MM_ATTRS_FLAG_RW,
1015                         {(void *)NULL},
1016                         MM_ATTRS_VALID_TYPE_NONE,
1017                         {0},
1018                         {0},
1019                         NULL,
1020                 },
1021                 {
1022                         MMPLAYER_ATTRS_DRC_MODE,
1023                         (char *)"drc_mode",
1024                         MM_ATTRS_TYPE_INT,
1025                         MM_ATTRS_FLAG_RW,
1026                         {(void *)FALSE},
1027                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1028                         {.int_min = FALSE},
1029                         {.int_max = TRUE},
1030                         NULL,
1031                 },
1032                 {
1033                         MMPLAYER_ATTRS_GAPLESS_MODE,
1034                         (char *)"gapless_mode",
1035                         MM_ATTRS_TYPE_INT,
1036                         MM_ATTRS_FLAG_RW,
1037                         {(void *)FALSE},
1038                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1039                         {.int_min = FALSE},
1040                         {.int_max = TRUE},
1041                         __mmplayer_commit_gapless_mode,
1042                 },
1043                 {
1044                         MMPLAYER_ATTRS_ENABLE_VIDEO_DECODED_CB,
1045                         (char *)"enable_video_decoded_cb",
1046                         MM_ATTRS_TYPE_INT,
1047                         MM_ATTRS_FLAG_RW,
1048                         {(void *)FALSE},
1049                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1050                         {.int_min = FALSE},
1051                         {.int_max = TRUE},
1052                         __mmplayer_commit_enable_video_decoded_cb,
1053                 },
1054                 {
1055                         MMPLAYER_ATTRS_VIDEO_CODEC_TYPE,
1056                         (char *)"video_codec_type",
1057                         MM_ATTRS_TYPE_INT,
1058                         MM_ATTRS_FLAG_RW,
1059                         {(void *)MM_PLAYER_CODEC_TYPE_DEFAULT},
1060                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1061                         {.int_min = MM_PLAYER_CODEC_TYPE_DEFAULT},
1062                         {.int_max = MM_PLAYER_CODEC_TYPE_SW},
1063                         NULL,
1064                 },
1065                 {
1066                         MMPLAYER_ATTRS_AUDIO_CODEC_TYPE,
1067                         (char *)"audio_codec_type",
1068                         MM_ATTRS_TYPE_INT,
1069                         MM_ATTRS_FLAG_RW,
1070                         {(void *)MM_PLAYER_CODEC_TYPE_DEFAULT},
1071                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1072                         {.int_min = MM_PLAYER_CODEC_TYPE_DEFAULT},
1073                         {.int_max = MM_PLAYER_CODEC_TYPE_SW},
1074                         NULL,
1075                 },
1076                 {
1077                         MMPLAYER_ATTRS_VIDEO_BUFFER_TOTAL_SIZE,
1078                         (char *)"video_buffer_total_size",
1079                         MM_ATTRS_TYPE_INT,
1080                         MM_ATTRS_FLAG_RW,
1081                         {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1082                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1083                         {.int_min = MMPLAYER_MIN_INT},
1084                         {.int_max = MMPLAYER_MAX_INT},
1085                         NULL,
1086                 },
1087                 {
1088                         MMPLAYER_ATTRS_VIDEO_BUFFER_EXTRA_SIZE,
1089                         (char *)"video_buffer_extra_size",
1090                         MM_ATTRS_TYPE_INT,
1091                         MM_ATTRS_FLAG_RW,
1092                         {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1093                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1094                         {.int_min = MMPLAYER_MIN_INT},
1095                         {.int_max = MMPLAYER_MAX_INT},
1096                         NULL,
1097                 },
1098                 {
1099                         MMPLAYER_ATTRS_PREBUFFER_MS,
1100                         (char *)"prebuffer_ms", /* user setting */
1101                         MM_ATTRS_TYPE_INT,
1102                         MM_ATTRS_FLAG_RW,
1103                         {(void *) MIN_BUFFERING_TIME},
1104                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1105                         {.int_min = MIN_BUFFERING_TIME},
1106                         {.int_max = MMPLAYER_MAX_INT},
1107                         NULL,
1108                 },
1109                 {
1110                         MMPLAYER_ATTRS_REBUFFER_MS,
1111                         (char *)"rebuffer_ms", /* user setting */
1112                         MM_ATTRS_TYPE_INT,
1113                         MM_ATTRS_FLAG_RW,
1114                         {(void *) MIN_BUFFERING_TIME},
1115                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1116                         {.int_min = MIN_BUFFERING_TIME},
1117                         {.int_max = MMPLAYER_MAX_INT},
1118                         NULL,
1119                 },
1120                 {
1121                         MMPLAYER_ATTRS_PITCH_CONTROL,
1122                         (char *)"pitch_control",        /* MM_PLAYER_PITCH_CONTROL */
1123                         MM_ATTRS_TYPE_INT,
1124                         MM_ATTRS_FLAG_RW,
1125                         {(void *)FALSE},
1126                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1127                         {.int_min = FALSE},
1128                         {.int_max = TRUE},
1129                         NULL,
1130                 },
1131                 {
1132                         MMPLAYER_ATTRS_PITCH_VALUE,
1133                         (char *)"pitch_value",          /* MM_PLAYER_PITCH_VALUE */
1134                         MM_ATTRS_TYPE_DOUBLE,
1135                         MM_ATTRS_FLAG_RW,
1136                         {.value_double = 1.0},
1137                         MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1138                         {.double_min = 0.5},
1139                         {.double_max = 2},
1140                         __mmplayer_commit_audio_pitch_value,
1141                 },
1142                 {
1143                         MMPLAYER_ATTRS_AUDIO_OFFLOAD,
1144                         (char *)"audio_offload",        /* MM_PLAYER_AUDIO_OFFLOAD */
1145                         MM_ATTRS_TYPE_INT,
1146                         MM_ATTRS_FLAG_RW,
1147                         {(void *)FALSE},
1148                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1149                         {.int_min = FALSE},
1150                         {.int_max = TRUE},
1151                         NULL,
1152                 },
1153                 {
1154                         MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT,
1155                         (char *)"audio_offload_format", /* MM_PLAYER_AUDIO_OFFLOAD_FORMAT, array of media_format_mimetype_e */
1156                         MM_ATTRS_TYPE_INT,
1157                         MM_ATTRS_FLAG_RW,
1158                         {(void *)NULL},
1159                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1160                         {.int_array = NULL},
1161                         {.count = 0},
1162                         NULL,
1163                 },
1164                 {
1165                         MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT, /* MM_PLAYER_MEDIA_STREAM_INPUT_FORMAT */
1166                         (char *)"media_stream_input_format",
1167                         MM_ATTRS_TYPE_INT,
1168                         MM_ATTRS_FLAG_RW,
1169                         {(void *)NULL},
1170                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1171                         {.int_array = NULL},
1172                         {.count = 0},
1173                         NULL,
1174                 },
1175         };
1176
1177         MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
1178
1179         num_of_attrs = ARRAY_SIZE(player_attrs);
1180
1181         base = g_try_new(MMAttrsConstructInfo, num_of_attrs);
1182         if (!base) {
1183                 LOGE("failed to alloc attrs constructor");
1184                 return NULL;
1185         }
1186
1187         /* initialize values of attributes */
1188         for (idx = 0; idx < num_of_attrs; idx++) {
1189                 base[idx].name = player_attrs[idx].name;
1190                 base[idx].value_type = player_attrs[idx].value_type;
1191                 base[idx].flags = player_attrs[idx].flags;
1192                 base[idx].default_value = player_attrs[idx].default_value.value_void; /* FIXME: need to consider the double data type */
1193         }
1194
1195         result = mm_attrs_new(base, num_of_attrs, "mmplayer_attrs",
1196                                                         _mmplayer_commit_attribute, (void *)handle, &attrs);
1197
1198         /* clean */
1199         MMPLAYER_FREEIF(base);
1200
1201         if (result) {
1202                 LOGE("failed to create player attrs");
1203                 return NULL;
1204         }
1205
1206         /* alloc default attribute info */
1207         player->default_attrs = (mmplayer_attrs_spec_t *)g_try_malloc(sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1208         if (player->default_attrs == NULL) {
1209                 LOGE("failed to alloc default attribute info");
1210                 goto ERROR;
1211         }
1212
1213         memcpy(player->default_attrs, player_attrs, sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1214
1215         __mmplayer_set_ini_to_valid_info(handle);
1216
1217         /* set validity type and range */
1218         for (idx = 0; idx < num_of_attrs; idx++) {
1219                 mm_attrs_set_valid_type(attrs, idx, player->default_attrs[idx].valid_type);
1220                 switch (player->default_attrs[idx].valid_type) {
1221                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1222                         mm_attrs_set_valid_range(attrs, idx,
1223                                         player->default_attrs[idx].validity_value_1.int_min,
1224                                         player->default_attrs[idx].validity_value_2.int_max,
1225                                         player->default_attrs[idx].default_value.value_int);
1226                         break;
1227                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1228                         if (player->default_attrs[idx].validity_value_1.int_array &&
1229                                         player->default_attrs[idx].validity_value_2.count > 0)
1230                                 mm_attrs_set_valid_array(attrs, idx,
1231                                                 (const int *)(player->default_attrs[idx].validity_value_1.int_array),
1232                                                 player->default_attrs[idx].validity_value_2.count,
1233                                                 player->default_attrs[idx].default_value.value_int);
1234                         break;
1235                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1236                         mm_attrs_set_valid_double_range(attrs, idx,
1237                                         player->default_attrs[idx].validity_value_1.double_min,
1238                                         player->default_attrs[idx].validity_value_2.double_max,
1239                                         player->default_attrs[idx].default_value.value_double);
1240                         break;
1241                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1242                         LOGW("FIXME: need to set range value if required.");
1243                 case MM_ATTRS_VALID_TYPE_NONE:
1244                 case MM_ATTRS_VALID_TYPE_INVALID:
1245                 default:
1246                         break;
1247                 }
1248         }
1249
1250         /* commit */
1251         if (mm_attrs_commit_all(attrs)) {
1252                 LOGE("failed to update attributes");
1253                 goto ERROR;
1254         }
1255
1256         __mmplayer_release_ini_info(handle);
1257
1258         return attrs;
1259
1260 ERROR:
1261         MMPLAYER_FREEIF(player->default_attrs);
1262
1263         if (attrs)
1264                 mm_attrs_free(attrs);
1265
1266         return NULL;
1267 }
1268
1269 bool _mmplayer_deconstruct_attribute(MMHandleType handle)
1270 {
1271         mmplayer_t *player = MM_PLAYER_CAST(handle);
1272
1273         MMPLAYER_RETURN_VAL_IF_FAIL(player, false);
1274
1275         if (player->attrs) {
1276                 mm_attrs_free(player->attrs);
1277                 player->attrs = NULL;
1278         }
1279
1280         MMPLAYER_FREEIF(player->default_attrs);
1281
1282         return true;
1283 }