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));
52 LOGE("Cannot allocate memory for player\n");
53 result = MM_ERROR_PLAYER_RESOURCE_LIMIT;
56 memset(new_player, 0, sizeof(mm_player_t));
58 /* create player lock */
59 g_mutex_init(&new_player->cmd_lock);
61 /* create player lock */
62 g_mutex_init(&new_player->playback_lock);
65 if (MM_ERROR_NONE != mm_player_ini_load(&new_player->ini))
67 LOGE("can't load ini");
71 if (MM_ERROR_NONE != mm_player_audio_effect_ini_load(&new_player->ini))
73 LOGE("can't load audio ini");
78 result = _mmplayer_create_player((MMHandleType)new_player);
79 if(result != MM_ERROR_NONE)
81 LOGE("failed to create player");
82 if (result != MM_ERROR_PLAYER_RESOURCE_LIMIT)
83 result = MM_ERROR_PLAYER_INTERNAL;
87 *player = (MMHandleType)new_player;
95 _mmplayer_destroy( (MMHandleType)new_player );
96 g_mutex_clear(&new_player->cmd_lock);
97 g_mutex_clear(&new_player->playback_lock);
99 MMPLAYER_FREEIF( new_player );
102 *player = (MMHandleType)0;
103 return result; /* MM_ERROR_PLAYER_INTERNAL or MM_ERROR_PLAYER_RESOURCE_LIMIT */
106 int mm_player_destroy(MMHandleType player)
108 int result = MM_ERROR_NONE;
110 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
112 MMPLAYER_CMD_LOCK( player );
114 result = _mmplayer_destroy(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)
482 LOGE("wrong format\n");
483 return MM_ERROR_COMMON_INVALID_ARGUMENT;
486 MMPLAYER_CMD_LOCK( player );
488 result = _mmplayer_set_position(player, format, pos);
490 MMPLAYER_CMD_UNLOCK( player );
495 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *pos)
497 int result = MM_ERROR_NONE;
499 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
500 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
502 if (format >= MM_PLAYER_POS_FORMAT_NUM)
504 LOGE("wrong format\n");
505 return MM_ERROR_COMMON_INVALID_ARGUMENT;
508 MMPLAYER_CMD_LOCK( player );
510 result = _mmplayer_get_position(player, (int)format, pos);
512 MMPLAYER_CMD_UNLOCK( player );
517 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
519 int result = MM_ERROR_NONE;
521 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
522 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
524 MMPLAYER_CMD_LOCK( player );
526 result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos );
528 MMPLAYER_CMD_UNLOCK( player );
533 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
535 int result = MM_ERROR_NONE;
537 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
539 MMPLAYER_CMD_LOCK( player );
541 result = _mmplayer_set_external_subtitle_path(player, path);
543 MMPLAYER_CMD_UNLOCK( player );
547 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
549 int result = MM_ERROR_NONE;
551 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
553 if (format >= MM_PLAYER_POS_FORMAT_NUM)
555 LOGE("wrong format(%d) \n", format);
556 return MM_ERROR_INVALID_ARGUMENT;
559 MMPLAYER_CMD_LOCK( player );
561 result = _mmplayer_adjust_subtitle_postion(player, format, pos);
563 MMPLAYER_CMD_UNLOCK( player );
568 int mm_player_adjust_video_position(MMHandleType player, int offset)
570 int result = MM_ERROR_NONE;
571 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
572 MMPLAYER_CMD_LOCK( player );
574 result = _mmplayer_adjust_video_postion(player, offset);
576 MMPLAYER_CMD_UNLOCK( player );
581 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
583 int result = MM_ERROR_NONE;
585 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
587 MMPLAYER_CMD_LOCK( player );
589 result = _mmplayer_set_subtitle_silent(player, silent);
591 MMPLAYER_CMD_UNLOCK( player );
596 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
598 int result = MM_ERROR_NONE;
600 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
602 MMPLAYER_CMD_LOCK( player );
604 result = _mmplayer_get_subtitle_silent(player, silent);
606 MMPLAYER_CMD_UNLOCK( player );
611 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
613 int result = MM_ERROR_NONE;
616 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
617 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
619 va_start (var_args, first_attribute_name);
620 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
626 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
628 int result = MM_ERROR_NONE;
631 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
632 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
634 va_start (var_args, first_attribute_name);
635 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
641 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
643 int result = MM_ERROR_NONE;
646 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
647 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
648 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
650 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
655 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
657 int result = MM_ERROR_NONE;
659 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
660 MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
661 MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
663 result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
668 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
670 int result = MM_ERROR_NONE;
672 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
673 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
675 MMPLAYER_CMD_LOCK( player );
677 result = _mmplayer_get_track_count(player, type, count);
679 MMPLAYER_CMD_UNLOCK( player );
684 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
686 int result = MM_ERROR_NONE;
688 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
690 MMPLAYER_CMD_LOCK( player );
692 result = _mmplayer_select_track(player, type, index);
694 MMPLAYER_CMD_UNLOCK( player );
699 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
701 int result = MM_ERROR_NONE;
703 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
705 MMPLAYER_CMD_LOCK( player );
707 result = _mmplayer_track_add_subtitle_language(player, index);
709 MMPLAYER_CMD_UNLOCK( player );
714 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
716 int result = MM_ERROR_NONE;
718 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
720 MMPLAYER_CMD_LOCK( player );
722 result = _mmplayer_track_remove_subtitle_language(player, index);
724 MMPLAYER_CMD_UNLOCK( player );
730 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
732 int result = MM_ERROR_NONE;
734 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
735 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
737 MMPLAYER_CMD_LOCK( player );
739 result = _mmplayer_get_current_track(player, type, index);
741 MMPLAYER_CMD_UNLOCK( player );
746 int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code)
748 int result = MM_ERROR_NONE;
750 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
752 MMPLAYER_CMD_LOCK( player );
754 result = _mmplayer_get_track_language_code(player, type, index, code);
756 MMPLAYER_CMD_UNLOCK( player );
761 int mm_player_set_video_share_master_clock(MMHandleType player,
763 long long clock_delta,
764 long long video_time,
765 long long media_clock,
766 long long audio_time)
768 int result = MM_ERROR_NONE;
770 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
772 MMPLAYER_CMD_LOCK( player );
774 result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
776 MMPLAYER_CMD_UNLOCK( player );
781 int mm_player_get_video_share_master_clock(MMHandleType player,
782 long long *video_time,
783 long long *media_clock,
784 long long *audio_time)
786 int result = MM_ERROR_NONE;
788 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
789 MMPLAYER_RETURN_VAL_IF_FAIL(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
790 MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
791 MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
793 MMPLAYER_CMD_LOCK( player );
795 result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
797 MMPLAYER_CMD_UNLOCK( player );
802 int mm_player_get_video_rotate_angle(MMHandleType player, int *angle)
804 int result = MM_ERROR_NONE;
806 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
807 MMPLAYER_RETURN_VAL_IF_FAIL(angle, MM_ERROR_COMMON_INVALID_ARGUMENT);
809 MMPLAYER_CMD_LOCK( player );
811 result = _mmplayer_get_video_rotate_angle(player, angle);
813 MMPLAYER_CMD_UNLOCK( player );
818 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
820 int result = MM_ERROR_NONE;
822 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
824 MMPLAYER_CMD_LOCK( player );
826 result = _mmplayer_set_video_hub_download_mode(player, mode);
828 MMPLAYER_CMD_UNLOCK( player );
833 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
835 int result = MM_ERROR_NONE;
837 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
839 MMPLAYER_CMD_LOCK( player );
841 result = _mmplayer_enable_sync_handler(player, enable);
843 MMPLAYER_CMD_UNLOCK( player );
848 int mm_player_set_uri(MMHandleType player, const char *uri)
850 int result = MM_ERROR_NONE;
852 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
854 MMPLAYER_CMD_LOCK( player );
856 result = _mmplayer_set_uri(player, uri);
858 MMPLAYER_CMD_UNLOCK( player );
864 int mm_player_set_next_uri(MMHandleType player, const char *uri)
866 int result = MM_ERROR_NONE;
868 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
870 MMPLAYER_CMD_LOCK( player );
872 result = _mmplayer_set_next_uri(player, uri, FALSE);
874 MMPLAYER_CMD_UNLOCK( player );
880 int mm_player_get_next_uri(MMHandleType player, char **uri)
882 int result = MM_ERROR_NONE;
884 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
886 MMPLAYER_CMD_LOCK( player );
888 result = _mmplayer_get_next_uri(player, uri);
890 MMPLAYER_CMD_UNLOCK( player );
896 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
898 int result = MM_ERROR_NONE;
900 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
902 MMPLAYER_CMD_LOCK( player );
904 result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
906 MMPLAYER_CMD_UNLOCK( player );
912 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
914 int result = MM_ERROR_NONE;
916 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
917 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
919 MMPLAYER_CMD_LOCK( player );
921 result = _mmplayer_has_closed_caption(player, exist);
923 MMPLAYER_CMD_UNLOCK( player );
928 void * mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer)
931 result = _mm_player_media_packet_video_stream_internal_buffer_ref(buffer);
936 void mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer)
938 _mm_player_media_packet_video_stream_internal_buffer_unref(buffer);
941 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
944 int result = MM_ERROR_NONE;
946 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
948 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
949 //MMPLAYER_CMD_LOCK( player );
951 result = _mmplayer_submit_packet(player, packet);
953 //MMPLAYER_CMD_UNLOCK( player );
958 int mm_player_set_video_info (MMHandleType player, media_format_h format)
960 int result = MM_ERROR_NONE;
964 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
966 MMPLAYER_CMD_LOCK( player );
968 result = _mmplayer_set_video_info(player, format);
970 MMPLAYER_CMD_UNLOCK( player );
976 int mm_player_set_audio_info (MMHandleType player, media_format_h format)
978 int result = MM_ERROR_NONE;
982 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
984 MMPLAYER_CMD_LOCK( player );
986 result = _mmplayer_set_audio_info(player, format);
988 MMPLAYER_CMD_UNLOCK( player );
993 int mm_player_set_subtitle_info (MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
995 int result = MM_ERROR_NONE;
999 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1001 MMPLAYER_CMD_LOCK( player );
1003 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
1005 MMPLAYER_CMD_UNLOCK( player );
1010 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
1012 int result = MM_ERROR_NONE;
1016 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1018 MMPLAYER_CMD_LOCK( player );
1020 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
1022 MMPLAYER_CMD_UNLOCK( player );
1027 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1029 int result = MM_ERROR_NONE;
1030 guint64 _max_size = 0;
1034 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1035 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1037 MMPLAYER_CMD_LOCK( player );
1039 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1040 *max_size = _max_size;
1042 MMPLAYER_CMD_UNLOCK( player );
1047 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
1049 int result = MM_ERROR_NONE;
1053 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1055 MMPLAYER_CMD_LOCK( player );
1057 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
1059 MMPLAYER_CMD_UNLOCK( player );
1064 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1066 int result = MM_ERROR_NONE;
1070 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1071 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1073 MMPLAYER_CMD_LOCK( player );
1075 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1077 MMPLAYER_CMD_UNLOCK( player );
1082 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1084 int result = MM_ERROR_NONE;
1088 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1090 MMPLAYER_CMD_LOCK( player );
1092 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1094 MMPLAYER_CMD_UNLOCK( player );
1099 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1101 int result = MM_ERROR_NONE;
1105 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1107 MMPLAYER_CMD_LOCK( player );
1109 result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
1111 MMPLAYER_CMD_UNLOCK( player );
1116 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1118 int result = MM_ERROR_NONE;
1120 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1122 MMPLAYER_CMD_LOCK( player );
1124 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
1126 MMPLAYER_CMD_UNLOCK( player );
1131 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1133 int result = MM_ERROR_NONE;
1135 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1137 MMPLAYER_CMD_LOCK( player );
1139 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1141 MMPLAYER_CMD_UNLOCK( player );
1146 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1148 int result = MM_ERROR_NONE;
1150 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1152 MMPLAYER_CMD_LOCK( player );
1154 result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1156 MMPLAYER_CMD_UNLOCK( player );
1161 int mm_player_get_timeout(MMHandleType player, int *timeout)
1163 int result = MM_ERROR_NONE;
1165 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1166 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1168 MMPLAYER_CMD_LOCK( player );
1170 result = _mmplayer_get_timeout(player, timeout);
1172 MMPLAYER_CMD_UNLOCK( player );
1177 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1179 int result = MM_ERROR_NONE;
1181 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1182 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1184 MMPLAYER_CMD_LOCK( player );
1186 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1188 MMPLAYER_CMD_UNLOCK( player );
1193 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1195 int result = MM_ERROR_NONE;
1197 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1199 MMPLAYER_CMD_LOCK( player );
1201 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1203 MMPLAYER_CMD_UNLOCK( player );
1208 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1210 int result = MM_ERROR_NONE;
1212 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1213 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1214 // MMPLAYER_CMD_LOCK( player );
1216 result = _mmplayer_video_stream_release_bo(player, bo);
1218 // MMPLAYER_CMD_UNLOCK( player );
1222 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1224 int result = MM_ERROR_NONE;
1226 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1228 MMPLAYER_CMD_LOCK( player );
1230 result = _mmplayer_set_file_buffering_path(player, file_path);
1232 MMPLAYER_CMD_UNLOCK( player );
1237 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1239 int result = MM_ERROR_NONE;
1241 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1242 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1244 MMPLAYER_CMD_LOCK( player );
1246 _mmplayer_sound_unregister(&((mm_player_t*)player)->sound_focus);
1247 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1249 MMPLAYER_CMD_UNLOCK( player );
1254 int mm_player_manage_external_storage_state(MMHandleType player, int state)
1256 int result = MM_ERROR_NONE;
1258 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1260 MMPLAYER_CMD_LOCK( player );
1262 result = _mmplayer_manage_external_storage_state(player, state);
1264 MMPLAYER_CMD_UNLOCK( player );
1269 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1271 int result = MM_ERROR_NONE;
1273 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1274 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1276 MMPLAYER_CMD_LOCK( player );
1278 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1280 MMPLAYER_CMD_UNLOCK( player );
1285 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1287 int result = MM_ERROR_NONE;
1289 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1291 MMPLAYER_CMD_LOCK( player );
1293 result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
1295 MMPLAYER_CMD_UNLOCK( player );
1300 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1302 int result = MM_ERROR_NONE;
1304 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1305 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1307 MMPLAYER_CMD_LOCK( player );
1309 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1311 MMPLAYER_CMD_UNLOCK( player );
1316 int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, int rebuffer_ms)
1318 int result = MM_ERROR_NONE;
1319 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1321 MMPLAYER_CMD_LOCK( player );
1323 result = _mmplayer_set_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1325 MMPLAYER_CMD_UNLOCK( player );
1330 int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms)
1332 int result = MM_ERROR_NONE;
1334 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1335 MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1337 MMPLAYER_CMD_LOCK( player );
1339 result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1341 MMPLAYER_CMD_UNLOCK( player );
1346 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1348 int result = MM_ERROR_NONE;
1349 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1351 MMPLAYER_CMD_LOCK( player );
1353 result = _mmplayer_set_audio_only(player, audio_only);
1355 MMPLAYER_CMD_UNLOCK( player );
1360 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1362 int result = MM_ERROR_NONE;
1364 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1365 MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1367 MMPLAYER_CMD_LOCK( player );
1369 result = _mmplayer_get_audio_only(player, audio_only);
1371 MMPLAYER_CMD_UNLOCK( player );
1376 int mm_player_360_set_enable(MMHandleType player, bool enable)
1378 int result = MM_ERROR_NONE;
1379 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1381 MMPLAYER_CMD_LOCK( player );
1383 result = _mmplayer_360_set_enable(player, enable);
1385 MMPLAYER_CMD_UNLOCK( player );
1390 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1392 int result = MM_ERROR_NONE;
1394 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1395 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1397 MMPLAYER_CMD_LOCK( player );
1399 result = _mmplayer_360_is_enabled(player, enabled);
1401 MMPLAYER_CMD_UNLOCK( player );
1406 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1408 int result = MM_ERROR_NONE;
1409 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1411 MMPLAYER_CMD_LOCK( player );
1413 result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1415 MMPLAYER_CMD_UNLOCK( player );
1420 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1422 int result = MM_ERROR_NONE;
1424 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1425 MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1427 MMPLAYER_CMD_LOCK( player );
1429 result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1431 MMPLAYER_CMD_UNLOCK( player );
1436 int mm_player_360_set_zoom(MMHandleType player, float level)
1438 int result = MM_ERROR_NONE;
1439 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1441 MMPLAYER_CMD_LOCK( player );
1443 result = _mmplayer_360_set_zoom(player, level);
1445 MMPLAYER_CMD_UNLOCK( player );
1450 int mm_player_360_get_zoom(MMHandleType player, float *level)
1452 int result = MM_ERROR_NONE;
1454 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1455 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1457 MMPLAYER_CMD_LOCK( player );
1459 result = _mmplayer_360_get_zoom(player, level);
1461 MMPLAYER_CMD_UNLOCK( player );
1466 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1468 int result = MM_ERROR_NONE;
1469 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1471 MMPLAYER_CMD_LOCK( player );
1473 result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1475 MMPLAYER_CMD_UNLOCK( player );
1480 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1482 int result = MM_ERROR_NONE;
1484 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1485 MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1487 MMPLAYER_CMD_LOCK( player );
1489 result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1491 MMPLAYER_CMD_UNLOCK( player );