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 * Seungbae Shin <seungbae.shin@samsung.com>, 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.
28 #include <mm_message.h>
30 #include "mm_player.h"
31 #include "mm_player_priv.h"
32 #include "mm_player_attrs.h"
33 #include "mm_player_utils.h"
34 #include "mm_player_ini.h"
35 #include "mm_player_capture.h"
36 #include "mm_player_tracks.h"
37 #include "mm_player_es.h"
38 #include "mm_player_360.h"
39 #include "mm_player_gst.h"
41 int mm_player_create(MMHandleType *player)
43 int result = MM_ERROR_PLAYER_INTERNAL;
44 mmplayer_t *new_player = NULL;
46 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
48 /* alloc player structure */
49 new_player = g_try_new0(mmplayer_t, 1);
51 LOGE("Cannot allocate memory for player\n");
52 result = MM_ERROR_PLAYER_RESOURCE_LIMIT;
56 /* create player cmd lock */
57 g_mutex_init(&new_player->cmd_lock);
59 /* create player playback lock */
60 g_mutex_init(&new_player->playback_lock);
63 if (MM_ERROR_NONE != mm_player_ini_load(&new_player->ini)) {
64 LOGE("can't load ini");
68 if (MM_ERROR_NONE != mm_player_audio_effect_ini_load(&new_player->ini)) {
69 LOGE("can't load audio ini");
74 result = _mmplayer_create_player((MMHandleType)new_player);
75 if (result != MM_ERROR_NONE) {
76 LOGE("failed to create player");
77 if (result != MM_ERROR_PLAYER_RESOURCE_LIMIT)
78 result = MM_ERROR_PLAYER_INTERNAL;
82 *player = (MMHandleType)new_player;
89 _mmplayer_destroy((MMHandleType)new_player);
90 g_mutex_clear(&new_player->cmd_lock);
91 g_mutex_clear(&new_player->playback_lock);
93 MMPLAYER_FREEIF(new_player);
96 *player = (MMHandleType)0;
97 return result; /* MM_ERROR_PLAYER_INTERNAL or MM_ERROR_PLAYER_RESOURCE_LIMIT */
100 int mm_player_destroy(MMHandleType player)
102 int result = MM_ERROR_NONE;
104 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
106 /* destroy the gst bus msg thread if it is remained.
107 this funct have to be called before getting cmd lock. */
108 _mmplayer_bus_msg_thread_destroy(player);
110 MMPLAYER_CMD_LOCK(player);
112 result = _mmplayer_destroy(player);
114 MMPLAYER_CMD_UNLOCK(player);
116 g_mutex_clear(&((mmplayer_t *)player)->cmd_lock);
117 g_mutex_clear(&((mmplayer_t *)player)->playback_lock);
119 memset((mmplayer_t *)player, 0x00, sizeof(mmplayer_t));
122 g_free((void *)player);
127 int mm_player_realize(MMHandleType player)
129 int result = MM_ERROR_NONE;
131 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
133 MMPLAYER_CMD_LOCK(player);
135 result = _mmplayer_realize(player);
137 MMPLAYER_CMD_UNLOCK(player);
142 int mm_player_abort_pause(MMHandleType player)
144 int result = MM_ERROR_NONE;
146 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
148 /* destroy the gst bus msg thread not to be blocked in pause(without cmd lock). */
149 _mmplayer_bus_msg_thread_destroy(player);
151 /* abort the pause operation for preparing(without cmd lock). */
152 result = _mmplayer_abort_pause(player);
157 int mm_player_unrealize(MMHandleType player)
159 int result = MM_ERROR_NONE;
161 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
163 MMPLAYER_CMD_LOCK(player);
165 result = _mmplayer_unrealize(player);
167 MMPLAYER_CMD_UNLOCK(player);
172 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
174 int result = MM_ERROR_NONE;
176 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
178 MMPLAYER_CMD_LOCK(player);
180 result = _mmplayer_set_message_callback(player, callback, user_param);
182 MMPLAYER_CMD_UNLOCK(player);
187 int mm_player_set_audio_decoded_callback(MMHandleType player, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param)
189 int result = MM_ERROR_NONE;
191 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
193 MMPLAYER_CMD_LOCK(player);
195 result = _mmplayer_set_audio_decoded_cb(player, opt, callback, user_param);
197 MMPLAYER_CMD_UNLOCK(player);
202 int mm_player_set_video_decoded_callback(MMHandleType player, mm_player_video_decoded_callback callback, void *user_param)
204 int result = MM_ERROR_NONE;
206 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
208 MMPLAYER_CMD_LOCK(player);
210 result = _mmplayer_set_video_decoded_cb(player, callback, user_param);
212 MMPLAYER_CMD_UNLOCK(player);
217 int mm_player_do_video_capture(MMHandleType player)
219 int result = MM_ERROR_NONE;
221 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
223 MMPLAYER_CMD_LOCK(player);
225 result = _mmplayer_do_video_capture(player);
227 MMPLAYER_CMD_UNLOCK(player);
232 int mm_player_set_volume(MMHandleType player, float volume)
234 int result = MM_ERROR_NONE;
236 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
238 MMPLAYER_CMD_LOCK(player);
240 result = _mmplayer_set_volume(player, volume);
242 MMPLAYER_CMD_UNLOCK(player);
247 int mm_player_get_volume(MMHandleType player, float *volume)
249 int result = MM_ERROR_NONE;
251 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
252 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
254 MMPLAYER_CMD_LOCK(player);
256 result = _mmplayer_get_volume(player, volume);
258 MMPLAYER_CMD_UNLOCK(player);
263 int mm_player_set_mute(MMHandleType player, bool mute)
265 int result = MM_ERROR_NONE;
267 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
269 MMPLAYER_CMD_LOCK(player);
271 result = _mmplayer_set_mute(player, mute);
273 MMPLAYER_CMD_UNLOCK(player);
278 int mm_player_get_mute(MMHandleType player, bool *mute)
280 int result = MM_ERROR_NONE;
282 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
283 MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
285 MMPLAYER_CMD_LOCK(player);
287 result = _mmplayer_get_mute(player, mute);
289 MMPLAYER_CMD_UNLOCK(player);
294 int mm_player_get_state(MMHandleType player, mmplayer_state_e *state)
296 int result = MM_ERROR_NONE;
298 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
299 MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
301 *state = MM_PLAYER_STATE_NULL;
303 result = _mmplayer_get_state(player, (int *)state);
308 /* NOTE : It does not support some use cases, eg using colorspace converter */
309 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
311 int result = MM_ERROR_NONE;
313 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
315 MMPLAYER_CMD_LOCK(player);
317 result = _mmplayer_change_videosink(player, display_surface_type, display_overlay);
319 MMPLAYER_CMD_UNLOCK(player);
324 int mm_player_start(MMHandleType player)
326 int result = MM_ERROR_NONE;
328 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
330 MMPLAYER_CMD_LOCK(player);
332 result = _mmplayer_start(player);
334 MMPLAYER_CMD_UNLOCK(player);
339 int mm_player_stop(MMHandleType player)
341 int result = MM_ERROR_NONE;
343 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
345 MMPLAYER_CMD_LOCK(player);
347 result = _mmplayer_stop(player);
349 MMPLAYER_CMD_UNLOCK(player);
354 int mm_player_pause(MMHandleType player)
356 int result = MM_ERROR_NONE;
358 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
360 MMPLAYER_CMD_LOCK(player);
362 result = _mmplayer_pause(player);
364 MMPLAYER_CMD_UNLOCK(player);
369 int mm_player_resume(MMHandleType player)
371 int result = MM_ERROR_NONE;
373 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
375 MMPLAYER_CMD_LOCK(player);
377 result = _mmplayer_resume(player);
379 MMPLAYER_CMD_UNLOCK(player);
384 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
386 int result = MM_ERROR_NONE;
388 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
390 MMPLAYER_CMD_LOCK(player);
392 result = _mmplayer_set_playspeed(player, rate, streaming);
394 MMPLAYER_CMD_UNLOCK(player);
399 int mm_player_set_position(MMHandleType player, int64_t pos)
401 int result = MM_ERROR_NONE;
403 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
405 MMPLAYER_CMD_LOCK(player);
407 result = _mmplayer_set_position(player, pos);
409 MMPLAYER_CMD_UNLOCK(player);
414 int mm_player_get_position(MMHandleType player, int64_t *pos)
416 int result = MM_ERROR_NONE;
418 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
419 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
421 MMPLAYER_CMD_LOCK(player);
423 result = _mmplayer_gst_get_position((mmplayer_t *)player, pos);
425 MMPLAYER_CMD_UNLOCK(player);
430 int mm_player_get_duration(MMHandleType player, int64_t *dur)
432 int result = MM_ERROR_NONE;
434 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
435 MMPLAYER_RETURN_VAL_IF_FAIL(dur, MM_ERROR_COMMON_INVALID_ARGUMENT);
437 MMPLAYER_CMD_LOCK(player);
439 result = _mmplayer_get_duration(player, dur);
441 MMPLAYER_CMD_UNLOCK(player);
447 int mm_player_get_buffer_position(MMHandleType player, int *start_pos, int *end_pos)
449 int result = MM_ERROR_NONE;
451 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
452 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && end_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
454 MMPLAYER_CMD_LOCK(player);
456 result = _mmplayer_get_buffer_position(player, start_pos, end_pos);
458 MMPLAYER_CMD_UNLOCK(player);
463 int mm_player_set_external_subtitle_path(MMHandleType player, const char *path)
465 int result = MM_ERROR_NONE;
467 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
469 MMPLAYER_CMD_LOCK(player);
471 result = _mmplayer_set_external_subtitle_path(player, path);
473 MMPLAYER_CMD_UNLOCK(player);
477 int mm_player_adjust_subtitle_position(MMHandleType player, int pos)
479 int result = MM_ERROR_NONE;
481 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
483 MMPLAYER_CMD_LOCK(player);
485 result = _mmplayer_adjust_subtitle_postion(player, pos);
487 MMPLAYER_CMD_UNLOCK(player);
492 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
494 int result = MM_ERROR_NONE;
496 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
498 MMPLAYER_CMD_LOCK(player);
500 result = _mmplayer_set_subtitle_silent(player, silent);
502 MMPLAYER_CMD_UNLOCK(player);
507 int mm_player_get_subtitle_silent(MMHandleType player, int *silent)
509 int result = MM_ERROR_NONE;
511 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
513 MMPLAYER_CMD_LOCK(player);
515 result = _mmplayer_get_subtitle_silent(player, silent);
517 MMPLAYER_CMD_UNLOCK(player);
522 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
524 int result = MM_ERROR_NONE;
527 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
528 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
530 va_start(var_args, first_attribute_name);
531 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
537 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
539 int result = MM_ERROR_NONE;
542 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
543 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
545 va_start(var_args, first_attribute_name);
546 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
552 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, mmplayer_attrs_info_t *info)
554 int result = MM_ERROR_NONE;
557 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
558 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
559 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
561 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
566 int mm_player_get_track_count(MMHandleType player, mmplayer_track_type_e type, int *count)
568 int result = MM_ERROR_NONE;
570 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
571 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
573 MMPLAYER_CMD_LOCK(player);
575 result = _mmplayer_get_track_count(player, type, count);
577 MMPLAYER_CMD_UNLOCK(player);
582 int mm_player_select_track(MMHandleType player, mmplayer_track_type_e type, int index)
584 int result = MM_ERROR_NONE;
586 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
588 MMPLAYER_CMD_LOCK(player);
590 result = _mmplayer_select_track(player, type, index);
592 MMPLAYER_CMD_UNLOCK(player);
597 int mm_player_get_current_track(MMHandleType player, mmplayer_track_type_e type, int *index)
599 int result = MM_ERROR_NONE;
601 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
602 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
604 MMPLAYER_CMD_LOCK(player);
606 result = _mmplayer_get_current_track(player, type, index);
608 MMPLAYER_CMD_UNLOCK(player);
613 int mm_player_get_track_language_code(MMHandleType player, mmplayer_track_type_e type, int index, char **code)
615 int result = MM_ERROR_NONE;
617 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
619 MMPLAYER_CMD_LOCK(player);
621 result = _mmplayer_get_track_language_code(player, type, index, code);
623 MMPLAYER_CMD_UNLOCK(player);
628 int mm_player_set_uri(MMHandleType player, const char *uri)
630 int result = MM_ERROR_NONE;
632 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
634 MMPLAYER_CMD_LOCK(player);
636 result = _mmplayer_set_uri(player, uri);
638 MMPLAYER_CMD_UNLOCK(player);
644 int mm_player_set_next_uri(MMHandleType player, const char *uri)
646 int result = MM_ERROR_NONE;
648 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
650 MMPLAYER_CMD_LOCK(player);
652 result = _mmplayer_set_next_uri(player, uri, FALSE);
654 MMPLAYER_CMD_UNLOCK(player);
660 int mm_player_get_next_uri(MMHandleType player, char **uri)
662 int result = MM_ERROR_NONE;
664 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
666 MMPLAYER_CMD_LOCK(player);
668 result = _mmplayer_get_next_uri(player, uri);
670 MMPLAYER_CMD_UNLOCK(player);
676 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
678 int result = MM_ERROR_NONE;
680 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
681 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
683 MMPLAYER_CMD_LOCK(player);
685 result = _mmplayer_has_closed_caption(player, exist);
687 MMPLAYER_CMD_UNLOCK(player);
692 void mm_player_video_stream_internal_buffer_unref(void *buffer)
694 _mm_player_video_stream_internal_buffer_unref(buffer);
697 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
700 int result = MM_ERROR_NONE;
702 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
704 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
705 //MMPLAYER_CMD_LOCK(player);
707 result = _mmplayer_submit_packet(player, packet);
709 //MMPLAYER_CMD_UNLOCK(player);
714 int mm_player_set_video_info(MMHandleType player, media_format_h format)
716 int result = MM_ERROR_NONE;
720 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
722 MMPLAYER_CMD_LOCK(player);
724 result = _mmplayer_set_video_info(player, format);
726 MMPLAYER_CMD_UNLOCK(player);
732 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
734 int result = MM_ERROR_NONE;
738 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
740 MMPLAYER_CMD_LOCK(player);
742 result = _mmplayer_set_audio_info(player, format);
744 MMPLAYER_CMD_UNLOCK(player);
749 int mm_player_set_subtitle_info(MMHandleType player, mmplayer_subtitle_stream_info_t *subtitle_stream_info)
751 int result = MM_ERROR_NONE;
755 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
757 MMPLAYER_CMD_LOCK(player);
759 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
761 MMPLAYER_CMD_UNLOCK(player);
766 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long max_size)
768 int result = MM_ERROR_NONE;
772 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
774 MMPLAYER_CMD_LOCK(player);
776 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
778 MMPLAYER_CMD_UNLOCK(player);
783 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long *max_size)
785 int result = MM_ERROR_NONE;
786 guint64 _max_size = 0;
790 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
791 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
793 MMPLAYER_CMD_LOCK(player);
795 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
796 *max_size = _max_size;
798 MMPLAYER_CMD_UNLOCK(player);
803 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned min_percent)
805 int result = MM_ERROR_NONE;
809 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
811 MMPLAYER_CMD_LOCK(player);
813 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
815 MMPLAYER_CMD_UNLOCK(player);
820 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned int *min_percent)
822 int result = MM_ERROR_NONE;
826 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
827 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
829 MMPLAYER_CMD_LOCK(player);
831 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
833 MMPLAYER_CMD_UNLOCK(player);
838 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, mmplayer_stream_type_e type, mm_player_media_stream_buffer_status_callback callback, void *user_param)
840 int result = MM_ERROR_NONE;
844 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
846 MMPLAYER_CMD_LOCK(player);
848 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
850 MMPLAYER_CMD_UNLOCK(player);
855 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, mmplayer_stream_type_e type, mm_player_media_stream_seek_data_callback callback, void *user_param)
857 int result = MM_ERROR_NONE;
861 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
863 MMPLAYER_CMD_LOCK(player);
865 result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
867 MMPLAYER_CMD_UNLOCK(player);
872 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
874 int result = MM_ERROR_NONE;
876 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
878 MMPLAYER_CMD_LOCK(player);
880 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
882 MMPLAYER_CMD_UNLOCK(player);
887 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
889 int result = MM_ERROR_NONE;
891 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
893 MMPLAYER_CMD_LOCK(player);
895 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
897 MMPLAYER_CMD_UNLOCK(player);
902 int mm_player_get_timeout(MMHandleType player, int *timeout)
904 int result = MM_ERROR_NONE;
906 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
907 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
909 MMPLAYER_CMD_LOCK(player);
911 result = _mmplayer_get_timeout(player, timeout);
913 MMPLAYER_CMD_UNLOCK(player);
918 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
920 int result = MM_ERROR_NONE;
922 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
924 MMPLAYER_CMD_LOCK(player);
926 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
928 MMPLAYER_CMD_UNLOCK(player);
933 int mm_player_release_video_stream_bo(MMHandleType player, void *bo)
935 int result = MM_ERROR_NONE;
937 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
938 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
940 //MMPLAYER_CMD_LOCK(player);
942 result = _mmplayer_video_stream_release_bo(player, bo);
944 //MMPLAYER_CMD_UNLOCK(player);
949 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
951 int result = MM_ERROR_NONE;
953 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
954 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
956 MMPLAYER_CMD_LOCK(player);
958 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
960 MMPLAYER_CMD_UNLOCK(player);
965 int mm_player_manage_external_storage_state(MMHandleType player, int id, int state)
967 int result = MM_ERROR_NONE;
969 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
971 MMPLAYER_CMD_LOCK(player);
973 result = _mmplayer_manage_external_storage_state(player, id, state);
975 MMPLAYER_CMD_UNLOCK(player);
980 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
982 int result = MM_ERROR_NONE;
984 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
985 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
987 MMPLAYER_CMD_LOCK(player);
989 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
991 MMPLAYER_CMD_UNLOCK(player);
996 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
998 int result = MM_ERROR_NONE;
1000 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1002 MMPLAYER_CMD_LOCK(player);
1004 result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
1006 MMPLAYER_CMD_UNLOCK(player);
1011 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1013 int result = MM_ERROR_NONE;
1015 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1016 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1018 MMPLAYER_CMD_LOCK(player);
1020 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1022 MMPLAYER_CMD_UNLOCK(player);
1027 int mm_player_get_streaming_buffering_time(MMHandleType player, int *prebuffer_ms, int *rebuffer_ms)
1029 int result = MM_ERROR_NONE;
1031 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1032 MMPLAYER_RETURN_VAL_IF_FAIL(prebuffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1034 MMPLAYER_CMD_LOCK(player);
1036 result = _mmplayer_get_streaming_buffering_time(player, prebuffer_ms, rebuffer_ms);
1038 MMPLAYER_CMD_UNLOCK(player);
1043 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1045 int result = MM_ERROR_NONE;
1046 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1048 MMPLAYER_CMD_LOCK(player);
1050 result = _mmplayer_set_audio_only(player, audio_only);
1052 MMPLAYER_CMD_UNLOCK(player);
1057 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1059 int result = MM_ERROR_NONE;
1061 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1062 MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1064 MMPLAYER_CMD_LOCK(player);
1066 result = _mmplayer_get_audio_only(player, audio_only);
1068 MMPLAYER_CMD_UNLOCK(player);
1073 int mm_player_360_is_content_spherical(MMHandleType player, bool *is_spherical)
1075 int result = MM_ERROR_NONE;
1077 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1078 MMPLAYER_RETURN_VAL_IF_FAIL(is_spherical, MM_ERROR_INVALID_ARGUMENT);
1080 MMPLAYER_CMD_LOCK(player);
1082 result = _mmplayer_360_is_content_spherical(player, is_spherical);
1084 MMPLAYER_CMD_UNLOCK(player);
1089 int mm_player_360_set_enabled(MMHandleType player, bool enabled)
1091 int result = MM_ERROR_NONE;
1092 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1094 MMPLAYER_CMD_LOCK(player);
1096 result = _mmplayer_360_set_enabled(player, enabled);
1098 MMPLAYER_CMD_UNLOCK(player);
1103 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1105 int result = MM_ERROR_NONE;
1107 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1108 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1110 MMPLAYER_CMD_LOCK(player);
1112 result = _mmplayer_360_is_enabled(player, enabled);
1114 MMPLAYER_CMD_UNLOCK(player);
1119 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1121 int result = MM_ERROR_NONE;
1122 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1124 MMPLAYER_CMD_LOCK(player);
1126 result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1128 MMPLAYER_CMD_UNLOCK(player);
1133 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1135 int result = MM_ERROR_NONE;
1137 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1138 MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1140 MMPLAYER_CMD_LOCK(player);
1142 result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1144 MMPLAYER_CMD_UNLOCK(player);
1149 int mm_player_360_set_zoom(MMHandleType player, float level)
1151 int result = MM_ERROR_NONE;
1152 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1154 MMPLAYER_CMD_LOCK(player);
1156 result = _mmplayer_360_set_zoom(player, level);
1158 MMPLAYER_CMD_UNLOCK(player);
1163 int mm_player_360_get_zoom(MMHandleType player, float *level)
1165 int result = MM_ERROR_NONE;
1167 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1168 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1170 MMPLAYER_CMD_LOCK(player);
1172 result = _mmplayer_360_get_zoom(player, level);
1174 MMPLAYER_CMD_UNLOCK(player);
1179 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1181 int result = MM_ERROR_NONE;
1182 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1184 MMPLAYER_CMD_LOCK(player);
1186 result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1188 MMPLAYER_CMD_UNLOCK(player);
1193 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1195 int result = MM_ERROR_NONE;
1197 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1198 MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1200 MMPLAYER_CMD_LOCK(player);
1202 result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1204 MMPLAYER_CMD_UNLOCK(player);
1209 int mm_player_set_codec_type(MMHandleType player, mmplayer_stream_type_e stream_type, mmplayer_video_codec_type_e codec_type)
1211 int result = MM_ERROR_NONE;
1213 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1215 MMPLAYER_CMD_LOCK(player);
1217 result = _mmplayer_set_codec_type(player, stream_type, codec_type);
1219 MMPLAYER_CMD_UNLOCK(player);
1224 int mm_player_set_replaygain_enabled(MMHandleType player, bool enabled)
1226 int result = MM_ERROR_NONE;
1228 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1230 MMPLAYER_CMD_LOCK(player);
1232 result = _mmplayer_set_replaygain_enabled(player, enabled);
1234 MMPLAYER_CMD_UNLOCK(player);
1239 int mm_player_is_replaygain_enabled(MMHandleType player, bool *enabled)
1241 int result = MM_ERROR_NONE;
1243 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1244 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1246 MMPLAYER_CMD_LOCK(player);
1248 result = _mmplayer_is_replaygain_enabled(player, enabled);
1250 MMPLAYER_CMD_UNLOCK(player);
1255 int mm_player_set_video_roi_area(MMHandleType player, double scale_x, double scale_y, double scale_width, double scale_height)
1257 int result = MM_ERROR_NONE;
1259 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1261 MMPLAYER_CMD_LOCK(player);
1263 result = _mmplayer_set_video_roi_area(player, scale_x, scale_y, scale_width, scale_height);
1265 MMPLAYER_CMD_UNLOCK(player);
1270 int mm_player_get_video_roi_area(MMHandleType player, double *scale_x, double *scale_y, double *scale_width, double *scale_height)
1272 int result = MM_ERROR_NONE;
1274 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1276 MMPLAYER_CMD_LOCK(player);
1278 result = _mmplayer_get_video_roi_area(player, scale_x, scale_y, scale_width, scale_height);
1280 MMPLAYER_CMD_UNLOCK(player);