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 /* destroy the gst bus msg thread if it is remained.
108 this funct have to be called before getting cmd lock. */
109 _mmplayer_bus_msg_thread_destroy(player);
111 MMPLAYER_CMD_LOCK(player);
113 result = _mmplayer_destroy(player);
115 MMPLAYER_CMD_UNLOCK(player);
117 g_mutex_clear(&((mm_player_t*)player)->cmd_lock);
118 g_mutex_clear(&((mm_player_t*)player)->playback_lock);
120 memset((mm_player_t*)player, 0x00, sizeof(mm_player_t));
123 g_free((void*)player);
128 int mm_player_sound_register(MMHandleType player, int pid)
130 int result = MM_ERROR_NONE;
132 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
134 MMPLAYER_CMD_LOCK(player);
136 result = _mmplayer_sound_register_with_pid(player, pid);
138 MMPLAYER_CMD_UNLOCK(player);
143 int mm_player_get_client_pid(MMHandleType player, int* pid)
145 int result = MM_ERROR_NONE;
147 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
148 MMPLAYER_RETURN_VAL_IF_FAIL(pid, MM_ERROR_INVALID_ARGUMENT);
150 MMPLAYER_CMD_LOCK(player);
152 result = _mmplayer_get_client_pid(player, pid);
154 MMPLAYER_CMD_UNLOCK(player);
159 int mm_player_realize(MMHandleType player)
161 int result = MM_ERROR_NONE;
163 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
165 MMPLAYER_CMD_LOCK(player);
167 result = _mmplayer_realize(player);
169 MMPLAYER_CMD_UNLOCK(player);
174 int mm_player_unrealize(MMHandleType player)
176 int result = MM_ERROR_NONE;
178 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
180 MMPLAYER_CMD_LOCK(player);
182 result = _mmplayer_unrealize(player);
184 MMPLAYER_CMD_UNLOCK(player);
189 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
191 int result = MM_ERROR_NONE;
193 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
195 MMPLAYER_CMD_LOCK(player);
197 result = _mmplayer_set_message_callback(player, callback, user_param);
199 MMPLAYER_CMD_UNLOCK(player);
204 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
206 int result = MM_ERROR_NONE;
208 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
210 result = _mm_player_set_pd_downloader_message_cb(player, callback, user_param);
215 int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param)
217 int result = MM_ERROR_NONE;
219 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
221 MMPLAYER_CMD_LOCK(player);
223 result = _mmplayer_set_audiostream_cb(player, callback, user_param);
225 MMPLAYER_CMD_UNLOCK(player);
230 int mm_player_set_audio_stream_callback_ex(MMHandleType player, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param)
232 int result = MM_ERROR_NONE;
234 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
236 MMPLAYER_CMD_LOCK(player);
238 result = _mmplayer_set_audiostream_cb_ex(player, sync, callback, user_param);
240 MMPLAYER_CMD_UNLOCK(player);
245 int mm_player_set_video_stream_callback(MMHandleType player, mm_player_video_stream_callback callback, void *user_param)
247 int result = MM_ERROR_NONE;
249 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
251 MMPLAYER_CMD_LOCK(player);
253 result = _mmplayer_set_videostream_cb(player, callback, user_param);
255 MMPLAYER_CMD_UNLOCK(player);
260 int mm_player_do_video_capture(MMHandleType player)
262 int result = MM_ERROR_NONE;
264 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
266 MMPLAYER_CMD_LOCK(player);
268 result = _mmplayer_do_video_capture(player);
270 MMPLAYER_CMD_UNLOCK(player);
275 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume)
277 int result = MM_ERROR_NONE;
279 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
280 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
282 MMPLAYER_CMD_LOCK(player);
284 result = _mmplayer_set_volume(player, *volume);
286 MMPLAYER_CMD_UNLOCK(player);
291 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume)
293 int result = MM_ERROR_NONE;
295 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
296 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
298 MMPLAYER_CMD_LOCK(player);
300 result = _mmplayer_get_volume(player, volume);
302 MMPLAYER_CMD_UNLOCK(player);
307 int mm_player_set_mute(MMHandleType player, int mute)
309 int result = MM_ERROR_NONE;
311 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
313 MMPLAYER_CMD_LOCK(player);
315 result = _mmplayer_set_mute(player, mute);
317 MMPLAYER_CMD_UNLOCK(player);
322 int mm_player_get_mute(MMHandleType player, int *mute)
324 int result = MM_ERROR_NONE;
326 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
327 MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
329 MMPLAYER_CMD_LOCK(player);
331 result = _mmplayer_get_mute(player, mute);
333 MMPLAYER_CMD_UNLOCK(player);
338 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state)
340 int result = MM_ERROR_NONE;
342 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
343 MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
345 *state = MM_PLAYER_STATE_NULL;
347 result = _mmplayer_get_state(player, (int*)state);
352 /* NOTE : It does not support some use cases, eg using colorspace converter */
353 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
355 int result = MM_ERROR_NONE;
357 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
359 MMPLAYER_CMD_LOCK(player);
361 result = _mmplayer_change_videosink(player, display_surface_type, display_overlay);
363 MMPLAYER_CMD_UNLOCK(player);
368 int mm_player_start(MMHandleType player)
370 int result = MM_ERROR_NONE;
372 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
374 MMPLAYER_CMD_LOCK(player);
376 result = _mmplayer_start(player);
378 MMPLAYER_CMD_UNLOCK(player);
383 int mm_player_stop(MMHandleType player)
385 int result = MM_ERROR_NONE;
387 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
389 MMPLAYER_CMD_LOCK(player);
391 result = _mmplayer_stop(player);
393 MMPLAYER_CMD_UNLOCK(player);
398 int mm_player_pause(MMHandleType player)
400 int result = MM_ERROR_NONE;
402 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
404 MMPLAYER_CMD_LOCK(player);
406 result = _mmplayer_pause(player);
408 MMPLAYER_CMD_UNLOCK(player);
413 int mm_player_resume(MMHandleType player)
415 int result = MM_ERROR_NONE;
417 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
419 MMPLAYER_CMD_LOCK(player);
421 result = _mmplayer_resume(player);
423 MMPLAYER_CMD_UNLOCK(player);
428 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos)
430 int result = MM_ERROR_NONE;
432 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
434 MMPLAYER_CMD_LOCK(player);
436 result = _mmplayer_activate_section_repeat(player, start_pos, end_pos);
438 MMPLAYER_CMD_UNLOCK(player);
443 int mm_player_deactivate_section_repeat(MMHandleType player)
445 int result = MM_ERROR_NONE;
447 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
449 MMPLAYER_CMD_LOCK(player);
451 result = _mmplayer_deactivate_section_repeat(player);
453 MMPLAYER_CMD_UNLOCK(player);
458 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
460 int result = MM_ERROR_NONE;
462 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
464 MMPLAYER_CMD_LOCK(player);
466 result = _mmplayer_set_playspeed(player, rate, streaming);
468 MMPLAYER_CMD_UNLOCK(player);
473 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
475 int result = MM_ERROR_NONE;
477 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
479 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
480 LOGE("wrong format\n");
481 return MM_ERROR_COMMON_INVALID_ARGUMENT;
484 MMPLAYER_CMD_LOCK(player);
486 result = _mmplayer_set_position(player, format, pos);
488 MMPLAYER_CMD_UNLOCK(player);
493 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *pos)
495 int result = MM_ERROR_NONE;
497 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
498 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
500 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
501 LOGE("wrong format\n");
502 return MM_ERROR_COMMON_INVALID_ARGUMENT;
505 MMPLAYER_CMD_LOCK(player);
507 result = _mmplayer_get_position(player, (int)format, pos);
509 MMPLAYER_CMD_UNLOCK(player);
514 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
516 int result = MM_ERROR_NONE;
518 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
519 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
521 MMPLAYER_CMD_LOCK(player);
523 result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos);
525 MMPLAYER_CMD_UNLOCK(player);
530 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
532 int result = MM_ERROR_NONE;
534 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
536 MMPLAYER_CMD_LOCK(player);
538 result = _mmplayer_set_external_subtitle_path(player, path);
540 MMPLAYER_CMD_UNLOCK(player);
544 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
546 int result = MM_ERROR_NONE;
548 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
550 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
551 LOGE("wrong format(%d) \n", format);
552 return MM_ERROR_INVALID_ARGUMENT;
555 MMPLAYER_CMD_LOCK(player);
557 result = _mmplayer_adjust_subtitle_postion(player, format, pos);
559 MMPLAYER_CMD_UNLOCK(player);
564 int mm_player_adjust_video_position(MMHandleType player, int offset)
566 int result = MM_ERROR_NONE;
567 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
568 MMPLAYER_CMD_LOCK(player);
570 result = _mmplayer_adjust_video_postion(player, offset);
572 MMPLAYER_CMD_UNLOCK(player);
577 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
579 int result = MM_ERROR_NONE;
581 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
583 MMPLAYER_CMD_LOCK(player);
585 result = _mmplayer_set_subtitle_silent(player, silent);
587 MMPLAYER_CMD_UNLOCK(player);
592 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
594 int result = MM_ERROR_NONE;
596 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
598 MMPLAYER_CMD_LOCK(player);
600 result = _mmplayer_get_subtitle_silent(player, silent);
602 MMPLAYER_CMD_UNLOCK(player);
607 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
609 int result = MM_ERROR_NONE;
612 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
613 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
615 va_start(var_args, first_attribute_name);
616 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
622 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
624 int result = MM_ERROR_NONE;
627 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
628 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
630 va_start(var_args, first_attribute_name);
631 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
637 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
639 int result = MM_ERROR_NONE;
642 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
643 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
644 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
646 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
651 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
653 int result = MM_ERROR_NONE;
655 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
656 MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
657 MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
659 result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
664 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
666 int result = MM_ERROR_NONE;
668 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
669 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
671 MMPLAYER_CMD_LOCK(player);
673 result = _mmplayer_get_track_count(player, type, count);
675 MMPLAYER_CMD_UNLOCK(player);
680 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
682 int result = MM_ERROR_NONE;
684 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
686 MMPLAYER_CMD_LOCK(player);
688 result = _mmplayer_select_track(player, type, index);
690 MMPLAYER_CMD_UNLOCK(player);
695 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
697 int result = MM_ERROR_NONE;
699 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
701 MMPLAYER_CMD_LOCK(player);
703 result = _mmplayer_track_add_subtitle_language(player, index);
705 MMPLAYER_CMD_UNLOCK(player);
710 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
712 int result = MM_ERROR_NONE;
714 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
716 MMPLAYER_CMD_LOCK(player);
718 result = _mmplayer_track_remove_subtitle_language(player, index);
720 MMPLAYER_CMD_UNLOCK(player);
726 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
728 int result = MM_ERROR_NONE;
730 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
731 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
733 MMPLAYER_CMD_LOCK(player);
735 result = _mmplayer_get_current_track(player, type, index);
737 MMPLAYER_CMD_UNLOCK(player);
742 int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code)
744 int result = MM_ERROR_NONE;
746 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
748 MMPLAYER_CMD_LOCK(player);
750 result = _mmplayer_get_track_language_code(player, type, index, code);
752 MMPLAYER_CMD_UNLOCK(player);
757 int mm_player_set_video_share_master_clock(MMHandleType player,
759 long long clock_delta,
760 long long video_time,
761 long long media_clock,
762 long long audio_time)
764 int result = MM_ERROR_NONE;
766 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
768 MMPLAYER_CMD_LOCK(player);
770 result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
772 MMPLAYER_CMD_UNLOCK(player);
777 int mm_player_get_video_share_master_clock(MMHandleType player,
778 long long *video_time,
779 long long *media_clock,
780 long long *audio_time)
782 int result = MM_ERROR_NONE;
784 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
785 MMPLAYER_RETURN_VAL_IF_FAIL(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
786 MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
787 MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
789 MMPLAYER_CMD_LOCK(player);
791 result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
793 MMPLAYER_CMD_UNLOCK(player);
798 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
800 int result = MM_ERROR_NONE;
802 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
804 MMPLAYER_CMD_LOCK(player);
806 result = _mmplayer_set_video_hub_download_mode(player, mode);
808 MMPLAYER_CMD_UNLOCK(player);
813 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
815 int result = MM_ERROR_NONE;
817 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
819 MMPLAYER_CMD_LOCK(player);
821 result = _mmplayer_enable_sync_handler(player, enable);
823 MMPLAYER_CMD_UNLOCK(player);
828 int mm_player_set_uri(MMHandleType player, const char *uri)
830 int result = MM_ERROR_NONE;
832 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
834 MMPLAYER_CMD_LOCK(player);
836 result = _mmplayer_set_uri(player, uri);
838 MMPLAYER_CMD_UNLOCK(player);
844 int mm_player_set_next_uri(MMHandleType player, const char *uri)
846 int result = MM_ERROR_NONE;
848 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
850 MMPLAYER_CMD_LOCK(player);
852 result = _mmplayer_set_next_uri(player, uri, FALSE);
854 MMPLAYER_CMD_UNLOCK(player);
860 int mm_player_get_next_uri(MMHandleType player, char **uri)
862 int result = MM_ERROR_NONE;
864 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
866 MMPLAYER_CMD_LOCK(player);
868 result = _mmplayer_get_next_uri(player, uri);
870 MMPLAYER_CMD_UNLOCK(player);
876 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
878 int result = MM_ERROR_NONE;
880 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
882 MMPLAYER_CMD_LOCK(player);
884 result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
886 MMPLAYER_CMD_UNLOCK(player);
892 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
894 int result = MM_ERROR_NONE;
896 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
897 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
899 MMPLAYER_CMD_LOCK(player);
901 result = _mmplayer_has_closed_caption(player, exist);
903 MMPLAYER_CMD_UNLOCK(player);
908 void mm_player_video_stream_internal_buffer_unref(void *buffer)
910 _mm_player_video_stream_internal_buffer_unref(buffer);
913 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
916 int result = MM_ERROR_NONE;
918 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
920 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
921 //MMPLAYER_CMD_LOCK(player);
923 result = _mmplayer_submit_packet(player, packet);
925 //MMPLAYER_CMD_UNLOCK(player);
930 int mm_player_set_video_info(MMHandleType player, media_format_h format)
932 int result = MM_ERROR_NONE;
936 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
938 MMPLAYER_CMD_LOCK(player);
940 result = _mmplayer_set_video_info(player, format);
942 MMPLAYER_CMD_UNLOCK(player);
948 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
950 int result = MM_ERROR_NONE;
954 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
956 MMPLAYER_CMD_LOCK(player);
958 result = _mmplayer_set_audio_info(player, format);
960 MMPLAYER_CMD_UNLOCK(player);
965 int mm_player_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
967 int result = MM_ERROR_NONE;
971 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
973 MMPLAYER_CMD_LOCK(player);
975 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
977 MMPLAYER_CMD_UNLOCK(player);
982 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
984 int result = MM_ERROR_NONE;
988 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
990 MMPLAYER_CMD_LOCK(player);
992 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
994 MMPLAYER_CMD_UNLOCK(player);
999 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1001 int result = MM_ERROR_NONE;
1002 guint64 _max_size = 0;
1006 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1007 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1009 MMPLAYER_CMD_LOCK(player);
1011 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1012 *max_size = _max_size;
1014 MMPLAYER_CMD_UNLOCK(player);
1019 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
1021 int result = MM_ERROR_NONE;
1025 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1027 MMPLAYER_CMD_LOCK(player);
1029 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
1031 MMPLAYER_CMD_UNLOCK(player);
1036 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1038 int result = MM_ERROR_NONE;
1042 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1043 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1045 MMPLAYER_CMD_LOCK(player);
1047 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1049 MMPLAYER_CMD_UNLOCK(player);
1054 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1056 int result = MM_ERROR_NONE;
1060 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1062 MMPLAYER_CMD_LOCK(player);
1064 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1066 MMPLAYER_CMD_UNLOCK(player);
1071 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1073 int result = MM_ERROR_NONE;
1077 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1079 MMPLAYER_CMD_LOCK(player);
1081 result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
1083 MMPLAYER_CMD_UNLOCK(player);
1088 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1090 int result = MM_ERROR_NONE;
1092 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1094 MMPLAYER_CMD_LOCK(player);
1096 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
1098 MMPLAYER_CMD_UNLOCK(player);
1103 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1105 int result = MM_ERROR_NONE;
1107 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1109 MMPLAYER_CMD_LOCK(player);
1111 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1113 MMPLAYER_CMD_UNLOCK(player);
1118 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1120 int result = MM_ERROR_NONE;
1122 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1124 MMPLAYER_CMD_LOCK(player);
1126 result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1128 MMPLAYER_CMD_UNLOCK(player);
1133 int mm_player_get_timeout(MMHandleType player, int *timeout)
1135 int result = MM_ERROR_NONE;
1137 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1138 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1140 MMPLAYER_CMD_LOCK(player);
1142 result = _mmplayer_get_timeout(player, timeout);
1144 MMPLAYER_CMD_UNLOCK(player);
1149 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1151 int result = MM_ERROR_NONE;
1153 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1154 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1156 MMPLAYER_CMD_LOCK(player);
1158 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1160 MMPLAYER_CMD_UNLOCK(player);
1165 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1167 int result = MM_ERROR_NONE;
1169 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1171 MMPLAYER_CMD_LOCK(player);
1173 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1175 MMPLAYER_CMD_UNLOCK(player);
1180 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1182 int result = MM_ERROR_NONE;
1184 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1185 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1187 //MMPLAYER_CMD_LOCK(player);
1189 result = _mmplayer_video_stream_release_bo(player, bo);
1191 //MMPLAYER_CMD_UNLOCK(player);
1196 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1198 int result = MM_ERROR_NONE;
1200 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1202 MMPLAYER_CMD_LOCK(player);
1204 result = _mmplayer_set_file_buffering_path(player, file_path);
1206 MMPLAYER_CMD_UNLOCK(player);
1211 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1213 int result = MM_ERROR_NONE;
1215 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1216 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1218 MMPLAYER_CMD_LOCK(player);
1220 _mmplayer_sound_unregister(&((mm_player_t*)player)->sound_focus);
1221 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1223 MMPLAYER_CMD_UNLOCK(player);
1228 int mm_player_manage_external_storage_state(MMHandleType player, int id, int state)
1230 int result = MM_ERROR_NONE;
1232 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1234 MMPLAYER_CMD_LOCK(player);
1236 result = _mmplayer_manage_external_storage_state(player, id, state);
1238 MMPLAYER_CMD_UNLOCK(player);
1243 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1245 int result = MM_ERROR_NONE;
1247 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1248 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1250 MMPLAYER_CMD_LOCK(player);
1252 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1254 MMPLAYER_CMD_UNLOCK(player);
1259 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1261 int result = MM_ERROR_NONE;
1263 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1265 MMPLAYER_CMD_LOCK(player);
1267 result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
1269 MMPLAYER_CMD_UNLOCK(player);
1274 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1276 int result = MM_ERROR_NONE;
1278 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1279 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1281 MMPLAYER_CMD_LOCK(player);
1283 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1285 MMPLAYER_CMD_UNLOCK(player);
1290 int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, int rebuffer_ms)
1292 int result = MM_ERROR_NONE;
1293 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1295 MMPLAYER_CMD_LOCK(player);
1297 result = _mmplayer_set_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1299 MMPLAYER_CMD_UNLOCK(player);
1304 int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms)
1306 int result = MM_ERROR_NONE;
1308 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1309 MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1311 MMPLAYER_CMD_LOCK(player);
1313 result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1315 MMPLAYER_CMD_UNLOCK(player);
1320 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1322 int result = MM_ERROR_NONE;
1323 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1325 MMPLAYER_CMD_LOCK(player);
1327 result = _mmplayer_set_audio_only(player, audio_only);
1329 MMPLAYER_CMD_UNLOCK(player);
1334 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1336 int result = MM_ERROR_NONE;
1338 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1339 MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1341 MMPLAYER_CMD_LOCK(player);
1343 result = _mmplayer_get_audio_only(player, audio_only);
1345 MMPLAYER_CMD_UNLOCK(player);
1350 int mm_player_360_set_enable(MMHandleType player, bool enable)
1352 int result = MM_ERROR_NONE;
1353 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1355 MMPLAYER_CMD_LOCK(player);
1357 result = _mmplayer_360_set_enable(player, enable);
1359 MMPLAYER_CMD_UNLOCK(player);
1364 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1366 int result = MM_ERROR_NONE;
1368 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1369 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1371 MMPLAYER_CMD_LOCK(player);
1373 result = _mmplayer_360_is_enabled(player, enabled);
1375 MMPLAYER_CMD_UNLOCK(player);
1380 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1382 int result = MM_ERROR_NONE;
1383 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1385 MMPLAYER_CMD_LOCK(player);
1387 result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1389 MMPLAYER_CMD_UNLOCK(player);
1394 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1396 int result = MM_ERROR_NONE;
1398 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1399 MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1401 MMPLAYER_CMD_LOCK(player);
1403 result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1405 MMPLAYER_CMD_UNLOCK(player);
1410 int mm_player_360_set_zoom(MMHandleType player, float level)
1412 int result = MM_ERROR_NONE;
1413 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1415 MMPLAYER_CMD_LOCK(player);
1417 result = _mmplayer_360_set_zoom(player, level);
1419 MMPLAYER_CMD_UNLOCK(player);
1424 int mm_player_360_get_zoom(MMHandleType player, float *level)
1426 int result = MM_ERROR_NONE;
1428 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1429 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1431 MMPLAYER_CMD_LOCK(player);
1433 result = _mmplayer_360_get_zoom(player, level);
1435 MMPLAYER_CMD_UNLOCK(player);
1440 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1442 int result = MM_ERROR_NONE;
1443 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1445 MMPLAYER_CMD_LOCK(player);
1447 result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1449 MMPLAYER_CMD_UNLOCK(player);
1454 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1456 int result = MM_ERROR_NONE;
1458 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1459 MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1461 MMPLAYER_CMD_LOCK(player);
1463 result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1465 MMPLAYER_CMD_UNLOCK(player);
1470 int mm_player_set_codec_type(MMHandleType player, MMPlayerStreamType stream_type, MMPlayerVideoCodecType codec_type)
1472 int result = MM_ERROR_NONE;
1474 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1476 MMPLAYER_CMD_LOCK(player);
1478 result = _mmplayer_set_codec_type(player, stream_type, codec_type);
1480 MMPLAYER_CMD_UNLOCK(player);