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 ========================================================================================== */
30 #include "mm_player_utils.h"
31 #include "mm_player_priv.h"
32 #include "mm_player_attrs.h"
34 /*===========================================================================================
36 | LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE |
38 ========================================================================================== */
40 /*-----------------------------------------------------------------------
41 | LOCAL FUNCTION PROTOTYPES: |
42 -----------------------------------------------------------------------*/
43 static bool __mmplayer_commit_gapless_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
44 static bool __mmplayer_commit_enable_video_decoded_cb(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
45 static bool __mmplayer_commit_audio_pitch_value(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
47 /*===========================================================================================
49 | FUNCTION DEFINITIONS |
51 ========================================================================================== */
53 static bool __mmplayer_commit_enable_video_decoded_cb(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
55 mmplayer_t *player = MM_PLAYER_CAST(handle);
56 mmplayer_gst_element_t *videobin = NULL;
59 MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
61 if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
62 LOGD("will be applied when videosink is ready");
66 if (!player->set_mode.video_export) {
67 LOGW("there is no callback for enabling");
71 videobin = player->pipeline->videobin;
73 LOGD("[update plugin][videosink] handoff %d", value->value.i_val);
75 g_object_set(videobin[MMPLAYER_V_SINK].gst,
76 "signal-handoffs", (value->value.i_val) ? TRUE : FALSE, NULL);
81 static bool __mmplayer_commit_gapless_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
83 mmplayer_t *player = MM_PLAYER_CAST(handle);
84 mmplayer_gst_element_t *videobin = NULL;
87 MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
89 if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
90 LOGD("will be applied when videosink is ready");
94 videobin = player->pipeline->videobin;
96 if (value->value.i_val > 0) {
97 LOGD("[update plugin][videosink] disable last sample for gapless");
98 g_object_set(videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
104 static bool __mmplayer_commit_audio_pitch_value(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
106 mmplayer_t *player = MM_PLAYER_CAST(handle);
107 mmplayer_pipeline_info_t *pipeline;
108 int pitch_control = 0;
111 MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
112 MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline && player->pipeline->audiobin, true);
114 pipeline = player->pipeline;
115 mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_PITCH_CONTROL, &pitch_control);
117 if (!pitch_control || !pipeline->audiobin[MMPLAYER_A_PITCH].gst) {
118 LOGW("audio pitch is disabled");
122 LOGD("[update plugin][pitch] value to %1.3f", value->value.d_val);
123 g_object_set(pipeline->audiobin[MMPLAYER_A_PITCH].gst, "pitch", (value->value.d_val), NULL);
128 static int __mmplayer_get_array_count(MMHandleType handle, int type)
130 mmplayer_t *player = MM_PLAYER_CAST(handle);
135 if (type == KEYWORD_A_OFFLOAD_MEDIA_FORMAT) {
136 while (player->ini.audio_offload_media_format[i++][0])
138 } else if (type == KEYWORD_MEDIA_STREAM_IN_FORMAT) {
139 while (player->ini.media_stream_input_format[i++][0])
145 static media_format_mimetype_e __mmplayer_get_supported_format_mimetype(MMHandleType handle, int type, int i)
147 mmplayer_t *player = MM_PLAYER_CAST(handle);
148 media_format_mimetype_e format = MEDIA_FORMAT_MAX;
151 if (type == KEYWORD_A_OFFLOAD_MEDIA_FORMAT) {
152 name = player->ini.audio_offload_media_format[i];
153 } else if (type == KEYWORD_MEDIA_STREAM_IN_FORMAT) {
154 name = player->ini.media_stream_input_format[i];
156 LOGE("invalid ini type");
160 if (!strcmp(name, "MP3"))
161 format = MEDIA_FORMAT_MP3;
162 else if (!strcmp(name, "AAC"))
163 format = MEDIA_FORMAT_AAC;
164 else if (!strcmp(name, "H264_SP"))
165 format = MEDIA_FORMAT_H264_SP;
166 else if (!strcmp(name, "H264_MP"))
167 format = MEDIA_FORMAT_H264_MP;
168 else if (!strcmp(name, "H264_HP"))
169 format = MEDIA_FORMAT_H264_HP;
170 else if (!strcmp(name, "PCM"))
171 format = MEDIA_FORMAT_PCM;
172 else if (!strcmp(name, "PCM_S16LE"))
173 format = MEDIA_FORMAT_PCM_S16LE;
174 else if (!strcmp(name, "PCM_S24LE"))
175 format = MEDIA_FORMAT_PCM_S24LE;
176 else if (!strcmp(name, "PCM_S32LE"))
177 format = MEDIA_FORMAT_PCM_S32LE;
178 else if (!strcmp(name, "PCM_S16BE"))
179 format = MEDIA_FORMAT_PCM_S16BE;
180 else if (!strcmp(name, "PCM_S24BE"))
181 format = MEDIA_FORMAT_PCM_S24BE;
182 else if (!strcmp(name, "PCM_S32BE"))
183 format = MEDIA_FORMAT_PCM_S32BE;
184 else if (!strcmp(name, "PCM_F32LE"))
185 format = MEDIA_FORMAT_PCM_F32LE;
186 else if (!strcmp(name, "PCM_F32BE"))
187 format = MEDIA_FORMAT_PCM_F32BE;
188 else if (!strcmp(name, "PCM_U16LE"))
189 format = MEDIA_FORMAT_PCM_U16LE;
190 else if (!strcmp(name, "PCM_U24LE"))
191 format = MEDIA_FORMAT_PCM_U24LE;
192 else if (!strcmp(name, "PCM_U32LE"))
193 format = MEDIA_FORMAT_PCM_U32LE;
194 else if (!strcmp(name, "PCM_U16BE"))
195 format = MEDIA_FORMAT_PCM_U16BE;
196 else if (!strcmp(name, "PCM_U24BE"))
197 format = MEDIA_FORMAT_PCM_U24BE;
198 else if (!strcmp(name, "PCM_U32BE"))
199 format = MEDIA_FORMAT_PCM_U32BE;
201 LOGE("FIXME: need to modify function to support more format");
204 LOGD("[%d type] supported format 0x%X(%s)", type, format, name);
209 static int __mmplayer_get_available_format(MMHandleType handle, int type, int **format)
217 MMPLAYER_RETURN_VAL_IF_FAIL(handle, -1);
219 count = __mmplayer_get_array_count(handle, type);
224 arr = (int *) g_malloc0(count * sizeof(int));
225 for (i = 0 ; i < count ; i++) {
226 fmt = __mmplayer_get_supported_format_mimetype(handle, type, i);
227 if (fmt != MEDIA_FORMAT_MAX)
228 arr[total_count++] = fmt;
231 if (total_count <= 0) {
236 LOGD("[%d type] num of supported codec %d", type, total_count);
242 static int __mmplayer_set_ini_to_valid_info(MMHandleType handle)
244 mmplayer_t *player = MM_PLAYER_CAST(handle);
248 /* supported format of audio offload */
249 total_count = __mmplayer_get_available_format(handle, KEYWORD_A_OFFLOAD_MEDIA_FORMAT, &format);
250 if (format && total_count > 0) {
251 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = format;
252 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = total_count;
255 /* supported format of media stream input */
256 total_count = __mmplayer_get_available_format(handle, KEYWORD_MEDIA_STREAM_IN_FORMAT, &format);
257 if (format && total_count > 0) {
258 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = format;
259 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = total_count;
262 /* default codec type */
263 if (!strcmp(player->ini.audiocodec_default_type, "sw"))
264 player->default_attrs[MMPLAYER_ATTRS_AUDIO_CODEC_TYPE].default_value.value_int = MM_PLAYER_CODEC_TYPE_SW;
266 if (!strcmp(player->ini.videocodec_default_type, "sw"))
267 player->default_attrs[MMPLAYER_ATTRS_VIDEO_CODEC_TYPE].default_value.value_int = MM_PLAYER_CODEC_TYPE_SW;
269 return MM_ERROR_NONE;
272 static int __mmplayer_release_ini_info(MMHandleType handle)
274 mmplayer_t *player = MM_PLAYER_CAST(handle);
279 mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array);
281 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = NULL;
282 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = 0;
284 mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array);
286 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = NULL;
287 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = 0;
290 return MM_ERROR_NONE;
293 static void __mmplayer_print_attrs(const char *attr_name, const MMAttrsValue * value, const char *prefix)
295 switch (value->type) {
296 case MM_ATTRS_TYPE_INT:
297 LOGD("[ %s : %s : %d ]", prefix, attr_name, value->value.i_val);
299 case MM_ATTRS_TYPE_DOUBLE:
300 LOGD("[ %s : %s : %f ]", prefix, attr_name, value->value.d_val);
302 case MM_ATTRS_TYPE_STRING:
303 LOGD("[ %s : %s : %s ]", prefix, attr_name, value->value.s_val);
305 case MM_ATTRS_TYPE_DATA:
306 LOGD("[ %s : %s : %p ]", prefix, attr_name, value->value.p_val);
315 bool _mmplayer_commit_attribute(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
318 mmplayer_t *player = MM_PLAYER_CAST(commit_param);
320 MMPLAYER_RETURN_VAL_IF_FAIL(player && (attr_idx >= 0) && attr_name && value, false);
322 if (player->default_attrs[attr_idx].attr_commit) {
323 __mmplayer_print_attrs(attr_name, value, "Dynamic");
324 ret = player->default_attrs[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
326 __mmplayer_print_attrs(attr_name, value, "Static");
333 int _mmplayer_get_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
335 int result = MM_ERROR_NONE;
336 MMHandleType attrs = NULL;
338 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
339 /* if it's not want to know it. */
340 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
341 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
343 attrs = MM_PLAYER_GET_ATTRS(handle);
345 result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
347 if (result != MM_ERROR_NONE)
348 LOGE("failed to get %s attribute", attribute_name);
353 int __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
355 mmplayer_t *player = NULL;
358 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
359 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
361 player = MM_PLAYER_CAST(handle);
363 if (!g_strrstr(attribute_name, "display") || !g_strcmp0(attribute_name, "exported_shell_handle"))
364 return MM_ERROR_NONE;
366 if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
367 LOGD("will be applied when videosink is ready");
368 return MM_ERROR_NONE;
371 if (_mmplayer_update_video_overlay_param(player, attribute_name) != MM_ERROR_NONE) {
372 LOGW("not supported video param %s", attribute_name);
373 return MM_ERROR_NONE;
376 return MM_ERROR_NONE;
379 int _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
381 int result = MM_ERROR_NONE;
382 MMHandleType attrs = NULL;
384 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
385 /* if it's not want to know it. */
386 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
387 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
389 attrs = MM_PLAYER_GET_ATTRS(handle);
391 /* set attributes and commit them */
392 result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
393 if (result != MM_ERROR_NONE) {
394 LOGE("failed to set %s attribute", attribute_name);
398 /* Note: 'attr_commit' function is called before committing the new value to attr struct.
399 so if there is a value to apply after committing, it should be added below function. */
400 result = __mmplayer_apply_attribute(handle, attribute_name);
401 if (result != MM_ERROR_NONE) {
402 LOGE("failed to apply attributes");
406 return MM_ERROR_NONE;
409 int _mmplayer_get_attributes_info(MMHandleType handle, const char *attribute_name, mmplayer_attrs_info_t *dst_info)
411 int result = MM_ERROR_NONE;
412 MMHandleType attrs = NULL;
413 MMAttrsInfo src_info = {0, };
415 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
416 MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
417 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
419 attrs = MM_PLAYER_GET_ATTRS(handle);
421 result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
423 if (result != MM_ERROR_NONE) {
424 LOGE("failed to get attribute info");
428 memset(dst_info, 0x00, sizeof(mmplayer_attrs_info_t));
430 dst_info->type = src_info.type;
431 dst_info->flag = src_info.flag;
432 dst_info->validity_type = src_info.validity_type;
434 switch (src_info.validity_type) {
435 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
436 dst_info->int_array.array = src_info.int_array.array;
437 dst_info->int_array.count = src_info.int_array.count;
438 dst_info->int_array.d_val = src_info.int_array.dval;
441 case MM_ATTRS_VALID_TYPE_INT_RANGE:
442 dst_info->int_range.min = src_info.int_range.min;
443 dst_info->int_range.max = src_info.int_range.max;
444 dst_info->int_range.d_val = src_info.int_range.dval;
447 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
448 dst_info->double_array.array = src_info.double_array.array;
449 dst_info->double_array.count = src_info.double_array.count;
450 dst_info->double_array.d_val = src_info.double_array.dval;
453 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
454 dst_info->double_range.min = src_info.double_range.min;
455 dst_info->double_range.max = src_info.double_range.max;
456 dst_info->double_range.d_val = src_info.double_range.dval;
466 MMHandleType _mmplayer_construct_attribute(MMHandleType handle)
468 mmplayer_t *player = MM_PLAYER_CAST(handle);
469 int result = MM_ERROR_NONE;
471 MMHandleType attrs = NULL;
472 int num_of_attrs = 0;
473 MMAttrsConstructInfo *base = NULL;
475 mmplayer_attrs_spec_t player_attrs[] = {
477 MMPLAYER_ATTRS_PROFILE_URI, /* ID */
478 (char *)"profile_uri", /* Name */
479 MM_ATTRS_TYPE_STRING, /* Value Type */
480 MM_ATTRS_FLAG_RW, /* Flag */
481 {(void *)NULL}, /* default value */
482 MM_ATTRS_VALID_TYPE_NONE, /* validity type */
483 {0}, /* validity min value */
484 {0}, /* validity max value */
485 NULL, /* Runtime setting function of the attribute */
488 MMPLAYER_ATTRS_PROFILE_USER_PARAM,
489 (char *)"profile_user_param",
493 MM_ATTRS_VALID_TYPE_NONE,
499 MMPLAYER_ATTRS_PROFILE_PLAY_COUNT,
500 (char *)"profile_play_count",
503 {(void *)1}, /* -1 : repeat continually */
504 MM_ATTRS_VALID_TYPE_INT_RANGE,
510 MMPLAYER_ATTRS_PROFILE_PREPARE_ASYNC,
511 (char *)"profile_prepare_async",
515 MM_ATTRS_VALID_TYPE_INT_RANGE,
521 MMPLAYER_ATTRS_STREAMING_USER_AGENT,
522 (char *)"streaming_user_agent",
523 MM_ATTRS_TYPE_STRING,
526 MM_ATTRS_VALID_TYPE_NONE,
532 MMPLAYER_ATTRS_STREAMING_COOKIE,
533 (char *)"streaming_cookie",
534 MM_ATTRS_TYPE_STRING,
537 MM_ATTRS_VALID_TYPE_NONE,
543 MMPLAYER_ATTRS_SUBTITLE_URI,
544 (char *)"subtitle_uri",
545 MM_ATTRS_TYPE_STRING,
548 MM_ATTRS_VALID_TYPE_NONE,
554 MMPLAYER_ATTRS_CONTENT_BITRATE,
555 (char *)"content_bitrate",
559 MM_ATTRS_VALID_TYPE_INT_RANGE,
561 {.int_max = MMPLAYER_MAX_INT},
565 MMPLAYER_ATTRS_CONTENT_MAX_BITRATE,
566 (char *)"content_max_bitrate",
570 MM_ATTRS_VALID_TYPE_INT_RANGE,
572 {.int_max = MMPLAYER_MAX_INT},
576 MMPLAYER_ATTRS_CONTENT_VIDEO_FOUND,
577 (char *)"content_video_found",
581 MM_ATTRS_VALID_TYPE_INT_RANGE,
587 MMPLAYER_ATTRS_CONTENT_VIDEO_CODEC,
588 (char *)"content_video_codec",
589 MM_ATTRS_TYPE_STRING,
592 MM_ATTRS_VALID_TYPE_NONE,
598 MMPLAYER_ATTRS_CONTENT_VIDEO_BITRATE,
599 (char *)"content_video_bitrate",
603 MM_ATTRS_VALID_TYPE_INT_RANGE,
605 {.int_max = MMPLAYER_MAX_INT},
609 MMPLAYER_ATTRS_CONTENT_VIDEO_FPS,
610 (char *)"content_video_fps",
614 MM_ATTRS_VALID_TYPE_INT_RANGE,
616 {.int_max = MMPLAYER_MAX_INT},
620 MMPLAYER_ATTRS_CONTENT_VIDEO_WIDTH,
621 (char *)"content_video_width",
625 MM_ATTRS_VALID_TYPE_INT_RANGE,
627 {.int_max = MMPLAYER_MAX_INT},
631 MMPLAYER_ATTRS_CONTENT_VIDEO_HEIGHT,
632 (char *)"content_video_height",
636 MM_ATTRS_VALID_TYPE_INT_RANGE,
638 {.int_max = MMPLAYER_MAX_INT},
642 MMPLAYER_ATTRS_CONTENT_VIDEO_ORIENTATION,
643 (char *)"content_video_orientation", /* orientation of video content */
644 MM_ATTRS_TYPE_STRING,
647 MM_ATTRS_VALID_TYPE_NONE,
653 MMPLAYER_ATTRS_CONTENT_VIDEO_IS_SPHERICAL,
654 (char *)"content_video_is_spherical",
658 MM_ATTRS_VALID_TYPE_INT_RANGE,
660 {.int_max = MMPLAYER_MAX_INT},
664 MMPLAYER_ATTRS_CONTENT_AUDIO_CODEC,
665 (char *)"content_audio_codec",
666 MM_ATTRS_TYPE_STRING,
669 MM_ATTRS_VALID_TYPE_NONE,
675 MMPLAYER_ATTRS_CONTENT_AUDIO_BITRATE,
676 (char *)"content_audio_bitrate",
680 MM_ATTRS_VALID_TYPE_INT_RANGE,
682 {.int_max = MMPLAYER_MAX_INT},
686 MMPLAYER_ATTRS_CONTENT_AUDIO_CHANNELS,
687 (char *)"content_audio_channels",
691 MM_ATTRS_VALID_TYPE_INT_RANGE,
693 {.int_max = MMPLAYER_MAX_INT},
697 MMPLAYER_ATTRS_CONTENT_AUDIO_SAMPLERATE,
698 (char *)"content_audio_samplerate",
702 MM_ATTRS_VALID_TYPE_INT_RANGE,
704 {.int_max = MMPLAYER_MAX_INT},
708 MMPLAYER_ATTRS_CONTENT_AUDIO_FORMAT,
709 (char *)"content_audio_format",
710 MM_ATTRS_TYPE_STRING,
713 MM_ATTRS_VALID_TYPE_NONE,
719 MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_NUM,
720 (char *)"content_text_track_num",
724 MM_ATTRS_VALID_TYPE_INT_RANGE,
726 {.int_max = MMPLAYER_MAX_INT},
730 MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_INDEX,
731 (char *)"current_text_track_index",
735 MM_ATTRS_VALID_TYPE_INT_RANGE,
737 {.int_max = MMPLAYER_MAX_INT},
741 MMPLAYER_ATTRS_TAG_ARTIST,
742 (char *)"tag_artist",
743 MM_ATTRS_TYPE_STRING,
746 MM_ATTRS_VALID_TYPE_NONE,
752 MMPLAYER_ATTRS_TAG_TITLE,
754 MM_ATTRS_TYPE_STRING,
757 MM_ATTRS_VALID_TYPE_NONE,
763 MMPLAYER_ATTRS_TAG_ALBUM,
765 MM_ATTRS_TYPE_STRING,
768 MM_ATTRS_VALID_TYPE_NONE,
774 MMPLAYER_ATTRS_TAG_GENRE,
776 MM_ATTRS_TYPE_STRING,
779 MM_ATTRS_VALID_TYPE_NONE,
785 MMPLAYER_ATTRS_TAG_AUTHOR,
786 (char *)"tag_author",
787 MM_ATTRS_TYPE_STRING,
790 MM_ATTRS_VALID_TYPE_NONE,
796 MMPLAYER_ATTRS_TAG_COPYRIGHT,
797 (char *)"tag_copyright",
798 MM_ATTRS_TYPE_STRING,
801 MM_ATTRS_VALID_TYPE_NONE,
807 MMPLAYER_ATTRS_TAG_DATE,
809 MM_ATTRS_TYPE_STRING,
812 MM_ATTRS_VALID_TYPE_NONE,
818 MMPLAYER_ATTRS_TAG_DESCRIPTION,
819 (char *)"tag_description",
820 MM_ATTRS_TYPE_STRING,
823 MM_ATTRS_VALID_TYPE_NONE,
829 MMPLAYER_ATTRS_TAG_TRACK_NUM,
830 (char *)"tag_track_num",
834 MM_ATTRS_VALID_TYPE_INT_RANGE,
836 {.int_max = MMPLAYER_MAX_INT},
840 MMPLAYER_ATTRS_TAG_ALBUM_COVER,
841 (char *)"tag_album_cover",
845 MM_ATTRS_VALID_TYPE_NONE,
851 MMPLAYER_ATTRS_DISPLAY_ROTATION,
852 (char *)"display_rotation",
855 {(void *)MM_DISPLAY_ROTATION_NONE},
856 MM_ATTRS_VALID_TYPE_INT_RANGE,
857 {.int_min = MM_DISPLAY_ROTATION_NONE},
858 {.int_max = MM_DISPLAY_ROTATION_270},
862 MMPLAYER_ATTRS_DISPLAY_VISIBLE,
863 (char *)"display_visible",
867 MM_ATTRS_VALID_TYPE_INT_RANGE,
873 MMPLAYER_ATTRS_DISPLAY_METHOD,
874 (char *)"display_method",
877 {(void *)MM_DISPLAY_METHOD_LETTER_BOX},
878 MM_ATTRS_VALID_TYPE_INT_RANGE,
879 {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
880 {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
884 MMPLAYER_ATTRS_DISPLAY_OVERLAY,
885 (char *)"display_overlay",
889 MM_ATTRS_VALID_TYPE_INT_RANGE,
891 {.int_max = MMPLAYER_MAX_INT},
895 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_X,
896 (char *)"display_win_roi_x",
900 MM_ATTRS_VALID_TYPE_INT_RANGE,
901 {.int_min = MMPLAYER_MIN_INT},
902 {.int_max = MMPLAYER_MAX_INT},
906 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_Y,
907 (char *)"display_win_roi_y",
911 MM_ATTRS_VALID_TYPE_INT_RANGE,
912 {.int_min = MMPLAYER_MIN_INT},
913 {.int_max = MMPLAYER_MAX_INT},
917 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_WIDTH,
918 (char *)"display_win_roi_width",
922 MM_ATTRS_VALID_TYPE_INT_RANGE,
924 {.int_max = MMPLAYER_MAX_INT},
928 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_HEIGHT,
929 (char *)"display_win_roi_height",
933 MM_ATTRS_VALID_TYPE_INT_RANGE,
935 {.int_max = MMPLAYER_MAX_INT},
939 MMPLAYER_ATTRS_DISPLAY_SURFACE_TYPE,
940 (char *)"display_surface_type",
943 {(void *)MM_DISPLAY_SURFACE_NULL},
944 MM_ATTRS_VALID_TYPE_INT_RANGE,
945 {.int_min = MM_DISPLAY_SURFACE_OVERLAY},
946 {.int_max = MM_DISPLAY_SURFACE_NUM - 1},
950 MMPLAYER_ATTRS_DISPLAY_EXPORTED_SHELL_HANDLE,
951 (char *)"exported_shell_handle",
952 MM_ATTRS_TYPE_STRING,
955 MM_ATTRS_VALID_TYPE_NONE,
961 MMPLAYER_ATTRS_SOUND_STREAM_TYPE,
962 (char *)"sound_stream_type",
963 MM_ATTRS_TYPE_STRING,
966 MM_ATTRS_VALID_TYPE_NONE,
972 MMPLAYER_ATTRS_SOUND_STREAM_INDEX,
973 (char *)"sound_stream_index",
977 MM_ATTRS_VALID_TYPE_INT_RANGE,
979 {.int_max = MMPLAYER_MAX_INT},
983 MMPLAYER_ATTRS_SOUND_LATENCY_MODE,
984 (char *)"sound_latency_mode",
987 {(void *)1}, /* 0: low latency, 1: middle latency 2: high latency */
988 MM_ATTRS_VALID_TYPE_INT_RANGE,
994 MMPLAYER_ATTRS_PCM_EXTRACTION_SAMPLERATE,
995 (char *)"pcm_extraction_samplerate", /* set samplerate for pcm extraction */
999 MM_ATTRS_VALID_TYPE_INT_RANGE,
1001 {.int_max = MMPLAYER_MAX_INT},
1005 MMPLAYER_ATTRS_PCM_EXTRACTION_CHANNELS,
1006 (char *)"pcm_extraction_channels", /* set channels for pcm extraction */
1010 MM_ATTRS_VALID_TYPE_INT_RANGE,
1012 {.int_max = MMPLAYER_MAX_INT},
1016 MMPLAYER_ATTRS_ACCURATE_SEEK,
1017 (char *)"accurate_seek",
1021 MM_ATTRS_VALID_TYPE_INT_RANGE,
1027 MMPLAYER_ATTRS_PCM_EXTRACTION_FORMAT,
1028 (char *)"pcm_extraction_format",
1029 MM_ATTRS_TYPE_STRING,
1032 MM_ATTRS_VALID_TYPE_NONE,
1038 MMPLAYER_ATTRS_DRC_MODE,
1043 MM_ATTRS_VALID_TYPE_INT_RANGE,
1049 MMPLAYER_ATTRS_GAPLESS_MODE,
1050 (char *)"gapless_mode",
1054 MM_ATTRS_VALID_TYPE_INT_RANGE,
1057 __mmplayer_commit_gapless_mode,
1060 MMPLAYER_ATTRS_ENABLE_VIDEO_DECODED_CB,
1061 (char *)"enable_video_decoded_cb",
1065 MM_ATTRS_VALID_TYPE_INT_RANGE,
1068 __mmplayer_commit_enable_video_decoded_cb,
1071 MMPLAYER_ATTRS_VIDEO_CODEC_TYPE,
1072 (char *)"video_codec_type",
1075 {(void *)MM_PLAYER_CODEC_TYPE_HW},
1076 MM_ATTRS_VALID_TYPE_INT_RANGE,
1077 {.int_min = MM_PLAYER_CODEC_TYPE_HW},
1078 {.int_max = MM_PLAYER_CODEC_TYPE_SW},
1082 MMPLAYER_ATTRS_AUDIO_CODEC_TYPE,
1083 (char *)"audio_codec_type",
1086 {(void *)MM_PLAYER_CODEC_TYPE_HW},
1087 MM_ATTRS_VALID_TYPE_INT_RANGE,
1088 {.int_min = MM_PLAYER_CODEC_TYPE_HW},
1089 {.int_max = MM_PLAYER_CODEC_TYPE_SW},
1093 MMPLAYER_ATTRS_VIDEO_BUFFER_TOTAL_SIZE,
1094 (char *)"video_buffer_total_size",
1097 {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1098 MM_ATTRS_VALID_TYPE_INT_RANGE,
1099 {.int_min = MMPLAYER_MIN_INT},
1100 {.int_max = MMPLAYER_MAX_INT},
1104 MMPLAYER_ATTRS_VIDEO_BUFFER_EXTRA_SIZE,
1105 (char *)"video_buffer_extra_size",
1108 {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1109 MM_ATTRS_VALID_TYPE_INT_RANGE,
1110 {.int_min = MMPLAYER_MIN_INT},
1111 {.int_max = MMPLAYER_MAX_INT},
1115 MMPLAYER_ATTRS_PREBUFFER_MS,
1116 (char *)"prebuffer_ms", /* user setting */
1119 {(void *) MIN_BUFFERING_TIME},
1120 MM_ATTRS_VALID_TYPE_INT_RANGE,
1121 {.int_min = MIN_BUFFERING_TIME},
1122 {.int_max = MMPLAYER_MAX_INT},
1126 MMPLAYER_ATTRS_REBUFFER_MS,
1127 (char *)"rebuffer_ms", /* user setting */
1130 {(void *) MIN_BUFFERING_TIME},
1131 MM_ATTRS_VALID_TYPE_INT_RANGE,
1132 {.int_min = MIN_BUFFERING_TIME},
1133 {.int_max = MMPLAYER_MAX_INT},
1137 MMPLAYER_ATTRS_PITCH_CONTROL,
1138 (char *)"pitch_control", /* MM_PLAYER_PITCH_CONTROL */
1142 MM_ATTRS_VALID_TYPE_INT_RANGE,
1148 MMPLAYER_ATTRS_PITCH_VALUE,
1149 (char *)"pitch_value", /* MM_PLAYER_PITCH_VALUE */
1150 MM_ATTRS_TYPE_DOUBLE,
1152 {.value_double = 1.0},
1153 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1154 {.double_min = 0.5},
1156 __mmplayer_commit_audio_pitch_value,
1159 MMPLAYER_ATTRS_AUDIO_OFFLOAD,
1160 (char *)"audio_offload", /* MM_PLAYER_AUDIO_OFFLOAD */
1164 MM_ATTRS_VALID_TYPE_INT_RANGE,
1170 MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT,
1171 (char *)"audio_offload_format", /* MM_PLAYER_AUDIO_OFFLOAD_FORMAT, array of media_format_mimetype_e */
1175 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1176 {.int_array = NULL},
1181 MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT, /* MM_PLAYER_MEDIA_STREAM_INPUT_FORMAT */
1182 (char *)"media_stream_input_format",
1186 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1187 {.int_array = NULL},
1192 MMPLAYER_ATTRS_AUDIO_ONLY,
1193 (char *)"audio_only", /* MM_PLAYER_AUDIO_ONLY */
1197 MM_ATTRS_VALID_TYPE_INT_RANGE,
1204 MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
1206 num_of_attrs = ARRAY_SIZE(player_attrs);
1208 base = g_try_new(MMAttrsConstructInfo, num_of_attrs);
1210 LOGE("failed to alloc attrs constructor");
1214 /* alloc default attribute info */
1215 player->default_attrs = (mmplayer_attrs_spec_t *)g_try_malloc(sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1216 if (player->default_attrs == NULL) {
1217 LOGE("failed to alloc default attribute info");
1221 memcpy(player->default_attrs, player_attrs, sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1222 __mmplayer_set_ini_to_valid_info(handle);
1224 /* initialize values of attributes */
1225 for (idx = 0; idx < num_of_attrs; idx++) {
1226 base[idx].name = player->default_attrs[idx].name;
1227 base[idx].value_type = player->default_attrs[idx].value_type;
1228 base[idx].flags = player->default_attrs[idx].flags;
1229 base[idx].default_value = player->default_attrs[idx].default_value.value_void; /* FIXME: need to consider the double data type */
1232 result = mm_attrs_new(base, num_of_attrs, "mmplayer_attrs",
1233 _mmplayer_commit_attribute, (void *)handle, &attrs);
1236 MMPLAYER_FREEIF(base);
1238 if (result != MM_ERROR_NONE) {
1239 LOGE("failed to create player attrs");
1243 /* set validity type and range */
1244 for (idx = 0; idx < num_of_attrs; idx++) {
1245 mm_attrs_set_valid_type(attrs, idx, player->default_attrs[idx].valid_type);
1246 switch (player->default_attrs[idx].valid_type) {
1247 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1248 mm_attrs_set_valid_range(attrs, idx,
1249 player->default_attrs[idx].validity_value_1.int_min,
1250 player->default_attrs[idx].validity_value_2.int_max,
1251 player->default_attrs[idx].default_value.value_int);
1253 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1254 if (player->default_attrs[idx].validity_value_1.int_array &&
1255 player->default_attrs[idx].validity_value_2.count > 0)
1256 mm_attrs_set_valid_array(attrs, idx,
1257 (const int *)(player->default_attrs[idx].validity_value_1.int_array),
1258 player->default_attrs[idx].validity_value_2.count,
1259 player->default_attrs[idx].default_value.value_int);
1261 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1262 mm_attrs_set_valid_double_range(attrs, idx,
1263 player->default_attrs[idx].validity_value_1.double_min,
1264 player->default_attrs[idx].validity_value_2.double_max,
1265 player->default_attrs[idx].default_value.value_double);
1267 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1268 LOGW("FIXME: need to set range value if required.");
1269 case MM_ATTRS_VALID_TYPE_NONE:
1270 case MM_ATTRS_VALID_TYPE_INVALID:
1277 if (mm_attrs_commit_all(attrs)) {
1278 LOGE("failed to update attributes");
1282 __mmplayer_release_ini_info(handle);
1287 MMPLAYER_FREEIF(base);
1288 MMPLAYER_FREEIF(player->default_attrs);
1291 mm_attrs_free(attrs);
1296 bool _mmplayer_deconstruct_attribute(MMHandleType handle)
1298 mmplayer_t *player = MM_PLAYER_CAST(handle);
1300 MMPLAYER_RETURN_VAL_IF_FAIL(player, false);
1302 if (player->attrs) {
1303 mm_attrs_free(player->attrs);
1304 player->attrs = NULL;
1307 MMPLAYER_FREEIF(player->default_attrs);