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 "mm_player_utils.h"
32 #include "mm_player_priv.h"
33 #include "mm_player_attrs.h"
35 /*===========================================================================================
37 | LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE |
39 ========================================================================================== */
41 /*---------------------------------------------------------------------------
42 | LOCAL FUNCTION PROTOTYPES: |
43 ---------------------------------------------------------------------------*/
45 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name);
47 /*===========================================================================================
49 | FUNCTION DEFINITIONS |
51 ========================================================================================== */
54 _mmplayer_get_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
56 int result = MM_ERROR_NONE;
57 MMHandleType attrs = 0;
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);
64 attrs = MM_PLAYER_GET_ATTRS(handle);
66 result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
68 if (result != MM_ERROR_NONE)
69 LOGE("failed to get %s attribute\n", attribute_name);
75 _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
77 int result = MM_ERROR_NONE;
78 MMHandleType attrs = 0;
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);
85 attrs = MM_PLAYER_GET_ATTRS(handle);
87 /* set attributes and commit them */
88 result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
90 if (result != MM_ERROR_NONE) {
91 LOGE("failed to set %s attribute\n", attribute_name);
95 result = __mmplayer_apply_attribute(handle, attribute_name);
96 if (result != MM_ERROR_NONE) {
97 LOGE("failed to apply attributes\n");
105 _mmplayer_get_attributes_info(MMHandleType handle, const char *attribute_name, MMPlayerAttrsInfo *dst_info)
107 int result = MM_ERROR_NONE;
108 MMHandleType attrs = 0;
109 MMAttrsInfo src_info = {0, };
111 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
112 MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
113 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
115 attrs = MM_PLAYER_GET_ATTRS(handle);
117 result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
119 if (result != MM_ERROR_NONE) {
120 LOGE("failed to get attribute info\n");
124 memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
126 dst_info->type = src_info.type;
127 dst_info->flag = src_info.flag;
128 dst_info->validity_type = src_info.validity_type;
130 switch (src_info.validity_type) {
131 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
132 dst_info->int_array.array = src_info.int_array.array;
133 dst_info->int_array.count = src_info.int_array.count;
134 dst_info->int_array.d_val = src_info.int_array.dval;
137 case MM_ATTRS_VALID_TYPE_INT_RANGE:
138 dst_info->int_range.min = src_info.int_range.min;
139 dst_info->int_range.max = src_info.int_range.max;
140 dst_info->int_range.d_val = src_info.int_range.dval;
143 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
144 dst_info->double_array.array = src_info.double_array.array;
145 dst_info->double_array.count = src_info.double_array.count;
146 dst_info->double_array.d_val = src_info.double_array.dval;
149 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
150 dst_info->double_range.min = src_info.double_range.min;
151 dst_info->double_range.max = src_info.double_range.max;
152 dst_info->double_range.d_val = src_info.double_range.dval;
163 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
165 mm_player_t* player = 0;
167 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
168 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
170 player = MM_PLAYER_CAST(handle);
171 MMPlayerGstPipelineInfo *pipeline = player->pipeline;
173 /* Currently, there are only display related implementation at below */
175 !pipeline->videobin ||
176 !pipeline->videobin[MMPLAYER_V_SINK].gst) {
178 * The attribute should be committed even though videobin is not created yet.
179 * So, true should be returned here.
180 * Otherwise, video can be diaplayed abnormal.
182 return MM_ERROR_NONE;
185 if (g_strrstr(attribute_name, "display") || g_strrstr(attribute_name, "wl_window_render_x")) {
186 char *param_name = NULL;
187 int str_len = strlen(attribute_name);
188 param_name = g_malloc0(str_len);
190 LOGE("failed to alloc param_name");
191 return MM_ERROR_PLAYER_INTERNAL;
193 strncpy(param_name, attribute_name, str_len);
194 LOGD(" param_name: %s", param_name);
195 if (MM_ERROR_NONE != _mmplayer_update_video_param(player, param_name)) {
197 LOGE("failed to update video param");
198 return MM_ERROR_PLAYER_INTERNAL;
203 if (g_strrstr(attribute_name, MM_PLAYER_GAPLESS_MODE)) {
206 mm_attrs_get_int_by_name(player->attrs, "gapless_mode", &gapless);
209 LOGD("disable last-sample at videosink");
210 g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
214 return MM_ERROR_NONE;
218 _mmplayer_construct_attribute(MMHandleType handle)
220 mm_player_t *player = NULL;
222 MMHandleType attrs = 0;
223 int num_of_attrs = 0;
224 mmf_attrs_construct_info_t *base = NULL;
226 MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
228 player = MM_PLAYER_CAST(handle);
230 MMPlayerAttrsSpec player_attrs[] = {
232 "profile_uri", // name
233 MM_ATTRS_TYPE_STRING, // type
234 MM_ATTRS_FLAG_RW, // flag
235 (void *) NULL, // default value
236 MM_ATTRS_VALID_TYPE_NONE, // validity type
237 0, // validity min value
238 0 // validity max value
241 "profile_user_param",
245 MM_ATTRS_VALID_TYPE_NONE,
250 "profile_play_count",
253 (void *) 1, // -1 : repeat continually
254 MM_ATTRS_VALID_TYPE_INT_RANGE,
259 "profile_prepare_async",
263 MM_ATTRS_VALID_TYPE_INT_RANGE,
267 { /* update registry for downloadable codec */
268 "profile_update_registry",
272 MM_ATTRS_VALID_TYPE_INT_RANGE,
280 (void *) STREAMING_SERVICE_NONE,
281 MM_ATTRS_VALID_TYPE_INT_RANGE,
282 STREAMING_SERVICE_VOD,
283 STREAMING_SERVICE_NUM
286 "streaming_udp_timeout",
290 MM_ATTRS_VALID_TYPE_INT_RANGE,
295 "streaming_user_agent",
296 MM_ATTRS_TYPE_STRING,
299 MM_ATTRS_VALID_TYPE_NONE,
304 "streaming_wap_profile",
305 MM_ATTRS_TYPE_STRING,
308 MM_ATTRS_VALID_TYPE_NONE,
313 "streaming_network_bandwidth",
317 MM_ATTRS_VALID_TYPE_INT_RANGE,
323 MM_ATTRS_TYPE_STRING,
326 MM_ATTRS_VALID_TYPE_NONE,
332 MM_ATTRS_TYPE_STRING,
335 MM_ATTRS_VALID_TYPE_NONE,
343 (void *) -1, // DEFAULT_HTTP_TIMEOUT
344 MM_ATTRS_VALID_TYPE_INT_RANGE,
350 MM_ATTRS_TYPE_STRING,
353 MM_ATTRS_VALID_TYPE_NONE,
362 MM_ATTRS_VALID_TYPE_INT_RANGE,
371 MM_ATTRS_VALID_TYPE_INT_RANGE,
376 "content_max_bitrate",
380 MM_ATTRS_VALID_TYPE_INT_RANGE,
385 "content_video_found",
389 MM_ATTRS_VALID_TYPE_INT_RANGE,
394 "content_video_codec",
395 MM_ATTRS_TYPE_STRING,
398 MM_ATTRS_VALID_TYPE_NONE,
403 "content_video_bitrate",
407 MM_ATTRS_VALID_TYPE_INT_RANGE,
416 MM_ATTRS_VALID_TYPE_INT_RANGE,
421 "content_video_width",
425 MM_ATTRS_VALID_TYPE_INT_RANGE,
430 "content_video_height",
434 MM_ATTRS_VALID_TYPE_INT_RANGE,
439 "content_video_track_num",
443 MM_ATTRS_VALID_TYPE_INT_RANGE,
448 "content_audio_found",
452 MM_ATTRS_VALID_TYPE_INT_RANGE,
457 "content_audio_codec",
458 MM_ATTRS_TYPE_STRING,
461 MM_ATTRS_VALID_TYPE_NONE,
466 "content_audio_bitrate",
470 MM_ATTRS_VALID_TYPE_INT_RANGE,
475 "content_audio_channels",
479 MM_ATTRS_VALID_TYPE_INT_RANGE,
484 "content_audio_samplerate",
488 MM_ATTRS_VALID_TYPE_INT_RANGE,
493 "content_audio_track_num",
497 MM_ATTRS_VALID_TYPE_INT_RANGE,
502 "content_audio_format",
506 MM_ATTRS_VALID_TYPE_INT_RANGE,
511 "content_text_track_num",
515 MM_ATTRS_VALID_TYPE_INT_RANGE,
521 MM_ATTRS_TYPE_STRING,
524 MM_ATTRS_VALID_TYPE_NONE,
530 MM_ATTRS_TYPE_STRING,
533 MM_ATTRS_VALID_TYPE_NONE,
539 MM_ATTRS_TYPE_STRING,
545 MM_ATTRS_TYPE_STRING,
548 MM_ATTRS_VALID_TYPE_NONE,
554 MM_ATTRS_TYPE_STRING,
557 MM_ATTRS_VALID_TYPE_NONE,
563 MM_ATTRS_TYPE_STRING,
566 MM_ATTRS_VALID_TYPE_NONE,
572 MM_ATTRS_TYPE_STRING,
575 MM_ATTRS_VALID_TYPE_NONE,
581 MM_ATTRS_TYPE_STRING,
584 MM_ATTRS_VALID_TYPE_NONE,
593 MM_ATTRS_VALID_TYPE_INT_RANGE,
602 MM_ATTRS_VALID_TYPE_NONE,
607 "display_src_crop_x",
611 MM_ATTRS_VALID_TYPE_INT_RANGE,
616 "display_src_crop_y",
620 MM_ATTRS_VALID_TYPE_INT_RANGE,
625 "display_src_crop_width",
629 MM_ATTRS_VALID_TYPE_INT_RANGE,
634 "display_src_crop_height",
638 MM_ATTRS_VALID_TYPE_INT_RANGE,
647 MM_ATTRS_VALID_TYPE_INT_RANGE,
656 MM_ATTRS_VALID_TYPE_INT_RANGE,
665 MM_ATTRS_VALID_TYPE_INT_RANGE,
670 "display_roi_height",
674 MM_ATTRS_VALID_TYPE_INT_RANGE,
682 (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
683 MM_ATTRS_VALID_TYPE_INT_RANGE,
684 MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
685 MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX
691 (void *) MM_DISPLAY_ROTATION_NONE,
692 MM_ATTRS_VALID_TYPE_INT_RANGE,
693 MM_DISPLAY_ROTATION_NONE,
694 MM_DISPLAY_ROTATION_270
701 MM_ATTRS_VALID_TYPE_INT_RANGE,
709 (void *) MM_DISPLAY_METHOD_LETTER_BOX,
710 MM_ATTRS_VALID_TYPE_INT_RANGE,
711 MM_DISPLAY_METHOD_LETTER_BOX,
712 MM_DISPLAY_METHOD_CUSTOM_ROI
719 MM_ATTRS_VALID_TYPE_NONE,
728 MM_ATTRS_VALID_TYPE_NONE,
733 "wl_window_render_x",
737 MM_ATTRS_VALID_TYPE_INT_RANGE,
742 "wl_window_render_y",
746 MM_ATTRS_VALID_TYPE_INT_RANGE,
751 "wl_window_render_width",
755 MM_ATTRS_VALID_TYPE_INT_RANGE,
760 "wl_window_render_height",
764 MM_ATTRS_VALID_TYPE_INT_RANGE,
773 MM_ATTRS_VALID_TYPE_INT_RANGE,
778 "display_overlay_user_data",
782 MM_ATTRS_VALID_TYPE_NONE,
787 "display_surface_type",
790 (void *) MM_DISPLAY_SURFACE_NULL,
791 MM_ATTRS_VALID_TYPE_INT_RANGE,
792 MM_DISPLAY_SURFACE_OVERLAY,
793 MM_DISPLAY_SURFACE_NUM - 1
796 "display_evas_surface_sink",
797 MM_ATTRS_TYPE_STRING,
798 MM_ATTRS_FLAG_READABLE,
799 (void *) player->ini.videosink_element_evas,
800 MM_ATTRS_VALID_TYPE_NONE,
805 "display_force_aspect_ration",
809 MM_ATTRS_VALID_TYPE_INT_RANGE,
814 "display_width", // dest width of fimcconvert ouput
818 MM_ATTRS_VALID_TYPE_INT_RANGE,
823 "display_height", // dest height of fimcconvert ouput
827 MM_ATTRS_VALID_TYPE_INT_RANGE,
832 "display_evas_do_scaling",
836 MM_ATTRS_VALID_TYPE_INT_RANGE,
845 MM_ATTRS_VALID_TYPE_INT_RANGE,
854 MM_ATTRS_VALID_TYPE_INT_RANGE,
862 (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
863 MM_ATTRS_VALID_TYPE_INT_RANGE,
869 MM_ATTRS_TYPE_STRING,
872 MM_ATTRS_VALID_TYPE_NONE,
877 "sound_stream_index",
881 MM_ATTRS_VALID_TYPE_INT_RANGE,
889 (void *) MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
890 MM_ATTRS_VALID_TYPE_INT_RANGE,
891 MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
892 MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY
895 "sound_stop_when_unplugged",
899 MM_ATTRS_VALID_TYPE_INT_RANGE,
904 "sound_application_pid",
908 MM_ATTRS_VALID_TYPE_INT_RANGE,
913 "sound_spk_out_only",
917 MM_ATTRS_VALID_TYPE_INT_RANGE,
925 (void *) 0, // 0: normal, 1: high 2: high with sound transition 3: mix with others regardless of priority
926 MM_ATTRS_VALID_TYPE_INT_RANGE,
931 "sound_close_resource",
935 MM_ATTRS_VALID_TYPE_INT_RANGE,
940 "sound_latency_mode",
943 (void *) 1, // 0: low latency, 1: middle latency 2: high latency
944 MM_ATTRS_VALID_TYPE_INT_RANGE,
949 "pcm_extraction", // enable pcm extraction
953 MM_ATTRS_VALID_TYPE_INT_RANGE,
958 "pcm_extraction_samplerate", // set samplerate for pcm extraction
961 (void *) 44100, // hz
962 MM_ATTRS_VALID_TYPE_INT_RANGE,
967 "pcm_extraction_depth", // set depth for pcm extraction
971 MM_ATTRS_VALID_TYPE_INT_RANGE,
976 "pcm_extraction_channels", // set channels for pcm extraction
980 MM_ATTRS_VALID_TYPE_INT_RANGE,
985 "pcm_extraction_start_msec", // set start position to extract pcm
989 MM_ATTRS_VALID_TYPE_INT_RANGE,
994 "pcm_extraction_end_msec", // set end position to extract pcm
998 MM_ATTRS_VALID_TYPE_INT_RANGE,
1003 "profile_smooth_repeat",
1007 MM_ATTRS_VALID_TYPE_INT_RANGE,
1012 "profile_progress_interval", // will be deprecated
1016 MM_ATTRS_VALID_TYPE_INT_RANGE,
1025 MM_ATTRS_VALID_TYPE_INT_RANGE,
1034 MM_ATTRS_VALID_TYPE_INT_RANGE,
1042 (void *) MM_PLAYER_PD_MODE_NONE,
1043 MM_ATTRS_VALID_TYPE_INT_RANGE,
1044 MM_PLAYER_PD_MODE_NONE,
1045 MM_PLAYER_PD_MODE_URI // not tested yet, because of no fixed scenario
1048 "pd_location", // location of the file to write
1049 MM_ATTRS_TYPE_STRING,
1052 MM_ATTRS_VALID_TYPE_NONE,
1061 MM_ATTRS_VALID_TYPE_INT_RANGE,
1066 "content_video_orientation", // orientation of video content
1067 MM_ATTRS_TYPE_STRING,
1070 MM_ATTRS_VALID_TYPE_NONE,
1076 MM_ATTRS_TYPE_STRING,
1079 MM_ATTRS_VALID_TYPE_NONE,
1088 MM_ATTRS_VALID_TYPE_INT_RANGE,
1097 MM_ATTRS_VALID_TYPE_INT_RANGE,
1103 num_of_attrs = ARRAY_SIZE(player_attrs);
1105 base = (mmf_attrs_construct_info_t*)malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
1108 LOGE("failed to alloc attrs constructor");
1112 /* initialize values of attributes */
1113 for (idx = 0; idx < num_of_attrs; idx++) {
1114 base[idx].name = player_attrs[idx].name;
1115 base[idx].value_type = player_attrs[idx].value_type;
1116 base[idx].flags = player_attrs[idx].flags;
1117 base[idx].default_value = player_attrs[idx].default_value;
1120 attrs = mmf_attrs_new_from_data(
1128 MMPLAYER_FREEIF(base);
1131 LOGE("failed to create player attrs");
1135 /* set validity type and range */
1136 for (idx = 0; idx < num_of_attrs; idx++) {
1137 switch (player_attrs[idx].valid_type) {
1138 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1140 mmf_attrs_set_valid_type(attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
1141 mmf_attrs_set_valid_range(attrs, idx,
1142 player_attrs[idx].value_min,
1143 player_attrs[idx].value_max,
1144 (int)(intptr_t)(player_attrs[idx].default_value));
1148 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1149 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1150 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1157 mmf_attrs_commit(attrs);
1163 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1165 mm_player_t *player = MM_PLAYER_CAST(handle);
1167 MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
1169 if (player->attrs) {
1170 mmf_attrs_free(player->attrs);