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