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_sound_focus.h"
39 #include "mm_player_360.h"
41 int mm_player_create(MMHandleType *player)
43 int result = MM_ERROR_PLAYER_INTERNAL;
44 mm_player_t* new_player = NULL;
46 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
48 /* alloc player structure */
49 new_player = g_malloc(sizeof(mm_player_t));
51 LOGE("Cannot allocate memory for player\n");
52 result = MM_ERROR_PLAYER_RESOURCE_LIMIT;
55 memset(new_player, 0, sizeof(mm_player_t));
57 /* create player lock */
58 g_mutex_init(&new_player->cmd_lock);
60 /* create player lock */
61 g_mutex_init(&new_player->playback_lock);
64 if (MM_ERROR_NONE != mm_player_ini_load(&new_player->ini)) {
65 LOGE("can't load ini");
69 if (MM_ERROR_NONE != mm_player_audio_effect_ini_load(&new_player->ini)) {
70 LOGE("can't load audio ini");
75 result = _mmplayer_create_player((MMHandleType)new_player);
76 if (result != MM_ERROR_NONE) {
77 LOGE("failed to create player");
78 if (result != MM_ERROR_PLAYER_RESOURCE_LIMIT)
79 result = MM_ERROR_PLAYER_INTERNAL;
83 *player = (MMHandleType)new_player;
90 _mmplayer_destroy((MMHandleType)new_player);
91 g_mutex_clear(&new_player->cmd_lock);
92 g_mutex_clear(&new_player->playback_lock);
94 MMPLAYER_FREEIF(new_player);
97 *player = (MMHandleType)0;
98 return result; /* MM_ERROR_PLAYER_INTERNAL or MM_ERROR_PLAYER_RESOURCE_LIMIT */
101 int mm_player_destroy(MMHandleType player)
103 int result = MM_ERROR_NONE;
105 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
107 MMPLAYER_CMD_LOCK(player);
109 result = _mmplayer_destroy(player);
111 MMPLAYER_CMD_UNLOCK(player);
113 g_mutex_clear(&((mm_player_t*)player)->cmd_lock);
114 g_mutex_clear(&((mm_player_t*)player)->playback_lock);
116 memset((mm_player_t*)player, 0x00, sizeof(mm_player_t));
119 g_free((void*)player);
124 int mm_player_sound_register(MMHandleType player, int pid)
126 int result = MM_ERROR_NONE;
128 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
130 MMPLAYER_CMD_LOCK(player);
132 result = _mmplayer_sound_register_with_pid(player, pid);
134 MMPLAYER_CMD_UNLOCK(player);
139 int mm_player_get_client_pid(MMHandleType player, int* pid)
141 int result = MM_ERROR_NONE;
143 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
144 MMPLAYER_RETURN_VAL_IF_FAIL(pid, MM_ERROR_INVALID_ARGUMENT);
146 MMPLAYER_CMD_LOCK(player);
148 result = _mmplayer_get_client_pid(player, pid);
150 MMPLAYER_CMD_UNLOCK(player);
155 int mm_player_realize(MMHandleType player)
157 int result = MM_ERROR_NONE;
159 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
161 MMPLAYER_CMD_LOCK(player);
163 result = _mmplayer_realize(player);
165 MMPLAYER_CMD_UNLOCK(player);
170 int mm_player_unrealize(MMHandleType player)
172 int result = MM_ERROR_NONE;
174 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
176 MMPLAYER_CMD_LOCK(player);
178 result = _mmplayer_unrealize(player);
180 MMPLAYER_CMD_UNLOCK(player);
185 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
187 int result = MM_ERROR_NONE;
189 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
191 MMPLAYER_CMD_LOCK(player);
193 result = _mmplayer_set_message_callback(player, callback, user_param);
195 MMPLAYER_CMD_UNLOCK(player);
200 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
202 int result = MM_ERROR_NONE;
204 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
206 result = _mm_player_set_pd_downloader_message_cb(player, callback, user_param);
211 int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param)
213 int result = MM_ERROR_NONE;
215 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
217 MMPLAYER_CMD_LOCK(player);
219 result = _mmplayer_set_audiostream_cb(player, callback, user_param);
221 MMPLAYER_CMD_UNLOCK(player);
226 int mm_player_set_audio_stream_callback_ex(MMHandleType player, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param)
228 int result = MM_ERROR_NONE;
230 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
232 MMPLAYER_CMD_LOCK(player);
234 result = _mmplayer_set_audiostream_cb_ex(player, sync, callback, user_param);
236 MMPLAYER_CMD_UNLOCK(player);
241 int mm_player_set_video_stream_callback(MMHandleType player, mm_player_video_stream_callback callback, void *user_param)
243 int result = MM_ERROR_NONE;
245 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
247 MMPLAYER_CMD_LOCK(player);
249 result = _mmplayer_set_videostream_cb(player, callback, user_param);
251 MMPLAYER_CMD_UNLOCK(player);
256 int mm_player_do_video_capture(MMHandleType player)
258 int result = MM_ERROR_NONE;
260 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
262 MMPLAYER_CMD_LOCK(player);
264 result = _mmplayer_do_video_capture(player);
266 MMPLAYER_CMD_UNLOCK(player);
271 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume)
273 int result = MM_ERROR_NONE;
275 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
276 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
278 MMPLAYER_CMD_LOCK(player);
280 result = _mmplayer_set_volume(player, *volume);
282 MMPLAYER_CMD_UNLOCK(player);
287 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume)
289 int result = MM_ERROR_NONE;
291 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
292 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
294 MMPLAYER_CMD_LOCK(player);
296 result = _mmplayer_get_volume(player, volume);
298 MMPLAYER_CMD_UNLOCK(player);
303 int mm_player_set_mute(MMHandleType player, int mute)
305 int result = MM_ERROR_NONE;
307 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
309 MMPLAYER_CMD_LOCK(player);
311 result = _mmplayer_set_mute(player, mute);
313 MMPLAYER_CMD_UNLOCK(player);
318 int mm_player_get_mute(MMHandleType player, int *mute)
320 int result = MM_ERROR_NONE;
322 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
323 MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
325 MMPLAYER_CMD_LOCK(player);
327 result = _mmplayer_get_mute(player, mute);
329 MMPLAYER_CMD_UNLOCK(player);
334 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state)
336 int result = MM_ERROR_NONE;
338 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
339 MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
341 *state = MM_PLAYER_STATE_NULL;
343 result = _mmplayer_get_state(player, (int*)state);
348 /* NOTE : It does not support some use cases, eg using colorspace converter */
349 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
351 int result = MM_ERROR_NONE;
353 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
355 MMPLAYER_CMD_LOCK(player);
357 result = _mmplayer_change_videosink(player, display_surface_type, display_overlay);
359 MMPLAYER_CMD_UNLOCK(player);
364 int mm_player_start(MMHandleType player)
366 int result = MM_ERROR_NONE;
368 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
370 MMPLAYER_CMD_LOCK(player);
372 result = _mmplayer_start(player);
374 MMPLAYER_CMD_UNLOCK(player);
379 int mm_player_stop(MMHandleType player)
381 int result = MM_ERROR_NONE;
383 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
385 MMPLAYER_CMD_LOCK(player);
387 result = _mmplayer_stop(player);
389 MMPLAYER_CMD_UNLOCK(player);
394 int mm_player_pause(MMHandleType player)
396 int result = MM_ERROR_NONE;
398 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
400 MMPLAYER_CMD_LOCK(player);
402 result = _mmplayer_pause(player);
404 MMPLAYER_CMD_UNLOCK(player);
409 int mm_player_resume(MMHandleType player)
411 int result = MM_ERROR_NONE;
413 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
415 MMPLAYER_CMD_LOCK(player);
417 result = _mmplayer_resume(player);
419 MMPLAYER_CMD_UNLOCK(player);
424 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos)
426 int result = MM_ERROR_NONE;
428 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
430 MMPLAYER_CMD_LOCK(player);
432 result = _mmplayer_activate_section_repeat(player, start_pos, end_pos);
434 MMPLAYER_CMD_UNLOCK(player);
439 int mm_player_deactivate_section_repeat(MMHandleType player)
441 int result = MM_ERROR_NONE;
443 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
445 MMPLAYER_CMD_LOCK(player);
447 result = _mmplayer_deactivate_section_repeat(player);
449 MMPLAYER_CMD_UNLOCK(player);
454 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
456 int result = MM_ERROR_NONE;
458 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
460 MMPLAYER_CMD_LOCK(player);
462 result = _mmplayer_set_playspeed(player, rate, streaming);
464 MMPLAYER_CMD_UNLOCK(player);
469 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
471 int result = MM_ERROR_NONE;
473 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
475 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
476 LOGE("wrong format\n");
477 return MM_ERROR_COMMON_INVALID_ARGUMENT;
480 MMPLAYER_CMD_LOCK(player);
482 result = _mmplayer_set_position(player, format, pos);
484 MMPLAYER_CMD_UNLOCK(player);
489 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *pos)
491 int result = MM_ERROR_NONE;
493 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
494 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
496 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
497 LOGE("wrong format\n");
498 return MM_ERROR_COMMON_INVALID_ARGUMENT;
501 MMPLAYER_CMD_LOCK(player);
503 result = _mmplayer_get_position(player, (int)format, pos);
505 MMPLAYER_CMD_UNLOCK(player);
510 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
512 int result = MM_ERROR_NONE;
514 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
515 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
517 MMPLAYER_CMD_LOCK(player);
519 result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos);
521 MMPLAYER_CMD_UNLOCK(player);
526 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
528 int result = MM_ERROR_NONE;
530 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
532 MMPLAYER_CMD_LOCK(player);
534 result = _mmplayer_set_external_subtitle_path(player, path);
536 MMPLAYER_CMD_UNLOCK(player);
540 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
542 int result = MM_ERROR_NONE;
544 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
546 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
547 LOGE("wrong format(%d) \n", format);
548 return MM_ERROR_INVALID_ARGUMENT;
551 MMPLAYER_CMD_LOCK(player);
553 result = _mmplayer_adjust_subtitle_postion(player, format, pos);
555 MMPLAYER_CMD_UNLOCK(player);
560 int mm_player_adjust_video_position(MMHandleType player, int offset)
562 int result = MM_ERROR_NONE;
563 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
564 MMPLAYER_CMD_LOCK(player);
566 result = _mmplayer_adjust_video_postion(player, offset);
568 MMPLAYER_CMD_UNLOCK(player);
573 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
575 int result = MM_ERROR_NONE;
577 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
579 MMPLAYER_CMD_LOCK(player);
581 result = _mmplayer_set_subtitle_silent(player, silent);
583 MMPLAYER_CMD_UNLOCK(player);
588 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
590 int result = MM_ERROR_NONE;
592 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
594 MMPLAYER_CMD_LOCK(player);
596 result = _mmplayer_get_subtitle_silent(player, silent);
598 MMPLAYER_CMD_UNLOCK(player);
603 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
605 int result = MM_ERROR_NONE;
608 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
609 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
611 va_start(var_args, first_attribute_name);
612 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
618 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
620 int result = MM_ERROR_NONE;
623 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
624 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
626 va_start(var_args, first_attribute_name);
627 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
633 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
635 int result = MM_ERROR_NONE;
638 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
639 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
640 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
642 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
647 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
649 int result = MM_ERROR_NONE;
651 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
652 MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
653 MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
655 result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
660 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
662 int result = MM_ERROR_NONE;
664 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
665 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
667 MMPLAYER_CMD_LOCK(player);
669 result = _mmplayer_get_track_count(player, type, count);
671 MMPLAYER_CMD_UNLOCK(player);
676 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
678 int result = MM_ERROR_NONE;
680 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
682 MMPLAYER_CMD_LOCK(player);
684 result = _mmplayer_select_track(player, type, index);
686 MMPLAYER_CMD_UNLOCK(player);
691 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
693 int result = MM_ERROR_NONE;
695 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
697 MMPLAYER_CMD_LOCK(player);
699 result = _mmplayer_track_add_subtitle_language(player, index);
701 MMPLAYER_CMD_UNLOCK(player);
706 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
708 int result = MM_ERROR_NONE;
710 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
712 MMPLAYER_CMD_LOCK(player);
714 result = _mmplayer_track_remove_subtitle_language(player, index);
716 MMPLAYER_CMD_UNLOCK(player);
722 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
724 int result = MM_ERROR_NONE;
726 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
727 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
729 MMPLAYER_CMD_LOCK(player);
731 result = _mmplayer_get_current_track(player, type, index);
733 MMPLAYER_CMD_UNLOCK(player);
738 int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code)
740 int result = MM_ERROR_NONE;
742 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
744 MMPLAYER_CMD_LOCK(player);
746 result = _mmplayer_get_track_language_code(player, type, index, code);
748 MMPLAYER_CMD_UNLOCK(player);
753 int mm_player_set_video_share_master_clock(MMHandleType player,
755 long long clock_delta,
756 long long video_time,
757 long long media_clock,
758 long long audio_time)
760 int result = MM_ERROR_NONE;
762 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
764 MMPLAYER_CMD_LOCK(player);
766 result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
768 MMPLAYER_CMD_UNLOCK(player);
773 int mm_player_get_video_share_master_clock(MMHandleType player,
774 long long *video_time,
775 long long *media_clock,
776 long long *audio_time)
778 int result = MM_ERROR_NONE;
780 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
781 MMPLAYER_RETURN_VAL_IF_FAIL(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
782 MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
783 MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
785 MMPLAYER_CMD_LOCK(player);
787 result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
789 MMPLAYER_CMD_UNLOCK(player);
794 int mm_player_get_video_rotate_angle(MMHandleType player, int *angle)
796 int result = MM_ERROR_NONE;
798 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
799 MMPLAYER_RETURN_VAL_IF_FAIL(angle, MM_ERROR_COMMON_INVALID_ARGUMENT);
801 MMPLAYER_CMD_LOCK(player);
803 result = _mmplayer_get_video_rotate_angle(player, angle);
805 MMPLAYER_CMD_UNLOCK(player);
810 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
812 int result = MM_ERROR_NONE;
814 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
816 MMPLAYER_CMD_LOCK(player);
818 result = _mmplayer_set_video_hub_download_mode(player, mode);
820 MMPLAYER_CMD_UNLOCK(player);
825 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
827 int result = MM_ERROR_NONE;
829 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
831 MMPLAYER_CMD_LOCK(player);
833 result = _mmplayer_enable_sync_handler(player, enable);
835 MMPLAYER_CMD_UNLOCK(player);
840 int mm_player_set_uri(MMHandleType player, const char *uri)
842 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_uri(player, uri);
850 MMPLAYER_CMD_UNLOCK(player);
856 int mm_player_set_next_uri(MMHandleType player, const char *uri)
858 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_next_uri(player, uri, FALSE);
866 MMPLAYER_CMD_UNLOCK(player);
872 int mm_player_get_next_uri(MMHandleType player, char **uri)
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_get_next_uri(player, uri);
882 MMPLAYER_CMD_UNLOCK(player);
888 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
890 int result = MM_ERROR_NONE;
892 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
894 MMPLAYER_CMD_LOCK(player);
896 result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
898 MMPLAYER_CMD_UNLOCK(player);
904 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
906 int result = MM_ERROR_NONE;
908 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
909 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
911 MMPLAYER_CMD_LOCK(player);
913 result = _mmplayer_has_closed_caption(player, exist);
915 MMPLAYER_CMD_UNLOCK(player);
920 void * mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer)
923 result = _mm_player_media_packet_video_stream_internal_buffer_ref(buffer);
928 void mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer)
930 _mm_player_media_packet_video_stream_internal_buffer_unref(buffer);
933 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
936 int result = MM_ERROR_NONE;
938 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
940 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
941 //MMPLAYER_CMD_LOCK(player);
943 result = _mmplayer_submit_packet(player, packet);
945 //MMPLAYER_CMD_UNLOCK(player);
950 int mm_player_set_video_info(MMHandleType player, media_format_h format)
952 int result = MM_ERROR_NONE;
956 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
958 MMPLAYER_CMD_LOCK(player);
960 result = _mmplayer_set_video_info(player, format);
962 MMPLAYER_CMD_UNLOCK(player);
968 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
970 int result = MM_ERROR_NONE;
974 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
976 MMPLAYER_CMD_LOCK(player);
978 result = _mmplayer_set_audio_info(player, format);
980 MMPLAYER_CMD_UNLOCK(player);
985 int mm_player_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
987 int result = MM_ERROR_NONE;
991 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
993 MMPLAYER_CMD_LOCK(player);
995 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
997 MMPLAYER_CMD_UNLOCK(player);
1002 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
1004 int result = MM_ERROR_NONE;
1008 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1010 MMPLAYER_CMD_LOCK(player);
1012 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
1014 MMPLAYER_CMD_UNLOCK(player);
1019 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1021 int result = MM_ERROR_NONE;
1022 guint64 _max_size = 0;
1026 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1027 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1029 MMPLAYER_CMD_LOCK(player);
1031 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1032 *max_size = _max_size;
1034 MMPLAYER_CMD_UNLOCK(player);
1039 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
1041 int result = MM_ERROR_NONE;
1045 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1047 MMPLAYER_CMD_LOCK(player);
1049 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
1051 MMPLAYER_CMD_UNLOCK(player);
1056 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1058 int result = MM_ERROR_NONE;
1062 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1063 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1065 MMPLAYER_CMD_LOCK(player);
1067 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1069 MMPLAYER_CMD_UNLOCK(player);
1074 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1076 int result = MM_ERROR_NONE;
1080 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1082 MMPLAYER_CMD_LOCK(player);
1084 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1086 MMPLAYER_CMD_UNLOCK(player);
1091 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1093 int result = MM_ERROR_NONE;
1097 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1099 MMPLAYER_CMD_LOCK(player);
1101 result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
1103 MMPLAYER_CMD_UNLOCK(player);
1108 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1110 int result = MM_ERROR_NONE;
1112 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1114 MMPLAYER_CMD_LOCK(player);
1116 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
1118 MMPLAYER_CMD_UNLOCK(player);
1123 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1125 int result = MM_ERROR_NONE;
1127 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1129 MMPLAYER_CMD_LOCK(player);
1131 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1133 MMPLAYER_CMD_UNLOCK(player);
1138 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1140 int result = MM_ERROR_NONE;
1142 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1144 MMPLAYER_CMD_LOCK(player);
1146 result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1148 MMPLAYER_CMD_UNLOCK(player);
1153 int mm_player_get_timeout(MMHandleType player, int *timeout)
1155 int result = MM_ERROR_NONE;
1157 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1158 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1160 MMPLAYER_CMD_LOCK(player);
1162 result = _mmplayer_get_timeout(player, timeout);
1164 MMPLAYER_CMD_UNLOCK(player);
1169 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1171 int result = MM_ERROR_NONE;
1173 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1174 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1176 MMPLAYER_CMD_LOCK(player);
1178 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1180 MMPLAYER_CMD_UNLOCK(player);
1185 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1187 int result = MM_ERROR_NONE;
1189 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1191 MMPLAYER_CMD_LOCK(player);
1193 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1195 MMPLAYER_CMD_UNLOCK(player);
1200 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1202 int result = MM_ERROR_NONE;
1204 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1205 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1207 //MMPLAYER_CMD_LOCK(player);
1209 result = _mmplayer_video_stream_release_bo(player, bo);
1211 //MMPLAYER_CMD_UNLOCK(player);
1216 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1218 int result = MM_ERROR_NONE;
1220 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1222 MMPLAYER_CMD_LOCK(player);
1224 result = _mmplayer_set_file_buffering_path(player, file_path);
1226 MMPLAYER_CMD_UNLOCK(player);
1231 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1233 int result = MM_ERROR_NONE;
1235 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1236 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1238 MMPLAYER_CMD_LOCK(player);
1240 _mmplayer_sound_unregister(&((mm_player_t*)player)->sound_focus);
1241 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1243 MMPLAYER_CMD_UNLOCK(player);
1248 int mm_player_manage_external_storage_state(MMHandleType player, int state)
1250 int result = MM_ERROR_NONE;
1252 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1254 MMPLAYER_CMD_LOCK(player);
1256 result = _mmplayer_manage_external_storage_state(player, state);
1258 MMPLAYER_CMD_UNLOCK(player);
1263 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1265 int result = MM_ERROR_NONE;
1267 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1268 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1270 MMPLAYER_CMD_LOCK(player);
1272 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1274 MMPLAYER_CMD_UNLOCK(player);
1279 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1281 int result = MM_ERROR_NONE;
1283 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1285 MMPLAYER_CMD_LOCK(player);
1287 result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
1289 MMPLAYER_CMD_UNLOCK(player);
1294 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1296 int result = MM_ERROR_NONE;
1298 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1299 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1301 MMPLAYER_CMD_LOCK(player);
1303 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1305 MMPLAYER_CMD_UNLOCK(player);
1310 int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, int rebuffer_ms)
1312 int result = MM_ERROR_NONE;
1313 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1315 MMPLAYER_CMD_LOCK(player);
1317 result = _mmplayer_set_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1319 MMPLAYER_CMD_UNLOCK(player);
1324 int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms)
1326 int result = MM_ERROR_NONE;
1328 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1329 MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1331 MMPLAYER_CMD_LOCK(player);
1333 result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1335 MMPLAYER_CMD_UNLOCK(player);
1340 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1342 int result = MM_ERROR_NONE;
1343 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1345 MMPLAYER_CMD_LOCK(player);
1347 result = _mmplayer_set_audio_only(player, audio_only);
1349 MMPLAYER_CMD_UNLOCK(player);
1354 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1356 int result = MM_ERROR_NONE;
1358 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1359 MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1361 MMPLAYER_CMD_LOCK(player);
1363 result = _mmplayer_get_audio_only(player, audio_only);
1365 MMPLAYER_CMD_UNLOCK(player);
1370 int mm_player_360_set_enable(MMHandleType player, bool enable)
1372 int result = MM_ERROR_NONE;
1373 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1375 MMPLAYER_CMD_LOCK(player);
1377 result = _mmplayer_360_set_enable(player, enable);
1379 MMPLAYER_CMD_UNLOCK(player);
1384 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1386 int result = MM_ERROR_NONE;
1388 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1389 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1391 MMPLAYER_CMD_LOCK(player);
1393 result = _mmplayer_360_is_enabled(player, enabled);
1395 MMPLAYER_CMD_UNLOCK(player);
1400 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1402 int result = MM_ERROR_NONE;
1403 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1405 MMPLAYER_CMD_LOCK(player);
1407 result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1409 MMPLAYER_CMD_UNLOCK(player);
1414 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1416 int result = MM_ERROR_NONE;
1418 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1419 MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1421 MMPLAYER_CMD_LOCK(player);
1423 result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1425 MMPLAYER_CMD_UNLOCK(player);
1430 int mm_player_360_set_zoom(MMHandleType player, float level)
1432 int result = MM_ERROR_NONE;
1433 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1435 MMPLAYER_CMD_LOCK(player);
1437 result = _mmplayer_360_set_zoom(player, level);
1439 MMPLAYER_CMD_UNLOCK(player);
1444 int mm_player_360_get_zoom(MMHandleType player, float *level)
1446 int result = MM_ERROR_NONE;
1448 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1449 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1451 MMPLAYER_CMD_LOCK(player);
1453 result = _mmplayer_360_get_zoom(player, level);
1455 MMPLAYER_CMD_UNLOCK(player);
1460 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1462 int result = MM_ERROR_NONE;
1463 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1465 MMPLAYER_CMD_LOCK(player);
1467 result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1469 MMPLAYER_CMD_UNLOCK(player);
1474 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1476 int result = MM_ERROR_NONE;
1478 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1479 MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1481 MMPLAYER_CMD_LOCK(player);
1483 result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1485 MMPLAYER_CMD_UNLOCK(player);