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>, YoungHwan An <younghwan_.an@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 /*===========================================================================================
26 ========================================================================================== */
28 #include <mm_attrs_private.h>
30 #ifndef GST_API_VERSION_1
31 #include <gst/interfaces/xoverlay.h>
33 #include <gst/video/videooverlay.h>
35 #include "mm_player_priv.h"
36 #include "mm_player_attrs.h"
38 /*===========================================================================================
40 | LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE |
42 ========================================================================================== */
49 int valid_type; // validity type
50 int value_min; //<- set validity value range
54 /*---------------------------------------------------------------------------
55 | LOCAL FUNCTION PROTOTYPES: |
56 ---------------------------------------------------------------------------*/
58 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name);
60 /*===========================================================================================
62 | FUNCTION DEFINITIONS |
64 ========================================================================================== */
67 _mmplayer_get_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
69 int result = MM_ERROR_NONE;
70 MMHandleType attrs = 0;
74 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
75 /* if it's not want to know it. */
76 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
77 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
79 attrs = MM_PLAYER_GET_ATTRS(handle);
81 result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
83 if ( result != MM_ERROR_NONE)
84 debug_error("failed to get %s attribute\n", attribute_name);
92 _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
94 int result = MM_ERROR_NONE;
95 MMHandleType attrs = 0;
99 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
100 /* if it's not want to know it. */
101 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
102 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
104 attrs = MM_PLAYER_GET_ATTRS(handle);
106 /* set attributes and commit them */
107 result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
109 if (result != MM_ERROR_NONE)
111 debug_error("failed to set %s attribute\n", attribute_name);
115 result = __mmplayer_apply_attribute(handle, attribute_name);
116 if (result != MM_ERROR_NONE)
118 debug_error("failed to apply attributes\n");
128 _mmplayer_get_attributes_info(MMHandleType handle, const char *attribute_name, MMPlayerAttrsInfo *dst_info)
130 int result = MM_ERROR_NONE;
131 MMHandleType attrs = 0;
132 MMAttrsInfo src_info = {0, };
136 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
137 return_val_if_fail(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
138 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
140 attrs = MM_PLAYER_GET_ATTRS(handle);
142 result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
144 if ( result != MM_ERROR_NONE)
146 debug_error("failed to get attribute info\n");
150 memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
152 dst_info->type = src_info.type;
153 dst_info->flag = src_info.flag;
154 dst_info->validity_type= src_info.validity_type;
156 switch(src_info.validity_type)
158 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
159 dst_info->int_array.array = src_info.int_array.array;
160 dst_info->int_array.count = src_info.int_array.count;
161 dst_info->int_array.d_val = src_info.int_array.dval;
164 case MM_ATTRS_VALID_TYPE_INT_RANGE:
165 dst_info->int_range.min = src_info.int_range.min;
166 dst_info->int_range.max = src_info.int_range.max;
167 dst_info->int_range.d_val = src_info.int_range.dval;
170 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
171 dst_info->double_array.array = src_info.double_array.array;
172 dst_info->double_array.count = src_info.double_array.count;
173 dst_info->double_array.d_val = src_info.double_array.dval;
176 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
177 dst_info->double_range.min = src_info.double_range.min;
178 dst_info->double_range.max = src_info.double_range.max;
179 dst_info->double_range.d_val = src_info.double_range.dval;
192 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
194 MMHandleType attrs = 0;
195 mm_player_t* player = 0;
199 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
200 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
202 attrs = MM_PLAYER_GET_ATTRS(handle);
203 player = MM_PLAYER_CAST(handle);
205 if ( g_strrstr(attribute_name, "display") )
207 /* check videosink element is created */
208 if ( !player->pipeline ||
209 !player->pipeline->videobin ||
210 !player->pipeline->videobin[MMPLAYER_V_SINK].gst )
213 * The attribute should be committed even though videobin is not created yet.
214 * So, true should be returned here.
215 * Otherwise, video can be diaplayed abnormal.
217 return MM_ERROR_NONE;
220 if ( MM_ERROR_NONE != _mmplayer_update_video_param( player ) )
222 debug_error("failed to update video param");
223 return MM_ERROR_PLAYER_INTERNAL;
229 return MM_ERROR_NONE;
233 _mmplayer_construct_attribute(MMHandleType handle)
236 MMHandleType attrs = 0;
237 int num_of_attrs = 0;
238 mmf_attrs_construct_info_t *base = NULL;
239 gchar *system_ua = NULL;
240 gchar *system_proxy = NULL;
244 return_val_if_fail (handle, 0);
246 MMPlayerAttrsSpec player_attrs[] =
249 "profile_uri", // name
250 MM_ATTRS_TYPE_STRING, // type
251 MM_ATTRS_FLAG_RW, // flag
252 (void *) NULL, // default value
253 MM_ATTRS_VALID_TYPE_NONE, // validity type
254 0, // validity min value
255 0 // validity max value
258 "profile_user_param",
262 MM_ATTRS_VALID_TYPE_NONE,
267 "profile_play_count",
270 (void *) 1, // -1 : repeat continually
271 MM_ATTRS_VALID_TYPE_INT_RANGE,
276 "profile_prepare_async",
280 MM_ATTRS_VALID_TYPE_INT_RANGE,
284 { /* update registry for downloadable codec */
285 "profile_update_registry",
289 MM_ATTRS_VALID_TYPE_INT_RANGE,
297 (void *) STREAMING_SERVICE_NONE,
298 MM_ATTRS_VALID_TYPE_INT_RANGE,
299 STREAMING_SERVICE_VOD,
300 STREAMING_SERVICE_NUM
303 "streaming_udp_timeout",
307 MM_ATTRS_VALID_TYPE_INT_RANGE,
312 "streaming_user_agent",
313 MM_ATTRS_TYPE_STRING,
316 MM_ATTRS_VALID_TYPE_NONE,
321 "streaming_wap_profile",
322 MM_ATTRS_TYPE_STRING,
325 MM_ATTRS_VALID_TYPE_NONE,
330 "streaming_network_bandwidth",
334 MM_ATTRS_VALID_TYPE_INT_RANGE,
340 MM_ATTRS_TYPE_STRING,
343 MM_ATTRS_VALID_TYPE_NONE,
349 MM_ATTRS_TYPE_STRING,
352 MM_ATTRS_VALID_TYPE_NONE,
358 MM_ATTRS_TYPE_STRING,
361 MM_ATTRS_VALID_TYPE_NONE,
370 MM_ATTRS_VALID_TYPE_INT_RANGE,
379 MM_ATTRS_VALID_TYPE_INT_RANGE,
384 "content_max_bitrate",
388 MM_ATTRS_VALID_TYPE_INT_RANGE,
393 "content_video_found",
397 MM_ATTRS_VALID_TYPE_INT_RANGE,
402 "content_video_codec",
403 MM_ATTRS_TYPE_STRING,
406 MM_ATTRS_VALID_TYPE_NONE,
411 "content_video_bitrate",
415 MM_ATTRS_VALID_TYPE_INT_RANGE,
424 MM_ATTRS_VALID_TYPE_INT_RANGE,
429 "content_video_width",
433 MM_ATTRS_VALID_TYPE_INT_RANGE,
438 "content_video_height",
442 MM_ATTRS_VALID_TYPE_INT_RANGE,
447 "content_video_track_num",
451 MM_ATTRS_VALID_TYPE_INT_RANGE,
456 "content_audio_found",
460 MM_ATTRS_VALID_TYPE_INT_RANGE,
465 "content_audio_codec",
466 MM_ATTRS_TYPE_STRING,
469 MM_ATTRS_VALID_TYPE_NONE,
474 "content_audio_bitrate",
478 MM_ATTRS_VALID_TYPE_INT_RANGE,
483 "content_audio_channels",
487 MM_ATTRS_VALID_TYPE_INT_RANGE,
492 "content_audio_samplerate",
496 MM_ATTRS_VALID_TYPE_INT_RANGE,
501 "content_audio_track_num",
505 MM_ATTRS_VALID_TYPE_INT_RANGE,
510 "content_audio_format",
514 MM_ATTRS_VALID_TYPE_INT_RANGE,
520 MM_ATTRS_TYPE_STRING,
523 MM_ATTRS_VALID_TYPE_NONE,
529 MM_ATTRS_TYPE_STRING,
532 MM_ATTRS_VALID_TYPE_NONE,
538 MM_ATTRS_TYPE_STRING,
544 MM_ATTRS_TYPE_STRING,
547 MM_ATTRS_VALID_TYPE_NONE,
553 MM_ATTRS_TYPE_STRING,
556 MM_ATTRS_VALID_TYPE_NONE,
562 MM_ATTRS_TYPE_STRING,
565 MM_ATTRS_VALID_TYPE_NONE,
571 MM_ATTRS_TYPE_STRING,
574 MM_ATTRS_VALID_TYPE_NONE,
580 MM_ATTRS_TYPE_STRING,
583 MM_ATTRS_VALID_TYPE_NONE,
592 MM_ATTRS_VALID_TYPE_INT_RANGE,
601 MM_ATTRS_VALID_TYPE_NONE,
610 MM_ATTRS_VALID_TYPE_INT_RANGE,
619 MM_ATTRS_VALID_TYPE_INT_RANGE,
628 MM_ATTRS_VALID_TYPE_INT_RANGE,
633 "display_roi_height",
637 MM_ATTRS_VALID_TYPE_INT_RANGE,
645 (void *) MM_DISPLAY_ROTATION_NONE,
646 MM_ATTRS_VALID_TYPE_INT_RANGE,
647 MM_DISPLAY_ROTATION_NONE,
648 MM_DISPLAY_ROTATION_270
655 MM_ATTRS_VALID_TYPE_INT_RANGE,
663 (void *) MM_DISPLAY_METHOD_LETTER_BOX,
664 MM_ATTRS_VALID_TYPE_INT_RANGE,
665 MM_DISPLAY_METHOD_LETTER_BOX,
666 MM_DISPLAY_METHOD_CUSTOM_ROI
673 MM_ATTRS_VALID_TYPE_NONE,
678 "display_overlay_user_data",
682 MM_ATTRS_VALID_TYPE_NONE,
691 MM_ATTRS_VALID_TYPE_INT_RANGE,
696 "display_surface_type",
699 (void *) MM_DISPLAY_SURFACE_NULL,
700 MM_ATTRS_VALID_TYPE_INT_RANGE,
701 MM_DISPLAY_SURFACE_X,
702 MM_DISPLAY_SURFACE_X_EXT
705 "display_evas_surface_sink",
706 MM_ATTRS_TYPE_STRING,
707 MM_ATTRS_FLAG_READABLE,
708 (void *) PLAYER_INI()->videosink_element_evas,
709 MM_ATTRS_VALID_TYPE_NONE,
714 "display_force_aspect_ration",
718 MM_ATTRS_VALID_TYPE_INT_RANGE,
723 "display_width", // dest width of fimcconvert ouput
727 MM_ATTRS_VALID_TYPE_INT_RANGE,
732 "display_height", // dest height of fimcconvert ouput
736 MM_ATTRS_VALID_TYPE_INT_RANGE,
741 "display_evas_do_scaling",
745 MM_ATTRS_VALID_TYPE_INT_RANGE,
754 MM_ATTRS_VALID_TYPE_INT_RANGE,
763 MM_ATTRS_VALID_TYPE_INT_RANGE,
771 (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
772 MM_ATTRS_VALID_TYPE_INT_RANGE,
773 MM_SOUND_VOLUME_TYPE_SYSTEM,
774 MM_SOUND_VOLUME_TYPE_CALL
780 (void *) MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
781 MM_ATTRS_VALID_TYPE_INT_RANGE,
782 MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
783 MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY
786 "sound_stop_when_unplugged",
790 MM_ATTRS_VALID_TYPE_INT_RANGE,
795 "sound_application_pid",
799 MM_ATTRS_VALID_TYPE_INT_RANGE,
804 "sound_spk_out_only",
808 MM_ATTRS_VALID_TYPE_INT_RANGE,
816 (void *) 0, // 0: normal, 1: high 2: high with sound transition
817 MM_ATTRS_VALID_TYPE_INT_RANGE,
822 "audio_latency_mode",
825 (void *) 1, // 0: low latency, 1: middle latency 2: high latency
826 MM_ATTRS_VALID_TYPE_INT_RANGE,
831 "pcm_extraction", // enable pcm extraction
835 MM_ATTRS_VALID_TYPE_INT_RANGE,
840 "pcm_extraction_samplerate", // set samplerate for pcm extraction
844 MM_ATTRS_VALID_TYPE_INT_RANGE,
849 "pcm_extraction_depth", // set depth for pcm extraction
853 MM_ATTRS_VALID_TYPE_INT_RANGE,
858 "pcm_extraction_channels", // set channels for pcm extraction
862 MM_ATTRS_VALID_TYPE_INT_RANGE,
867 "pcm_extraction_start_msec", // set start position to extract pcm
871 MM_ATTRS_VALID_TYPE_INT_RANGE,
876 "pcm_extraction_end_msec", // set end position to extract pcm
880 MM_ATTRS_VALID_TYPE_INT_RANGE,
885 "profile_smooth_repeat",
889 MM_ATTRS_VALID_TYPE_INT_RANGE,
894 "profile_progress_interval", // will be deprecated
898 MM_ATTRS_VALID_TYPE_INT_RANGE,
907 MM_ATTRS_VALID_TYPE_INT_RANGE,
916 MM_ATTRS_VALID_TYPE_INT_RANGE,
924 (void *) MM_PLAYER_PD_MODE_NONE,
925 MM_ATTRS_VALID_TYPE_INT_RANGE,
926 MM_PLAYER_PD_MODE_NONE,
927 MM_PLAYER_PD_MODE_URI // not tested yet, because of no fixed scenario
930 "pd_location", // location of the file to write
931 MM_ATTRS_TYPE_STRING,
934 MM_ATTRS_VALID_TYPE_NONE,
940 num_of_attrs = ARRAY_SIZE(player_attrs);
942 base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
946 debug_error("failed to alloc attrs constructor");
950 /* initialize values of attributes */
951 for ( idx = 0; idx < num_of_attrs; idx++ )
953 base[idx].name = player_attrs[idx].name;
954 base[idx].value_type = player_attrs[idx].value_type;
955 base[idx].flags = player_attrs[idx].flags;
956 base[idx].default_value = player_attrs[idx].default_value;
959 attrs = mmf_attrs_new_from_data(
967 MMPLAYER_FREEIF(base);
971 debug_error("failed to create player attrs");
975 /* set validity type and range */
976 for ( idx = 0; idx < num_of_attrs; idx++ )
978 switch ( player_attrs[idx].valid_type)
980 case MM_ATTRS_VALID_TYPE_INT_RANGE:
982 mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
983 mmf_attrs_set_valid_range (attrs, idx,
984 player_attrs[idx].value_min,
985 player_attrs[idx].value_max,
986 player_attrs[idx].default_value);
990 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
991 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
992 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
998 /* set proxy and user agent */
999 system_ua = vconf_get_str(VCONFKEY_ADMIN_UAGENT);
1000 system_proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
1004 mm_attrs_set_string_by_name(attrs, "streaming_user_agent", system_ua);
1010 mm_attrs_set_string_by_name(attrs, "streaming_proxy", system_proxy);
1011 g_free(system_proxy);
1015 mmf_attrs_commit(attrs);
1023 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1027 mm_player_t *player = MM_PLAYER_CAST(handle);
1029 return_val_if_fail ( player, FALSE );
1033 mmf_attrs_free (player->attrs);