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 + 1);
190 LOGE("failed to alloc param_name");
191 return MM_ERROR_PLAYER_INTERNAL;
193 strncpy(param_name, attribute_name, str_len);
194 param_name[str_len] = '\0';
195 LOGD(" param_name: %s", param_name);
196 if (MM_ERROR_NONE != _mmplayer_update_video_param(player, param_name)) {
198 LOGE("failed to update video param");
199 return MM_ERROR_PLAYER_INTERNAL;
204 if (g_strrstr(attribute_name, MM_PLAYER_GAPLESS_MODE)) {
207 mm_attrs_get_int_by_name(player->attrs, "gapless_mode", &gapless);
210 LOGD("disable last-sample at videosink");
211 g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
215 if (g_strrstr(attribute_name, MM_PLAYER_ENABLE_VIDEO_DECODED_CB)) {
216 if (!player->set_mode.media_packet_video_stream) {
217 LOGE("there is no callback for media_packet");
218 return MM_ERROR_PLAYER_INTERNAL;
221 mm_attrs_get_int_by_name(player->attrs, "enable_video_decoded_cb", &enable);
222 g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "signal-handoffs", enable ? TRUE : FALSE, NULL);
225 return MM_ERROR_NONE;
229 _mmplayer_construct_attribute(MMHandleType handle)
232 MMHandleType attrs = 0;
233 int num_of_attrs = 0;
234 mmf_attrs_construct_info_t *base = NULL;
236 MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
238 MMPlayerAttrsSpec player_attrs[] = {
240 "profile_uri", // name
241 MM_ATTRS_TYPE_STRING, // type
242 MM_ATTRS_FLAG_RW, // flag
243 (void *) NULL, // default value
244 MM_ATTRS_VALID_TYPE_NONE, // validity type
245 0, // validity min value
246 0 // validity max value
249 "profile_user_param",
253 MM_ATTRS_VALID_TYPE_NONE,
258 "profile_play_count",
261 (void *) 1, // -1 : repeat continually
262 MM_ATTRS_VALID_TYPE_INT_RANGE,
267 "profile_prepare_async",
271 MM_ATTRS_VALID_TYPE_INT_RANGE,
275 { /* update registry for downloadable codec */
276 "profile_update_registry",
280 MM_ATTRS_VALID_TYPE_INT_RANGE,
288 (void *) STREAMING_SERVICE_NONE,
289 MM_ATTRS_VALID_TYPE_INT_RANGE,
290 STREAMING_SERVICE_VOD,
291 STREAMING_SERVICE_NUM
294 "streaming_udp_timeout",
298 MM_ATTRS_VALID_TYPE_INT_RANGE,
303 "streaming_user_agent",
304 MM_ATTRS_TYPE_STRING,
307 MM_ATTRS_VALID_TYPE_NONE,
312 "streaming_wap_profile",
313 MM_ATTRS_TYPE_STRING,
316 MM_ATTRS_VALID_TYPE_NONE,
321 "streaming_network_bandwidth",
325 MM_ATTRS_VALID_TYPE_INT_RANGE,
331 MM_ATTRS_TYPE_STRING,
334 MM_ATTRS_VALID_TYPE_NONE,
340 MM_ATTRS_TYPE_STRING,
343 MM_ATTRS_VALID_TYPE_NONE,
351 (void *) -1, // DEFAULT_HTTP_TIMEOUT
352 MM_ATTRS_VALID_TYPE_INT_RANGE,
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,
519 "content_text_track_num",
523 MM_ATTRS_VALID_TYPE_INT_RANGE,
529 MM_ATTRS_TYPE_STRING,
532 MM_ATTRS_VALID_TYPE_NONE,
538 MM_ATTRS_TYPE_STRING,
541 MM_ATTRS_VALID_TYPE_NONE,
547 MM_ATTRS_TYPE_STRING,
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,
589 MM_ATTRS_TYPE_STRING,
592 MM_ATTRS_VALID_TYPE_NONE,
601 MM_ATTRS_VALID_TYPE_INT_RANGE,
610 MM_ATTRS_VALID_TYPE_NONE,
615 "display_src_crop_x",
619 MM_ATTRS_VALID_TYPE_INT_RANGE,
624 "display_src_crop_y",
628 MM_ATTRS_VALID_TYPE_INT_RANGE,
633 "display_src_crop_width",
637 MM_ATTRS_VALID_TYPE_INT_RANGE,
642 "display_src_crop_height",
646 MM_ATTRS_VALID_TYPE_INT_RANGE,
655 MM_ATTRS_VALID_TYPE_INT_RANGE,
664 MM_ATTRS_VALID_TYPE_INT_RANGE,
673 MM_ATTRS_VALID_TYPE_INT_RANGE,
678 "display_roi_height",
682 MM_ATTRS_VALID_TYPE_INT_RANGE,
690 (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
691 MM_ATTRS_VALID_TYPE_INT_RANGE,
692 MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
693 MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX
699 (void *) MM_DISPLAY_ROTATION_NONE,
700 MM_ATTRS_VALID_TYPE_INT_RANGE,
701 MM_DISPLAY_ROTATION_NONE,
702 MM_DISPLAY_ROTATION_270
709 MM_ATTRS_VALID_TYPE_INT_RANGE,
717 (void *) MM_DISPLAY_METHOD_LETTER_BOX,
718 MM_ATTRS_VALID_TYPE_INT_RANGE,
719 MM_DISPLAY_METHOD_LETTER_BOX,
720 MM_DISPLAY_METHOD_CUSTOM_ROI
727 MM_ATTRS_VALID_TYPE_NONE,
736 MM_ATTRS_VALID_TYPE_NONE,
741 "wl_window_render_x",
745 MM_ATTRS_VALID_TYPE_INT_RANGE,
750 "wl_window_render_y",
754 MM_ATTRS_VALID_TYPE_INT_RANGE,
759 "wl_window_render_width",
763 MM_ATTRS_VALID_TYPE_INT_RANGE,
768 "wl_window_render_height",
772 MM_ATTRS_VALID_TYPE_INT_RANGE,
777 "display_overlay_user_data",
781 MM_ATTRS_VALID_TYPE_NONE,
786 "display_surface_type",
789 (void *) MM_DISPLAY_SURFACE_NULL,
790 MM_ATTRS_VALID_TYPE_INT_RANGE,
791 MM_DISPLAY_SURFACE_OVERLAY,
792 MM_DISPLAY_SURFACE_NUM - 1
795 "display_force_aspect_ration",
799 MM_ATTRS_VALID_TYPE_INT_RANGE,
804 "display_width", // dest width of fimcconvert ouput
808 MM_ATTRS_VALID_TYPE_INT_RANGE,
813 "display_height", // dest height of fimcconvert ouput
817 MM_ATTRS_VALID_TYPE_INT_RANGE,
822 "display_evas_do_scaling",
826 MM_ATTRS_VALID_TYPE_INT_RANGE,
835 MM_ATTRS_VALID_TYPE_INT_RANGE,
844 MM_ATTRS_VALID_TYPE_INT_RANGE,
852 (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
853 MM_ATTRS_VALID_TYPE_INT_RANGE,
859 MM_ATTRS_TYPE_STRING,
862 MM_ATTRS_VALID_TYPE_NONE,
867 "sound_stream_index",
871 MM_ATTRS_VALID_TYPE_INT_RANGE,
879 (void *) MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
880 MM_ATTRS_VALID_TYPE_INT_RANGE,
881 MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
882 MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY
885 "sound_stop_when_unplugged",
889 MM_ATTRS_VALID_TYPE_INT_RANGE,
894 "sound_application_pid",
898 MM_ATTRS_VALID_TYPE_INT_RANGE,
903 "sound_spk_out_only",
907 MM_ATTRS_VALID_TYPE_INT_RANGE,
915 (void *) 0, // 0: normal, 1: high 2: high with sound transition 3: mix with others regardless of priority
916 MM_ATTRS_VALID_TYPE_INT_RANGE,
921 "sound_close_resource",
925 MM_ATTRS_VALID_TYPE_INT_RANGE,
930 "sound_latency_mode",
933 (void *) 1, // 0: low latency, 1: middle latency 2: high latency
934 MM_ATTRS_VALID_TYPE_INT_RANGE,
939 "pcm_extraction", // enable pcm extraction
943 MM_ATTRS_VALID_TYPE_INT_RANGE,
948 "pcm_extraction_samplerate", // set samplerate for pcm extraction
951 (void *) 44100, // hz
952 MM_ATTRS_VALID_TYPE_INT_RANGE,
957 "pcm_extraction_depth", // set depth for pcm extraction
961 MM_ATTRS_VALID_TYPE_INT_RANGE,
966 "pcm_extraction_channels", // set channels for pcm extraction
970 MM_ATTRS_VALID_TYPE_INT_RANGE,
975 "pcm_extraction_start_msec", // set start position to extract pcm
979 MM_ATTRS_VALID_TYPE_INT_RANGE,
984 "pcm_extraction_end_msec", // set end position to extract pcm
988 MM_ATTRS_VALID_TYPE_INT_RANGE,
993 "profile_smooth_repeat",
997 MM_ATTRS_VALID_TYPE_INT_RANGE,
1002 "profile_progress_interval", // will be deprecated
1006 MM_ATTRS_VALID_TYPE_INT_RANGE,
1015 MM_ATTRS_VALID_TYPE_INT_RANGE,
1024 MM_ATTRS_VALID_TYPE_INT_RANGE,
1032 (void *) MM_PLAYER_PD_MODE_NONE,
1033 MM_ATTRS_VALID_TYPE_INT_RANGE,
1034 MM_PLAYER_PD_MODE_NONE,
1035 MM_PLAYER_PD_MODE_URI // not tested yet, because of no fixed scenario
1038 "pd_location", // location of the file to write
1039 MM_ATTRS_TYPE_STRING,
1042 MM_ATTRS_VALID_TYPE_NONE,
1051 MM_ATTRS_VALID_TYPE_INT_RANGE,
1056 "content_video_orientation", // orientation of video content
1057 MM_ATTRS_TYPE_STRING,
1060 MM_ATTRS_VALID_TYPE_NONE,
1066 MM_ATTRS_TYPE_STRING,
1069 MM_ATTRS_VALID_TYPE_NONE,
1078 MM_ATTRS_VALID_TYPE_INT_RANGE,
1087 MM_ATTRS_VALID_TYPE_INT_RANGE,
1092 "enable_video_decoded_cb",
1096 MM_ATTRS_VALID_TYPE_INT_RANGE,
1102 num_of_attrs = ARRAY_SIZE(player_attrs);
1104 base = (mmf_attrs_construct_info_t*)malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
1107 LOGE("failed to alloc attrs constructor");
1111 /* initialize values of attributes */
1112 for (idx = 0; idx < num_of_attrs; idx++) {
1113 base[idx].name = player_attrs[idx].name;
1114 base[idx].value_type = player_attrs[idx].value_type;
1115 base[idx].flags = player_attrs[idx].flags;
1116 base[idx].default_value = player_attrs[idx].default_value;
1119 attrs = mmf_attrs_new_from_data(
1127 MMPLAYER_FREEIF(base);
1130 LOGE("failed to create player attrs");
1134 /* set validity type and range */
1135 for (idx = 0; idx < num_of_attrs; idx++) {
1136 switch (player_attrs[idx].valid_type) {
1137 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1139 mmf_attrs_set_valid_type(attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
1140 mmf_attrs_set_valid_range(attrs, idx,
1141 player_attrs[idx].value_min,
1142 player_attrs[idx].value_max,
1143 (int)(intptr_t)(player_attrs[idx].default_value));
1147 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1148 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1149 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1156 mmf_attrs_commit(attrs);
1162 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1164 mm_player_t *player = MM_PLAYER_CAST(handle);
1166 MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
1168 if (player->attrs) {
1169 mmf_attrs_free(player->attrs);