Add interface for audio latency mode setting, fixed TDIS-1656
[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>, YoungHwan An <younghwan_.an@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 /*===========================================================================================
23 |                                                                                                                                                                                       |
24 |  INCLUDE FILES                                                                                                                                                        |
25 |                                                                                                                                                                                       |
26 ========================================================================================== */
27 #include <vconf.h>
28 #include <mm_attrs_private.h>
29 #include <mm_attrs.h>
30 #include <gst/interfaces/xoverlay.h>
31
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 typedef struct{
42         char *name;
43         int value_type;
44         int flags;                              // r, w
45         void *default_value;
46         int valid_type;                 // validity type
47         int value_min;                  //<- set validity value range
48         int value_max;          //->
49 }MMPlayerAttrsSpec;
50
51 /*---------------------------------------------------------------------------
52 |    LOCAL FUNCTION PROTOTYPES:                                                                                         |
53 ---------------------------------------------------------------------------*/
54 int
55 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name);
56
57 /*===========================================================================================
58 |                                                                                                                                                                                                               |
59 |  FUNCTION DEFINITIONS                                                                                                                                                                 |
60 |                                                                                                                                                                                                               |
61 ========================================================================================== */
62
63 int
64 _mmplayer_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
65 {
66         int result = MM_ERROR_NONE;
67         MMHandleType attrs = 0;
68
69         debug_fenter();
70
71         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
72         /* if it's not want to know it. */
73         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
74         return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
75
76         attrs = MM_PLAYER_GET_ATTRS(handle);
77
78         result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
79
80         if ( result != MM_ERROR_NONE)
81                 debug_error("failed to get %s attribute\n", attribute_name);
82
83         debug_fleave();
84
85         return result;
86 }
87
88 int
89 _mmplayer_set_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
90 {
91         int result = MM_ERROR_NONE;
92         MMHandleType attrs = 0;
93
94         debug_fenter();
95
96         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
97         /* if it's not want to know it. */
98         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
99         return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
100
101         attrs = MM_PLAYER_GET_ATTRS(handle);
102
103         /* set attributes and commit them */
104         result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
105
106         if (result != MM_ERROR_NONE)
107         {
108                 debug_error("failed to set %s attribute\n", attribute_name);
109                 return result;
110         }
111
112         result = __mmplayer_apply_attribute(handle, attribute_name);
113         if (result != MM_ERROR_NONE)
114         {
115                 debug_error("failed to apply attributes\n");
116                 return result;
117         }
118
119         debug_fleave();
120
121         return result;
122 }
123
124 int
125 _mmplayer_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMPlayerAttrsInfo *dst_info)
126 {
127         int result = MM_ERROR_NONE;
128         MMHandleType attrs = 0;
129         MMAttrsInfo src_info = {0, };
130
131         debug_fenter();
132
133         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
134         return_val_if_fail(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
135         return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
136
137         attrs = MM_PLAYER_GET_ATTRS(handle);
138
139         result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
140
141         if ( result != MM_ERROR_NONE)
142         {
143                 debug_error("failed to get attribute info\n");
144                 return result;
145         }
146
147         memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
148
149         dst_info->type = src_info.type;
150         dst_info->flag = src_info.flag;
151         dst_info->validity_type= src_info.validity_type;
152
153         switch(src_info.validity_type)
154         {
155                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
156                         dst_info->int_array.array = src_info.int_array.array;
157                         dst_info->int_array.count = src_info.int_array.count;
158                         dst_info->int_array.d_val = src_info.int_array.dval;
159                 break;
160
161                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
162                         dst_info->int_range.min = src_info.int_range.min;
163                         dst_info->int_range.max = src_info.int_range.max;
164                         dst_info->int_range.d_val = src_info.int_range.dval;
165                 break;
166
167                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
168                         dst_info->double_array.array = src_info.double_array.array;
169                         dst_info->double_array.count = src_info.double_array.count;
170                         dst_info->double_array.d_val = src_info.double_array.dval;
171                 break;
172
173                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
174                         dst_info->double_range.min = src_info.double_range.min;
175                         dst_info->double_range.max = src_info.double_range.max;
176                         dst_info->double_range.d_val = src_info.double_range.dval;
177                 break;
178
179                 default:
180                 break;
181         }
182
183         debug_fleave();
184
185         return result;
186 }
187
188 int
189 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
190 {
191         MMHandleType attrs = 0;
192         mm_player_t* player = 0;
193
194         debug_fenter();
195
196         return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
197         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
198
199         attrs = MM_PLAYER_GET_ATTRS(handle);
200         player = MM_PLAYER_CAST(handle);
201
202         if ( g_strrstr(attribute_name, "display") )
203         {
204                 /* check videosink element is created */
205                 if ( !player->pipeline ||
206                          !player->pipeline->videobin ||
207                          !player->pipeline->videobin[MMPLAYER_V_SINK].gst )
208                 {
209                         debug_warning("videosink element is not yet ready");
210                         /*
211                          * The attribute should be committed even though videobin is not created yet.
212                          * So, true should be returned here.
213                          * Otherwise, video can be diaplayed abnormal.
214                          */
215                         return MM_ERROR_NONE;
216                 }
217
218                 if ( MM_ERROR_NONE != _mmplayer_update_video_param( player ) )
219                 {
220                         debug_error("failed to update video param");
221                         return MM_ERROR_PLAYER_INTERNAL;
222                 }
223         }
224
225         debug_fleave();
226
227         return MM_ERROR_NONE;
228 }
229
230 MMHandleType
231 _mmplayer_construct_attribute(MMHandleType handle)
232 {
233         int idx = 0;
234         MMHandleType attrs = 0;
235         int num_of_attrs = 0;
236         mmf_attrs_construct_info_t *base = NULL;
237         gchar *system_ua = NULL;
238         gchar *system_proxy = NULL;
239
240         debug_fenter();
241
242         return_val_if_fail (handle, 0);
243
244         MMPlayerAttrsSpec player_attrs[] =
245         {
246                 {
247                         "profile_uri",                  // name
248                         MM_ATTRS_TYPE_STRING,           // type
249                         MM_ATTRS_FLAG_RW,               // flag
250                         (void *) NULL,                  // default value
251                         MM_ATTRS_VALID_TYPE_NONE,       // validity type
252                         0,                              // validity min value
253                         0                               // validity max value
254                 },
255                 {
256                         "profile_user_param",
257                         MM_ATTRS_TYPE_DATA,
258                         MM_ATTRS_FLAG_RW,
259                         (void *) NULL,
260                         MM_ATTRS_VALID_TYPE_NONE,
261                         0,
262                         0
263                 },
264                 {
265                         "profile_play_count",
266                         MM_ATTRS_TYPE_INT,
267                         MM_ATTRS_FLAG_RW,
268                         (void *) 1,                     // -1 : repeat continually
269                         MM_ATTRS_VALID_TYPE_INT_RANGE,
270                         -1,
271                         MMPLAYER_MAX_INT
272                 },
273                 {
274                         "profile_prepare_async",
275                         MM_ATTRS_TYPE_INT,
276                         MM_ATTRS_FLAG_RW,
277                         (void *) 0,
278                         MM_ATTRS_VALID_TYPE_INT_RANGE,
279                         0,
280                         1
281                 },
282                 {       /* update registry for downloadable codec */
283                         "profile_update_registry",
284                         MM_ATTRS_TYPE_INT,
285                         MM_ATTRS_FLAG_RW,
286                         (void *) 0,
287                         MM_ATTRS_VALID_TYPE_INT_RANGE,
288                         0,
289                         1
290                 },
291                 {
292                         "streaming_type",
293                         MM_ATTRS_TYPE_INT,
294                         MM_ATTRS_FLAG_RW,
295                         (void *) STREAMING_SERVICE_NONE,
296                         MM_ATTRS_VALID_TYPE_INT_RANGE,
297                         STREAMING_SERVICE_VOD,
298                         STREAMING_SERVICE_NUM
299                 },
300                 {
301                         "streaming_udp_timeout",
302                         MM_ATTRS_TYPE_INT,
303                         MM_ATTRS_FLAG_RW,
304                         (void *) 10000,
305                         MM_ATTRS_VALID_TYPE_INT_RANGE,
306                         0,
307                         MMPLAYER_MAX_INT
308                 },
309                 {
310                         "streaming_user_agent",
311                         MM_ATTRS_TYPE_STRING,
312                         MM_ATTRS_FLAG_RW,
313                         (void *) NULL,
314                         MM_ATTRS_VALID_TYPE_NONE,
315                         0,
316                         0
317                 },
318                 {
319                         "streaming_wap_profile",
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_network_bandwidth",
329                         MM_ATTRS_TYPE_INT,
330                         MM_ATTRS_FLAG_RW,
331                         (void *) 128000,
332                         MM_ATTRS_VALID_TYPE_INT_RANGE,
333                         0,
334                         MMPLAYER_MAX_INT
335                 },
336                 {
337                         "streaming_cookie",
338                         MM_ATTRS_TYPE_STRING,
339                         MM_ATTRS_FLAG_RW,
340                         (void *) NULL,
341                         MM_ATTRS_VALID_TYPE_NONE,
342                         0,
343                         0
344                 },
345                 {
346                         "streaming_proxy",
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                         "subtitle_uri",
356                         MM_ATTRS_TYPE_STRING,
357                         MM_ATTRS_FLAG_RW,
358                         (void *) NULL,
359                         MM_ATTRS_VALID_TYPE_NONE,
360                         0,
361                         0
362                 },
363                 {
364                         "content_duration",
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_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_max_bitrate",
383                         MM_ATTRS_TYPE_INT,
384                         MM_ATTRS_FLAG_RW,
385                         (void *) 0,
386                         MM_ATTRS_VALID_TYPE_INT_RANGE,
387                         0,
388                         MMPLAYER_MAX_INT
389                 },
390                 {
391                         "content_video_found",
392                         MM_ATTRS_TYPE_INT,
393                         MM_ATTRS_FLAG_RW,
394                         (void *) 0,
395                         MM_ATTRS_VALID_TYPE_INT_RANGE,
396                         0,
397                         1
398                 },
399                 {
400                         "content_video_codec",
401                         MM_ATTRS_TYPE_STRING,
402                         MM_ATTRS_FLAG_RW,
403                         (void *) NULL,
404                         MM_ATTRS_VALID_TYPE_NONE,
405                         0,
406                         0
407                 },
408                 {
409                         "content_video_bitrate",
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_fps",
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_width",
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_height",
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_video_track_num",
446                         MM_ATTRS_TYPE_INT,
447                         MM_ATTRS_FLAG_RW,
448                         (void *) 0,
449                         MM_ATTRS_VALID_TYPE_INT_RANGE,
450                         0,
451                         MMPLAYER_MAX_INT
452                 },
453                 {
454                         "content_audio_found",
455                         MM_ATTRS_TYPE_INT,
456                         MM_ATTRS_FLAG_RW,
457                         (void *) 0,
458                         MM_ATTRS_VALID_TYPE_INT_RANGE,
459                         0,
460                         1
461                 },
462                 {
463                         "content_audio_codec",
464                         MM_ATTRS_TYPE_STRING,
465                         MM_ATTRS_FLAG_RW,
466                         (void *) NULL,
467                         MM_ATTRS_VALID_TYPE_NONE,
468                         0,
469                         0
470                 },
471                 {
472                         "content_audio_bitrate",
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_channels",
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_samplerate",
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_track_num",
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_audio_format",
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_roi_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_roi_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_roi_width",
623                         MM_ATTRS_TYPE_INT,
624                         MM_ATTRS_FLAG_RW,
625                         (void *) 480,
626                         MM_ATTRS_VALID_TYPE_INT_RANGE,
627                         0,
628                         MMPLAYER_MAX_INT
629                 },
630                 {
631                         "display_roi_height",
632                         MM_ATTRS_TYPE_INT,
633                         MM_ATTRS_FLAG_RW,
634                         (void *) 800,
635                         MM_ATTRS_VALID_TYPE_INT_RANGE,
636                         0,
637                         MMPLAYER_MAX_INT
638                 },
639                 {
640                         "display_rotation",
641                         MM_ATTRS_TYPE_INT,
642                         MM_ATTRS_FLAG_RW,
643                         (void *) MM_DISPLAY_ROTATION_NONE,
644                         MM_ATTRS_VALID_TYPE_INT_RANGE,
645                         MM_DISPLAY_ROTATION_NONE,
646                         MM_DISPLAY_ROTATION_270
647                 },
648                 {
649                         "display_visible",
650                         MM_ATTRS_TYPE_INT,
651                         MM_ATTRS_FLAG_RW,
652                         (void *) TRUE,
653                         MM_ATTRS_VALID_TYPE_INT_RANGE,
654                         0,
655                         1
656                 },
657                 {
658                         "display_method",
659                         MM_ATTRS_TYPE_INT,
660                         MM_ATTRS_FLAG_RW,
661                         (void *) MM_DISPLAY_METHOD_LETTER_BOX,
662                         MM_ATTRS_VALID_TYPE_INT_RANGE,
663                         MM_DISPLAY_METHOD_LETTER_BOX,
664                         MM_DISPLAY_METHOD_CUSTOM_ROI
665                 },
666                 {
667                         "display_overlay",
668                         MM_ATTRS_TYPE_DATA,
669                         MM_ATTRS_FLAG_RW,
670                         (void *) NULL,
671                         MM_ATTRS_VALID_TYPE_NONE,
672                         0,
673                         0
674                 },
675                 {
676                         "display_overlay_user_data",
677                         MM_ATTRS_TYPE_DATA,
678                         MM_ATTRS_FLAG_RW,
679                         (void *) NULL,
680                         MM_ATTRS_VALID_TYPE_NONE,
681                         0,
682                         0
683                 },
684                 {
685                         "display_zoom",
686                         MM_ATTRS_TYPE_INT,
687                         MM_ATTRS_FLAG_RW,
688                         (void *) 1,
689                         MM_ATTRS_VALID_TYPE_INT_RANGE,
690                         1,
691                         MMPLAYER_MAX_INT
692                 },
693                 {
694                         "display_surface_type",
695                         MM_ATTRS_TYPE_INT,
696                         MM_ATTRS_FLAG_RW,
697                         (void *) MM_DISPLAY_SURFACE_NULL,
698                         MM_ATTRS_VALID_TYPE_INT_RANGE,
699                         MM_DISPLAY_SURFACE_X,
700                         MM_DISPLAY_SURFACE_X_EXT
701                 },
702                 {
703                         "display_evas_surface_sink",
704                         MM_ATTRS_TYPE_STRING,
705                         MM_ATTRS_FLAG_READABLE,
706                         (void *) PLAYER_INI()->videosink_element_evas,
707                         MM_ATTRS_VALID_TYPE_NONE,
708                         0,
709                         0
710                 },
711                 {
712                         "display_force_aspect_ration",
713                         MM_ATTRS_TYPE_INT,
714                         MM_ATTRS_FLAG_RW,
715                         (void *) 1,
716                         MM_ATTRS_VALID_TYPE_INT_RANGE,
717                         0,
718                         MMPLAYER_MAX_INT
719                 },
720                 {
721                         "display_width",                // dest width of fimcconvert ouput
722                         MM_ATTRS_TYPE_INT,
723                         MM_ATTRS_FLAG_RW,
724                         (void *) 0,
725                         MM_ATTRS_VALID_TYPE_INT_RANGE,
726                         0,
727                         MMPLAYER_MAX_INT
728                 },
729                 {
730                         "display_height",               // dest height of fimcconvert ouput
731                         MM_ATTRS_TYPE_INT,
732                         MM_ATTRS_FLAG_RW,
733                         (void *) 0,
734                         MM_ATTRS_VALID_TYPE_INT_RANGE,
735                         0,
736                         MMPLAYER_MAX_INT
737                 },
738                 {
739                         "display_evas_do_scaling",
740                         MM_ATTRS_TYPE_INT,
741                         MM_ATTRS_FLAG_RW,
742                         (void *) TRUE,
743                         MM_ATTRS_VALID_TYPE_INT_RANGE,
744                         FALSE,
745                         TRUE
746                 },
747                 {
748                         "sound_fadeup",
749                         MM_ATTRS_TYPE_INT,
750                         MM_ATTRS_FLAG_RW,
751                         (void *) FALSE,
752                         MM_ATTRS_VALID_TYPE_INT_RANGE,
753                         FALSE,
754                         TRUE
755                 },
756                 {
757                         "sound_fadedown",
758                         MM_ATTRS_TYPE_INT,
759                         MM_ATTRS_FLAG_RW,
760                         (void *) FALSE,
761                         MM_ATTRS_VALID_TYPE_INT_RANGE,
762                         FALSE,
763                         TRUE
764                 },
765                 {
766                         "sound_volume_type",
767                         MM_ATTRS_TYPE_INT,
768                         MM_ATTRS_FLAG_RW,
769                         (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
770                         MM_ATTRS_VALID_TYPE_INT_RANGE,
771                         MM_SOUND_VOLUME_TYPE_SYSTEM,
772                         MM_SOUND_VOLUME_TYPE_CALL
773                 },
774                 {
775                         "sound_route",
776                         MM_ATTRS_TYPE_INT,
777                         MM_ATTRS_FLAG_RW,
778                         (void *) MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
779                         MM_ATTRS_VALID_TYPE_INT_RANGE,
780                         MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
781                         MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY
782                 },
783                 {
784                         "sound_stop_when_unplugged",
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_application_pid",
794                         MM_ATTRS_TYPE_INT,
795                         MM_ATTRS_FLAG_RW,
796                         (void *) 0,
797                         MM_ATTRS_VALID_TYPE_INT_RANGE,
798                         0,
799                         MMPLAYER_MAX_INT
800                 },
801                 {
802                         "sound_spk_out_only",
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_priority",
812                         MM_ATTRS_TYPE_INT,
813                         MM_ATTRS_FLAG_RW,
814                         (void *) 0,                     // 0: normal, 1: high 2: high with sound transition
815                         MM_ATTRS_VALID_TYPE_INT_RANGE,
816                         0,
817                         2
818                 },
819                 {
820                         "audio_latency_mode",
821                         MM_ATTRS_TYPE_INT,
822                         MM_ATTRS_FLAG_RW,
823                         (void *) 1,                     // 0: low latency, 1: middle latency 2: high latency
824                         MM_ATTRS_VALID_TYPE_INT_RANGE,
825                         0,
826                         2
827                 },
828                 {
829                         "pcm_extraction",               // enable pcm extraction
830                         MM_ATTRS_TYPE_INT,
831                         MM_ATTRS_FLAG_RW,
832                         (void *) FALSE,
833                         MM_ATTRS_VALID_TYPE_INT_RANGE,
834                         FALSE,
835                         TRUE
836                 },
837                 {
838                         "pcm_extraction_samplerate",    // set samplerate for pcm extraction
839                         MM_ATTRS_TYPE_INT,
840                         MM_ATTRS_FLAG_RW,
841                         (void *) 8000,                          // hz
842                         MM_ATTRS_VALID_TYPE_INT_RANGE,
843                         0,
844                         MMPLAYER_MAX_INT
845                 },
846                 {
847                         "pcm_extraction_depth", // set depth for pcm extraction
848                         MM_ATTRS_TYPE_INT,
849                         MM_ATTRS_FLAG_RW,
850                         (void *) 16,                    // bits
851                         MM_ATTRS_VALID_TYPE_INT_RANGE,
852                         0,
853                         MMPLAYER_MAX_INT
854                 },
855                 {
856                         "pcm_extraction_channels",      // set channels for pcm extraction
857                         MM_ATTRS_TYPE_INT,
858                         MM_ATTRS_FLAG_RW,
859                         (void *) 1,
860                         MM_ATTRS_VALID_TYPE_INT_RANGE,
861                         0,
862                         MMPLAYER_MAX_INT
863                 },
864                 {
865                         "pcm_extraction_start_msec",    // set start position to extract pcm
866                         MM_ATTRS_TYPE_INT,
867                         MM_ATTRS_FLAG_RW,
868                         (void *) 0,
869                         MM_ATTRS_VALID_TYPE_INT_RANGE,
870                         0,
871                         MMPLAYER_MAX_INT
872                 },
873                 {
874                         "pcm_extraction_end_msec",      // set end position to extract pcm
875                         MM_ATTRS_TYPE_INT,
876                         MM_ATTRS_FLAG_RW,
877                         (void *) 0,
878                         MM_ATTRS_VALID_TYPE_INT_RANGE,
879                         0,
880                         MMPLAYER_MAX_INT
881                 },
882                 {
883                         "profile_smooth_repeat",
884                         MM_ATTRS_TYPE_INT,
885                         MM_ATTRS_FLAG_RW,
886                         (void *) FALSE,
887                         MM_ATTRS_VALID_TYPE_INT_RANGE,
888                         0,
889                         MMPLAYER_MAX_INT
890                 },
891                 {
892                         "profile_progress_interval",    // will be deprecated
893                         MM_ATTRS_TYPE_INT,
894                         MM_ATTRS_FLAG_RW,
895                         (void *) 500,
896                         MM_ATTRS_VALID_TYPE_INT_RANGE,
897                         0,
898                         MMPLAYER_MAX_INT
899                 },
900                 {
901                         "display_x",
902                         MM_ATTRS_TYPE_INT,
903                         MM_ATTRS_FLAG_RW,
904                         (void *) 0,
905                         MM_ATTRS_VALID_TYPE_INT_RANGE,
906                         0,
907                         MMPLAYER_MAX_INT
908                 },
909                 {
910                         "display_y",
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                         "pd_mode",
920                         MM_ATTRS_TYPE_INT,
921                         MM_ATTRS_FLAG_RW,
922                         (void *) MM_PLAYER_PD_MODE_NONE,
923                         MM_ATTRS_VALID_TYPE_INT_RANGE,
924                         MM_PLAYER_PD_MODE_NONE,
925                         MM_PLAYER_PD_MODE_URI           // not tested yet, because of no fixed scenario
926                 },
927                 {
928                         "pd_location",                  // location of the file to write
929                         MM_ATTRS_TYPE_STRING,
930                         MM_ATTRS_FLAG_RW,
931                         (void *) NULL,
932                         MM_ATTRS_VALID_TYPE_NONE,
933                         0,
934                         0
935                 }
936         };
937
938         num_of_attrs = ARRAY_SIZE(player_attrs);
939
940         base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
941
942         if ( !base )
943         {
944                 debug_error("failed to alloc attrs constructor");
945                 return 0;
946         }
947
948         /* initialize values of attributes */
949         for ( idx = 0; idx < num_of_attrs; idx++ )
950         {
951                 base[idx].name = player_attrs[idx].name;
952                 base[idx].value_type = player_attrs[idx].value_type;
953                 base[idx].flags = player_attrs[idx].flags;
954                 base[idx].default_value = player_attrs[idx].default_value;
955         }
956
957         attrs = mmf_attrs_new_from_data(
958                                         "mmplayer_attrs",
959                                         base,
960                                         num_of_attrs,
961                                         NULL,
962                                         NULL);
963
964         /* clean */
965         MMPLAYER_FREEIF(base);
966
967         if ( !attrs )
968         {
969                 debug_error("failed to create player attrs");
970                 return 0;
971         }
972
973         /* set validity type and range */
974         for ( idx = 0; idx < num_of_attrs; idx++ )
975         {
976                 switch ( player_attrs[idx].valid_type)
977                 {
978                         case MM_ATTRS_VALID_TYPE_INT_RANGE:
979                         {
980                                 mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
981                                 mmf_attrs_set_valid_range (attrs, idx,
982                                                 player_attrs[idx].value_min,
983                                                 player_attrs[idx].value_max,
984                                                 player_attrs[idx].default_value);
985                         }
986                         break;
987
988                         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
989                         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
990                         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
991                         default:
992                         break;
993                 }
994         }
995
996         /* set proxy and user agent */
997         system_ua = vconf_get_str(VCONFKEY_ADMIN_UAGENT);
998         system_proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
999
1000         if (system_ua)
1001         {
1002                         mm_attrs_set_string_by_name(attrs, "streaming_user_agent", system_ua);
1003                         g_free(system_ua);
1004         }
1005
1006         if (system_proxy)
1007         {
1008                         mm_attrs_set_string_by_name(attrs, "streaming_proxy", system_proxy);
1009                         g_free(system_proxy);
1010         }
1011
1012         /* commit */
1013         mmf_attrs_commit(attrs);
1014
1015         debug_fleave();
1016
1017         return attrs;
1018 }
1019
1020 bool
1021 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1022 {
1023         debug_fenter();
1024
1025         mm_player_t *player = MM_PLAYER_CAST(handle);
1026
1027         return_val_if_fail ( player, FALSE );
1028
1029         if (player->attrs)
1030         {
1031                 mmf_attrs_free (player->attrs);
1032                 player->attrs = 0;
1033         }
1034
1035         debug_fleave();
1036
1037         return TRUE;
1038 }