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->mainbin, 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 = (mmplayer_t *)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)
148 media_format_mimetype_e format = MEDIA_FORMAT_MAX;
150 mmplayer_t *player = (mmplayer_t *)handle;
152 if (type == KEYWORD_A_OFFLOAD_MEDIA_FORMAT) {
153 name = player->ini.audio_offload_media_format[i];
154 } else if (type == KEYWORD_MEDIA_STREAM_IN_FORMAT) {
155 name = player->ini.media_stream_input_format[i];
157 LOGE("invalid ini type");
161 if (!strcmp(name, "MP3"))
162 format = MEDIA_FORMAT_MP3;
163 else if (!strcmp(name, "AAC"))
164 format = MEDIA_FORMAT_AAC;
165 else if (!strcmp(name, "H264_SP"))
166 format = MEDIA_FORMAT_H264_SP;
167 else if (!strcmp(name, "H264_MP"))
168 format = MEDIA_FORMAT_H264_MP;
169 else if (!strcmp(name, "H264_HP"))
170 format = MEDIA_FORMAT_H264_HP;
171 else if (!strcmp(name, "PCM"))
172 format = MEDIA_FORMAT_PCM;
173 else if (!strcmp(name, "PCM_S16LE"))
174 format = MEDIA_FORMAT_PCM_S16LE;
175 else if (!strcmp(name, "PCM_S24LE"))
176 format = MEDIA_FORMAT_PCM_S24LE;
177 else if (!strcmp(name, "PCM_S32LE"))
178 format = MEDIA_FORMAT_PCM_S32LE;
179 else if (!strcmp(name, "PCM_S16BE"))
180 format = MEDIA_FORMAT_PCM_S16BE;
181 else if (!strcmp(name, "PCM_S24BE"))
182 format = MEDIA_FORMAT_PCM_S24BE;
183 else if (!strcmp(name, "PCM_S32BE"))
184 format = MEDIA_FORMAT_PCM_S32BE;
185 else if (!strcmp(name, "PCM_F32LE"))
186 format = MEDIA_FORMAT_PCM_F32LE;
187 else if (!strcmp(name, "PCM_F32BE"))
188 format = MEDIA_FORMAT_PCM_F32BE;
189 else if (!strcmp(name, "PCM_S16LE"))
190 format = MEDIA_FORMAT_PCM_U16LE;
191 else if (!strcmp(name, "PCM_U24LE"))
192 format = MEDIA_FORMAT_PCM_U24LE;
193 else if (!strcmp(name, "PCM_U32LE"))
194 format = MEDIA_FORMAT_PCM_U32LE;
195 else if (!strcmp(name, "PCM_U16BE"))
196 format = MEDIA_FORMAT_PCM_U16BE;
197 else if (!strcmp(name, "PCM_U24BE"))
198 format = MEDIA_FORMAT_PCM_U24BE;
199 else if (!strcmp(name, "PCM_U32BE"))
200 format = MEDIA_FORMAT_PCM_U32BE;
202 LOGE("FIXME: need to modify function to support more format");
205 LOGD("[%d type] supported format 0x%X(%s)", type, format, name);
210 static int __mmplayer_get_available_format(MMHandleType handle, int type, int **format)
218 MMPLAYER_RETURN_VAL_IF_FAIL(handle, -1);
220 count = __mmplayer_get_array_count(handle, type);
225 arr = (int *) g_malloc0(count * sizeof(int));
226 for (i = 0 ; i < count ; i++) {
227 fmt = __mmplayer_get_supported_format_mimetype(handle, type, i);
228 if (fmt != MEDIA_FORMAT_MAX)
229 arr[total_count++] = fmt;
232 if (total_count <= 0) {
237 LOGD("[%d type] num of supported codec %d", type, total_count);
243 static int __mmplayer_set_ini_to_valid_info(MMHandleType handle)
245 mmplayer_t *player = MM_PLAYER_CAST(handle);
249 /* supported format of audio offload */
250 total_count = __mmplayer_get_available_format(handle, KEYWORD_A_OFFLOAD_MEDIA_FORMAT, &format);
251 if (format && total_count > 0) {
252 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = format;
253 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = total_count;
256 /* supported format of media stream input */
257 total_count = __mmplayer_get_available_format(handle, KEYWORD_MEDIA_STREAM_IN_FORMAT, &format);
258 if (format && total_count > 0) {
259 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = format;
260 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = total_count;
263 return MM_ERROR_NONE;
266 static int __mmplayer_release_ini_info(MMHandleType handle)
268 mmplayer_t *player = MM_PLAYER_CAST(handle);
273 mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array);
275 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = NULL;
276 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = 0;
278 mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array);
280 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = NULL;
281 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = 0;
284 return MM_ERROR_NONE;
287 static void __mmplayer_print_attrs(const char *attr_name, const MMAttrsValue * value, const char *prefix)
289 switch (value->type) {
290 case MM_ATTRS_TYPE_INT:
291 LOGD("[ %s : %s : %d ]", prefix, attr_name, value->value.i_val);
293 case MM_ATTRS_TYPE_DOUBLE:
294 LOGD("[ %s : %s : %f ]", prefix, attr_name, value->value.d_val);
296 case MM_ATTRS_TYPE_STRING:
297 LOGD("[ %s : %s : %s ]", prefix, attr_name, value->value.s_val);
299 case MM_ATTRS_TYPE_DATA:
300 LOGD("[ %s : %s : %p ]", prefix, attr_name, value->value.p_val);
309 bool _mmplayer_commit_attribute(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
312 mmplayer_t *player = MM_PLAYER_CAST(commit_param);
314 MMPLAYER_RETURN_VAL_IF_FAIL(player && (attr_idx >= 0) && attr_name && value, false);
316 if (player->default_attrs[attr_idx].attr_commit) {
317 __mmplayer_print_attrs(attr_name, value, "Dynamic");
318 ret = player->default_attrs[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
320 __mmplayer_print_attrs(attr_name, value, "Static");
327 int _mmplayer_get_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
329 int result = MM_ERROR_NONE;
330 MMHandleType attrs = NULL;
332 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
333 /* if it's not want to know it. */
334 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
335 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
337 attrs = MM_PLAYER_GET_ATTRS(handle);
339 result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
341 if (result != MM_ERROR_NONE)
342 LOGE("failed to get %s attribute", attribute_name);
347 int __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
349 mmplayer_t *player = NULL;
352 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
353 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
355 player = MM_PLAYER_CAST(handle);
357 /* apply display attr value to player handle */
358 if (!g_strrstr(attribute_name, "display"))
359 return MM_ERROR_NONE;
361 if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
362 LOGD("will be applied when videosink is ready");
363 return MM_ERROR_NONE;
366 if (_mmplayer_update_video_overlay_param(player, attribute_name) != MM_ERROR_NONE) {
367 LOGW("not supported video param %s", attribute_name);
368 return MM_ERROR_NONE;
371 return MM_ERROR_NONE;
374 int _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
376 int result = MM_ERROR_NONE;
377 MMHandleType attrs = NULL;
379 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
380 /* if it's not want to know it. */
381 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
382 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
384 attrs = MM_PLAYER_GET_ATTRS(handle);
386 /* set attributes and commit them */
387 result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
388 if (result != MM_ERROR_NONE) {
389 LOGE("failed to set %s attribute", attribute_name);
393 /* Note: 'attr_commit' function is called before committing the new value to attr struct.
394 so if there is a value to apply after committing, it should be added below function. */
395 result = __mmplayer_apply_attribute(handle, attribute_name);
396 if (result != MM_ERROR_NONE) {
397 LOGE("failed to apply attributes");
401 return MM_ERROR_NONE;
404 int _mmplayer_get_attributes_info(MMHandleType handle, const char *attribute_name, mmplayer_attrs_info_t *dst_info)
406 int result = MM_ERROR_NONE;
407 MMHandleType attrs = NULL;
408 MMAttrsInfo src_info = {0, };
410 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
411 MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
412 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
414 attrs = MM_PLAYER_GET_ATTRS(handle);
416 result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
418 if (result != MM_ERROR_NONE) {
419 LOGE("failed to get attribute info");
423 memset(dst_info, 0x00, sizeof(mmplayer_attrs_info_t));
425 dst_info->type = src_info.type;
426 dst_info->flag = src_info.flag;
427 dst_info->validity_type = src_info.validity_type;
429 switch (src_info.validity_type) {
430 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
431 dst_info->int_array.array = src_info.int_array.array;
432 dst_info->int_array.count = src_info.int_array.count;
433 dst_info->int_array.d_val = src_info.int_array.dval;
436 case MM_ATTRS_VALID_TYPE_INT_RANGE:
437 dst_info->int_range.min = src_info.int_range.min;
438 dst_info->int_range.max = src_info.int_range.max;
439 dst_info->int_range.d_val = src_info.int_range.dval;
442 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
443 dst_info->double_array.array = src_info.double_array.array;
444 dst_info->double_array.count = src_info.double_array.count;
445 dst_info->double_array.d_val = src_info.double_array.dval;
448 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
449 dst_info->double_range.min = src_info.double_range.min;
450 dst_info->double_range.max = src_info.double_range.max;
451 dst_info->double_range.d_val = src_info.double_range.dval;
461 MMHandleType _mmplayer_construct_attribute(MMHandleType handle)
463 mmplayer_t *player = MM_PLAYER_CAST(handle);
464 int result = MM_ERROR_NONE;
466 MMHandleType attrs = NULL;
467 int num_of_attrs = 0;
468 MMAttrsConstructInfo *base = NULL;
470 mmplayer_attrs_spec_t player_attrs[] = {
472 MMPLAYER_ATTRS_PROFILE_URI, /* ID */
473 (char *)"profile_uri", /* Name */
474 MM_ATTRS_TYPE_STRING, /* Value Type */
475 MM_ATTRS_FLAG_RW, /* Flag */
476 {(void *)NULL}, /* default value */
477 MM_ATTRS_VALID_TYPE_NONE, /* validity type */
478 {0}, /* validity min value */
479 {0}, /* validity max value */
480 NULL, /* Runtime setting function of the attribute */
483 MMPLAYER_ATTRS_PROFILE_USER_PARAM,
484 (char *)"profile_user_param",
488 MM_ATTRS_VALID_TYPE_NONE,
494 MMPLAYER_ATTRS_PROFILE_PLAY_COUNT,
495 (char *)"profile_play_count",
498 {(void *)1}, /* -1 : repeat continually */
499 MM_ATTRS_VALID_TYPE_INT_RANGE,
505 MMPLAYER_ATTRS_PROFILE_PREPARE_ASYNC,
506 (char *)"profile_prepare_async",
510 MM_ATTRS_VALID_TYPE_INT_RANGE,
516 MMPLAYER_ATTRS_STREAMING_USER_AGENT,
517 (char *)"streaming_user_agent",
518 MM_ATTRS_TYPE_STRING,
521 MM_ATTRS_VALID_TYPE_NONE,
527 MMPLAYER_ATTRS_STREAMING_COOKIE,
528 (char *)"streaming_cookie",
529 MM_ATTRS_TYPE_STRING,
532 MM_ATTRS_VALID_TYPE_NONE,
538 MMPLAYER_ATTRS_SUBTITLE_URI,
539 (char *)"subtitle_uri",
540 MM_ATTRS_TYPE_STRING,
543 MM_ATTRS_VALID_TYPE_NONE,
549 MMPLAYER_ATTRS_CONTENT_BITRATE,
550 (char *)"content_bitrate",
554 MM_ATTRS_VALID_TYPE_INT_RANGE,
556 {.int_max = MMPLAYER_MAX_INT},
560 MMPLAYER_ATTRS_CONTENT_MAX_BITRATE,
561 (char *)"content_max_bitrate",
565 MM_ATTRS_VALID_TYPE_INT_RANGE,
567 {.int_max = MMPLAYER_MAX_INT},
571 MMPLAYER_ATTRS_CONTENT_VIDEO_FOUND,
572 (char *)"content_video_found",
576 MM_ATTRS_VALID_TYPE_INT_RANGE,
582 MMPLAYER_ATTRS_CONTENT_VIDEO_CODEC,
583 (char *)"content_video_codec",
584 MM_ATTRS_TYPE_STRING,
587 MM_ATTRS_VALID_TYPE_NONE,
593 MMPLAYER_ATTRS_CONTENT_VIDEO_BITRATE,
594 (char *)"content_video_bitrate",
598 MM_ATTRS_VALID_TYPE_INT_RANGE,
600 {.int_max = MMPLAYER_MAX_INT},
604 MMPLAYER_ATTRS_CONTENT_VIDEO_FPS,
605 (char *)"content_video_fps",
609 MM_ATTRS_VALID_TYPE_INT_RANGE,
611 {.int_max = MMPLAYER_MAX_INT},
615 MMPLAYER_ATTRS_CONTENT_VIDEO_WIDTH,
616 (char *)"content_video_width",
620 MM_ATTRS_VALID_TYPE_INT_RANGE,
622 {.int_max = MMPLAYER_MAX_INT},
626 MMPLAYER_ATTRS_CONTENT_VIDEO_HEIGHT,
627 (char *)"content_video_height",
631 MM_ATTRS_VALID_TYPE_INT_RANGE,
633 {.int_max = MMPLAYER_MAX_INT},
637 MMPLAYER_ATTRS_CONTENT_VIDEO_ORIENTATION,
638 (char *)"content_video_orientation", /* orientation of video content */
639 MM_ATTRS_TYPE_STRING,
642 MM_ATTRS_VALID_TYPE_NONE,
648 MMPLAYER_ATTRS_CONTENT_VIDEO_IS_SPHERICAL,
649 (char *)"content_video_is_spherical",
653 MM_ATTRS_VALID_TYPE_INT_RANGE,
655 {.int_max = MMPLAYER_MAX_INT},
659 MMPLAYER_ATTRS_CONTENT_AUDIO_CODEC,
660 (char *)"content_audio_codec",
661 MM_ATTRS_TYPE_STRING,
664 MM_ATTRS_VALID_TYPE_NONE,
670 MMPLAYER_ATTRS_CONTENT_AUDIO_BITRATE,
671 (char *)"content_audio_bitrate",
675 MM_ATTRS_VALID_TYPE_INT_RANGE,
677 {.int_max = MMPLAYER_MAX_INT},
681 MMPLAYER_ATTRS_CONTENT_AUDIO_CHANNELS,
682 (char *)"content_audio_channels",
686 MM_ATTRS_VALID_TYPE_INT_RANGE,
688 {.int_max = MMPLAYER_MAX_INT},
692 MMPLAYER_ATTRS_CONTENT_AUDIO_SAMPLERATE,
693 (char *)"content_audio_samplerate",
697 MM_ATTRS_VALID_TYPE_INT_RANGE,
699 {.int_max = MMPLAYER_MAX_INT},
703 MMPLAYER_ATTRS_CONTENT_AUDIO_FORMAT,
704 (char *)"content_audio_format",
705 MM_ATTRS_TYPE_STRING,
708 MM_ATTRS_VALID_TYPE_NONE,
714 MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_NUM,
715 (char *)"content_text_track_num",
719 MM_ATTRS_VALID_TYPE_INT_RANGE,
721 {.int_max = MMPLAYER_MAX_INT},
725 MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_INDEX,
726 (char *)"current_text_track_index",
730 MM_ATTRS_VALID_TYPE_INT_RANGE,
732 {.int_max = MMPLAYER_MAX_INT},
736 MMPLAYER_ATTRS_TAG_ARTIST,
737 (char *)"tag_artist",
738 MM_ATTRS_TYPE_STRING,
741 MM_ATTRS_VALID_TYPE_NONE,
747 MMPLAYER_ATTRS_TAG_TITLE,
749 MM_ATTRS_TYPE_STRING,
752 MM_ATTRS_VALID_TYPE_NONE,
758 MMPLAYER_ATTRS_TAG_ALBUM,
760 MM_ATTRS_TYPE_STRING,
763 MM_ATTRS_VALID_TYPE_NONE,
769 MMPLAYER_ATTRS_TAG_GENRE,
771 MM_ATTRS_TYPE_STRING,
774 MM_ATTRS_VALID_TYPE_NONE,
780 MMPLAYER_ATTRS_TAG_AUTHOR,
781 (char *)"tag_author",
782 MM_ATTRS_TYPE_STRING,
785 MM_ATTRS_VALID_TYPE_NONE,
791 MMPLAYER_ATTRS_TAG_COPYRIGHT,
792 (char *)"tag_copyright",
793 MM_ATTRS_TYPE_STRING,
796 MM_ATTRS_VALID_TYPE_NONE,
802 MMPLAYER_ATTRS_TAG_DATE,
804 MM_ATTRS_TYPE_STRING,
807 MM_ATTRS_VALID_TYPE_NONE,
813 MMPLAYER_ATTRS_TAG_DESCRIPTION,
814 (char *)"tag_description",
815 MM_ATTRS_TYPE_STRING,
818 MM_ATTRS_VALID_TYPE_NONE,
824 MMPLAYER_ATTRS_TAG_TRACK_NUM,
825 (char *)"tag_track_num",
829 MM_ATTRS_VALID_TYPE_INT_RANGE,
831 {.int_max = MMPLAYER_MAX_INT},
835 MMPLAYER_ATTRS_TAG_ALBUM_COVER,
836 (char *)"tag_album_cover",
840 MM_ATTRS_VALID_TYPE_NONE,
846 MMPLAYER_ATTRS_DISPLAY_ROTATION,
847 (char *)"display_rotation",
850 {(void *)MM_DISPLAY_ROTATION_NONE},
851 MM_ATTRS_VALID_TYPE_INT_RANGE,
852 {.int_min = MM_DISPLAY_ROTATION_NONE},
853 {.int_max = MM_DISPLAY_ROTATION_270},
857 MMPLAYER_ATTRS_DISPLAY_VISIBLE,
858 (char *)"display_visible",
862 MM_ATTRS_VALID_TYPE_INT_RANGE,
868 MMPLAYER_ATTRS_DISPLAY_METHOD,
869 (char *)"display_method",
872 {(void *)MM_DISPLAY_METHOD_LETTER_BOX},
873 MM_ATTRS_VALID_TYPE_INT_RANGE,
874 {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
875 {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
879 MMPLAYER_ATTRS_DISPLAY_OVERLAY,
880 (char *)"display_overlay",
884 MM_ATTRS_VALID_TYPE_INT_RANGE,
886 {.int_max = MMPLAYER_MAX_INT},
890 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_X,
891 (char *)"display_win_roi_x",
895 MM_ATTRS_VALID_TYPE_INT_RANGE,
896 {.int_min = MMPLAYER_MIN_INT},
897 {.int_max = MMPLAYER_MAX_INT},
901 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_Y,
902 (char *)"display_win_roi_y",
906 MM_ATTRS_VALID_TYPE_INT_RANGE,
907 {.int_min = MMPLAYER_MIN_INT},
908 {.int_max = MMPLAYER_MAX_INT},
912 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_WIDTH,
913 (char *)"display_win_roi_width",
917 MM_ATTRS_VALID_TYPE_INT_RANGE,
919 {.int_max = MMPLAYER_MAX_INT},
923 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_HEIGHT,
924 (char *)"display_win_roi_height",
928 MM_ATTRS_VALID_TYPE_INT_RANGE,
930 {.int_max = MMPLAYER_MAX_INT},
934 MMPLAYER_ATTRS_DISPLAY_SURFACE_TYPE,
935 (char *)"display_surface_type",
938 {(void *)MM_DISPLAY_SURFACE_NULL},
939 MM_ATTRS_VALID_TYPE_INT_RANGE,
940 {.int_min = MM_DISPLAY_SURFACE_OVERLAY},
941 {.int_max = MM_DISPLAY_SURFACE_NUM - 1},
945 MMPLAYER_ATTRS_SOUND_STREAM_TYPE,
946 (char *)"sound_stream_type",
947 MM_ATTRS_TYPE_STRING,
950 MM_ATTRS_VALID_TYPE_NONE,
956 MMPLAYER_ATTRS_SOUND_STREAM_INDEX,
957 (char *)"sound_stream_index",
961 MM_ATTRS_VALID_TYPE_INT_RANGE,
963 {.int_max = MMPLAYER_MAX_INT},
967 MMPLAYER_ATTRS_SOUND_LATENCY_MODE,
968 (char *)"sound_latency_mode",
971 {(void *)1}, /* 0: low latency, 1: middle latency 2: high latency */
972 MM_ATTRS_VALID_TYPE_INT_RANGE,
978 MMPLAYER_ATTRS_PCM_EXTRACTION_SAMPLERATE,
979 (char *)"pcm_extraction_samplerate", /* set samplerate for pcm extraction */
983 MM_ATTRS_VALID_TYPE_INT_RANGE,
985 {.int_max = MMPLAYER_MAX_INT},
989 MMPLAYER_ATTRS_PCM_EXTRACTION_CHANNELS,
990 (char *)"pcm_extraction_channels", /* set channels for pcm extraction */
994 MM_ATTRS_VALID_TYPE_INT_RANGE,
996 {.int_max = MMPLAYER_MAX_INT},
1000 MMPLAYER_ATTRS_ACCURATE_SEEK,
1001 (char *)"accurate_seek",
1005 MM_ATTRS_VALID_TYPE_INT_RANGE,
1011 MMPLAYER_ATTRS_PCM_EXTRACTION_FORMAT,
1012 (char *)"pcm_extraction_format",
1013 MM_ATTRS_TYPE_STRING,
1016 MM_ATTRS_VALID_TYPE_NONE,
1022 MMPLAYER_ATTRS_DRC_MODE,
1027 MM_ATTRS_VALID_TYPE_INT_RANGE,
1033 MMPLAYER_ATTRS_GAPLESS_MODE,
1034 (char *)"gapless_mode",
1038 MM_ATTRS_VALID_TYPE_INT_RANGE,
1041 __mmplayer_commit_gapless_mode,
1044 MMPLAYER_ATTRS_ENABLE_VIDEO_DECODED_CB,
1045 (char *)"enable_video_decoded_cb",
1049 MM_ATTRS_VALID_TYPE_INT_RANGE,
1052 __mmplayer_commit_enable_video_decoded_cb,
1055 MMPLAYER_ATTRS_VIDEO_CODEC_TYPE,
1056 (char *)"video_codec_type",
1059 {(void *)MM_PLAYER_CODEC_TYPE_DEFAULT},
1060 MM_ATTRS_VALID_TYPE_INT_RANGE,
1061 {.int_min = MM_PLAYER_CODEC_TYPE_DEFAULT},
1062 {.int_max = MM_PLAYER_CODEC_TYPE_SW},
1066 MMPLAYER_ATTRS_AUDIO_CODEC_TYPE,
1067 (char *)"audio_codec_type",
1070 {(void *)MM_PLAYER_CODEC_TYPE_DEFAULT},
1071 MM_ATTRS_VALID_TYPE_INT_RANGE,
1072 {.int_min = MM_PLAYER_CODEC_TYPE_DEFAULT},
1073 {.int_max = MM_PLAYER_CODEC_TYPE_SW},
1077 MMPLAYER_ATTRS_VIDEO_BUFFER_TOTAL_SIZE,
1078 (char *)"video_buffer_total_size",
1081 {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1082 MM_ATTRS_VALID_TYPE_INT_RANGE,
1083 {.int_min = MMPLAYER_MIN_INT},
1084 {.int_max = MMPLAYER_MAX_INT},
1088 MMPLAYER_ATTRS_VIDEO_BUFFER_EXTRA_SIZE,
1089 (char *)"video_buffer_extra_size",
1092 {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1093 MM_ATTRS_VALID_TYPE_INT_RANGE,
1094 {.int_min = MMPLAYER_MIN_INT},
1095 {.int_max = MMPLAYER_MAX_INT},
1099 MMPLAYER_ATTRS_PREBUFFER_MS,
1100 (char *)"prebuffer_ms", /* user setting */
1103 {(void *) MIN_BUFFERING_TIME},
1104 MM_ATTRS_VALID_TYPE_INT_RANGE,
1105 {.int_min = MIN_BUFFERING_TIME},
1106 {.int_max = MMPLAYER_MAX_INT},
1110 MMPLAYER_ATTRS_REBUFFER_MS,
1111 (char *)"rebuffer_ms", /* user setting */
1114 {(void *) MIN_BUFFERING_TIME},
1115 MM_ATTRS_VALID_TYPE_INT_RANGE,
1116 {.int_min = MIN_BUFFERING_TIME},
1117 {.int_max = MMPLAYER_MAX_INT},
1121 MMPLAYER_ATTRS_PITCH_CONTROL,
1122 (char *)"pitch_control", /* MM_PLAYER_PITCH_CONTROL */
1126 MM_ATTRS_VALID_TYPE_INT_RANGE,
1132 MMPLAYER_ATTRS_PITCH_VALUE,
1133 (char *)"pitch_value", /* MM_PLAYER_PITCH_VALUE */
1134 MM_ATTRS_TYPE_DOUBLE,
1136 {.value_double = 1.0},
1137 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1138 {.double_min = 0.5},
1140 __mmplayer_commit_audio_pitch_value,
1143 MMPLAYER_ATTRS_AUDIO_OFFLOAD,
1144 (char *)"audio_offload", /* MM_PLAYER_AUDIO_OFFLOAD */
1148 MM_ATTRS_VALID_TYPE_INT_RANGE,
1154 MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT,
1155 (char *)"audio_offload_format", /* MM_PLAYER_AUDIO_OFFLOAD_FORMAT, array of media_format_mimetype_e */
1159 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1160 {.int_array = NULL},
1165 MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT, /* MM_PLAYER_MEDIA_STREAM_INPUT_FORMAT */
1166 (char *)"media_stream_input_format",
1170 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1171 {.int_array = NULL},
1177 MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
1179 num_of_attrs = ARRAY_SIZE(player_attrs);
1181 base = g_try_new(MMAttrsConstructInfo, num_of_attrs);
1183 LOGE("failed to alloc attrs constructor");
1187 /* initialize values of attributes */
1188 for (idx = 0; idx < num_of_attrs; idx++) {
1189 base[idx].name = player_attrs[idx].name;
1190 base[idx].value_type = player_attrs[idx].value_type;
1191 base[idx].flags = player_attrs[idx].flags;
1192 base[idx].default_value = player_attrs[idx].default_value.value_void; /* FIXME: need to consider the double data type */
1195 result = mm_attrs_new(base, num_of_attrs, "mmplayer_attrs",
1196 _mmplayer_commit_attribute, (void *)handle, &attrs);
1199 MMPLAYER_FREEIF(base);
1202 LOGE("failed to create player attrs");
1206 /* alloc default attribute info */
1207 player->default_attrs = (mmplayer_attrs_spec_t *)g_try_malloc(sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1208 if (player->default_attrs == NULL) {
1209 LOGE("failed to alloc default attribute info");
1213 memcpy(player->default_attrs, player_attrs, sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1215 __mmplayer_set_ini_to_valid_info(handle);
1217 /* set validity type and range */
1218 for (idx = 0; idx < num_of_attrs; idx++) {
1219 mm_attrs_set_valid_type(attrs, idx, player->default_attrs[idx].valid_type);
1220 switch (player->default_attrs[idx].valid_type) {
1221 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1222 mm_attrs_set_valid_range(attrs, idx,
1223 player->default_attrs[idx].validity_value_1.int_min,
1224 player->default_attrs[idx].validity_value_2.int_max,
1225 player->default_attrs[idx].default_value.value_int);
1227 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1228 if (player->default_attrs[idx].validity_value_1.int_array &&
1229 player->default_attrs[idx].validity_value_2.count > 0)
1230 mm_attrs_set_valid_array(attrs, idx,
1231 (const int *)(player->default_attrs[idx].validity_value_1.int_array),
1232 player->default_attrs[idx].validity_value_2.count,
1233 player->default_attrs[idx].default_value.value_int);
1235 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1236 mm_attrs_set_valid_double_range(attrs, idx,
1237 player->default_attrs[idx].validity_value_1.double_min,
1238 player->default_attrs[idx].validity_value_2.double_max,
1239 player->default_attrs[idx].default_value.value_double);
1241 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1242 LOGW("FIXME: need to set range value if required.");
1243 case MM_ATTRS_VALID_TYPE_NONE:
1244 case MM_ATTRS_VALID_TYPE_INVALID:
1251 if (mm_attrs_commit_all(attrs)) {
1252 LOGE("failed to update attributes");
1256 __mmplayer_release_ini_info(handle);
1261 MMPLAYER_FREEIF(player->default_attrs);
1264 mm_attrs_free(attrs);
1269 bool _mmplayer_deconstruct_attribute(MMHandleType handle)
1271 mmplayer_t *player = MM_PLAYER_CAST(handle);
1273 MMPLAYER_RETURN_VAL_IF_FAIL(player, false);
1275 if (player->attrs) {
1276 mm_attrs_free(player->attrs);
1277 player->attrs = NULL;
1280 MMPLAYER_FREEIF(player->default_attrs);