4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
7 * YoungHwan An <younghwan_.an@samsung.com>
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 /*===========================================================================================
27 ========================================================================================== */
29 #include <mm_attrs_private.h>
31 #include <gst/interfaces/xoverlay.h>
32 #include "mm_player_utils.h"
33 #include "mm_player_priv.h"
34 #include "mm_player_attrs.h"
36 /*===========================================================================================
38 | LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE |
40 ========================================================================================== */
47 int valid_type; // validity type
48 int value_min; //<- set validity value range
52 /*---------------------------------------------------------------------------
53 | LOCAL FUNCTION PROTOTYPES: |
54 ---------------------------------------------------------------------------*/
56 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name);
58 /*===========================================================================================
60 | FUNCTION DEFINITIONS |
62 ========================================================================================== */
65 _mmplayer_get_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
67 int result = MM_ERROR_NONE;
68 MMHandleType attrs = 0;
70 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
71 /* if it's not want to know it. */
72 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
73 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
75 attrs = MM_PLAYER_GET_ATTRS(handle);
77 result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
79 if ( result != MM_ERROR_NONE)
80 debug_error("failed to get %s attribute\n", attribute_name);
86 _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
88 int result = MM_ERROR_NONE;
89 MMHandleType attrs = 0;
91 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
92 /* if it's not want to know it. */
93 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
94 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
96 attrs = MM_PLAYER_GET_ATTRS(handle);
98 /* set attributes and commit them */
99 result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
101 if (result != MM_ERROR_NONE)
103 debug_error("failed to set %s attribute\n", attribute_name);
107 result = __mmplayer_apply_attribute(handle, attribute_name);
108 if (result != MM_ERROR_NONE)
110 debug_error("failed to apply attributes\n");
118 _mmplayer_get_attributes_info(MMHandleType handle, const char *attribute_name, MMPlayerAttrsInfo *dst_info)
120 int result = MM_ERROR_NONE;
121 MMHandleType attrs = 0;
122 MMAttrsInfo src_info = {0, };
124 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
125 return_val_if_fail(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
126 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
128 attrs = MM_PLAYER_GET_ATTRS(handle);
130 result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
132 if ( result != MM_ERROR_NONE)
134 debug_error("failed to get attribute info\n");
138 memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
140 dst_info->type = src_info.type;
141 dst_info->flag = src_info.flag;
142 dst_info->validity_type= src_info.validity_type;
144 switch(src_info.validity_type)
146 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
147 dst_info->int_array.array = src_info.int_array.array;
148 dst_info->int_array.count = src_info.int_array.count;
149 dst_info->int_array.d_val = src_info.int_array.dval;
152 case MM_ATTRS_VALID_TYPE_INT_RANGE:
153 dst_info->int_range.min = src_info.int_range.min;
154 dst_info->int_range.max = src_info.int_range.max;
155 dst_info->int_range.d_val = src_info.int_range.dval;
158 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
159 dst_info->double_array.array = src_info.double_array.array;
160 dst_info->double_array.count = src_info.double_array.count;
161 dst_info->double_array.d_val = src_info.double_array.dval;
164 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
165 dst_info->double_range.min = src_info.double_range.min;
166 dst_info->double_range.max = src_info.double_range.max;
167 dst_info->double_range.d_val = src_info.double_range.dval;
178 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
180 mm_player_t* player = 0;
182 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
183 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
185 player = MM_PLAYER_CAST(handle);
187 if ( g_strrstr(attribute_name, "display") )
189 /* check videosink element is created */
190 if ( !player->pipeline ||
191 !player->pipeline->videobin ||
192 !player->pipeline->videobin[MMPLAYER_V_SINK].gst )
195 * The attribute should be committed even though videobin is not created yet.
196 * So, true should be returned here.
197 * Otherwise, video can be diaplayed abnormal.
199 return MM_ERROR_NONE;
202 if ( MM_ERROR_NONE != _mmplayer_update_video_param( player ) )
204 debug_error("failed to update video param");
205 return MM_ERROR_PLAYER_INTERNAL;
209 return MM_ERROR_NONE;
213 _mmplayer_construct_attribute(MMHandleType handle)
215 mm_player_t *player = NULL;
217 MMHandleType attrs = 0;
218 int num_of_attrs = 0;
219 mmf_attrs_construct_info_t *base = NULL;
220 //gchar *system_ua = NULL;
222 return_val_if_fail (handle, 0);
224 player = MM_PLAYER_CAST(handle);
226 MMPlayerAttrsSpec player_attrs[] =
229 "profile_uri", // name
230 MM_ATTRS_TYPE_STRING, // type
231 MM_ATTRS_FLAG_RW, // flag
232 (void *) NULL, // default value
233 MM_ATTRS_VALID_TYPE_NONE, // validity type
234 0, // validity min value
235 0 // validity max value
238 "profile_user_param",
242 MM_ATTRS_VALID_TYPE_NONE,
247 "profile_play_count",
250 (void *) 1, // -1 : repeat continually
251 MM_ATTRS_VALID_TYPE_INT_RANGE,
256 "profile_prepare_async",
260 MM_ATTRS_VALID_TYPE_INT_RANGE,
264 { /* update registry for downloadable codec */
265 "profile_update_registry",
269 MM_ATTRS_VALID_TYPE_INT_RANGE,
277 (void *) STREAMING_SERVICE_NONE,
278 MM_ATTRS_VALID_TYPE_INT_RANGE,
279 STREAMING_SERVICE_VOD,
280 STREAMING_SERVICE_NUM
283 "streaming_udp_timeout",
287 MM_ATTRS_VALID_TYPE_INT_RANGE,
292 "streaming_user_agent",
293 MM_ATTRS_TYPE_STRING,
296 MM_ATTRS_VALID_TYPE_NONE,
301 "streaming_wap_profile",
302 MM_ATTRS_TYPE_STRING,
305 MM_ATTRS_VALID_TYPE_NONE,
310 "streaming_network_bandwidth",
314 MM_ATTRS_VALID_TYPE_INT_RANGE,
320 MM_ATTRS_TYPE_STRING,
323 MM_ATTRS_VALID_TYPE_NONE,
329 MM_ATTRS_TYPE_STRING,
332 MM_ATTRS_VALID_TYPE_NONE,
340 (void *) -1, // DEFAULT_HTTP_TIMEOUT
341 MM_ATTRS_VALID_TYPE_INT_RANGE,
347 MM_ATTRS_TYPE_STRING,
350 MM_ATTRS_VALID_TYPE_NONE,
359 MM_ATTRS_VALID_TYPE_INT_RANGE,
368 MM_ATTRS_VALID_TYPE_INT_RANGE,
373 "content_max_bitrate",
377 MM_ATTRS_VALID_TYPE_INT_RANGE,
382 "content_video_found",
386 MM_ATTRS_VALID_TYPE_INT_RANGE,
391 "content_video_codec",
392 MM_ATTRS_TYPE_STRING,
395 MM_ATTRS_VALID_TYPE_NONE,
400 "content_video_bitrate",
404 MM_ATTRS_VALID_TYPE_INT_RANGE,
413 MM_ATTRS_VALID_TYPE_INT_RANGE,
418 "content_video_width",
422 MM_ATTRS_VALID_TYPE_INT_RANGE,
427 "content_video_height",
431 MM_ATTRS_VALID_TYPE_INT_RANGE,
436 "content_video_track_num",
440 MM_ATTRS_VALID_TYPE_INT_RANGE,
445 "content_audio_found",
449 MM_ATTRS_VALID_TYPE_INT_RANGE,
454 "content_audio_codec",
455 MM_ATTRS_TYPE_STRING,
458 MM_ATTRS_VALID_TYPE_NONE,
463 "content_audio_bitrate",
467 MM_ATTRS_VALID_TYPE_INT_RANGE,
472 "content_audio_channels",
476 MM_ATTRS_VALID_TYPE_INT_RANGE,
481 "content_audio_samplerate",
485 MM_ATTRS_VALID_TYPE_INT_RANGE,
490 "content_audio_track_num",
494 MM_ATTRS_VALID_TYPE_INT_RANGE,
499 "content_audio_format",
503 MM_ATTRS_VALID_TYPE_INT_RANGE,
508 "content_text_track_num",
512 MM_ATTRS_VALID_TYPE_INT_RANGE,
518 MM_ATTRS_TYPE_STRING,
521 MM_ATTRS_VALID_TYPE_NONE,
527 MM_ATTRS_TYPE_STRING,
530 MM_ATTRS_VALID_TYPE_NONE,
536 MM_ATTRS_TYPE_STRING,
542 MM_ATTRS_TYPE_STRING,
545 MM_ATTRS_VALID_TYPE_NONE,
551 MM_ATTRS_TYPE_STRING,
554 MM_ATTRS_VALID_TYPE_NONE,
560 MM_ATTRS_TYPE_STRING,
563 MM_ATTRS_VALID_TYPE_NONE,
569 MM_ATTRS_TYPE_STRING,
572 MM_ATTRS_VALID_TYPE_NONE,
578 MM_ATTRS_TYPE_STRING,
581 MM_ATTRS_VALID_TYPE_NONE,
590 MM_ATTRS_VALID_TYPE_INT_RANGE,
599 MM_ATTRS_VALID_TYPE_NONE,
604 "display_src_crop_x",
608 MM_ATTRS_VALID_TYPE_INT_RANGE,
613 "display_src_crop_y",
617 MM_ATTRS_VALID_TYPE_INT_RANGE,
622 "display_src_crop_width",
626 MM_ATTRS_VALID_TYPE_INT_RANGE,
631 "display_src_crop_height",
635 MM_ATTRS_VALID_TYPE_INT_RANGE,
644 MM_ATTRS_VALID_TYPE_INT_RANGE,
653 MM_ATTRS_VALID_TYPE_INT_RANGE,
662 MM_ATTRS_VALID_TYPE_INT_RANGE,
667 "display_roi_height",
671 MM_ATTRS_VALID_TYPE_INT_RANGE,
679 (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
680 MM_ATTRS_VALID_TYPE_INT_RANGE,
681 MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
682 MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX
688 (void *) MM_DISPLAY_ROTATION_NONE,
689 MM_ATTRS_VALID_TYPE_INT_RANGE,
690 MM_DISPLAY_ROTATION_NONE,
691 MM_DISPLAY_ROTATION_270
698 MM_ATTRS_VALID_TYPE_INT_RANGE,
706 (void *) MM_DISPLAY_METHOD_LETTER_BOX,
707 MM_ATTRS_VALID_TYPE_INT_RANGE,
708 MM_DISPLAY_METHOD_LETTER_BOX,
709 MM_DISPLAY_METHOD_CUSTOM_ROI
716 MM_ATTRS_VALID_TYPE_NONE,
721 "display_overlay_user_data",
725 MM_ATTRS_VALID_TYPE_NONE,
731 MM_ATTRS_TYPE_DOUBLE,
734 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
739 "display_surface_type",
742 (void *) MM_DISPLAY_SURFACE_NULL,
743 MM_ATTRS_VALID_TYPE_INT_RANGE,
744 MM_DISPLAY_SURFACE_X,
745 MM_DISPLAY_SURFACE_X_EXT
748 "display_evas_surface_sink",
749 MM_ATTRS_TYPE_STRING,
750 MM_ATTRS_FLAG_READABLE,
751 (void *) player->ini.videosink_element_evas,
752 MM_ATTRS_VALID_TYPE_NONE,
757 "display_force_aspect_ration",
761 MM_ATTRS_VALID_TYPE_INT_RANGE,
766 "display_width", // dest width of fimcconvert ouput
770 MM_ATTRS_VALID_TYPE_INT_RANGE,
775 "display_height", // dest height of fimcconvert ouput
779 MM_ATTRS_VALID_TYPE_INT_RANGE,
784 "display_evas_do_scaling",
788 MM_ATTRS_VALID_TYPE_INT_RANGE,
797 MM_ATTRS_VALID_TYPE_INT_RANGE,
806 MM_ATTRS_VALID_TYPE_INT_RANGE,
814 (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
815 MM_ATTRS_VALID_TYPE_INT_RANGE,
823 (void *) MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
824 MM_ATTRS_VALID_TYPE_INT_RANGE,
825 MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
826 MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY
829 "sound_stop_when_unplugged",
833 MM_ATTRS_VALID_TYPE_INT_RANGE,
838 "sound_application_pid",
842 MM_ATTRS_VALID_TYPE_INT_RANGE,
847 "sound_spk_out_only",
851 MM_ATTRS_VALID_TYPE_INT_RANGE,
859 (void *) 0, // 0: normal, 1: high 2: high with sound transition 3: mix with others regardless of priority
860 MM_ATTRS_VALID_TYPE_INT_RANGE,
865 "sound_latency_mode",
868 (void *) 1, // 0: low latency, 1: middle latency 2: high latency
869 MM_ATTRS_VALID_TYPE_INT_RANGE,
874 "pcm_extraction", // enable pcm extraction
878 MM_ATTRS_VALID_TYPE_INT_RANGE,
883 "pcm_extraction_samplerate", // set samplerate for pcm extraction
886 (void *) 44100, // hz
887 MM_ATTRS_VALID_TYPE_INT_RANGE,
892 "pcm_extraction_depth", // set depth for pcm extraction
896 MM_ATTRS_VALID_TYPE_INT_RANGE,
901 "pcm_extraction_channels", // set channels for pcm extraction
905 MM_ATTRS_VALID_TYPE_INT_RANGE,
910 "pcm_extraction_start_msec", // set start position to extract pcm
914 MM_ATTRS_VALID_TYPE_INT_RANGE,
919 "pcm_extraction_end_msec", // set end position to extract pcm
923 MM_ATTRS_VALID_TYPE_INT_RANGE,
928 "profile_smooth_repeat",
932 MM_ATTRS_VALID_TYPE_INT_RANGE,
937 "profile_progress_interval", // will be deprecated
941 MM_ATTRS_VALID_TYPE_INT_RANGE,
950 MM_ATTRS_VALID_TYPE_INT_RANGE,
959 MM_ATTRS_VALID_TYPE_INT_RANGE,
967 (void *) MM_PLAYER_PD_MODE_NONE,
968 MM_ATTRS_VALID_TYPE_INT_RANGE,
969 MM_PLAYER_PD_MODE_NONE,
970 MM_PLAYER_PD_MODE_URI // not tested yet, because of no fixed scenario
973 "pd_location", // location of the file to write
974 MM_ATTRS_TYPE_STRING,
977 MM_ATTRS_VALID_TYPE_NONE,
986 MM_ATTRS_VALID_TYPE_INT_RANGE,
992 num_of_attrs = ARRAY_SIZE(player_attrs);
994 base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
998 debug_error("failed to alloc attrs constructor");
1002 /* initialize values of attributes */
1003 for ( idx = 0; idx < num_of_attrs; idx++ )
1005 base[idx].name = player_attrs[idx].name;
1006 base[idx].value_type = player_attrs[idx].value_type;
1007 base[idx].flags = player_attrs[idx].flags;
1008 base[idx].default_value = player_attrs[idx].default_value;
1011 attrs = mmf_attrs_new_from_data(
1019 MMPLAYER_FREEIF(base);
1023 debug_error("failed to create player attrs");
1027 /* set validity type and range */
1028 for ( idx = 0; idx < num_of_attrs; idx++ )
1030 switch ( player_attrs[idx].valid_type)
1032 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1034 mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
1035 mmf_attrs_set_valid_range (attrs, idx,
1036 player_attrs[idx].value_min,
1037 player_attrs[idx].value_max,
1038 (int)(player_attrs[idx].default_value));
1042 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1043 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1044 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1051 mmf_attrs_commit(attrs);
1057 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1059 mm_player_t *player = MM_PLAYER_CAST(handle);
1061 return_val_if_fail ( player, FALSE );
1065 mmf_attrs_free (player->attrs);