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/video/videooverlay.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 ========================================================================================== */
42 /*---------------------------------------------------------------------------
43 | LOCAL FUNCTION PROTOTYPES: |
44 ---------------------------------------------------------------------------*/
46 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name);
48 /*===========================================================================================
50 | FUNCTION DEFINITIONS |
52 ========================================================================================== */
55 _mmplayer_get_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
57 int result = MM_ERROR_NONE;
58 MMHandleType attrs = 0;
60 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
61 /* if it's not want to know it. */
62 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
63 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
65 attrs = MM_PLAYER_GET_ATTRS(handle);
67 result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
69 if ( result != MM_ERROR_NONE)
70 debug_error("failed to get %s attribute\n", attribute_name);
76 _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
78 int result = MM_ERROR_NONE;
79 MMHandleType attrs = 0;
81 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
82 /* if it's not want to know it. */
83 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
84 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
86 attrs = MM_PLAYER_GET_ATTRS(handle);
88 /* set attributes and commit them */
89 result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
91 if (result != MM_ERROR_NONE)
93 debug_error("failed to set %s attribute\n", attribute_name);
97 result = __mmplayer_apply_attribute(handle, attribute_name);
98 if (result != MM_ERROR_NONE)
100 debug_error("failed to apply attributes\n");
108 _mmplayer_get_attributes_info(MMHandleType handle, const char *attribute_name, MMPlayerAttrsInfo *dst_info)
110 int result = MM_ERROR_NONE;
111 MMHandleType attrs = 0;
112 MMAttrsInfo src_info = {0, };
114 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
115 return_val_if_fail(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
116 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
118 attrs = MM_PLAYER_GET_ATTRS(handle);
120 result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
122 if ( result != MM_ERROR_NONE)
124 debug_error("failed to get attribute info\n");
128 memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
130 dst_info->type = src_info.type;
131 dst_info->flag = src_info.flag;
132 dst_info->validity_type= src_info.validity_type;
134 switch(src_info.validity_type)
136 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
137 dst_info->int_array.array = src_info.int_array.array;
138 dst_info->int_array.count = src_info.int_array.count;
139 dst_info->int_array.d_val = src_info.int_array.dval;
142 case MM_ATTRS_VALID_TYPE_INT_RANGE:
143 dst_info->int_range.min = src_info.int_range.min;
144 dst_info->int_range.max = src_info.int_range.max;
145 dst_info->int_range.d_val = src_info.int_range.dval;
148 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
149 dst_info->double_array.array = src_info.double_array.array;
150 dst_info->double_array.count = src_info.double_array.count;
151 dst_info->double_array.d_val = src_info.double_array.dval;
154 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
155 dst_info->double_range.min = src_info.double_range.min;
156 dst_info->double_range.max = src_info.double_range.max;
157 dst_info->double_range.d_val = src_info.double_range.dval;
168 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
170 mm_player_t* player = 0;
172 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
173 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
175 player = MM_PLAYER_CAST(handle);
177 if ( g_strrstr(attribute_name, "display") )
179 /* check videosink element is created */
180 if ( !player->pipeline ||
181 !player->pipeline->videobin ||
182 !player->pipeline->videobin[MMPLAYER_V_SINK].gst )
185 * The attribute should be committed even though videobin is not created yet.
186 * So, true should be returned here.
187 * Otherwise, video can be diaplayed abnormal.
189 return MM_ERROR_NONE;
192 if ( MM_ERROR_NONE != _mmplayer_update_video_param( player ) )
194 debug_error("failed to update video param");
195 return MM_ERROR_PLAYER_INTERNAL;
199 return MM_ERROR_NONE;
203 _mmplayer_construct_attribute(MMHandleType handle)
205 mm_player_t *player = NULL;
207 MMHandleType attrs = 0;
208 int num_of_attrs = 0;
209 mmf_attrs_construct_info_t *base = NULL;
210 //gchar *system_ua = NULL;
211 gchar *system_proxy = NULL;
213 return_val_if_fail (handle, 0);
215 player = MM_PLAYER_CAST(handle);
217 MMPlayerAttrsSpec player_attrs[] =
220 "profile_uri", // name
221 MM_ATTRS_TYPE_STRING, // type
222 MM_ATTRS_FLAG_RW, // flag
223 (void *) NULL, // default value
224 MM_ATTRS_VALID_TYPE_NONE, // validity type
225 0, // validity min value
226 0 // validity max value
229 "profile_user_param",
233 MM_ATTRS_VALID_TYPE_NONE,
238 "profile_play_count",
241 (void *) 1, // -1 : repeat continually
242 MM_ATTRS_VALID_TYPE_INT_RANGE,
247 "profile_prepare_async",
251 MM_ATTRS_VALID_TYPE_INT_RANGE,
255 { /* update registry for downloadable codec */
256 "profile_update_registry",
260 MM_ATTRS_VALID_TYPE_INT_RANGE,
268 (void *) STREAMING_SERVICE_NONE,
269 MM_ATTRS_VALID_TYPE_INT_RANGE,
270 STREAMING_SERVICE_VOD,
271 STREAMING_SERVICE_NUM
274 "streaming_udp_timeout",
278 MM_ATTRS_VALID_TYPE_INT_RANGE,
283 "streaming_user_agent",
284 MM_ATTRS_TYPE_STRING,
287 MM_ATTRS_VALID_TYPE_NONE,
292 "streaming_wap_profile",
293 MM_ATTRS_TYPE_STRING,
296 MM_ATTRS_VALID_TYPE_NONE,
301 "streaming_network_bandwidth",
305 MM_ATTRS_VALID_TYPE_INT_RANGE,
311 MM_ATTRS_TYPE_STRING,
314 MM_ATTRS_VALID_TYPE_NONE,
320 MM_ATTRS_TYPE_STRING,
323 MM_ATTRS_VALID_TYPE_NONE,
331 (void *) -1, // DEFAULT_HTTP_TIMEOUT
332 MM_ATTRS_VALID_TYPE_INT_RANGE,
338 MM_ATTRS_TYPE_STRING,
341 MM_ATTRS_VALID_TYPE_NONE,
350 MM_ATTRS_VALID_TYPE_INT_RANGE,
359 MM_ATTRS_VALID_TYPE_INT_RANGE,
364 "content_max_bitrate",
368 MM_ATTRS_VALID_TYPE_INT_RANGE,
373 "content_video_found",
377 MM_ATTRS_VALID_TYPE_INT_RANGE,
382 "content_video_codec",
383 MM_ATTRS_TYPE_STRING,
386 MM_ATTRS_VALID_TYPE_NONE,
391 "content_video_bitrate",
395 MM_ATTRS_VALID_TYPE_INT_RANGE,
404 MM_ATTRS_VALID_TYPE_INT_RANGE,
409 "content_video_width",
413 MM_ATTRS_VALID_TYPE_INT_RANGE,
418 "content_video_height",
422 MM_ATTRS_VALID_TYPE_INT_RANGE,
427 "content_video_track_num",
431 MM_ATTRS_VALID_TYPE_INT_RANGE,
436 "content_audio_found",
440 MM_ATTRS_VALID_TYPE_INT_RANGE,
445 "content_audio_codec",
446 MM_ATTRS_TYPE_STRING,
449 MM_ATTRS_VALID_TYPE_NONE,
454 "content_audio_bitrate",
458 MM_ATTRS_VALID_TYPE_INT_RANGE,
463 "content_audio_channels",
467 MM_ATTRS_VALID_TYPE_INT_RANGE,
472 "content_audio_samplerate",
476 MM_ATTRS_VALID_TYPE_INT_RANGE,
481 "content_audio_track_num",
485 MM_ATTRS_VALID_TYPE_INT_RANGE,
490 "content_audio_format",
494 MM_ATTRS_VALID_TYPE_INT_RANGE,
499 "content_text_track_num",
503 MM_ATTRS_VALID_TYPE_INT_RANGE,
509 MM_ATTRS_TYPE_STRING,
512 MM_ATTRS_VALID_TYPE_NONE,
518 MM_ATTRS_TYPE_STRING,
521 MM_ATTRS_VALID_TYPE_NONE,
527 MM_ATTRS_TYPE_STRING,
533 MM_ATTRS_TYPE_STRING,
536 MM_ATTRS_VALID_TYPE_NONE,
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,
581 MM_ATTRS_VALID_TYPE_INT_RANGE,
590 MM_ATTRS_VALID_TYPE_NONE,
595 "display_src_crop_x",
599 MM_ATTRS_VALID_TYPE_INT_RANGE,
604 "display_src_crop_y",
608 MM_ATTRS_VALID_TYPE_INT_RANGE,
613 "display_src_crop_width",
617 MM_ATTRS_VALID_TYPE_INT_RANGE,
622 "display_src_crop_height",
626 MM_ATTRS_VALID_TYPE_INT_RANGE,
635 MM_ATTRS_VALID_TYPE_INT_RANGE,
644 MM_ATTRS_VALID_TYPE_INT_RANGE,
653 MM_ATTRS_VALID_TYPE_INT_RANGE,
658 "display_roi_height",
662 MM_ATTRS_VALID_TYPE_INT_RANGE,
670 (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
671 MM_ATTRS_VALID_TYPE_INT_RANGE,
672 MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
673 MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX
679 (void *) MM_DISPLAY_ROTATION_NONE,
680 MM_ATTRS_VALID_TYPE_INT_RANGE,
681 MM_DISPLAY_ROTATION_NONE,
682 MM_DISPLAY_ROTATION_270
689 MM_ATTRS_VALID_TYPE_INT_RANGE,
697 (void *) MM_DISPLAY_METHOD_LETTER_BOX,
698 MM_ATTRS_VALID_TYPE_INT_RANGE,
699 MM_DISPLAY_METHOD_LETTER_BOX,
700 MM_DISPLAY_METHOD_CUSTOM_ROI
707 MM_ATTRS_VALID_TYPE_NONE,
717 MM_ATTRS_VALID_TYPE_NONE,
722 "wl_window_render_x",
726 MM_ATTRS_VALID_TYPE_INT_RANGE,
731 "wl_window_render_y",
735 MM_ATTRS_VALID_TYPE_INT_RANGE,
740 "wl_window_render_width",
744 MM_ATTRS_VALID_TYPE_INT_RANGE,
749 "wl_window_render_height",
753 MM_ATTRS_VALID_TYPE_INT_RANGE,
759 "display_overlay_user_data",
763 MM_ATTRS_VALID_TYPE_NONE,
768 "display_surface_type",
771 (void *) MM_DISPLAY_SURFACE_NULL,
772 MM_ATTRS_VALID_TYPE_INT_RANGE,
773 MM_DISPLAY_SURFACE_X,
774 MM_DISPLAY_SURFACE_NUM - 1
777 "display_evas_surface_sink",
778 MM_ATTRS_TYPE_STRING,
779 MM_ATTRS_FLAG_READABLE,
780 (void *) player->ini.videosink_element_evas,
781 MM_ATTRS_VALID_TYPE_NONE,
786 "display_force_aspect_ration",
790 MM_ATTRS_VALID_TYPE_INT_RANGE,
795 "display_width", // dest width of fimcconvert ouput
799 MM_ATTRS_VALID_TYPE_INT_RANGE,
804 "display_height", // dest height of fimcconvert ouput
808 MM_ATTRS_VALID_TYPE_INT_RANGE,
813 "display_evas_do_scaling",
817 MM_ATTRS_VALID_TYPE_INT_RANGE,
826 MM_ATTRS_VALID_TYPE_INT_RANGE,
835 MM_ATTRS_VALID_TYPE_INT_RANGE,
843 (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
844 MM_ATTRS_VALID_TYPE_INT_RANGE,
850 MM_ATTRS_TYPE_STRING,
853 MM_ATTRS_VALID_TYPE_NONE,
858 "sound_stream_index",
862 MM_ATTRS_VALID_TYPE_INT_RANGE,
870 (void *) MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
871 MM_ATTRS_VALID_TYPE_INT_RANGE,
872 MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
873 MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY
876 "sound_stop_when_unplugged",
880 MM_ATTRS_VALID_TYPE_INT_RANGE,
885 "sound_application_pid",
889 MM_ATTRS_VALID_TYPE_INT_RANGE,
894 "sound_spk_out_only",
898 MM_ATTRS_VALID_TYPE_INT_RANGE,
906 (void *) 0, // 0: normal, 1: high 2: high with sound transition 3: mix with others regardless of priority
907 MM_ATTRS_VALID_TYPE_INT_RANGE,
912 "sound_close_resource",
916 MM_ATTRS_VALID_TYPE_INT_RANGE,
921 "sound_latency_mode",
924 (void *) 1, // 0: low latency, 1: middle latency 2: high latency
925 MM_ATTRS_VALID_TYPE_INT_RANGE,
930 "pcm_extraction", // enable pcm extraction
934 MM_ATTRS_VALID_TYPE_INT_RANGE,
939 "pcm_extraction_samplerate", // set samplerate for pcm extraction
942 (void *) 44100, // hz
943 MM_ATTRS_VALID_TYPE_INT_RANGE,
948 "pcm_extraction_depth", // set depth for pcm extraction
952 MM_ATTRS_VALID_TYPE_INT_RANGE,
957 "pcm_extraction_channels", // set channels for pcm extraction
961 MM_ATTRS_VALID_TYPE_INT_RANGE,
966 "pcm_extraction_start_msec", // set start position to extract pcm
970 MM_ATTRS_VALID_TYPE_INT_RANGE,
975 "pcm_extraction_end_msec", // set end position to extract pcm
979 MM_ATTRS_VALID_TYPE_INT_RANGE,
984 "profile_smooth_repeat",
988 MM_ATTRS_VALID_TYPE_INT_RANGE,
993 "profile_progress_interval", // will be deprecated
997 MM_ATTRS_VALID_TYPE_INT_RANGE,
1006 MM_ATTRS_VALID_TYPE_INT_RANGE,
1015 MM_ATTRS_VALID_TYPE_INT_RANGE,
1023 (void *) MM_PLAYER_PD_MODE_NONE,
1024 MM_ATTRS_VALID_TYPE_INT_RANGE,
1025 MM_PLAYER_PD_MODE_NONE,
1026 MM_PLAYER_PD_MODE_URI // not tested yet, because of no fixed scenario
1029 "pd_location", // location of the file to write
1030 MM_ATTRS_TYPE_STRING,
1033 MM_ATTRS_VALID_TYPE_NONE,
1042 MM_ATTRS_VALID_TYPE_INT_RANGE,
1047 "content_video_orientation", // orientation of video content
1048 MM_ATTRS_TYPE_STRING,
1051 MM_ATTRS_VALID_TYPE_NONE,
1057 MM_ATTRS_TYPE_STRING,
1060 MM_ATTRS_VALID_TYPE_NONE,
1066 MM_ATTRS_TYPE_STRING,
1069 MM_ATTRS_VALID_TYPE_NONE,
1074 "display_surface_client_type",
1077 (void *) MM_DISPLAY_SURFACE_NULL,
1078 MM_ATTRS_VALID_TYPE_INT_RANGE,
1079 MM_DISPLAY_SURFACE_X,
1080 MM_DISPLAY_SURFACE_NUM - 1
1084 num_of_attrs = ARRAY_SIZE(player_attrs);
1086 base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
1090 debug_error("failed to alloc attrs constructor");
1094 /* initialize values of attributes */
1095 for ( idx = 0; idx < num_of_attrs; idx++ )
1097 base[idx].name = player_attrs[idx].name;
1098 base[idx].value_type = player_attrs[idx].value_type;
1099 base[idx].flags = player_attrs[idx].flags;
1100 base[idx].default_value = player_attrs[idx].default_value;
1103 attrs = mmf_attrs_new_from_data(
1111 MMPLAYER_FREEIF(base);
1115 debug_error("failed to create player attrs");
1119 /* set validity type and range */
1120 for ( idx = 0; idx < num_of_attrs; idx++ )
1122 switch ( player_attrs[idx].valid_type)
1124 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1126 mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
1127 mmf_attrs_set_valid_range (attrs, idx,
1128 player_attrs[idx].value_min,
1129 player_attrs[idx].value_max,
1130 (int)(intptr_t)(player_attrs[idx].default_value));
1134 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1135 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1136 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1143 /* set proxy and user agent */
1144 system_ua = vconf_get_str(VCONFKEY_ADMIN_UAGENT);
1145 system_proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
1149 mm_attrs_set_string_by_name(attrs, "streaming_user_agent", system_ua);
1156 mm_attrs_set_string_by_name(attrs, "streaming_proxy", system_proxy);
1157 g_free(system_proxy);
1161 mmf_attrs_commit(attrs);
1167 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1169 mm_player_t *player = MM_PLAYER_CAST(handle);
1171 return_val_if_fail ( player, FALSE );
1175 mmf_attrs_free (player->attrs);