Change attribute value type of display_overlay
[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
735 /*===========================================================================================
736 |                                                                                                                                                                                                               |
737 |  FUNCTION DEFINITIONS                                                                                                                                                                 |
738 |                                                                                                                                                                                                               |
739 ========================================================================================== */
740
741 static bool __mmplayer_commit_enable_video_decoded_cb(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
742 {
743         mmplayer_t *player = MM_PLAYER_CAST(handle);
744         mmplayer_gst_element_t *videobin = NULL;
745
746         MMPLAYER_FENTER();
747         MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
748
749         if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
750                 LOGD("will be applied when videosink is ready");
751                 return true;
752         }
753
754         if (!player->set_mode.video_export) {
755                 LOGW("there is no callback for enabling");
756                 return true;
757         }
758
759         videobin = player->pipeline->videobin;
760
761         LOGD("[update plugin][videosink] handoff %d", value->value.i_val);
762
763         g_object_set(videobin[MMPLAYER_V_SINK].gst,
764                                 "signal-handoffs", (value->value.i_val) ? TRUE : FALSE, NULL);
765
766         return true;
767 }
768
769 static bool __mmplayer_commit_gapless_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
770 {
771         mmplayer_t *player = MM_PLAYER_CAST(handle);
772         mmplayer_gst_element_t *videobin = NULL;
773
774         MMPLAYER_FENTER();
775         MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
776
777         if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
778                 LOGD("will be applied when videosink is ready");
779                 return true;
780         }
781
782         videobin = player->pipeline->videobin;
783
784         if (value->value.i_val > 0) {
785                 LOGD("[update plugin][videosink] disable last sample for gapless");
786                 g_object_set(videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
787         }
788
789         return true;
790 }
791
792 static bool __mmplayer_commit_audio_pitch_value(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
793 {
794         mmplayer_t *player = MM_PLAYER_CAST(handle);
795         mmplayer_pipeline_info_t *pipeline;
796         int pitch_control = 0;
797
798         MMPLAYER_FENTER();
799         MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
800         MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline && player->pipeline->mainbin, true);
801
802         pipeline = player->pipeline;
803         mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_PITCH_CONTROL, &pitch_control);
804
805         if (!pitch_control || !pipeline->audiobin[MMPLAYER_A_PITCH].gst) {
806                 LOGW("audio pitch is disabled");
807                 return true;
808         }
809
810         LOGD("[update plugin][pitch] value to %1.3f", value->value.d_val);
811         g_object_set(pipeline->audiobin[MMPLAYER_A_PITCH].gst, "pitch", (value->value.d_val), NULL);
812
813         return true;
814 }
815
816 static void __mmplayer_print_attrs(const char *attr_name, const MMAttrsValue * value, const char *prefix)
817 {
818         switch (value->type) {
819         case MM_ATTRS_TYPE_INT:
820                 LOGD("[ %s : %s : %d ]", prefix, attr_name, value->value.i_val);
821                 break;
822         case MM_ATTRS_TYPE_DOUBLE:
823                 LOGD("[ %s : %s : %f ]", prefix, attr_name, value->value.d_val);
824                 break;
825         case MM_ATTRS_TYPE_STRING:
826                 LOGD("[ %s : %s : %s ]", prefix, attr_name, value->value.s_val);
827                 break;
828         case MM_ATTRS_TYPE_DATA:
829                 LOGD("[ %s : %s : %p ]", prefix, attr_name, value->value.p_val);
830                 break;
831         default:
832                 break;
833         }
834
835         return;
836 }
837
838 bool _mmplayer_commit_attribute(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *user_data)
839 {
840         bool ret = false;
841         mmplayer_t *player = MM_PLAYER_CAST(user_data);
842
843         MMPLAYER_RETURN_VAL_IF_FAIL(player && (attr_idx >= 0) && attr_name && value, false);
844
845         if (player_attrs[attr_idx].attr_commit) {
846                 __mmplayer_print_attrs(attr_name, value, "Dynamic");
847                 ret = player_attrs[attr_idx].attr_commit((MMHandleType)user_data, attr_idx, value);
848         } else {
849                 __mmplayer_print_attrs(attr_name, value, "Static");
850                 ret = true;
851         }
852
853         return ret;
854 }
855
856 int _mmplayer_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
857 {
858         int result = MM_ERROR_NONE;
859         MMHandleType attrs = NULL;
860
861         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
862         /* if it's not want to know it. */
863         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
864         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
865
866         attrs = MM_PLAYER_GET_ATTRS(handle);
867
868         result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
869
870         if (result != MM_ERROR_NONE)
871                 LOGE("failed to get %s attribute", attribute_name);
872
873         return result;
874 }
875
876 int __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
877 {
878         mmplayer_t *player = NULL;
879
880         MMPLAYER_FENTER();
881         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
882         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
883
884         player = MM_PLAYER_CAST(handle);
885
886         /* apply display attr value to player handle */
887         if (!g_strrstr(attribute_name, "display"))
888                 return MM_ERROR_NONE;
889
890         if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
891                 LOGD("will be applied when videosink is ready");
892                 return MM_ERROR_NONE;
893         }
894
895         if (_mmplayer_update_video_overlay_param(player, attribute_name) != MM_ERROR_NONE) {
896                 LOGW("not supported video param %s", attribute_name);
897                 return MM_ERROR_NONE;
898         }
899
900         return MM_ERROR_NONE;
901 }
902
903 int _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
904 {
905         int result = MM_ERROR_NONE;
906         MMHandleType attrs = NULL;
907
908         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
909         /* if it's not want to know it. */
910         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
911         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
912
913         attrs = MM_PLAYER_GET_ATTRS(handle);
914
915         /* set attributes and commit them */
916         result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
917         if (result != MM_ERROR_NONE) {
918                 LOGE("failed to set %s attribute", attribute_name);
919                 return result;
920         }
921
922         /* Note: 'attr_commit' function is called before committing the new value to attr struct.
923                  so if there is a value to apply after committing, it should be added below function. */
924         result = __mmplayer_apply_attribute(handle, attribute_name);
925         if (result != MM_ERROR_NONE) {
926                 LOGE("failed to apply attributes");
927                 return result;
928         }
929
930         return MM_ERROR_NONE;
931 }
932
933 int _mmplayer_get_attributes_info(MMHandleType handle,  const char *attribute_name, mmplayer_attrs_info_t *dst_info)
934 {
935         int result = MM_ERROR_NONE;
936         MMHandleType attrs = NULL;
937         MMAttrsInfo src_info = {0, };
938
939         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
940         MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
941         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
942
943         attrs = MM_PLAYER_GET_ATTRS(handle);
944
945         result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
946
947         if (result != MM_ERROR_NONE) {
948                 LOGE("failed to get attribute info");
949                 return result;
950         }
951
952         memset(dst_info, 0x00, sizeof(mmplayer_attrs_info_t));
953
954         dst_info->type = src_info.type;
955         dst_info->flag = src_info.flag;
956         dst_info->validity_type = src_info.validity_type;
957
958         switch (src_info.validity_type) {
959         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
960                 dst_info->int_array.array = src_info.int_array.array;
961                 dst_info->int_array.count = src_info.int_array.count;
962                 dst_info->int_array.d_val = src_info.int_array.dval;
963                 break;
964
965         case MM_ATTRS_VALID_TYPE_INT_RANGE:
966                 dst_info->int_range.min = src_info.int_range.min;
967                 dst_info->int_range.max = src_info.int_range.max;
968                 dst_info->int_range.d_val = src_info.int_range.dval;
969                 break;
970
971         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
972                 dst_info->double_array.array = src_info.double_array.array;
973                 dst_info->double_array.count = src_info.double_array.count;
974                 dst_info->double_array.d_val = src_info.double_array.dval;
975                 break;
976
977         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
978                 dst_info->double_range.min = src_info.double_range.min;
979                 dst_info->double_range.max = src_info.double_range.max;
980                 dst_info->double_range.d_val = src_info.double_range.dval;
981                 break;
982
983         default:
984                 break;
985         }
986
987         return result;
988 }
989
990 MMHandleType _mmplayer_construct_attribute(MMHandleType handle)
991 {
992         int result = MM_ERROR_NONE;
993         int idx = 0;
994         MMHandleType attrs = NULL;
995         int num_of_attrs = 0;
996         MMAttrsConstructInfo *base = NULL;
997
998         MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
999
1000         num_of_attrs = ARRAY_SIZE(player_attrs);
1001
1002         base = g_try_new(MMAttrsConstructInfo, num_of_attrs);
1003         if (!base) {
1004                 LOGE("failed to alloc attrs constructor");
1005                 return NULL;
1006         }
1007
1008         /* initialize values of attributes */
1009         for (idx = 0; idx < num_of_attrs; idx++) {
1010                 base[idx].name = player_attrs[idx].name;
1011                 base[idx].value_type = player_attrs[idx].value_type;
1012                 base[idx].flags = player_attrs[idx].flags;
1013                 base[idx].default_value = player_attrs[idx].default_value.value_void; /* FIXME: need to consider the double data type */
1014         }
1015
1016         result = mm_attrs_new(base, num_of_attrs, "mmplayer_attrs",
1017                                                         _mmplayer_commit_attribute, (void *)handle, &attrs);
1018
1019         /* clean */
1020         MMPLAYER_FREEIF(base);
1021
1022         if (result) {
1023                 LOGE("failed to create player attrs");
1024                 return NULL;
1025         }
1026
1027         /* set validity type and range */
1028         for (idx = 0; idx < num_of_attrs; idx++) {
1029                 mm_attrs_set_valid_type(attrs, idx, player_attrs[idx].valid_type);
1030                 switch (player_attrs[idx].valid_type) {
1031                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1032                         mm_attrs_set_valid_range(attrs, idx,
1033                                         player_attrs[idx].validity_value_1.int_min,
1034                                         player_attrs[idx].validity_value_2.int_max,
1035                                         player_attrs[idx].default_value.value_int);
1036                         break;
1037                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1038                         if (player_attrs[idx].validity_value_1.int_array &&
1039                                         player_attrs[idx].validity_value_2.count > 0)
1040                                 mm_attrs_set_valid_array(attrs, idx,
1041                                                 (const int *)(player_attrs[idx].validity_value_1.int_array),
1042                                                 player_attrs[idx].validity_value_2.count,
1043                                                 player_attrs[idx].default_value.value_int);
1044                         break;
1045                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1046                         mm_attrs_set_valid_double_range(attrs, idx,
1047                                         player_attrs[idx].validity_value_1.double_min,
1048                                         player_attrs[idx].validity_value_2.double_max,
1049                                         player_attrs[idx].default_value.value_double);
1050                         break;
1051                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1052                         LOGW("FIXME: need to set range value if required.");
1053                 case MM_ATTRS_VALID_TYPE_NONE:
1054                 case MM_ATTRS_VALID_TYPE_INVALID:
1055                 default:
1056                         break;
1057                 }
1058         }
1059
1060         /* commit */
1061         if (mm_attrs_commit_all(attrs)) {
1062                 LOGE("failed to update attributes");
1063                 mm_attrs_free(attrs);
1064                 return NULL;
1065         }
1066
1067         return attrs;
1068 }
1069
1070 bool _mmplayer_deconstruct_attribute(MMHandleType handle)
1071 {
1072         mmplayer_t *player = MM_PLAYER_CAST(handle);
1073
1074         MMPLAYER_RETURN_VAL_IF_FAIL(player, false);
1075
1076         if (player->attrs) {
1077                 mm_attrs_free(player->attrs);
1078                 player->attrs = NULL;
1079         }
1080
1081         return true;
1082 }