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 /* to make sure unlocked.
114 @see __mmplayer_gst_callback, GST_MESSAGE_BUFFERING handling */
115 MMPLAYER_CMD_LOCK(player);
116 MMPLAYER_CMD_UNLOCK(player);
118 g_mutex_clear(&((mm_player_t*)player)->cmd_lock);
119 g_mutex_clear(&((mm_player_t*)player)->playback_lock);
121 memset((mm_player_t*)player, 0x00, sizeof(mm_player_t));
124 g_free((void*)player);
129 int mm_player_sound_register(MMHandleType player, int pid)
131 int result = MM_ERROR_NONE;
133 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
135 MMPLAYER_CMD_LOCK(player);
137 result = _mmplayer_sound_register_with_pid(player, pid);
139 MMPLAYER_CMD_UNLOCK(player);
144 int mm_player_get_client_pid(MMHandleType player, int* pid)
146 int result = MM_ERROR_NONE;
148 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
149 MMPLAYER_RETURN_VAL_IF_FAIL(pid, MM_ERROR_INVALID_ARGUMENT);
151 MMPLAYER_CMD_LOCK(player);
153 result = _mmplayer_get_client_pid(player, pid);
155 MMPLAYER_CMD_UNLOCK(player);
160 int mm_player_realize(MMHandleType player)
162 int result = MM_ERROR_NONE;
164 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
166 MMPLAYER_CMD_LOCK(player);
168 result = _mmplayer_realize(player);
170 MMPLAYER_CMD_UNLOCK(player);
175 int mm_player_unrealize(MMHandleType player)
177 int result = MM_ERROR_NONE;
179 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
181 MMPLAYER_CMD_LOCK(player);
183 result = _mmplayer_unrealize(player);
185 MMPLAYER_CMD_UNLOCK(player);
190 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
192 int result = MM_ERROR_NONE;
194 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
196 MMPLAYER_CMD_LOCK(player);
198 result = _mmplayer_set_message_callback(player, callback, user_param);
200 MMPLAYER_CMD_UNLOCK(player);
205 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
207 int result = MM_ERROR_NONE;
209 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
211 result = _mm_player_set_pd_downloader_message_cb(player, callback, user_param);
216 int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param)
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_set_audiostream_cb(player, callback, user_param);
226 MMPLAYER_CMD_UNLOCK(player);
231 int mm_player_set_audio_stream_callback_ex(MMHandleType player, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param)
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_audiostream_cb_ex(player, sync, callback, user_param);
241 MMPLAYER_CMD_UNLOCK(player);
246 int mm_player_set_video_stream_callback(MMHandleType player, mm_player_video_stream_callback callback, void *user_param)
248 int result = MM_ERROR_NONE;
250 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
252 MMPLAYER_CMD_LOCK(player);
254 result = _mmplayer_set_videostream_cb(player, callback, user_param);
256 MMPLAYER_CMD_UNLOCK(player);
261 int mm_player_do_video_capture(MMHandleType player)
263 int result = MM_ERROR_NONE;
265 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
267 MMPLAYER_CMD_LOCK(player);
269 result = _mmplayer_do_video_capture(player);
271 MMPLAYER_CMD_UNLOCK(player);
276 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume)
278 int result = MM_ERROR_NONE;
280 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
281 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
283 MMPLAYER_CMD_LOCK(player);
285 result = _mmplayer_set_volume(player, *volume);
287 MMPLAYER_CMD_UNLOCK(player);
292 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume)
294 int result = MM_ERROR_NONE;
296 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
297 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
299 MMPLAYER_CMD_LOCK(player);
301 result = _mmplayer_get_volume(player, volume);
303 MMPLAYER_CMD_UNLOCK(player);
308 int mm_player_set_mute(MMHandleType player, int mute)
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_set_mute(player, mute);
318 MMPLAYER_CMD_UNLOCK(player);
323 int mm_player_get_mute(MMHandleType player, int *mute)
325 int result = MM_ERROR_NONE;
327 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
328 MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
330 MMPLAYER_CMD_LOCK(player);
332 result = _mmplayer_get_mute(player, mute);
334 MMPLAYER_CMD_UNLOCK(player);
339 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state)
341 int result = MM_ERROR_NONE;
343 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
344 MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
346 *state = MM_PLAYER_STATE_NULL;
348 result = _mmplayer_get_state(player, (int*)state);
353 /* NOTE : It does not support some use cases, eg using colorspace converter */
354 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
356 int result = MM_ERROR_NONE;
358 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
360 MMPLAYER_CMD_LOCK(player);
362 result = _mmplayer_change_videosink(player, display_surface_type, display_overlay);
364 MMPLAYER_CMD_UNLOCK(player);
369 int mm_player_start(MMHandleType player)
371 int result = MM_ERROR_NONE;
373 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
375 MMPLAYER_CMD_LOCK(player);
377 result = _mmplayer_start(player);
379 MMPLAYER_CMD_UNLOCK(player);
384 int mm_player_stop(MMHandleType player)
386 int result = MM_ERROR_NONE;
388 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
390 MMPLAYER_CMD_LOCK(player);
392 result = _mmplayer_stop(player);
394 MMPLAYER_CMD_UNLOCK(player);
399 int mm_player_pause(MMHandleType player)
401 int result = MM_ERROR_NONE;
403 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
405 MMPLAYER_CMD_LOCK(player);
407 result = _mmplayer_pause(player);
409 MMPLAYER_CMD_UNLOCK(player);
414 int mm_player_resume(MMHandleType player)
416 int result = MM_ERROR_NONE;
418 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
420 MMPLAYER_CMD_LOCK(player);
422 result = _mmplayer_resume(player);
424 MMPLAYER_CMD_UNLOCK(player);
429 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos)
431 int result = MM_ERROR_NONE;
433 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
435 MMPLAYER_CMD_LOCK(player);
437 result = _mmplayer_activate_section_repeat(player, start_pos, end_pos);
439 MMPLAYER_CMD_UNLOCK(player);
444 int mm_player_deactivate_section_repeat(MMHandleType player)
446 int result = MM_ERROR_NONE;
448 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
450 MMPLAYER_CMD_LOCK(player);
452 result = _mmplayer_deactivate_section_repeat(player);
454 MMPLAYER_CMD_UNLOCK(player);
459 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
461 int result = MM_ERROR_NONE;
463 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
465 MMPLAYER_CMD_LOCK(player);
467 result = _mmplayer_set_playspeed(player, rate, streaming);
469 MMPLAYER_CMD_UNLOCK(player);
474 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
476 int result = MM_ERROR_NONE;
478 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
480 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
481 LOGE("wrong format\n");
482 return MM_ERROR_COMMON_INVALID_ARGUMENT;
485 MMPLAYER_CMD_LOCK(player);
487 result = _mmplayer_set_position(player, format, pos);
489 MMPLAYER_CMD_UNLOCK(player);
494 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *pos)
496 int result = MM_ERROR_NONE;
498 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
499 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
501 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
502 LOGE("wrong format\n");
503 return MM_ERROR_COMMON_INVALID_ARGUMENT;
506 MMPLAYER_CMD_LOCK(player);
508 result = _mmplayer_get_position(player, (int)format, pos);
510 MMPLAYER_CMD_UNLOCK(player);
515 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
517 int result = MM_ERROR_NONE;
519 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
520 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
522 MMPLAYER_CMD_LOCK(player);
524 result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos);
526 MMPLAYER_CMD_UNLOCK(player);
531 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
533 int result = MM_ERROR_NONE;
535 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
537 MMPLAYER_CMD_LOCK(player);
539 result = _mmplayer_set_external_subtitle_path(player, path);
541 MMPLAYER_CMD_UNLOCK(player);
545 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
547 int result = MM_ERROR_NONE;
549 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
551 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
552 LOGE("wrong format(%d) \n", format);
553 return MM_ERROR_INVALID_ARGUMENT;
556 MMPLAYER_CMD_LOCK(player);
558 result = _mmplayer_adjust_subtitle_postion(player, format, pos);
560 MMPLAYER_CMD_UNLOCK(player);
565 int mm_player_adjust_video_position(MMHandleType player, int offset)
567 int result = MM_ERROR_NONE;
568 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
569 MMPLAYER_CMD_LOCK(player);
571 result = _mmplayer_adjust_video_postion(player, offset);
573 MMPLAYER_CMD_UNLOCK(player);
578 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
580 int result = MM_ERROR_NONE;
582 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
584 MMPLAYER_CMD_LOCK(player);
586 result = _mmplayer_set_subtitle_silent(player, silent);
588 MMPLAYER_CMD_UNLOCK(player);
593 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
595 int result = MM_ERROR_NONE;
597 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
599 MMPLAYER_CMD_LOCK(player);
601 result = _mmplayer_get_subtitle_silent(player, silent);
603 MMPLAYER_CMD_UNLOCK(player);
608 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
610 int result = MM_ERROR_NONE;
613 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
614 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
616 va_start(var_args, first_attribute_name);
617 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
623 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
625 int result = MM_ERROR_NONE;
628 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
629 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
631 va_start(var_args, first_attribute_name);
632 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
638 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
640 int result = MM_ERROR_NONE;
643 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
644 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
645 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
647 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
652 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
654 int result = MM_ERROR_NONE;
656 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
657 MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
658 MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
660 result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
665 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
667 int result = MM_ERROR_NONE;
669 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
670 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
672 MMPLAYER_CMD_LOCK(player);
674 result = _mmplayer_get_track_count(player, type, count);
676 MMPLAYER_CMD_UNLOCK(player);
681 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
683 int result = MM_ERROR_NONE;
685 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
687 MMPLAYER_CMD_LOCK(player);
689 result = _mmplayer_select_track(player, type, index);
691 MMPLAYER_CMD_UNLOCK(player);
696 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
698 int result = MM_ERROR_NONE;
700 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
702 MMPLAYER_CMD_LOCK(player);
704 result = _mmplayer_track_add_subtitle_language(player, index);
706 MMPLAYER_CMD_UNLOCK(player);
711 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
713 int result = MM_ERROR_NONE;
715 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
717 MMPLAYER_CMD_LOCK(player);
719 result = _mmplayer_track_remove_subtitle_language(player, index);
721 MMPLAYER_CMD_UNLOCK(player);
727 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
729 int result = MM_ERROR_NONE;
731 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
732 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
734 MMPLAYER_CMD_LOCK(player);
736 result = _mmplayer_get_current_track(player, type, index);
738 MMPLAYER_CMD_UNLOCK(player);
743 int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code)
745 int result = MM_ERROR_NONE;
747 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
749 MMPLAYER_CMD_LOCK(player);
751 result = _mmplayer_get_track_language_code(player, type, index, code);
753 MMPLAYER_CMD_UNLOCK(player);
758 int mm_player_set_video_share_master_clock(MMHandleType player,
760 long long clock_delta,
761 long long video_time,
762 long long media_clock,
763 long long audio_time)
765 int result = MM_ERROR_NONE;
767 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
769 MMPLAYER_CMD_LOCK(player);
771 result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
773 MMPLAYER_CMD_UNLOCK(player);
778 int mm_player_get_video_share_master_clock(MMHandleType player,
779 long long *video_time,
780 long long *media_clock,
781 long long *audio_time)
783 int result = MM_ERROR_NONE;
785 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
786 MMPLAYER_RETURN_VAL_IF_FAIL(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
787 MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
788 MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
790 MMPLAYER_CMD_LOCK(player);
792 result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
794 MMPLAYER_CMD_UNLOCK(player);
799 int mm_player_get_video_rotate_angle(MMHandleType player, int *angle)
801 int result = MM_ERROR_NONE;
803 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
804 MMPLAYER_RETURN_VAL_IF_FAIL(angle, MM_ERROR_COMMON_INVALID_ARGUMENT);
806 MMPLAYER_CMD_LOCK(player);
808 result = _mmplayer_get_video_rotate_angle(player, angle);
810 MMPLAYER_CMD_UNLOCK(player);
815 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
817 int result = MM_ERROR_NONE;
819 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
821 MMPLAYER_CMD_LOCK(player);
823 result = _mmplayer_set_video_hub_download_mode(player, mode);
825 MMPLAYER_CMD_UNLOCK(player);
830 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
832 int result = MM_ERROR_NONE;
834 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
836 MMPLAYER_CMD_LOCK(player);
838 result = _mmplayer_enable_sync_handler(player, enable);
840 MMPLAYER_CMD_UNLOCK(player);
845 int mm_player_set_uri(MMHandleType player, const char *uri)
847 int result = MM_ERROR_NONE;
849 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
851 MMPLAYER_CMD_LOCK(player);
853 result = _mmplayer_set_uri(player, uri);
855 MMPLAYER_CMD_UNLOCK(player);
861 int mm_player_set_next_uri(MMHandleType player, const char *uri)
863 int result = MM_ERROR_NONE;
865 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
867 MMPLAYER_CMD_LOCK(player);
869 result = _mmplayer_set_next_uri(player, uri, FALSE);
871 MMPLAYER_CMD_UNLOCK(player);
877 int mm_player_get_next_uri(MMHandleType player, char **uri)
879 int result = MM_ERROR_NONE;
881 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
883 MMPLAYER_CMD_LOCK(player);
885 result = _mmplayer_get_next_uri(player, uri);
887 MMPLAYER_CMD_UNLOCK(player);
893 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
895 int result = MM_ERROR_NONE;
897 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
899 MMPLAYER_CMD_LOCK(player);
901 result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
903 MMPLAYER_CMD_UNLOCK(player);
909 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
911 int result = MM_ERROR_NONE;
913 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
914 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
916 MMPLAYER_CMD_LOCK(player);
918 result = _mmplayer_has_closed_caption(player, exist);
920 MMPLAYER_CMD_UNLOCK(player);
925 void * mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer)
928 result = _mm_player_media_packet_video_stream_internal_buffer_ref(buffer);
933 void mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer)
935 _mm_player_media_packet_video_stream_internal_buffer_unref(buffer);
938 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
941 int result = MM_ERROR_NONE;
943 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
945 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
946 //MMPLAYER_CMD_LOCK(player);
948 result = _mmplayer_submit_packet(player, packet);
950 //MMPLAYER_CMD_UNLOCK(player);
955 int mm_player_set_video_info(MMHandleType player, media_format_h format)
957 int result = MM_ERROR_NONE;
961 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
963 MMPLAYER_CMD_LOCK(player);
965 result = _mmplayer_set_video_info(player, format);
967 MMPLAYER_CMD_UNLOCK(player);
973 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
975 int result = MM_ERROR_NONE;
979 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
981 MMPLAYER_CMD_LOCK(player);
983 result = _mmplayer_set_audio_info(player, format);
985 MMPLAYER_CMD_UNLOCK(player);
990 int mm_player_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
992 int result = MM_ERROR_NONE;
996 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
998 MMPLAYER_CMD_LOCK(player);
1000 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
1002 MMPLAYER_CMD_UNLOCK(player);
1007 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
1009 int result = MM_ERROR_NONE;
1013 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1015 MMPLAYER_CMD_LOCK(player);
1017 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
1019 MMPLAYER_CMD_UNLOCK(player);
1024 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1026 int result = MM_ERROR_NONE;
1027 guint64 _max_size = 0;
1031 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1032 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1034 MMPLAYER_CMD_LOCK(player);
1036 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1037 *max_size = _max_size;
1039 MMPLAYER_CMD_UNLOCK(player);
1044 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
1046 int result = MM_ERROR_NONE;
1050 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1052 MMPLAYER_CMD_LOCK(player);
1054 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
1056 MMPLAYER_CMD_UNLOCK(player);
1061 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1063 int result = MM_ERROR_NONE;
1067 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1068 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1070 MMPLAYER_CMD_LOCK(player);
1072 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1074 MMPLAYER_CMD_UNLOCK(player);
1079 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1081 int result = MM_ERROR_NONE;
1085 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1087 MMPLAYER_CMD_LOCK(player);
1089 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1091 MMPLAYER_CMD_UNLOCK(player);
1096 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1098 int result = MM_ERROR_NONE;
1102 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1104 MMPLAYER_CMD_LOCK(player);
1106 result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
1108 MMPLAYER_CMD_UNLOCK(player);
1113 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1115 int result = MM_ERROR_NONE;
1117 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1119 MMPLAYER_CMD_LOCK(player);
1121 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
1123 MMPLAYER_CMD_UNLOCK(player);
1128 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1130 int result = MM_ERROR_NONE;
1132 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1134 MMPLAYER_CMD_LOCK(player);
1136 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1138 MMPLAYER_CMD_UNLOCK(player);
1143 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1145 int result = MM_ERROR_NONE;
1147 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1149 MMPLAYER_CMD_LOCK(player);
1151 result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1153 MMPLAYER_CMD_UNLOCK(player);
1158 int mm_player_get_timeout(MMHandleType player, int *timeout)
1160 int result = MM_ERROR_NONE;
1162 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1163 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1165 MMPLAYER_CMD_LOCK(player);
1167 result = _mmplayer_get_timeout(player, timeout);
1169 MMPLAYER_CMD_UNLOCK(player);
1174 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1176 int result = MM_ERROR_NONE;
1178 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1179 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1181 MMPLAYER_CMD_LOCK(player);
1183 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1185 MMPLAYER_CMD_UNLOCK(player);
1190 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1192 int result = MM_ERROR_NONE;
1194 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1196 MMPLAYER_CMD_LOCK(player);
1198 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1200 MMPLAYER_CMD_UNLOCK(player);
1205 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1207 int result = MM_ERROR_NONE;
1209 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1210 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1212 //MMPLAYER_CMD_LOCK(player);
1214 result = _mmplayer_video_stream_release_bo(player, bo);
1216 //MMPLAYER_CMD_UNLOCK(player);
1221 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1223 int result = MM_ERROR_NONE;
1225 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1227 MMPLAYER_CMD_LOCK(player);
1229 result = _mmplayer_set_file_buffering_path(player, file_path);
1231 MMPLAYER_CMD_UNLOCK(player);
1236 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1238 int result = MM_ERROR_NONE;
1240 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1241 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1243 MMPLAYER_CMD_LOCK(player);
1245 _mmplayer_sound_unregister(&((mm_player_t*)player)->sound_focus);
1246 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1248 MMPLAYER_CMD_UNLOCK(player);
1253 int mm_player_manage_external_storage_state(MMHandleType player, int id, int state)
1255 int result = MM_ERROR_NONE;
1257 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1259 MMPLAYER_CMD_LOCK(player);
1261 result = _mmplayer_manage_external_storage_state(player, id, state);
1263 MMPLAYER_CMD_UNLOCK(player);
1268 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1270 int result = MM_ERROR_NONE;
1272 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1273 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1275 MMPLAYER_CMD_LOCK(player);
1277 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1279 MMPLAYER_CMD_UNLOCK(player);
1284 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1286 int result = MM_ERROR_NONE;
1288 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1290 MMPLAYER_CMD_LOCK(player);
1292 result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
1294 MMPLAYER_CMD_UNLOCK(player);
1299 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1301 int result = MM_ERROR_NONE;
1303 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1304 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1306 MMPLAYER_CMD_LOCK(player);
1308 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1310 MMPLAYER_CMD_UNLOCK(player);
1315 int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, int rebuffer_ms)
1317 int result = MM_ERROR_NONE;
1318 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1320 MMPLAYER_CMD_LOCK(player);
1322 result = _mmplayer_set_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1324 MMPLAYER_CMD_UNLOCK(player);
1329 int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms)
1331 int result = MM_ERROR_NONE;
1333 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1334 MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1336 MMPLAYER_CMD_LOCK(player);
1338 result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1340 MMPLAYER_CMD_UNLOCK(player);
1345 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1347 int result = MM_ERROR_NONE;
1348 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1350 MMPLAYER_CMD_LOCK(player);
1352 result = _mmplayer_set_audio_only(player, audio_only);
1354 MMPLAYER_CMD_UNLOCK(player);
1359 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1361 int result = MM_ERROR_NONE;
1363 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1364 MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1366 MMPLAYER_CMD_LOCK(player);
1368 result = _mmplayer_get_audio_only(player, audio_only);
1370 MMPLAYER_CMD_UNLOCK(player);
1375 int mm_player_360_set_enable(MMHandleType player, bool enable)
1377 int result = MM_ERROR_NONE;
1378 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1380 MMPLAYER_CMD_LOCK(player);
1382 result = _mmplayer_360_set_enable(player, enable);
1384 MMPLAYER_CMD_UNLOCK(player);
1389 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1391 int result = MM_ERROR_NONE;
1393 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1394 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1396 MMPLAYER_CMD_LOCK(player);
1398 result = _mmplayer_360_is_enabled(player, enabled);
1400 MMPLAYER_CMD_UNLOCK(player);
1405 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1407 int result = MM_ERROR_NONE;
1408 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1410 MMPLAYER_CMD_LOCK(player);
1412 result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1414 MMPLAYER_CMD_UNLOCK(player);
1419 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1421 int result = MM_ERROR_NONE;
1423 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1424 MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1426 MMPLAYER_CMD_LOCK(player);
1428 result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1430 MMPLAYER_CMD_UNLOCK(player);
1435 int mm_player_360_set_zoom(MMHandleType player, float level)
1437 int result = MM_ERROR_NONE;
1438 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1440 MMPLAYER_CMD_LOCK(player);
1442 result = _mmplayer_360_set_zoom(player, level);
1444 MMPLAYER_CMD_UNLOCK(player);
1449 int mm_player_360_get_zoom(MMHandleType player, float *level)
1451 int result = MM_ERROR_NONE;
1453 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1454 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1456 MMPLAYER_CMD_LOCK(player);
1458 result = _mmplayer_360_get_zoom(player, level);
1460 MMPLAYER_CMD_UNLOCK(player);
1465 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1467 int result = MM_ERROR_NONE;
1468 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1470 MMPLAYER_CMD_LOCK(player);
1472 result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1474 MMPLAYER_CMD_UNLOCK(player);
1479 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1481 int result = MM_ERROR_NONE;
1483 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1484 MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1486 MMPLAYER_CMD_LOCK(player);
1488 result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1490 MMPLAYER_CMD_UNLOCK(player);