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"
40 int mm_player_create(MMHandleType *player)
42 int result = MM_ERROR_PLAYER_INTERNAL;
43 mmplayer_t *new_player = NULL;
45 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
47 /* alloc player structure */
48 new_player = g_try_new0(mmplayer_t, 1);
50 LOGE("Cannot allocate memory for player\n");
51 result = MM_ERROR_PLAYER_RESOURCE_LIMIT;
55 /* create player cmd lock */
56 g_mutex_init(&new_player->cmd_lock);
58 /* create player playback lock */
59 g_mutex_init(&new_player->playback_lock);
62 if (MM_ERROR_NONE != mm_player_ini_load(&new_player->ini)) {
63 LOGE("can't load ini");
67 if (MM_ERROR_NONE != mm_player_audio_effect_ini_load(&new_player->ini)) {
68 LOGE("can't load audio ini");
73 result = _mmplayer_create_player((MMHandleType)new_player);
74 if (result != MM_ERROR_NONE) {
75 LOGE("failed to create player");
76 if (result != MM_ERROR_PLAYER_RESOURCE_LIMIT)
77 result = MM_ERROR_PLAYER_INTERNAL;
81 *player = (MMHandleType)new_player;
88 _mmplayer_destroy((MMHandleType)new_player);
89 g_mutex_clear(&new_player->cmd_lock);
90 g_mutex_clear(&new_player->playback_lock);
92 MMPLAYER_FREEIF(new_player);
95 *player = (MMHandleType)0;
96 return result; /* MM_ERROR_PLAYER_INTERNAL or MM_ERROR_PLAYER_RESOURCE_LIMIT */
99 int mm_player_destroy(MMHandleType player)
101 int result = MM_ERROR_NONE;
103 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
105 /* destroy the gst bus msg thread if it is remained.
106 this funct have to be called before getting cmd lock. */
107 __mmplayer_bus_msg_thread_destroy(player);
109 MMPLAYER_CMD_LOCK(player);
111 result = _mmplayer_destroy(player);
113 MMPLAYER_CMD_UNLOCK(player);
115 g_mutex_clear(&((mmplayer_t *)player)->cmd_lock);
116 g_mutex_clear(&((mmplayer_t *)player)->playback_lock);
118 memset((mmplayer_t *)player, 0x00, sizeof(mmplayer_t));
121 g_free((void *)player);
126 int mm_player_realize(MMHandleType player)
128 int result = MM_ERROR_NONE;
130 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
132 MMPLAYER_CMD_LOCK(player);
134 result = _mmplayer_realize(player);
136 MMPLAYER_CMD_UNLOCK(player);
141 int mm_player_abort_pause(MMHandleType player)
143 int result = MM_ERROR_NONE;
145 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
147 /* destroy the gst bus msg thread not to be blocked in pause(without cmd lock). */
148 __mmplayer_bus_msg_thread_destroy(player);
150 /* abort the pause operation for preparing(without cmd lock). */
151 result = _mmplayer_abort_pause(player);
156 int mm_player_unrealize(MMHandleType player)
158 int result = MM_ERROR_NONE;
160 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
162 MMPLAYER_CMD_LOCK(player);
164 result = _mmplayer_unrealize(player);
166 MMPLAYER_CMD_UNLOCK(player);
171 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
173 int result = MM_ERROR_NONE;
175 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
177 MMPLAYER_CMD_LOCK(player);
179 result = _mmplayer_set_message_callback(player, callback, user_param);
181 MMPLAYER_CMD_UNLOCK(player);
186 int mm_player_set_audio_decoded_callback(MMHandleType player, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param)
188 int result = MM_ERROR_NONE;
190 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
192 MMPLAYER_CMD_LOCK(player);
194 result = _mmplayer_set_audio_decoded_cb(player, opt, callback, user_param);
196 MMPLAYER_CMD_UNLOCK(player);
201 int mm_player_set_video_decoded_callback(MMHandleType player, mm_player_video_decoded_callback callback, void *user_param)
203 int result = MM_ERROR_NONE;
205 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
207 MMPLAYER_CMD_LOCK(player);
209 result = _mmplayer_set_video_decoded_cb(player, callback, user_param);
211 MMPLAYER_CMD_UNLOCK(player);
216 int mm_player_do_video_capture(MMHandleType player)
218 int result = MM_ERROR_NONE;
220 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
222 MMPLAYER_CMD_LOCK(player);
224 result = _mmplayer_do_video_capture(player);
226 MMPLAYER_CMD_UNLOCK(player);
231 int mm_player_set_volume(MMHandleType player, float volume)
233 int result = MM_ERROR_NONE;
235 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
237 MMPLAYER_CMD_LOCK(player);
239 result = _mmplayer_set_volume(player, volume);
241 MMPLAYER_CMD_UNLOCK(player);
246 int mm_player_get_volume(MMHandleType player, float *volume)
248 int result = MM_ERROR_NONE;
250 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
251 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
253 MMPLAYER_CMD_LOCK(player);
255 result = _mmplayer_get_volume(player, volume);
257 MMPLAYER_CMD_UNLOCK(player);
262 int mm_player_set_mute(MMHandleType player, bool mute)
264 int result = MM_ERROR_NONE;
266 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
268 MMPLAYER_CMD_LOCK(player);
270 result = _mmplayer_set_mute(player, mute);
272 MMPLAYER_CMD_UNLOCK(player);
277 int mm_player_get_mute(MMHandleType player, bool *mute)
279 int result = MM_ERROR_NONE;
281 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
282 MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
284 MMPLAYER_CMD_LOCK(player);
286 result = _mmplayer_get_mute(player, mute);
288 MMPLAYER_CMD_UNLOCK(player);
293 int mm_player_get_state(MMHandleType player, mmplayer_state_e *state)
295 int result = MM_ERROR_NONE;
297 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
298 MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
300 *state = MM_PLAYER_STATE_NULL;
302 result = _mmplayer_get_state(player, (int *)state);
307 /* NOTE : It does not support some use cases, eg using colorspace converter */
308 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
310 int result = MM_ERROR_NONE;
312 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
314 MMPLAYER_CMD_LOCK(player);
316 result = _mmplayer_change_videosink(player, display_surface_type, display_overlay);
318 MMPLAYER_CMD_UNLOCK(player);
323 int mm_player_start(MMHandleType player)
325 int result = MM_ERROR_NONE;
327 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
329 MMPLAYER_CMD_LOCK(player);
331 result = _mmplayer_start(player);
333 MMPLAYER_CMD_UNLOCK(player);
338 int mm_player_stop(MMHandleType player)
340 int result = MM_ERROR_NONE;
342 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
344 MMPLAYER_CMD_LOCK(player);
346 result = _mmplayer_stop(player);
348 MMPLAYER_CMD_UNLOCK(player);
353 int mm_player_pause(MMHandleType player)
355 int result = MM_ERROR_NONE;
357 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
359 MMPLAYER_CMD_LOCK(player);
361 result = _mmplayer_pause(player);
363 MMPLAYER_CMD_UNLOCK(player);
368 int mm_player_resume(MMHandleType player)
370 int result = MM_ERROR_NONE;
372 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
374 MMPLAYER_CMD_LOCK(player);
376 result = _mmplayer_resume(player);
378 MMPLAYER_CMD_UNLOCK(player);
383 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
385 int result = MM_ERROR_NONE;
387 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
389 MMPLAYER_CMD_LOCK(player);
391 result = _mmplayer_set_playspeed(player, rate, streaming);
393 MMPLAYER_CMD_UNLOCK(player);
398 int mm_player_set_position(MMHandleType player, int64_t pos)
400 int result = MM_ERROR_NONE;
402 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
404 MMPLAYER_CMD_LOCK(player);
406 result = _mmplayer_set_position(player, pos);
408 MMPLAYER_CMD_UNLOCK(player);
413 int mm_player_get_position(MMHandleType player, int64_t *pos)
415 int result = MM_ERROR_NONE;
417 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
418 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
420 MMPLAYER_CMD_LOCK(player);
422 result = _mmplayer_get_position(player, pos);
424 MMPLAYER_CMD_UNLOCK(player);
429 int mm_player_get_duration(MMHandleType player, int64_t *dur)
431 int result = MM_ERROR_NONE;
433 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
434 MMPLAYER_RETURN_VAL_IF_FAIL(dur, MM_ERROR_COMMON_INVALID_ARGUMENT);
436 MMPLAYER_CMD_LOCK(player);
438 result = _mmplayer_get_duration(player, dur);
440 MMPLAYER_CMD_UNLOCK(player);
446 int mm_player_get_buffer_position(MMHandleType player, int *start_pos, int *end_pos)
448 int result = MM_ERROR_NONE;
450 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
451 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && end_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
453 MMPLAYER_CMD_LOCK(player);
455 result = _mmplayer_get_buffer_position(player, start_pos, end_pos);
457 MMPLAYER_CMD_UNLOCK(player);
462 int mm_player_set_external_subtitle_path(MMHandleType player, const char *path)
464 int result = MM_ERROR_NONE;
466 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
468 MMPLAYER_CMD_LOCK(player);
470 result = _mmplayer_set_external_subtitle_path(player, path);
472 MMPLAYER_CMD_UNLOCK(player);
476 int mm_player_adjust_subtitle_position(MMHandleType player, int pos)
478 int result = MM_ERROR_NONE;
480 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
482 MMPLAYER_CMD_LOCK(player);
484 result = _mmplayer_adjust_subtitle_postion(player, pos);
486 MMPLAYER_CMD_UNLOCK(player);
491 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
493 int result = MM_ERROR_NONE;
495 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
497 MMPLAYER_CMD_LOCK(player);
499 result = _mmplayer_set_subtitle_silent(player, silent);
501 MMPLAYER_CMD_UNLOCK(player);
506 int mm_player_get_subtitle_silent(MMHandleType player, int *silent)
508 int result = MM_ERROR_NONE;
510 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
512 MMPLAYER_CMD_LOCK(player);
514 result = _mmplayer_get_subtitle_silent(player, silent);
516 MMPLAYER_CMD_UNLOCK(player);
521 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
523 int result = MM_ERROR_NONE;
526 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
527 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
529 va_start(var_args, first_attribute_name);
530 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
536 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
538 int result = MM_ERROR_NONE;
541 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
542 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
544 va_start(var_args, first_attribute_name);
545 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
551 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, mmplayer_attrs_info_t *info)
553 int result = MM_ERROR_NONE;
556 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
557 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
558 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
560 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
565 int mm_player_get_track_count(MMHandleType player, mmplayer_track_type_e type, int *count)
567 int result = MM_ERROR_NONE;
569 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
570 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
572 MMPLAYER_CMD_LOCK(player);
574 result = _mmplayer_get_track_count(player, type, count);
576 MMPLAYER_CMD_UNLOCK(player);
581 int mm_player_select_track(MMHandleType player, mmplayer_track_type_e type, int index)
583 int result = MM_ERROR_NONE;
585 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
587 MMPLAYER_CMD_LOCK(player);
589 result = _mmplayer_select_track(player, type, index);
591 MMPLAYER_CMD_UNLOCK(player);
596 int mm_player_get_current_track(MMHandleType player, mmplayer_track_type_e type, int *index)
598 int result = MM_ERROR_NONE;
600 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
601 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
603 MMPLAYER_CMD_LOCK(player);
605 result = _mmplayer_get_current_track(player, type, index);
607 MMPLAYER_CMD_UNLOCK(player);
612 int mm_player_get_track_language_code(MMHandleType player, mmplayer_track_type_e type, int index, char **code)
614 int result = MM_ERROR_NONE;
616 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
618 MMPLAYER_CMD_LOCK(player);
620 result = _mmplayer_get_track_language_code(player, type, index, code);
622 MMPLAYER_CMD_UNLOCK(player);
627 int mm_player_set_uri(MMHandleType player, const char *uri)
629 int result = MM_ERROR_NONE;
631 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
633 MMPLAYER_CMD_LOCK(player);
635 result = _mmplayer_set_uri(player, uri);
637 MMPLAYER_CMD_UNLOCK(player);
643 int mm_player_set_next_uri(MMHandleType player, const char *uri)
645 int result = MM_ERROR_NONE;
647 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
649 MMPLAYER_CMD_LOCK(player);
651 result = _mmplayer_set_next_uri(player, uri, FALSE);
653 MMPLAYER_CMD_UNLOCK(player);
659 int mm_player_get_next_uri(MMHandleType player, char **uri)
661 int result = MM_ERROR_NONE;
663 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
665 MMPLAYER_CMD_LOCK(player);
667 result = _mmplayer_get_next_uri(player, uri);
669 MMPLAYER_CMD_UNLOCK(player);
675 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
677 int result = MM_ERROR_NONE;
679 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
680 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
682 MMPLAYER_CMD_LOCK(player);
684 result = _mmplayer_has_closed_caption(player, exist);
686 MMPLAYER_CMD_UNLOCK(player);
691 void mm_player_video_stream_internal_buffer_unref(void *buffer)
693 _mm_player_video_stream_internal_buffer_unref(buffer);
696 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
699 int result = MM_ERROR_NONE;
701 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
703 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
704 //MMPLAYER_CMD_LOCK(player);
706 result = _mmplayer_submit_packet(player, packet);
708 //MMPLAYER_CMD_UNLOCK(player);
713 int mm_player_set_video_info(MMHandleType player, media_format_h format)
715 int result = MM_ERROR_NONE;
719 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
721 MMPLAYER_CMD_LOCK(player);
723 result = _mmplayer_set_video_info(player, format);
725 MMPLAYER_CMD_UNLOCK(player);
731 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
733 int result = MM_ERROR_NONE;
737 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
739 MMPLAYER_CMD_LOCK(player);
741 result = _mmplayer_set_audio_info(player, format);
743 MMPLAYER_CMD_UNLOCK(player);
748 int mm_player_set_subtitle_info(MMHandleType player, mmplayer_subtitle_stream_info_t *subtitle_stream_info)
750 int result = MM_ERROR_NONE;
754 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
756 MMPLAYER_CMD_LOCK(player);
758 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
760 MMPLAYER_CMD_UNLOCK(player);
765 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long max_size)
767 int result = MM_ERROR_NONE;
771 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
773 MMPLAYER_CMD_LOCK(player);
775 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
777 MMPLAYER_CMD_UNLOCK(player);
782 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long *max_size)
784 int result = MM_ERROR_NONE;
785 guint64 _max_size = 0;
789 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
790 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
792 MMPLAYER_CMD_LOCK(player);
794 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
795 *max_size = _max_size;
797 MMPLAYER_CMD_UNLOCK(player);
802 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned min_percent)
804 int result = MM_ERROR_NONE;
808 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
810 MMPLAYER_CMD_LOCK(player);
812 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
814 MMPLAYER_CMD_UNLOCK(player);
819 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned int *min_percent)
821 int result = MM_ERROR_NONE;
825 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
826 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
828 MMPLAYER_CMD_LOCK(player);
830 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
832 MMPLAYER_CMD_UNLOCK(player);
837 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)
839 int result = MM_ERROR_NONE;
843 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
845 MMPLAYER_CMD_LOCK(player);
847 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
849 MMPLAYER_CMD_UNLOCK(player);
854 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)
856 int result = MM_ERROR_NONE;
860 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
862 MMPLAYER_CMD_LOCK(player);
864 result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
866 MMPLAYER_CMD_UNLOCK(player);
871 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
873 int result = MM_ERROR_NONE;
875 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
877 MMPLAYER_CMD_LOCK(player);
879 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
881 MMPLAYER_CMD_UNLOCK(player);
886 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
888 int result = MM_ERROR_NONE;
890 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
892 MMPLAYER_CMD_LOCK(player);
894 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
896 MMPLAYER_CMD_UNLOCK(player);
901 int mm_player_get_timeout(MMHandleType player, int *timeout)
903 int result = MM_ERROR_NONE;
905 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
906 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
908 MMPLAYER_CMD_LOCK(player);
910 result = _mmplayer_get_timeout(player, timeout);
912 MMPLAYER_CMD_UNLOCK(player);
917 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
919 int result = MM_ERROR_NONE;
921 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
922 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
924 MMPLAYER_CMD_LOCK(player);
926 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
928 MMPLAYER_CMD_UNLOCK(player);
933 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
935 int result = MM_ERROR_NONE;
937 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
939 MMPLAYER_CMD_LOCK(player);
941 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
943 MMPLAYER_CMD_UNLOCK(player);
948 int mm_player_release_video_stream_bo(MMHandleType player, void *bo)
950 int result = MM_ERROR_NONE;
952 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
953 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
955 //MMPLAYER_CMD_LOCK(player);
957 result = _mmplayer_video_stream_release_bo(player, bo);
959 //MMPLAYER_CMD_UNLOCK(player);
964 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
966 int result = MM_ERROR_NONE;
968 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
969 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
971 MMPLAYER_CMD_LOCK(player);
973 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
975 MMPLAYER_CMD_UNLOCK(player);
980 int mm_player_manage_external_storage_state(MMHandleType player, int id, int state)
982 int result = MM_ERROR_NONE;
984 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
986 MMPLAYER_CMD_LOCK(player);
988 result = _mmplayer_manage_external_storage_state(player, id, state);
990 MMPLAYER_CMD_UNLOCK(player);
995 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
997 int result = MM_ERROR_NONE;
999 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1000 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1002 MMPLAYER_CMD_LOCK(player);
1004 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1006 MMPLAYER_CMD_UNLOCK(player);
1011 int mm_player_set_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);
1017 MMPLAYER_CMD_LOCK(player);
1019 result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
1021 MMPLAYER_CMD_UNLOCK(player);
1026 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1028 int result = MM_ERROR_NONE;
1030 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1031 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1033 MMPLAYER_CMD_LOCK(player);
1035 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1037 MMPLAYER_CMD_UNLOCK(player);
1042 int mm_player_get_streaming_buffering_time(MMHandleType player, int *prebuffer_ms, int *rebuffer_ms)
1044 int result = MM_ERROR_NONE;
1046 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1047 MMPLAYER_RETURN_VAL_IF_FAIL(prebuffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1049 MMPLAYER_CMD_LOCK(player);
1051 result = _mmplayer_get_streaming_buffering_time(player, prebuffer_ms, rebuffer_ms);
1053 MMPLAYER_CMD_UNLOCK(player);
1058 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1060 int result = MM_ERROR_NONE;
1061 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1063 MMPLAYER_CMD_LOCK(player);
1065 result = _mmplayer_set_audio_only(player, audio_only);
1067 MMPLAYER_CMD_UNLOCK(player);
1072 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1074 int result = MM_ERROR_NONE;
1076 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1077 MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1079 MMPLAYER_CMD_LOCK(player);
1081 result = _mmplayer_get_audio_only(player, audio_only);
1083 MMPLAYER_CMD_UNLOCK(player);
1088 int mm_player_360_is_content_spherical(MMHandleType player, bool *is_spherical)
1090 int result = MM_ERROR_NONE;
1092 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1093 MMPLAYER_RETURN_VAL_IF_FAIL(is_spherical, MM_ERROR_INVALID_ARGUMENT);
1095 MMPLAYER_CMD_LOCK(player);
1097 result = _mmplayer_360_is_content_spherical(player, is_spherical);
1099 MMPLAYER_CMD_UNLOCK(player);
1104 int mm_player_360_set_enabled(MMHandleType player, bool enabled)
1106 int result = MM_ERROR_NONE;
1107 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1109 MMPLAYER_CMD_LOCK(player);
1111 result = _mmplayer_360_set_enabled(player, enabled);
1113 MMPLAYER_CMD_UNLOCK(player);
1118 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1120 int result = MM_ERROR_NONE;
1122 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1123 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1125 MMPLAYER_CMD_LOCK(player);
1127 result = _mmplayer_360_is_enabled(player, enabled);
1129 MMPLAYER_CMD_UNLOCK(player);
1134 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1136 int result = MM_ERROR_NONE;
1137 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1139 MMPLAYER_CMD_LOCK(player);
1141 result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1143 MMPLAYER_CMD_UNLOCK(player);
1148 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1150 int result = MM_ERROR_NONE;
1152 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1153 MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1155 MMPLAYER_CMD_LOCK(player);
1157 result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1159 MMPLAYER_CMD_UNLOCK(player);
1164 int mm_player_360_set_zoom(MMHandleType player, float level)
1166 int result = MM_ERROR_NONE;
1167 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1169 MMPLAYER_CMD_LOCK(player);
1171 result = _mmplayer_360_set_zoom(player, level);
1173 MMPLAYER_CMD_UNLOCK(player);
1178 int mm_player_360_get_zoom(MMHandleType player, float *level)
1180 int result = MM_ERROR_NONE;
1182 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1183 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1185 MMPLAYER_CMD_LOCK(player);
1187 result = _mmplayer_360_get_zoom(player, level);
1189 MMPLAYER_CMD_UNLOCK(player);
1194 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1196 int result = MM_ERROR_NONE;
1197 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1199 MMPLAYER_CMD_LOCK(player);
1201 result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1203 MMPLAYER_CMD_UNLOCK(player);
1208 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1210 int result = MM_ERROR_NONE;
1212 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1213 MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1215 MMPLAYER_CMD_LOCK(player);
1217 result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1219 MMPLAYER_CMD_UNLOCK(player);
1224 int mm_player_set_codec_type(MMHandleType player, mmplayer_stream_type_e stream_type, mmplayer_video_codec_type_e codec_type)
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_codec_type(player, stream_type, codec_type);
1234 MMPLAYER_CMD_UNLOCK(player);
1239 int mm_player_set_replaygain_enabled(MMHandleType player, bool enabled)
1241 int result = MM_ERROR_NONE;
1243 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1245 MMPLAYER_CMD_LOCK(player);
1247 result = _mmplayer_set_replaygain_enabled(player, enabled);
1249 MMPLAYER_CMD_UNLOCK(player);
1254 int mm_player_is_replaygain_enabled(MMHandleType player, bool *enabled)
1256 int result = MM_ERROR_NONE;
1258 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1259 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1261 MMPLAYER_CMD_LOCK(player);
1263 result = _mmplayer_is_replaygain_enabled(player, enabled);
1265 MMPLAYER_CMD_UNLOCK(player);
1270 int mm_player_set_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_set_video_roi_area(player, scale_x, scale_y, scale_width, scale_height);
1280 MMPLAYER_CMD_UNLOCK(player);
1285 int mm_player_get_video_roi_area(MMHandleType player, double *scale_x, double *scale_y, double *scale_width, double *scale_height)
1287 int result = MM_ERROR_NONE;
1289 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1291 MMPLAYER_CMD_LOCK(player);
1293 result = _mmplayer_get_video_roi_area(player, scale_x, scale_y, scale_width, scale_height);
1295 MMPLAYER_CMD_UNLOCK(player);