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