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