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_prepare_buffering_time(MMHandleType player, int second)
277 int result = MM_ERROR_NONE;
279 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
281 MMPLAYER_CMD_LOCK( player );
283 result = _mmplayer_set_prepare_buffering_time(player, second);
285 MMPLAYER_CMD_UNLOCK( player );
290 int mm_player_set_runtime_buffering_mode(MMHandleType player, MMPlayerBufferingMode mode, int second)
292 int result = MM_ERROR_NONE;
294 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
296 MMPLAYER_CMD_LOCK( player );
298 result = _mmplayer_set_runtime_buffering_mode(player, mode, second);
300 MMPLAYER_CMD_UNLOCK( player );
305 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume)
307 int result = MM_ERROR_NONE;
309 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
310 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
312 MMPLAYER_CMD_LOCK( player );
314 result = _mmplayer_set_volume(player, *volume);
316 MMPLAYER_CMD_UNLOCK( player );
321 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume)
323 int result = MM_ERROR_NONE;
325 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
326 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
328 MMPLAYER_CMD_LOCK( player );
330 result = _mmplayer_get_volume(player, volume);
332 MMPLAYER_CMD_UNLOCK( player );
337 int mm_player_set_mute(MMHandleType player, int mute)
339 int result = MM_ERROR_NONE;
341 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
343 MMPLAYER_CMD_LOCK( player );
345 result = _mmplayer_set_mute(player, mute);
347 MMPLAYER_CMD_UNLOCK( player );
352 int mm_player_get_mute(MMHandleType player, int *mute)
354 int result = MM_ERROR_NONE;
356 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
357 MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
359 MMPLAYER_CMD_LOCK( player );
361 result = _mmplayer_get_mute(player, mute);
363 MMPLAYER_CMD_UNLOCK( player );
368 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state)
370 int result = MM_ERROR_NONE;
372 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
373 MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
375 *state = MM_PLAYER_STATE_NULL;
377 result = _mmplayer_get_state(player, (int*)state);
382 /* NOTE : It does not support some use cases, eg using colorspace converter */
383 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
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_change_videosink(player, display_surface_type, display_overlay);
393 MMPLAYER_CMD_UNLOCK( player );
398 int mm_player_start(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_start(player);
408 MMPLAYER_CMD_UNLOCK( player );
413 int mm_player_stop(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_stop(player);
423 MMPLAYER_CMD_UNLOCK( player );
428 int mm_player_pause(MMHandleType player)
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_pause(player);
438 MMPLAYER_CMD_UNLOCK( player );
443 int mm_player_resume(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_resume(player);
453 MMPLAYER_CMD_UNLOCK( player );
458 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos)
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_activate_section_repeat(player, start_pos, end_pos);
468 MMPLAYER_CMD_UNLOCK( player );
473 int mm_player_deactivate_section_repeat(MMHandleType player)
475 int result = MM_ERROR_NONE;
477 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
479 MMPLAYER_CMD_LOCK( player );
481 result = _mmplayer_deactivate_section_repeat(player);
483 MMPLAYER_CMD_UNLOCK( player );
488 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
490 int result = MM_ERROR_NONE;
492 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
494 MMPLAYER_CMD_LOCK( player );
496 result = _mmplayer_set_playspeed(player, rate, streaming);
498 MMPLAYER_CMD_UNLOCK( player );
503 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
505 int result = MM_ERROR_NONE;
507 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
509 if (format >= MM_PLAYER_POS_FORMAT_NUM)
511 LOGE("wrong format\n");
512 return MM_ERROR_COMMON_INVALID_ARGUMENT;
515 MMPLAYER_CMD_LOCK( player );
517 result = _mmplayer_set_position(player, format, pos);
519 MMPLAYER_CMD_UNLOCK( player );
524 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *pos)
526 int result = MM_ERROR_NONE;
528 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
529 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
531 if (format >= MM_PLAYER_POS_FORMAT_NUM)
533 LOGE("wrong format\n");
534 return MM_ERROR_COMMON_INVALID_ARGUMENT;
537 MMPLAYER_CMD_LOCK( player );
539 result = _mmplayer_get_position(player, (int)format, pos);
541 MMPLAYER_CMD_UNLOCK( player );
546 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
548 int result = MM_ERROR_NONE;
550 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
551 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
553 MMPLAYER_CMD_LOCK( player );
555 result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos );
557 MMPLAYER_CMD_UNLOCK( player );
562 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
564 int result = MM_ERROR_NONE;
566 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
568 MMPLAYER_CMD_LOCK( player );
570 result = _mmplayer_set_external_subtitle_path(player, path);
572 MMPLAYER_CMD_UNLOCK( player );
576 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
578 int result = MM_ERROR_NONE;
580 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
582 if (format >= MM_PLAYER_POS_FORMAT_NUM)
584 LOGE("wrong format(%d) \n", format);
585 return MM_ERROR_INVALID_ARGUMENT;
588 MMPLAYER_CMD_LOCK( player );
590 result = _mmplayer_adjust_subtitle_postion(player, format, pos);
592 MMPLAYER_CMD_UNLOCK( player );
597 int mm_player_adjust_video_position(MMHandleType player, int offset)
599 int result = MM_ERROR_NONE;
600 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
601 MMPLAYER_CMD_LOCK( player );
603 result = _mmplayer_adjust_video_postion(player, offset);
605 MMPLAYER_CMD_UNLOCK( player );
610 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
612 int result = MM_ERROR_NONE;
614 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
616 MMPLAYER_CMD_LOCK( player );
618 result = _mmplayer_set_subtitle_silent(player, silent);
620 MMPLAYER_CMD_UNLOCK( player );
625 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
627 int result = MM_ERROR_NONE;
629 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
631 MMPLAYER_CMD_LOCK( player );
633 result = _mmplayer_get_subtitle_silent(player, silent);
635 MMPLAYER_CMD_UNLOCK( player );
640 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
642 int result = MM_ERROR_NONE;
645 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
646 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
648 va_start (var_args, first_attribute_name);
649 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
655 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
657 int result = MM_ERROR_NONE;
660 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
661 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
663 va_start (var_args, first_attribute_name);
664 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
670 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
672 int result = MM_ERROR_NONE;
675 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
676 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
677 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
679 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
684 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
686 int result = MM_ERROR_NONE;
688 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
689 MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
690 MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
692 result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
697 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
699 int result = MM_ERROR_NONE;
701 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
702 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
704 MMPLAYER_CMD_LOCK( player );
706 result = _mmplayer_get_track_count(player, type, count);
708 MMPLAYER_CMD_UNLOCK( player );
713 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, 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_select_track(player, type, index);
723 MMPLAYER_CMD_UNLOCK( player );
728 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
730 int result = MM_ERROR_NONE;
732 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
734 MMPLAYER_CMD_LOCK( player );
736 result = _mmplayer_track_add_subtitle_language(player, index);
738 MMPLAYER_CMD_UNLOCK( player );
743 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
745 int result = MM_ERROR_NONE;
747 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
749 MMPLAYER_CMD_LOCK( player );
751 result = _mmplayer_track_remove_subtitle_language(player, index);
753 MMPLAYER_CMD_UNLOCK( player );
759 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
761 int result = MM_ERROR_NONE;
763 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
764 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
766 MMPLAYER_CMD_LOCK( player );
768 result = _mmplayer_get_current_track(player, type, index);
770 MMPLAYER_CMD_UNLOCK( player );
775 int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code)
777 int result = MM_ERROR_NONE;
779 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
781 MMPLAYER_CMD_LOCK( player );
783 result = _mmplayer_get_track_language_code(player, type, index, code);
785 MMPLAYER_CMD_UNLOCK( player );
790 int mm_player_set_display_zoom(MMHandleType player, float level, int x, int y)
792 int result = MM_ERROR_NONE;
794 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
796 MMPLAYER_CMD_LOCK( player );
798 result = _mmplayer_set_display_zoom(player, level, x, y);
800 MMPLAYER_CMD_UNLOCK( player );
805 int mm_player_get_display_zoom(MMHandleType player, float *level, int *x, int *y)
807 int result = MM_ERROR_NONE;
809 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
810 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_COMMON_INVALID_ARGUMENT);
812 MMPLAYER_CMD_LOCK( player );
814 result = _mmplayer_get_display_zoom(player, level, x, y);
816 MMPLAYER_CMD_UNLOCK( player );
821 int mm_player_set_video_share_master_clock(MMHandleType player,
823 long long clock_delta,
824 long long video_time,
825 long long media_clock,
826 long long audio_time)
828 int result = MM_ERROR_NONE;
830 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
832 MMPLAYER_CMD_LOCK( player );
834 result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
836 MMPLAYER_CMD_UNLOCK( player );
841 int mm_player_get_video_share_master_clock(MMHandleType player,
842 long long *video_time,
843 long long *media_clock,
844 long long *audio_time)
846 int result = MM_ERROR_NONE;
848 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
849 MMPLAYER_RETURN_VAL_IF_FAIL(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
850 MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
851 MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
853 MMPLAYER_CMD_LOCK( player );
855 result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
857 MMPLAYER_CMD_UNLOCK( player );
862 int mm_player_get_video_rotate_angle(MMHandleType player, int *angle)
864 int result = MM_ERROR_NONE;
866 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
867 MMPLAYER_RETURN_VAL_IF_FAIL(angle, MM_ERROR_COMMON_INVALID_ARGUMENT);
869 MMPLAYER_CMD_LOCK( player );
871 result = _mmplayer_get_video_rotate_angle(player, angle);
873 MMPLAYER_CMD_UNLOCK( player );
878 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
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_video_hub_download_mode(player, mode);
888 MMPLAYER_CMD_UNLOCK( player );
893 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
895 int result = MM_ERROR_NONE;
897 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
899 MMPLAYER_CMD_LOCK( player );
901 result = _mmplayer_enable_sync_handler(player, enable);
903 MMPLAYER_CMD_UNLOCK( player );
908 int mm_player_set_uri(MMHandleType player, const char *uri)
910 int result = MM_ERROR_NONE;
912 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
914 MMPLAYER_CMD_LOCK( player );
916 result = _mmplayer_set_uri(player, uri);
918 MMPLAYER_CMD_UNLOCK( player );
924 int mm_player_set_next_uri(MMHandleType player, const char *uri)
926 int result = MM_ERROR_NONE;
928 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
930 MMPLAYER_CMD_LOCK( player );
932 result = _mmplayer_set_next_uri(player, uri, FALSE);
934 MMPLAYER_CMD_UNLOCK( player );
940 int mm_player_get_next_uri(MMHandleType player, char **uri)
942 int result = MM_ERROR_NONE;
944 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
946 MMPLAYER_CMD_LOCK( player );
948 result = _mmplayer_get_next_uri(player, uri);
950 MMPLAYER_CMD_UNLOCK( player );
956 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
958 int result = MM_ERROR_NONE;
960 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
962 MMPLAYER_CMD_LOCK( player );
964 result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
966 MMPLAYER_CMD_UNLOCK( player );
972 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
974 int result = MM_ERROR_NONE;
976 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
977 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
979 MMPLAYER_CMD_LOCK( player );
981 result = _mmplayer_has_closed_caption(player, exist);
983 MMPLAYER_CMD_UNLOCK( player );
988 void * mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer)
991 result = _mm_player_media_packet_video_stream_internal_buffer_ref(buffer);
996 void mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer)
998 _mm_player_media_packet_video_stream_internal_buffer_unref(buffer);
1001 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
1004 int result = MM_ERROR_NONE;
1006 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1008 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
1009 //MMPLAYER_CMD_LOCK( player );
1011 result = _mmplayer_submit_packet(player, packet);
1013 //MMPLAYER_CMD_UNLOCK( player );
1018 int mm_player_set_video_info (MMHandleType player, media_format_h format)
1020 int result = MM_ERROR_NONE;
1024 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1026 MMPLAYER_CMD_LOCK( player );
1028 result = _mmplayer_set_video_info(player, format);
1030 MMPLAYER_CMD_UNLOCK( player );
1036 int mm_player_set_audio_info (MMHandleType player, media_format_h format)
1038 int result = MM_ERROR_NONE;
1042 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1044 MMPLAYER_CMD_LOCK( player );
1046 result = _mmplayer_set_audio_info(player, format);
1048 MMPLAYER_CMD_UNLOCK( player );
1053 int mm_player_set_subtitle_info (MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
1055 int result = MM_ERROR_NONE;
1059 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1061 MMPLAYER_CMD_LOCK( player );
1063 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
1065 MMPLAYER_CMD_UNLOCK( player );
1070 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
1072 int result = MM_ERROR_NONE;
1076 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1078 MMPLAYER_CMD_LOCK( player );
1080 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
1082 MMPLAYER_CMD_UNLOCK( player );
1087 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1089 int result = MM_ERROR_NONE;
1090 guint64 _max_size = 0;
1094 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1095 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1097 MMPLAYER_CMD_LOCK( player );
1099 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1100 *max_size = _max_size;
1102 MMPLAYER_CMD_UNLOCK( player );
1107 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
1109 int result = MM_ERROR_NONE;
1113 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1115 MMPLAYER_CMD_LOCK( player );
1117 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
1119 MMPLAYER_CMD_UNLOCK( player );
1124 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1126 int result = MM_ERROR_NONE;
1130 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1131 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1133 MMPLAYER_CMD_LOCK( player );
1135 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1137 MMPLAYER_CMD_UNLOCK( player );
1142 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1144 int result = MM_ERROR_NONE;
1148 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1150 MMPLAYER_CMD_LOCK( player );
1152 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1154 MMPLAYER_CMD_UNLOCK( player );
1159 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1161 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_media_stream_seek_data_cb(player, type, callback, user_param);
1171 MMPLAYER_CMD_UNLOCK( player );
1176 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
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_audiostream_changed_cb(player, callback, user_param);
1186 MMPLAYER_CMD_UNLOCK( player );
1191 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1193 int result = MM_ERROR_NONE;
1195 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1197 MMPLAYER_CMD_LOCK( player );
1199 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1201 MMPLAYER_CMD_UNLOCK( player );
1206 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1208 int result = MM_ERROR_NONE;
1210 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1212 MMPLAYER_CMD_LOCK( player );
1214 result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1216 MMPLAYER_CMD_UNLOCK( player );
1221 int mm_player_get_timeout(MMHandleType player, int *timeout)
1223 int result = MM_ERROR_NONE;
1225 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1226 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1228 MMPLAYER_CMD_LOCK( player );
1230 result = _mmplayer_get_timeout(player, timeout);
1232 MMPLAYER_CMD_UNLOCK( player );
1237 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1239 int result = MM_ERROR_NONE;
1241 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1242 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1244 MMPLAYER_CMD_LOCK( player );
1246 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1248 MMPLAYER_CMD_UNLOCK( player );
1253 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1255 int result = MM_ERROR_NONE;
1257 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1259 MMPLAYER_CMD_LOCK( player );
1261 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1263 MMPLAYER_CMD_UNLOCK( player );
1268 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1270 int result = MM_ERROR_NONE;
1272 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1273 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1274 // MMPLAYER_CMD_LOCK( player );
1276 result = _mmplayer_video_stream_release_bo(player, bo);
1278 // MMPLAYER_CMD_UNLOCK( player );
1282 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1284 int result = MM_ERROR_NONE;
1286 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1288 MMPLAYER_CMD_LOCK( player );
1290 result = _mmplayer_set_file_buffering_path(player, file_path);
1292 MMPLAYER_CMD_UNLOCK( player );
1297 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1299 int result = MM_ERROR_NONE;
1301 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1302 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1304 MMPLAYER_CMD_LOCK( player );
1306 _mmplayer_sound_unregister(&((mm_player_t*)player)->sound_focus);
1307 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1309 MMPLAYER_CMD_UNLOCK( player );
1314 int mm_player_manage_external_storage_state(MMHandleType player, int state)
1316 int result = MM_ERROR_NONE;
1318 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1320 MMPLAYER_CMD_LOCK( player );
1322 result = _mmplayer_manage_external_storage_state(player, state);
1324 MMPLAYER_CMD_UNLOCK( player );
1329 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1331 int result = MM_ERROR_NONE;
1333 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1334 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1336 MMPLAYER_CMD_LOCK( player );
1338 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1340 MMPLAYER_CMD_UNLOCK( player );
1345 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1347 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_max_adaptive_variant_limit(player, bandwidth, width, height);
1355 MMPLAYER_CMD_UNLOCK( player );
1360 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1362 int result = MM_ERROR_NONE;
1364 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1365 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1367 MMPLAYER_CMD_LOCK( player );
1369 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1371 MMPLAYER_CMD_UNLOCK( player );