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"
40 int mm_player_create(MMHandleType *player)
42 int result = MM_ERROR_PLAYER_INTERNAL;
43 mm_player_t* new_player = NULL;
45 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
47 /* alloc player structure */
48 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))
66 LOGE("can't load ini");
70 if (MM_ERROR_NONE != mm_player_audio_effect_ini_load(&new_player->ini))
72 LOGE("can't load audio ini");
77 result = _mmplayer_create_player((MMHandleType)new_player);
78 if(result != MM_ERROR_NONE)
80 LOGE("failed to create player");
81 if (result != MM_ERROR_PLAYER_RESOURCE_LIMIT)
82 result = MM_ERROR_PLAYER_INTERNAL;
86 *player = (MMHandleType)new_player;
94 _mmplayer_destroy( (MMHandleType)new_player );
95 g_mutex_clear(&new_player->cmd_lock);
96 g_mutex_clear(&new_player->playback_lock);
98 MMPLAYER_FREEIF( new_player );
101 *player = (MMHandleType)0;
102 return result; /* MM_ERROR_PLAYER_INTERNAL or MM_ERROR_PLAYER_RESOURCE_LIMIT */
105 int mm_player_destroy(MMHandleType player)
107 int result = MM_ERROR_NONE;
109 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
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)
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)
503 LOGE("wrong format\n");
504 return MM_ERROR_COMMON_INVALID_ARGUMENT;
507 MMPLAYER_CMD_LOCK( player );
509 result = _mmplayer_get_position(player, (int)format, pos);
511 MMPLAYER_CMD_UNLOCK( player );
516 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
518 int result = MM_ERROR_NONE;
520 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
521 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
523 MMPLAYER_CMD_LOCK( player );
525 result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos );
527 MMPLAYER_CMD_UNLOCK( player );
532 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
534 int result = MM_ERROR_NONE;
536 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
538 MMPLAYER_CMD_LOCK( player );
540 result = _mmplayer_set_external_subtitle_path(player, path);
542 MMPLAYER_CMD_UNLOCK( player );
546 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
548 int result = MM_ERROR_NONE;
550 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
552 if (format >= MM_PLAYER_POS_FORMAT_NUM)
554 LOGE("wrong format(%d) \n", format);
555 return MM_ERROR_INVALID_ARGUMENT;
558 MMPLAYER_CMD_LOCK( player );
560 result = _mmplayer_adjust_subtitle_postion(player, format, pos);
562 MMPLAYER_CMD_UNLOCK( player );
567 int mm_player_adjust_video_position(MMHandleType player, int offset)
569 int result = MM_ERROR_NONE;
570 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
571 MMPLAYER_CMD_LOCK( player );
573 result = _mmplayer_adjust_video_postion(player, offset);
575 MMPLAYER_CMD_UNLOCK( player );
580 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
582 int result = MM_ERROR_NONE;
584 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
586 MMPLAYER_CMD_LOCK( player );
588 result = _mmplayer_set_subtitle_silent(player, silent);
590 MMPLAYER_CMD_UNLOCK( player );
595 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
597 int result = MM_ERROR_NONE;
599 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
601 MMPLAYER_CMD_LOCK( player );
603 result = _mmplayer_get_subtitle_silent(player, silent);
605 MMPLAYER_CMD_UNLOCK( player );
610 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
612 int result = MM_ERROR_NONE;
615 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
616 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
618 va_start (var_args, first_attribute_name);
619 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
625 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
627 int result = MM_ERROR_NONE;
630 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
631 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
633 va_start (var_args, first_attribute_name);
634 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
640 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
642 int result = MM_ERROR_NONE;
645 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
646 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
647 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
649 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
654 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
656 int result = MM_ERROR_NONE;
658 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
659 MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
660 MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
662 result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
667 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
669 int result = MM_ERROR_NONE;
671 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
672 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
674 MMPLAYER_CMD_LOCK( player );
676 result = _mmplayer_get_track_count(player, type, count);
678 MMPLAYER_CMD_UNLOCK( player );
683 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
685 int result = MM_ERROR_NONE;
687 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
689 MMPLAYER_CMD_LOCK( player );
691 result = _mmplayer_select_track(player, type, index);
693 MMPLAYER_CMD_UNLOCK( player );
698 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
700 int result = MM_ERROR_NONE;
702 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
704 MMPLAYER_CMD_LOCK( player );
706 result = _mmplayer_track_add_subtitle_language(player, index);
708 MMPLAYER_CMD_UNLOCK( player );
713 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
715 int result = MM_ERROR_NONE;
717 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
719 MMPLAYER_CMD_LOCK( player );
721 result = _mmplayer_track_remove_subtitle_language(player, index);
723 MMPLAYER_CMD_UNLOCK( player );
729 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
731 int result = MM_ERROR_NONE;
733 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
734 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
736 MMPLAYER_CMD_LOCK( player );
738 result = _mmplayer_get_current_track(player, type, index);
740 MMPLAYER_CMD_UNLOCK( player );
745 int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code)
747 int result = MM_ERROR_NONE;
749 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
751 MMPLAYER_CMD_LOCK( player );
753 result = _mmplayer_get_track_language_code(player, type, index, code);
755 MMPLAYER_CMD_UNLOCK( player );
760 int mm_player_set_display_zoom(MMHandleType player, float level, int x, int y)
762 int result = MM_ERROR_NONE;
764 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
766 MMPLAYER_CMD_LOCK( player );
768 result = _mmplayer_set_display_zoom(player, level, x, y);
770 MMPLAYER_CMD_UNLOCK( player );
775 int mm_player_get_display_zoom(MMHandleType player, float *level, int *x, int *y)
777 int result = MM_ERROR_NONE;
779 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
780 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_COMMON_INVALID_ARGUMENT);
782 MMPLAYER_CMD_LOCK( player );
784 result = _mmplayer_get_display_zoom(player, level, x, y);
786 MMPLAYER_CMD_UNLOCK( player );
791 int mm_player_set_video_share_master_clock(MMHandleType player,
793 long long clock_delta,
794 long long video_time,
795 long long media_clock,
796 long long audio_time)
798 int result = MM_ERROR_NONE;
800 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
802 MMPLAYER_CMD_LOCK( player );
804 result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
806 MMPLAYER_CMD_UNLOCK( player );
811 int mm_player_get_video_share_master_clock(MMHandleType player,
812 long long *video_time,
813 long long *media_clock,
814 long long *audio_time)
816 int result = MM_ERROR_NONE;
818 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
819 MMPLAYER_RETURN_VAL_IF_FAIL(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
820 MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
821 MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
823 MMPLAYER_CMD_LOCK( player );
825 result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
827 MMPLAYER_CMD_UNLOCK( player );
832 int mm_player_get_video_rotate_angle(MMHandleType player, int *angle)
834 int result = MM_ERROR_NONE;
836 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
837 MMPLAYER_RETURN_VAL_IF_FAIL(angle, MM_ERROR_COMMON_INVALID_ARGUMENT);
839 MMPLAYER_CMD_LOCK( player );
841 result = _mmplayer_get_video_rotate_angle(player, angle);
843 MMPLAYER_CMD_UNLOCK( player );
848 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
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_video_hub_download_mode(player, mode);
858 MMPLAYER_CMD_UNLOCK( player );
863 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
865 int result = MM_ERROR_NONE;
867 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
869 MMPLAYER_CMD_LOCK( player );
871 result = _mmplayer_enable_sync_handler(player, enable);
873 MMPLAYER_CMD_UNLOCK( player );
878 int mm_player_set_uri(MMHandleType player, const char *uri)
880 int result = MM_ERROR_NONE;
882 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
884 MMPLAYER_CMD_LOCK( player );
886 result = _mmplayer_set_uri(player, uri);
888 MMPLAYER_CMD_UNLOCK( player );
894 int mm_player_set_next_uri(MMHandleType player, const char *uri)
896 int result = MM_ERROR_NONE;
898 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
900 MMPLAYER_CMD_LOCK( player );
902 result = _mmplayer_set_next_uri(player, uri, FALSE);
904 MMPLAYER_CMD_UNLOCK( player );
910 int mm_player_get_next_uri(MMHandleType player, char **uri)
912 int result = MM_ERROR_NONE;
914 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
916 MMPLAYER_CMD_LOCK( player );
918 result = _mmplayer_get_next_uri(player, uri);
920 MMPLAYER_CMD_UNLOCK( player );
926 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
928 int result = MM_ERROR_NONE;
930 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
932 MMPLAYER_CMD_LOCK( player );
934 result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
936 MMPLAYER_CMD_UNLOCK( player );
942 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
944 int result = MM_ERROR_NONE;
946 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
947 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
949 MMPLAYER_CMD_LOCK( player );
951 result = _mmplayer_has_closed_caption(player, exist);
953 MMPLAYER_CMD_UNLOCK( player );
958 void * mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer)
961 result = _mm_player_media_packet_video_stream_internal_buffer_ref(buffer);
966 void mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer)
968 _mm_player_media_packet_video_stream_internal_buffer_unref(buffer);
971 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
974 int result = MM_ERROR_NONE;
976 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
978 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
979 //MMPLAYER_CMD_LOCK( player );
981 result = _mmplayer_submit_packet(player, packet);
983 //MMPLAYER_CMD_UNLOCK( player );
988 int mm_player_set_video_info (MMHandleType player, media_format_h format)
990 int result = MM_ERROR_NONE;
994 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
996 MMPLAYER_CMD_LOCK( player );
998 result = _mmplayer_set_video_info(player, format);
1000 MMPLAYER_CMD_UNLOCK( player );
1006 int mm_player_set_audio_info (MMHandleType player, media_format_h format)
1008 int result = MM_ERROR_NONE;
1012 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1014 MMPLAYER_CMD_LOCK( player );
1016 result = _mmplayer_set_audio_info(player, format);
1018 MMPLAYER_CMD_UNLOCK( player );
1023 int mm_player_set_subtitle_info (MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
1025 int result = MM_ERROR_NONE;
1029 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1031 MMPLAYER_CMD_LOCK( player );
1033 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
1035 MMPLAYER_CMD_UNLOCK( player );
1040 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
1042 int result = MM_ERROR_NONE;
1046 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1048 MMPLAYER_CMD_LOCK( player );
1050 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
1052 MMPLAYER_CMD_UNLOCK( player );
1057 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1059 int result = MM_ERROR_NONE;
1060 guint64 _max_size = 0;
1064 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1065 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1067 MMPLAYER_CMD_LOCK( player );
1069 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1070 *max_size = _max_size;
1072 MMPLAYER_CMD_UNLOCK( player );
1077 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
1079 int result = MM_ERROR_NONE;
1083 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1085 MMPLAYER_CMD_LOCK( player );
1087 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
1089 MMPLAYER_CMD_UNLOCK( player );
1094 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1096 int result = MM_ERROR_NONE;
1100 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1101 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1103 MMPLAYER_CMD_LOCK( player );
1105 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1107 MMPLAYER_CMD_UNLOCK( player );
1112 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1114 int result = MM_ERROR_NONE;
1118 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1120 MMPLAYER_CMD_LOCK( player );
1122 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1124 MMPLAYER_CMD_UNLOCK( player );
1129 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1131 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_media_stream_seek_data_cb(player, type, callback, user_param);
1141 MMPLAYER_CMD_UNLOCK( player );
1146 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
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_audiostream_changed_cb(player, callback, user_param);
1156 MMPLAYER_CMD_UNLOCK( player );
1161 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1163 int result = MM_ERROR_NONE;
1165 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1167 MMPLAYER_CMD_LOCK( player );
1169 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1171 MMPLAYER_CMD_UNLOCK( player );
1176 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1178 int result = MM_ERROR_NONE;
1180 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1182 MMPLAYER_CMD_LOCK( player );
1184 result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1186 MMPLAYER_CMD_UNLOCK( player );
1191 int mm_player_get_timeout(MMHandleType player, int *timeout)
1193 int result = MM_ERROR_NONE;
1195 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1196 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1198 MMPLAYER_CMD_LOCK( player );
1200 result = _mmplayer_get_timeout(player, timeout);
1202 MMPLAYER_CMD_UNLOCK( player );
1207 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1209 int result = MM_ERROR_NONE;
1211 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1212 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1214 MMPLAYER_CMD_LOCK( player );
1216 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1218 MMPLAYER_CMD_UNLOCK( player );
1223 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1225 int result = MM_ERROR_NONE;
1227 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1229 MMPLAYER_CMD_LOCK( player );
1231 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1233 MMPLAYER_CMD_UNLOCK( player );
1238 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1240 int result = MM_ERROR_NONE;
1242 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1243 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1244 // MMPLAYER_CMD_LOCK( player );
1246 result = _mmplayer_video_stream_release_bo(player, bo);
1248 // MMPLAYER_CMD_UNLOCK( player );
1252 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1254 int result = MM_ERROR_NONE;
1256 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1258 MMPLAYER_CMD_LOCK( player );
1260 result = _mmplayer_set_file_buffering_path(player, file_path);
1262 MMPLAYER_CMD_UNLOCK( player );
1267 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1269 int result = MM_ERROR_NONE;
1271 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1272 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1274 MMPLAYER_CMD_LOCK( player );
1276 _mmplayer_sound_unregister(&((mm_player_t*)player)->sound_focus);
1277 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1279 MMPLAYER_CMD_UNLOCK( player );
1284 int mm_player_manage_external_storage_state(MMHandleType player, int state)
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_manage_external_storage_state(player, state);
1294 MMPLAYER_CMD_UNLOCK( player );
1299 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1301 int result = MM_ERROR_NONE;
1303 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1304 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1306 MMPLAYER_CMD_LOCK( player );
1308 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1310 MMPLAYER_CMD_UNLOCK( player );
1315 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1317 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_max_adaptive_variant_limit(player, bandwidth, width, height);
1325 MMPLAYER_CMD_UNLOCK( player );
1330 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1332 int result = MM_ERROR_NONE;
1334 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1335 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1337 MMPLAYER_CMD_LOCK( player );
1339 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1341 MMPLAYER_CMD_UNLOCK( player );
1346 int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, int rebuffer_ms)
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_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1355 MMPLAYER_CMD_UNLOCK( player );
1360 int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms)
1362 int result = MM_ERROR_NONE;
1364 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1365 MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1367 MMPLAYER_CMD_LOCK( player );
1369 result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1371 MMPLAYER_CMD_UNLOCK( player );
1376 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
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_set_audio_only(player, audio_only);
1385 MMPLAYER_CMD_UNLOCK( player );
1390 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1392 int result = MM_ERROR_NONE;
1394 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1395 MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1397 MMPLAYER_CMD_LOCK( player );
1399 result = _mmplayer_get_audio_only(player, audio_only);
1401 MMPLAYER_CMD_UNLOCK( player );