1528242694e7b021c95147eaebf3fdb603a13008
[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_private.h>
30 #include <mm_attrs.h>
31 #include "mm_player_utils.h"
32 #include "mm_player_priv.h"
33 #include "mm_player_attrs.h"
34
35 /*===========================================================================================
36 |                                                                                                                                                                                       |
37 |  LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE                                                                                        |
38 |                                                                                                                                                                                       |
39 ========================================================================================== */
40
41 /*---------------------------------------------------------------------------
42 |    LOCAL FUNCTION PROTOTYPES:                                                                                         |
43 ---------------------------------------------------------------------------*/
44 int
45 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name);
46
47 /*===========================================================================================
48 |                                                                                                                                                                                                               |
49 |  FUNCTION DEFINITIONS                                                                                                                                                                 |
50 |                                                                                                                                                                                                               |
51 ========================================================================================== */
52
53 int
54 _mmplayer_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
55 {
56         int result = MM_ERROR_NONE;
57         MMHandleType attrs = 0;
58
59         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
60         /* if it's not want to know it. */
61         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
62         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
63
64         attrs = MM_PLAYER_GET_ATTRS(handle);
65
66         result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
67
68         if ( result != MM_ERROR_NONE)
69                 LOGE("failed to get %s attribute\n", attribute_name);
70
71         return result;
72 }
73
74 int
75 _mmplayer_set_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
76 {
77         int result = MM_ERROR_NONE;
78         MMHandleType attrs = 0;
79
80         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
81         /* if it's not want to know it. */
82         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
83         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
84
85         attrs = MM_PLAYER_GET_ATTRS(handle);
86
87         /* set attributes and commit them */
88         result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
89
90         if (result != MM_ERROR_NONE)
91         {
92                 LOGE("failed to set %s attribute\n", attribute_name);
93                 return result;
94         }
95
96         result = __mmplayer_apply_attribute(handle, attribute_name);
97         if (result != MM_ERROR_NONE)
98         {
99                 LOGE("failed to apply attributes\n");
100                 return result;
101         }
102
103         return result;
104 }
105
106 int
107 _mmplayer_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMPlayerAttrsInfo *dst_info)
108 {
109         int result = MM_ERROR_NONE;
110         MMHandleType attrs = 0;
111         MMAttrsInfo src_info = {0, };
112
113         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
114         MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
115         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
116
117         attrs = MM_PLAYER_GET_ATTRS(handle);
118
119         result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
120
121         if ( result != MM_ERROR_NONE)
122         {
123                 LOGE("failed to get attribute info\n");
124                 return result;
125         }
126
127         memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
128
129         dst_info->type = src_info.type;
130         dst_info->flag = src_info.flag;
131         dst_info->validity_type= src_info.validity_type;
132
133         switch(src_info.validity_type)
134         {
135                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
136                         dst_info->int_array.array = src_info.int_array.array;
137                         dst_info->int_array.count = src_info.int_array.count;
138                         dst_info->int_array.d_val = src_info.int_array.dval;
139                 break;
140
141                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
142                         dst_info->int_range.min = src_info.int_range.min;
143                         dst_info->int_range.max = src_info.int_range.max;
144                         dst_info->int_range.d_val = src_info.int_range.dval;
145                 break;
146
147                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
148                         dst_info->double_array.array = src_info.double_array.array;
149                         dst_info->double_array.count = src_info.double_array.count;
150                         dst_info->double_array.d_val = src_info.double_array.dval;
151                 break;
152
153                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
154                         dst_info->double_range.min = src_info.double_range.min;
155                         dst_info->double_range.max = src_info.double_range.max;
156                         dst_info->double_range.d_val = src_info.double_range.dval;
157                 break;
158
159                 default:
160                 break;
161         }
162
163         return result;
164 }
165
166 int
167 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
168 {
169         mm_player_t* player = 0;
170
171         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
172         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
173
174         player = MM_PLAYER_CAST(handle);
175
176         if ( g_strrstr(attribute_name, "display") || g_strrstr(attribute_name, "wl_window_render_x"))
177         {
178                 int pipeline_type = 0;
179                 MMPlayerGstPipelineInfo *pipeline = player->pipeline;
180
181                 /* check videosink element is created */
182                 if(!pipeline)
183                         return MM_ERROR_NONE;
184                 mm_attrs_get_int_by_name(player->attrs, "pipeline_type", &pipeline_type);
185                 if (pipeline_type == MM_PLAYER_PIPELINE_CLIENT) {
186                         if(!pipeline->mainbin || !pipeline->mainbin[MMPLAYER_M_V_SINK].gst)
187                                 return MM_ERROR_NONE;
188                 } else {
189                         if(!pipeline->videobin || !pipeline->videobin[MMPLAYER_V_SINK].gst)
190                                 return MM_ERROR_NONE;
191                 }
192
193                 char *param_name = NULL;
194                 int str_len = strlen(attribute_name);
195                 param_name = g_malloc0(str_len);
196                 if (!param_name) {
197                         LOGE("failed to alloc param_name");
198                         return MM_ERROR_PLAYER_INTERNAL;
199                 }
200                 strncpy(param_name, attribute_name, str_len);
201                 LOGD(" param_name: %s", param_name);
202                 if ( MM_ERROR_NONE != _mmplayer_update_video_param( player, param_name))
203                 {
204                         g_free(param_name);
205                         LOGE("failed to update video param");
206                         return MM_ERROR_PLAYER_INTERNAL;
207                 }
208                 g_free(param_name);
209         }
210
211         return MM_ERROR_NONE;
212 }
213
214 MMHandleType
215 _mmplayer_construct_attribute(MMHandleType handle)
216 {
217         mm_player_t *player = NULL;
218         int idx = 0;
219         MMHandleType attrs = 0;
220         int num_of_attrs = 0;
221         mmf_attrs_construct_info_t *base = NULL;
222
223         MMPLAYER_RETURN_VAL_IF_FAIL (handle, 0);
224
225         player = MM_PLAYER_CAST(handle);
226
227         MMPlayerAttrsSpec player_attrs[] =
228         {
229                 {
230                         "profile_uri",                                  // name
231                         MM_ATTRS_TYPE_STRING,           // type
232                         MM_ATTRS_FLAG_RW,                       // flag
233                         (void *) NULL,                          // default value
234                         MM_ATTRS_VALID_TYPE_NONE,       // validity type
235                         0,                                                      // validity min value
236                         0                                                       // validity max value
237                 },
238                 {
239                         "profile_user_param",
240                         MM_ATTRS_TYPE_DATA,
241                         MM_ATTRS_FLAG_RW,
242                         (void *) NULL,
243                         MM_ATTRS_VALID_TYPE_NONE,
244                         0,
245                         0
246                 },
247                 {
248                         "profile_play_count",
249                         MM_ATTRS_TYPE_INT,
250                         MM_ATTRS_FLAG_RW,
251                         (void *) 1,                     // -1 : repeat continually
252                         MM_ATTRS_VALID_TYPE_INT_RANGE,
253                         -1,
254                         MMPLAYER_MAX_INT
255                 },
256                 {
257                         "profile_prepare_async",
258                         MM_ATTRS_TYPE_INT,
259                         MM_ATTRS_FLAG_RW,
260                         (void *) 0,
261                         MM_ATTRS_VALID_TYPE_INT_RANGE,
262                         0,
263                         1
264                 },
265                 {       /* update registry for downloadable codec */
266                         "profile_update_registry",
267                         MM_ATTRS_TYPE_INT,
268                         MM_ATTRS_FLAG_RW,
269                         (void *) 0,
270                         MM_ATTRS_VALID_TYPE_INT_RANGE,
271                         0,
272                         1
273                 },
274                 {
275                         "streaming_type",
276                         MM_ATTRS_TYPE_INT,
277                         MM_ATTRS_FLAG_RW,
278                         (void *) STREAMING_SERVICE_NONE,
279                         MM_ATTRS_VALID_TYPE_INT_RANGE,
280                         STREAMING_SERVICE_VOD,
281                         STREAMING_SERVICE_NUM
282                 },
283                 {
284                         "streaming_udp_timeout",
285                         MM_ATTRS_TYPE_INT,
286                         MM_ATTRS_FLAG_RW,
287                         (void *) 10000,
288                         MM_ATTRS_VALID_TYPE_INT_RANGE,
289                         0,
290                         MMPLAYER_MAX_INT
291                 },
292                 {
293                         "streaming_user_agent",
294                         MM_ATTRS_TYPE_STRING,
295                         MM_ATTRS_FLAG_RW,
296                         (void *) NULL,
297                         MM_ATTRS_VALID_TYPE_NONE,
298                         0,
299                         0
300                 },
301                 {
302                         "streaming_wap_profile",
303                         MM_ATTRS_TYPE_STRING,
304                         MM_ATTRS_FLAG_RW,
305                         (void *) NULL,
306                         MM_ATTRS_VALID_TYPE_NONE,
307                         0,
308                         0
309                 },
310                 {
311                         "streaming_network_bandwidth",
312                         MM_ATTRS_TYPE_INT,
313                         MM_ATTRS_FLAG_RW,
314                         (void *) 128000,
315                         MM_ATTRS_VALID_TYPE_INT_RANGE,
316                         0,
317                         MMPLAYER_MAX_INT
318                 },
319                 {
320                         "streaming_cookie",
321                         MM_ATTRS_TYPE_STRING,
322                         MM_ATTRS_FLAG_RW,
323                         (void *) NULL,
324                         MM_ATTRS_VALID_TYPE_NONE,
325                         0,
326                         0
327                 },
328                 {
329                         "streaming_proxy",
330                         MM_ATTRS_TYPE_STRING,
331                         MM_ATTRS_FLAG_RW,
332                         (void *) NULL,
333                         MM_ATTRS_VALID_TYPE_NONE,
334                         0,
335                         0
336                 },
337                 {
338                         "streaming_timeout",
339                         MM_ATTRS_TYPE_INT,
340                         MM_ATTRS_FLAG_RW,
341                         (void *) -1,    // DEFAULT_HTTP_TIMEOUT
342                         MM_ATTRS_VALID_TYPE_INT_RANGE,
343                         -1,
344                         MMPLAYER_MAX_INT
345                 },
346                 {
347                         "subtitle_uri",
348                         MM_ATTRS_TYPE_STRING,
349                         MM_ATTRS_FLAG_RW,
350                         (void *) NULL,
351                         MM_ATTRS_VALID_TYPE_NONE,
352                         0,
353                         0
354                 },
355                 {
356                         "content_duration",
357                         MM_ATTRS_TYPE_INT,
358                         MM_ATTRS_FLAG_RW,
359                         (void *) 0,
360                         MM_ATTRS_VALID_TYPE_INT_RANGE,
361                         0,
362                         MMPLAYER_MAX_INT
363                 },
364                 {
365                         "content_bitrate",
366                         MM_ATTRS_TYPE_INT,
367                         MM_ATTRS_FLAG_RW,
368                         (void *) 0,
369                         MM_ATTRS_VALID_TYPE_INT_RANGE,
370                         0,
371                         MMPLAYER_MAX_INT
372                 },
373                 {
374                         "content_max_bitrate",
375                         MM_ATTRS_TYPE_INT,
376                         MM_ATTRS_FLAG_RW,
377                         (void *) 0,
378                         MM_ATTRS_VALID_TYPE_INT_RANGE,
379                         0,
380                         MMPLAYER_MAX_INT
381                 },
382                 {
383                         "content_video_found",
384                         MM_ATTRS_TYPE_INT,
385                         MM_ATTRS_FLAG_RW,
386                         (void *) 0,
387                         MM_ATTRS_VALID_TYPE_INT_RANGE,
388                         0,
389                         1
390                 },
391                 {
392                         "content_video_codec",
393                         MM_ATTRS_TYPE_STRING,
394                         MM_ATTRS_FLAG_RW,
395                         (void *) NULL,
396                         MM_ATTRS_VALID_TYPE_NONE,
397                         0,
398                         0
399                 },
400                 {
401                         "content_video_bitrate",
402                         MM_ATTRS_TYPE_INT,
403                         MM_ATTRS_FLAG_RW,
404                         (void *) 0,
405                         MM_ATTRS_VALID_TYPE_INT_RANGE,
406                         0,
407                         MMPLAYER_MAX_INT
408                 },
409                 {
410                         "content_video_fps",
411                         MM_ATTRS_TYPE_INT,
412                         MM_ATTRS_FLAG_RW,
413                         (void *) 0,
414                         MM_ATTRS_VALID_TYPE_INT_RANGE,
415                         0,
416                         MMPLAYER_MAX_INT
417                 },
418                 {
419                         "content_video_width",
420                         MM_ATTRS_TYPE_INT,
421                         MM_ATTRS_FLAG_RW,
422                         (void *) 0,
423                         MM_ATTRS_VALID_TYPE_INT_RANGE,
424                         0,
425                         MMPLAYER_MAX_INT
426                 },
427                 {
428                         "content_video_height",
429                         MM_ATTRS_TYPE_INT,
430                         MM_ATTRS_FLAG_RW,
431                         (void *) 0,
432                         MM_ATTRS_VALID_TYPE_INT_RANGE,
433                         0,
434                         MMPLAYER_MAX_INT
435                 },
436                 {
437                         "content_video_track_num",
438                         MM_ATTRS_TYPE_INT,
439                         MM_ATTRS_FLAG_RW,
440                         (void *) 0,
441                         MM_ATTRS_VALID_TYPE_INT_RANGE,
442                         0,
443                         MMPLAYER_MAX_INT
444                 },
445                 {
446                         "content_audio_found",
447                         MM_ATTRS_TYPE_INT,
448                         MM_ATTRS_FLAG_RW,
449                         (void *) 0,
450                         MM_ATTRS_VALID_TYPE_INT_RANGE,
451                         0,
452                         1
453                 },
454                 {
455                         "content_audio_codec",
456                         MM_ATTRS_TYPE_STRING,
457                         MM_ATTRS_FLAG_RW,
458                         (void *) NULL,
459                         MM_ATTRS_VALID_TYPE_NONE,
460                         0,
461                         0
462                 },
463                 {
464                         "content_audio_bitrate",
465                         MM_ATTRS_TYPE_INT,
466                         MM_ATTRS_FLAG_RW,
467                         (void *) 0,
468                         MM_ATTRS_VALID_TYPE_INT_RANGE,
469                         0,
470                         MMPLAYER_MAX_INT
471                 },
472                 {
473                         "content_audio_channels",
474                         MM_ATTRS_TYPE_INT,
475                         MM_ATTRS_FLAG_RW,
476                         (void *) 0,
477                         MM_ATTRS_VALID_TYPE_INT_RANGE,
478                         0,
479                         MMPLAYER_MAX_INT
480                 },
481                 {
482                         "content_audio_samplerate",
483                         MM_ATTRS_TYPE_INT,
484                         MM_ATTRS_FLAG_RW,
485                         (void *) 0,
486                         MM_ATTRS_VALID_TYPE_INT_RANGE,
487                         0,
488                         MMPLAYER_MAX_INT
489                 },
490                 {
491                         "content_audio_track_num",
492                         MM_ATTRS_TYPE_INT,
493                         MM_ATTRS_FLAG_RW,
494                         (void *) 0,
495                         MM_ATTRS_VALID_TYPE_INT_RANGE,
496                         0,
497                         MMPLAYER_MAX_INT
498                 },
499                 {
500                         "content_audio_format",
501                         MM_ATTRS_TYPE_INT,
502                         MM_ATTRS_FLAG_RW,
503                         (void *) 0,
504                         MM_ATTRS_VALID_TYPE_INT_RANGE,
505                         0,
506                         MMPLAYER_MAX_INT
507                 },
508                 {
509                         "content_text_track_num",
510                         MM_ATTRS_TYPE_INT,
511                         MM_ATTRS_FLAG_RW,
512                         (void *) 0,
513                         MM_ATTRS_VALID_TYPE_INT_RANGE,
514                         0,
515                         MMPLAYER_MAX_INT
516                 },
517                 {
518                         "tag_artist",
519                         MM_ATTRS_TYPE_STRING,
520                         MM_ATTRS_FLAG_RW,
521                         (void *) NULL,
522                         MM_ATTRS_VALID_TYPE_NONE,
523                         0,
524                         0
525                 },
526                 {
527                         "tag_title",
528                         MM_ATTRS_TYPE_STRING,
529                         MM_ATTRS_FLAG_RW,
530                         (void *) NULL,
531                         MM_ATTRS_VALID_TYPE_NONE,
532                         0,
533                         0
534                 },
535                 {
536                         "tag_album",
537                         MM_ATTRS_TYPE_STRING,
538                         MM_ATTRS_FLAG_RW,
539                         (void *) NULL
540                 },
541                 {
542                         "tag_genre",
543                         MM_ATTRS_TYPE_STRING,
544                         MM_ATTRS_FLAG_RW,
545                         (void *) NULL,
546                         MM_ATTRS_VALID_TYPE_NONE,
547                         0,
548                         0
549                 },
550                 {
551                         "tag_author",
552                         MM_ATTRS_TYPE_STRING,
553                         MM_ATTRS_FLAG_RW,
554                         (void *) NULL,
555                         MM_ATTRS_VALID_TYPE_NONE,
556                         0,
557                         0
558                 },
559                 {
560                         "tag_copyright",
561                         MM_ATTRS_TYPE_STRING,
562                         MM_ATTRS_FLAG_RW,
563                         (void *) NULL,
564                         MM_ATTRS_VALID_TYPE_NONE,
565                         0,
566                         0
567                 },
568                 {
569                         "tag_date",
570                         MM_ATTRS_TYPE_STRING,
571                         MM_ATTRS_FLAG_RW,
572                         (void *) NULL,
573                         MM_ATTRS_VALID_TYPE_NONE,
574                         0,
575                         0
576                 },
577                 {
578                         "tag_description",
579                         MM_ATTRS_TYPE_STRING,
580                         MM_ATTRS_FLAG_RW,
581                         (void *) NULL,
582                         MM_ATTRS_VALID_TYPE_NONE,
583                         0,
584                         0
585                 },
586                 {
587                         "tag_track_num",
588                         MM_ATTRS_TYPE_INT,
589                         MM_ATTRS_FLAG_RW,
590                         (void *) 0,
591                         MM_ATTRS_VALID_TYPE_INT_RANGE,
592                         0,
593                         MMPLAYER_MAX_INT
594                 },
595                 {
596                         "tag_album_cover",
597                         MM_ATTRS_TYPE_DATA,
598                         MM_ATTRS_FLAG_RW,
599                         (void *) NULL,
600                         MM_ATTRS_VALID_TYPE_NONE,
601                         0,
602                         0
603                 },
604                 {
605                         "display_src_crop_x",
606                         MM_ATTRS_TYPE_INT,
607                         MM_ATTRS_FLAG_RW,
608                         (void *) 0,
609                         MM_ATTRS_VALID_TYPE_INT_RANGE,
610                         0,
611                         MMPLAYER_MAX_INT
612                 },
613                 {
614                         "display_src_crop_y",
615                         MM_ATTRS_TYPE_INT,
616                         MM_ATTRS_FLAG_RW,
617                         (void *) 0,
618                         MM_ATTRS_VALID_TYPE_INT_RANGE,
619                         0,
620                         MMPLAYER_MAX_INT
621                 },
622                 {
623                         "display_src_crop_width",
624                         MM_ATTRS_TYPE_INT,
625                         MM_ATTRS_FLAG_RW,
626                         (void *) 0,
627                         MM_ATTRS_VALID_TYPE_INT_RANGE,
628                         0,
629                         MMPLAYER_MAX_INT
630                 },
631                 {
632                         "display_src_crop_height",
633                         MM_ATTRS_TYPE_INT,
634                         MM_ATTRS_FLAG_RW,
635                         (void *) 0,
636                         MM_ATTRS_VALID_TYPE_INT_RANGE,
637                         0,
638                         MMPLAYER_MAX_INT
639                 },
640                 {
641                         "display_roi_x",
642                         MM_ATTRS_TYPE_INT,
643                         MM_ATTRS_FLAG_RW,
644                         (void *) 0,
645                         MM_ATTRS_VALID_TYPE_INT_RANGE,
646                         0,
647                         MMPLAYER_MAX_INT
648                 },
649                 {
650                         "display_roi_y",
651                         MM_ATTRS_TYPE_INT,
652                         MM_ATTRS_FLAG_RW,
653                         (void *) 0,
654                         MM_ATTRS_VALID_TYPE_INT_RANGE,
655                         0,
656                         MMPLAYER_MAX_INT
657                 },
658                 {
659                         "display_roi_width",
660                         MM_ATTRS_TYPE_INT,
661                         MM_ATTRS_FLAG_RW,
662                         (void *) 480,
663                         MM_ATTRS_VALID_TYPE_INT_RANGE,
664                         0,
665                         MMPLAYER_MAX_INT
666                 },
667                 {
668                         "display_roi_height",
669                         MM_ATTRS_TYPE_INT,
670                         MM_ATTRS_FLAG_RW,
671                         (void *) 800,
672                         MM_ATTRS_VALID_TYPE_INT_RANGE,
673                         0,
674                         MMPLAYER_MAX_INT
675                 },
676                 {
677                         "display_roi_mode",
678                         MM_ATTRS_TYPE_INT,
679                         MM_ATTRS_FLAG_RW,
680                         (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
681                         MM_ATTRS_VALID_TYPE_INT_RANGE,
682                         MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
683                         MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX
684                 },
685                 {
686                         "display_rotation",
687                         MM_ATTRS_TYPE_INT,
688                         MM_ATTRS_FLAG_RW,
689                         (void *) MM_DISPLAY_ROTATION_NONE,
690                         MM_ATTRS_VALID_TYPE_INT_RANGE,
691                         MM_DISPLAY_ROTATION_NONE,
692                         MM_DISPLAY_ROTATION_270
693                 },
694                 {
695                         "display_visible",
696                         MM_ATTRS_TYPE_INT,
697                         MM_ATTRS_FLAG_RW,
698                         (void *) FALSE,
699                         MM_ATTRS_VALID_TYPE_INT_RANGE,
700                         0,
701                         1
702                 },
703                 {
704                         "display_method",
705                         MM_ATTRS_TYPE_INT,
706                         MM_ATTRS_FLAG_RW,
707                         (void *) MM_DISPLAY_METHOD_LETTER_BOX,
708                         MM_ATTRS_VALID_TYPE_INT_RANGE,
709                         MM_DISPLAY_METHOD_LETTER_BOX,
710                         MM_DISPLAY_METHOD_CUSTOM_ROI
711                 },
712                 {
713                         "display_overlay",
714                         MM_ATTRS_TYPE_DATA,
715                         MM_ATTRS_FLAG_RW,
716                         (void *) NULL,
717                         MM_ATTRS_VALID_TYPE_NONE,
718                         0,
719                         0
720                 },
721                 {
722                         "wl_display",
723                         MM_ATTRS_TYPE_DATA,
724                         MM_ATTRS_FLAG_RW,
725                         (void *) NULL,
726                         MM_ATTRS_VALID_TYPE_NONE,
727                         0,
728                         0
729                 },
730                 {
731                         "wl_window_render_x",
732                         MM_ATTRS_TYPE_INT,
733                         MM_ATTRS_FLAG_RW,
734                         (void *) 0,
735                         MM_ATTRS_VALID_TYPE_INT_RANGE,
736                         0,
737                         MMPLAYER_MAX_INT
738                 },
739                 {
740                         "wl_window_render_y",
741                         MM_ATTRS_TYPE_INT,
742                         MM_ATTRS_FLAG_RW,
743                         (void *) 0,
744                         MM_ATTRS_VALID_TYPE_INT_RANGE,
745                         0,
746                         MMPLAYER_MAX_INT
747                 },
748                 {
749                         "wl_window_render_width",
750                         MM_ATTRS_TYPE_INT,
751                         MM_ATTRS_FLAG_RW,
752                         (void *) 0,
753                         MM_ATTRS_VALID_TYPE_INT_RANGE,
754                         0,
755                         MMPLAYER_MAX_INT
756                 },
757                 {
758                         "wl_window_render_height",
759                         MM_ATTRS_TYPE_INT,
760                         MM_ATTRS_FLAG_RW,
761                         (void *) 0,
762                         MM_ATTRS_VALID_TYPE_INT_RANGE,
763                         0,
764                         MMPLAYER_MAX_INT
765                 },
766                 {
767                         "use_wl_surface",
768                         MM_ATTRS_TYPE_INT,
769                         MM_ATTRS_FLAG_RW,
770                         (void *) FALSE,
771                         MM_ATTRS_VALID_TYPE_INT_RANGE,
772                         FALSE,
773                         TRUE
774                 },
775                 {
776                         "display_overlay_user_data",
777                         MM_ATTRS_TYPE_DATA,
778                         MM_ATTRS_FLAG_RW,
779                         (void *) NULL,
780                         MM_ATTRS_VALID_TYPE_NONE,
781                         0,
782                         0
783                 },
784                 {
785                         "display_surface_type",
786                         MM_ATTRS_TYPE_INT,
787                         MM_ATTRS_FLAG_RW,
788                         (void *) MM_DISPLAY_SURFACE_NULL,
789                         MM_ATTRS_VALID_TYPE_INT_RANGE,
790                         MM_DISPLAY_SURFACE_OVERLAY,
791                         MM_DISPLAY_SURFACE_NUM - 1
792                 },
793                 {
794                         "display_evas_surface_sink",
795                         MM_ATTRS_TYPE_STRING,
796                         MM_ATTRS_FLAG_READABLE,
797                         (void *) player->ini.videosink_element_evas,
798                         MM_ATTRS_VALID_TYPE_NONE,
799                         0,
800                         0
801                 },
802                 {
803                         "display_force_aspect_ration",
804                         MM_ATTRS_TYPE_INT,
805                         MM_ATTRS_FLAG_RW,
806                         (void *) 1,
807                         MM_ATTRS_VALID_TYPE_INT_RANGE,
808                         0,
809                         MMPLAYER_MAX_INT
810                 },
811                 {
812                         "display_width",                // dest width of fimcconvert ouput
813                         MM_ATTRS_TYPE_INT,
814                         MM_ATTRS_FLAG_RW,
815                         (void *) 0,
816                         MM_ATTRS_VALID_TYPE_INT_RANGE,
817                         0,
818                         MMPLAYER_MAX_INT
819                 },
820                 {
821                         "display_height",               // dest height of fimcconvert ouput
822                         MM_ATTRS_TYPE_INT,
823                         MM_ATTRS_FLAG_RW,
824                         (void *) 0,
825                         MM_ATTRS_VALID_TYPE_INT_RANGE,
826                         0,
827                         MMPLAYER_MAX_INT
828                 },
829                 {
830                         "display_evas_do_scaling",
831                         MM_ATTRS_TYPE_INT,
832                         MM_ATTRS_FLAG_RW,
833                         (void *) TRUE,
834                         MM_ATTRS_VALID_TYPE_INT_RANGE,
835                         FALSE,
836                         TRUE
837                 },
838                 {
839                         "sound_fadeup",
840                         MM_ATTRS_TYPE_INT,
841                         MM_ATTRS_FLAG_RW,
842                         (void *) FALSE,
843                         MM_ATTRS_VALID_TYPE_INT_RANGE,
844                         FALSE,
845                         TRUE
846                 },
847                 {
848                         "sound_fadedown",
849                         MM_ATTRS_TYPE_INT,
850                         MM_ATTRS_FLAG_RW,
851                         (void *) FALSE,
852                         MM_ATTRS_VALID_TYPE_INT_RANGE,
853                         FALSE,
854                         TRUE
855                 },
856                 {
857                         "sound_volume_type",
858                         MM_ATTRS_TYPE_INT,
859                         MM_ATTRS_FLAG_RW,
860                         (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
861                         MM_ATTRS_VALID_TYPE_INT_RANGE,
862                         0,
863                         MMPLAYER_MAX_INT
864                 },
865                 {
866                         "sound_stream_type",
867                         MM_ATTRS_TYPE_STRING,
868                         MM_ATTRS_FLAG_RW,
869                         (void *) NULL,
870                         MM_ATTRS_VALID_TYPE_NONE,
871                         0,
872                         0
873                 },
874                 {
875                         "sound_stream_index",
876                         MM_ATTRS_TYPE_INT,
877                         MM_ATTRS_FLAG_RW,
878                         0,
879                         MM_ATTRS_VALID_TYPE_INT_RANGE,
880                         -1,
881                         MMPLAYER_MAX_INT
882                 },
883                 {
884                         "sound_route",
885                         MM_ATTRS_TYPE_INT,
886                         MM_ATTRS_FLAG_RW,
887                         (void *) MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
888                         MM_ATTRS_VALID_TYPE_INT_RANGE,
889                         MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
890                         MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY
891                 },
892                 {
893                         "sound_stop_when_unplugged",
894                         MM_ATTRS_TYPE_INT,
895                         MM_ATTRS_FLAG_RW,
896                         (void *) TRUE,
897                         MM_ATTRS_VALID_TYPE_INT_RANGE,
898                         FALSE,
899                         TRUE
900                 },
901                 {
902                         "sound_application_pid",
903                         MM_ATTRS_TYPE_INT,
904                         MM_ATTRS_FLAG_RW,
905                         (void *) 0,
906                         MM_ATTRS_VALID_TYPE_INT_RANGE,
907                         0,
908                         MMPLAYER_MAX_INT
909                 },
910                 {
911                         "sound_spk_out_only",
912                         MM_ATTRS_TYPE_INT,
913                         MM_ATTRS_FLAG_RW,
914                         (void *) FALSE,
915                         MM_ATTRS_VALID_TYPE_INT_RANGE,
916                         FALSE,
917                         TRUE
918                 },
919                 {
920                         "sound_priority",
921                         MM_ATTRS_TYPE_INT,
922                         MM_ATTRS_FLAG_RW,
923                         (void *) 0,                     // 0: normal, 1: high 2: high with sound transition 3: mix with others regardless of priority
924                         MM_ATTRS_VALID_TYPE_INT_RANGE,
925                         0,
926                         3
927                 },
928                 {
929                         "sound_close_resource",
930                         MM_ATTRS_TYPE_INT,
931                         MM_ATTRS_FLAG_RW,
932                         (void *) 0,
933                         MM_ATTRS_VALID_TYPE_INT_RANGE,
934                         0,
935                         1
936                 },
937                 {
938                         "sound_latency_mode",
939                         MM_ATTRS_TYPE_INT,
940                         MM_ATTRS_FLAG_RW,
941                         (void *) 1,                     // 0: low latency, 1: middle latency 2: high latency
942                         MM_ATTRS_VALID_TYPE_INT_RANGE,
943                         0,
944                         2
945                 },
946                 {
947                         "pcm_extraction",               // enable pcm extraction
948                         MM_ATTRS_TYPE_INT,
949                         MM_ATTRS_FLAG_RW,
950                         (void *) FALSE,
951                         MM_ATTRS_VALID_TYPE_INT_RANGE,
952                         FALSE,
953                         TRUE
954                 },
955                 {
956                         "pcm_extraction_samplerate",    // set samplerate for pcm extraction
957                         MM_ATTRS_TYPE_INT,
958                         MM_ATTRS_FLAG_RW,
959                         (void *) 44100,                         // hz
960                         MM_ATTRS_VALID_TYPE_INT_RANGE,
961                         0,
962                         MMPLAYER_MAX_INT
963                 },
964                 {
965                         "pcm_extraction_depth", // set depth for pcm extraction
966                         MM_ATTRS_TYPE_INT,
967                         MM_ATTRS_FLAG_RW,
968                         (void *) 16,                    // bits
969                         MM_ATTRS_VALID_TYPE_INT_RANGE,
970                         0,
971                         MMPLAYER_MAX_INT
972                 },
973                 {
974                         "pcm_extraction_channels",      // set channels for pcm extraction
975                         MM_ATTRS_TYPE_INT,
976                         MM_ATTRS_FLAG_RW,
977                         (void *) 1,
978                         MM_ATTRS_VALID_TYPE_INT_RANGE,
979                         0,
980                         MMPLAYER_MAX_INT
981                 },
982                 {
983                         "pcm_extraction_start_msec",    // set start position to extract pcm
984                         MM_ATTRS_TYPE_INT,
985                         MM_ATTRS_FLAG_RW,
986                         (void *) 0,
987                         MM_ATTRS_VALID_TYPE_INT_RANGE,
988                         0,
989                         MMPLAYER_MAX_INT
990                 },
991                 {
992                         "pcm_extraction_end_msec",      // set end position to extract pcm
993                         MM_ATTRS_TYPE_INT,
994                         MM_ATTRS_FLAG_RW,
995                         (void *) 0,
996                         MM_ATTRS_VALID_TYPE_INT_RANGE,
997                         0,
998                         MMPLAYER_MAX_INT
999                 },
1000                 {
1001                         "profile_smooth_repeat",
1002                         MM_ATTRS_TYPE_INT,
1003                         MM_ATTRS_FLAG_RW,
1004                         (void *) FALSE,
1005                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1006                         0,
1007                         MMPLAYER_MAX_INT
1008                 },
1009                 {
1010                         "profile_progress_interval",    // will be deprecated
1011                         MM_ATTRS_TYPE_INT,
1012                         MM_ATTRS_FLAG_RW,
1013                         (void *) 500,
1014                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1015                         0,
1016                         MMPLAYER_MAX_INT
1017                 },
1018                 {
1019                         "display_x",
1020                         MM_ATTRS_TYPE_INT,
1021                         MM_ATTRS_FLAG_RW,
1022                         (void *) 0,
1023                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1024                         0,
1025                         MMPLAYER_MAX_INT
1026                 },
1027                 {
1028                         "display_y",
1029                         MM_ATTRS_TYPE_INT,
1030                         MM_ATTRS_FLAG_RW,
1031                         (void *) 0,
1032                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1033                         0,
1034                         MMPLAYER_MAX_INT
1035                 },
1036                 {
1037                         "pd_mode",
1038                         MM_ATTRS_TYPE_INT,
1039                         MM_ATTRS_FLAG_RW,
1040                         (void *) MM_PLAYER_PD_MODE_NONE,
1041                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1042                         MM_PLAYER_PD_MODE_NONE,
1043                         MM_PLAYER_PD_MODE_URI           // not tested yet, because of no fixed scenario
1044                 },
1045                 {
1046                         "pd_location",                  // location of the file to write
1047                         MM_ATTRS_TYPE_STRING,
1048                         MM_ATTRS_FLAG_RW,
1049                         (void *) NULL,
1050                         MM_ATTRS_VALID_TYPE_NONE,
1051                         0,
1052                         0
1053                 },
1054                 {
1055                         "accurate_seek",
1056                         MM_ATTRS_TYPE_INT,
1057                         MM_ATTRS_FLAG_RW,
1058                         (void *) 0,
1059                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1060                         0,
1061                         1
1062                 },
1063                 {
1064                         "content_video_orientation",    // orientation of video content
1065                         MM_ATTRS_TYPE_STRING,
1066                         MM_ATTRS_FLAG_RW,
1067                         (void *) NULL,
1068                         MM_ATTRS_VALID_TYPE_NONE,
1069                         0,
1070                         0
1071                 },
1072                 {
1073                         "pcm_audioformat",
1074                         MM_ATTRS_TYPE_STRING,
1075                         MM_ATTRS_FLAG_RW,
1076                         (void *) NULL,
1077                         MM_ATTRS_VALID_TYPE_NONE,
1078                         0,
1079                         0
1080                 },
1081                 {
1082                         "display_surface_client_type",
1083                         MM_ATTRS_TYPE_INT,
1084                         MM_ATTRS_FLAG_RW,
1085                         (void *) MM_DISPLAY_SURFACE_NULL,
1086                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1087                         MM_DISPLAY_SURFACE_OVERLAY,
1088                         MM_DISPLAY_SURFACE_NUM - 1
1089                 },
1090                 {
1091                         "pipeline_type",
1092                         MM_ATTRS_TYPE_INT,
1093                         MM_ATTRS_FLAG_RW,
1094                         (void *) MM_PLAYER_PIPELINE_LEGACY,
1095                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1096                         MM_PLAYER_PIPELINE_LEGACY,
1097                         MM_PLAYER_PIPELINE_MAX - 1
1098                 },
1099                 {
1100                         "drc_mode",
1101                         MM_ATTRS_TYPE_INT,
1102                         MM_ATTRS_FLAG_RW,
1103                         (void *) FALSE,
1104                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1105                         FALSE,
1106                         TRUE
1107                 },
1108                 {
1109                         "gapless_mode",
1110                         MM_ATTRS_TYPE_INT,
1111                         MM_ATTRS_FLAG_RW,
1112                         (void *) FALSE,
1113                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1114                         FALSE,
1115                         TRUE
1116                 }
1117         };
1118
1119         num_of_attrs = ARRAY_SIZE(player_attrs);
1120
1121         base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
1122
1123         if ( !base )
1124         {
1125                 LOGE("failed to alloc attrs constructor");
1126                 return 0;
1127         }
1128
1129         /* initialize values of attributes */
1130         for ( idx = 0; idx < num_of_attrs; idx++ )
1131         {
1132                 base[idx].name = player_attrs[idx].name;
1133                 base[idx].value_type = player_attrs[idx].value_type;
1134                 base[idx].flags = player_attrs[idx].flags;
1135                 base[idx].default_value = player_attrs[idx].default_value;
1136         }
1137
1138         attrs = mmf_attrs_new_from_data(
1139                                         "mmplayer_attrs",
1140                                         base,
1141                                         num_of_attrs,
1142                                         NULL,
1143                                         NULL);
1144
1145         /* clean */
1146         MMPLAYER_FREEIF(base);
1147
1148         if ( !attrs )
1149         {
1150                 LOGE("failed to create player attrs");
1151                 return 0;
1152         }
1153
1154         /* set validity type and range */
1155         for ( idx = 0; idx < num_of_attrs; idx++ )
1156         {
1157                 switch ( player_attrs[idx].valid_type)
1158                 {
1159                         case MM_ATTRS_VALID_TYPE_INT_RANGE:
1160                         {
1161                                 mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
1162                                 mmf_attrs_set_valid_range (attrs, idx,
1163                                                 player_attrs[idx].value_min,
1164                                                 player_attrs[idx].value_max,
1165                                                 (int)(intptr_t)(player_attrs[idx].default_value));
1166                         }
1167                         break;
1168
1169                         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1170                         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1171                         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1172                         default:
1173                         break;
1174                 }
1175         }
1176
1177         /* commit */
1178         mmf_attrs_commit(attrs);
1179
1180         return attrs;
1181 }
1182
1183 bool
1184 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1185 {
1186         mm_player_t *player = MM_PLAYER_CAST(handle);
1187
1188         MMPLAYER_RETURN_VAL_IF_FAIL ( player, FALSE );
1189
1190         if (player->attrs)
1191         {
1192                 mmf_attrs_free (player->attrs);
1193                 player->attrs = 0;
1194         }
1195
1196         return TRUE;
1197 }