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_video_stream_internal_buffer_unref(void *buffer)
922 _mm_player_video_stream_internal_buffer_unref(buffer);
925 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
928 int result = MM_ERROR_NONE;
930 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
932 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
933 //MMPLAYER_CMD_LOCK(player);
935 result = _mmplayer_submit_packet(player, packet);
937 //MMPLAYER_CMD_UNLOCK(player);
942 int mm_player_set_video_info(MMHandleType player, media_format_h format)
944 int result = MM_ERROR_NONE;
948 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
950 MMPLAYER_CMD_LOCK(player);
952 result = _mmplayer_set_video_info(player, format);
954 MMPLAYER_CMD_UNLOCK(player);
960 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
962 int result = MM_ERROR_NONE;
966 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
968 MMPLAYER_CMD_LOCK(player);
970 result = _mmplayer_set_audio_info(player, format);
972 MMPLAYER_CMD_UNLOCK(player);
977 int mm_player_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
979 int result = MM_ERROR_NONE;
983 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
985 MMPLAYER_CMD_LOCK(player);
987 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
989 MMPLAYER_CMD_UNLOCK(player);
994 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
996 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_media_stream_max_size(player, type, max_size);
1006 MMPLAYER_CMD_UNLOCK(player);
1011 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1013 int result = MM_ERROR_NONE;
1014 guint64 _max_size = 0;
1018 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1019 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1021 MMPLAYER_CMD_LOCK(player);
1023 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1024 *max_size = _max_size;
1026 MMPLAYER_CMD_UNLOCK(player);
1031 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
1033 int result = MM_ERROR_NONE;
1037 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1039 MMPLAYER_CMD_LOCK(player);
1041 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
1043 MMPLAYER_CMD_UNLOCK(player);
1048 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1050 int result = MM_ERROR_NONE;
1054 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1055 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1057 MMPLAYER_CMD_LOCK(player);
1059 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1061 MMPLAYER_CMD_UNLOCK(player);
1066 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1068 int result = MM_ERROR_NONE;
1072 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1074 MMPLAYER_CMD_LOCK(player);
1076 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1078 MMPLAYER_CMD_UNLOCK(player);
1083 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1085 int result = MM_ERROR_NONE;
1089 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1091 MMPLAYER_CMD_LOCK(player);
1093 result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
1095 MMPLAYER_CMD_UNLOCK(player);
1100 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1102 int result = MM_ERROR_NONE;
1104 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1106 MMPLAYER_CMD_LOCK(player);
1108 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
1110 MMPLAYER_CMD_UNLOCK(player);
1115 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1117 int result = MM_ERROR_NONE;
1119 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1121 MMPLAYER_CMD_LOCK(player);
1123 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1125 MMPLAYER_CMD_UNLOCK(player);
1130 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1132 int result = MM_ERROR_NONE;
1134 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1136 MMPLAYER_CMD_LOCK(player);
1138 result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1140 MMPLAYER_CMD_UNLOCK(player);
1145 int mm_player_get_timeout(MMHandleType player, int *timeout)
1147 int result = MM_ERROR_NONE;
1149 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1150 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1152 MMPLAYER_CMD_LOCK(player);
1154 result = _mmplayer_get_timeout(player, timeout);
1156 MMPLAYER_CMD_UNLOCK(player);
1161 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1163 int result = MM_ERROR_NONE;
1165 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1166 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1168 MMPLAYER_CMD_LOCK(player);
1170 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1172 MMPLAYER_CMD_UNLOCK(player);
1177 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1179 int result = MM_ERROR_NONE;
1181 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1183 MMPLAYER_CMD_LOCK(player);
1185 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1187 MMPLAYER_CMD_UNLOCK(player);
1192 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1194 int result = MM_ERROR_NONE;
1196 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1197 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1199 //MMPLAYER_CMD_LOCK(player);
1201 result = _mmplayer_video_stream_release_bo(player, bo);
1203 //MMPLAYER_CMD_UNLOCK(player);
1208 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1210 int result = MM_ERROR_NONE;
1212 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1214 MMPLAYER_CMD_LOCK(player);
1216 result = _mmplayer_set_file_buffering_path(player, file_path);
1218 MMPLAYER_CMD_UNLOCK(player);
1223 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1225 int result = MM_ERROR_NONE;
1227 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1228 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1230 MMPLAYER_CMD_LOCK(player);
1232 _mmplayer_sound_unregister(&((mm_player_t*)player)->sound_focus);
1233 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1235 MMPLAYER_CMD_UNLOCK(player);
1240 int mm_player_manage_external_storage_state(MMHandleType player, int state)
1242 int result = MM_ERROR_NONE;
1244 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1246 MMPLAYER_CMD_LOCK(player);
1248 result = _mmplayer_manage_external_storage_state(player, state);
1250 MMPLAYER_CMD_UNLOCK(player);
1255 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1257 int result = MM_ERROR_NONE;
1259 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1260 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1262 MMPLAYER_CMD_LOCK(player);
1264 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1266 MMPLAYER_CMD_UNLOCK(player);
1271 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1273 int result = MM_ERROR_NONE;
1275 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1277 MMPLAYER_CMD_LOCK(player);
1279 result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
1281 MMPLAYER_CMD_UNLOCK(player);
1286 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1288 int result = MM_ERROR_NONE;
1290 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1291 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1293 MMPLAYER_CMD_LOCK(player);
1295 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1297 MMPLAYER_CMD_UNLOCK(player);
1302 int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, int rebuffer_ms)
1304 int result = MM_ERROR_NONE;
1305 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1307 MMPLAYER_CMD_LOCK(player);
1309 result = _mmplayer_set_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1311 MMPLAYER_CMD_UNLOCK(player);
1316 int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms)
1318 int result = MM_ERROR_NONE;
1320 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1321 MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1323 MMPLAYER_CMD_LOCK(player);
1325 result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1327 MMPLAYER_CMD_UNLOCK(player);
1332 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1334 int result = MM_ERROR_NONE;
1335 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1337 MMPLAYER_CMD_LOCK(player);
1339 result = _mmplayer_set_audio_only(player, audio_only);
1341 MMPLAYER_CMD_UNLOCK(player);
1346 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1348 int result = MM_ERROR_NONE;
1350 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1351 MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1353 MMPLAYER_CMD_LOCK(player);
1355 result = _mmplayer_get_audio_only(player, audio_only);
1357 MMPLAYER_CMD_UNLOCK(player);
1362 int mm_player_360_set_enable(MMHandleType player, bool enable)
1364 int result = MM_ERROR_NONE;
1365 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1367 MMPLAYER_CMD_LOCK(player);
1369 result = _mmplayer_360_set_enable(player, enable);
1371 MMPLAYER_CMD_UNLOCK(player);
1376 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1378 int result = MM_ERROR_NONE;
1380 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1381 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1383 MMPLAYER_CMD_LOCK(player);
1385 result = _mmplayer_360_is_enabled(player, enabled);
1387 MMPLAYER_CMD_UNLOCK(player);
1392 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1394 int result = MM_ERROR_NONE;
1395 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1397 MMPLAYER_CMD_LOCK(player);
1399 result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1401 MMPLAYER_CMD_UNLOCK(player);
1406 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1408 int result = MM_ERROR_NONE;
1410 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1411 MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1413 MMPLAYER_CMD_LOCK(player);
1415 result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1417 MMPLAYER_CMD_UNLOCK(player);
1422 int mm_player_360_set_zoom(MMHandleType player, float level)
1424 int result = MM_ERROR_NONE;
1425 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1427 MMPLAYER_CMD_LOCK(player);
1429 result = _mmplayer_360_set_zoom(player, level);
1431 MMPLAYER_CMD_UNLOCK(player);
1436 int mm_player_360_get_zoom(MMHandleType player, float *level)
1438 int result = MM_ERROR_NONE;
1440 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1441 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1443 MMPLAYER_CMD_LOCK(player);
1445 result = _mmplayer_360_get_zoom(player, level);
1447 MMPLAYER_CMD_UNLOCK(player);
1452 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1454 int result = MM_ERROR_NONE;
1455 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1457 MMPLAYER_CMD_LOCK(player);
1459 result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1461 MMPLAYER_CMD_UNLOCK(player);
1466 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1468 int result = MM_ERROR_NONE;
1470 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1471 MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1473 MMPLAYER_CMD_LOCK(player);
1475 result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1477 MMPLAYER_CMD_UNLOCK(player);