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