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_gst_set_audio_channel(MMHandleType player, MMPlayerAudioChannel ch)
490 int result = MM_ERROR_NONE;
492 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
493 MMPLAYER_CMD_LOCK( player );
495 result = _mmplayer_gst_set_audio_channel(player, ch);
497 MMPLAYER_CMD_UNLOCK( player );
501 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
503 int result = MM_ERROR_NONE;
505 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
507 MMPLAYER_CMD_LOCK( player );
509 result = _mmplayer_set_playspeed(player, rate, streaming);
511 MMPLAYER_CMD_UNLOCK( player );
516 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
518 int result = MM_ERROR_NONE;
520 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
522 if (format >= MM_PLAYER_POS_FORMAT_NUM)
524 LOGE("wrong format\n");
525 return MM_ERROR_COMMON_INVALID_ARGUMENT;
528 MMPLAYER_CMD_LOCK( player );
530 result = _mmplayer_set_position(player, format, pos);
532 MMPLAYER_CMD_UNLOCK( player );
537 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *pos)
539 int result = MM_ERROR_NONE;
541 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
542 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
544 if (format >= MM_PLAYER_POS_FORMAT_NUM)
546 LOGE("wrong format\n");
547 return MM_ERROR_COMMON_INVALID_ARGUMENT;
550 MMPLAYER_CMD_LOCK( player );
552 result = _mmplayer_get_position(player, (int)format, pos);
554 MMPLAYER_CMD_UNLOCK( player );
559 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
561 int result = MM_ERROR_NONE;
563 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
564 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
566 MMPLAYER_CMD_LOCK( player );
568 result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos );
570 MMPLAYER_CMD_UNLOCK( player );
575 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
577 int result = MM_ERROR_NONE;
579 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
581 MMPLAYER_CMD_LOCK( player );
583 result = _mmplayer_set_external_subtitle_path(player, path);
585 MMPLAYER_CMD_UNLOCK( player );
589 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
591 int result = MM_ERROR_NONE;
593 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
595 if (format >= MM_PLAYER_POS_FORMAT_NUM)
597 LOGE("wrong format(%d) \n", format);
598 return MM_ERROR_INVALID_ARGUMENT;
601 MMPLAYER_CMD_LOCK( player );
603 result = _mmplayer_adjust_subtitle_postion(player, format, pos);
605 MMPLAYER_CMD_UNLOCK( player );
610 int mm_player_adjust_video_position(MMHandleType player, int offset)
612 int result = MM_ERROR_NONE;
613 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
614 MMPLAYER_CMD_LOCK( player );
616 result = _mmplayer_adjust_video_postion(player, offset);
618 MMPLAYER_CMD_UNLOCK( player );
623 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
625 int result = MM_ERROR_NONE;
627 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
629 MMPLAYER_CMD_LOCK( player );
631 result = _mmplayer_set_subtitle_silent(player, silent);
633 MMPLAYER_CMD_UNLOCK( player );
638 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
640 int result = MM_ERROR_NONE;
642 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
644 MMPLAYER_CMD_LOCK( player );
646 result = _mmplayer_get_subtitle_silent(player, silent);
648 MMPLAYER_CMD_UNLOCK( player );
653 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
655 int result = MM_ERROR_NONE;
658 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
659 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
661 va_start (var_args, first_attribute_name);
662 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
668 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
670 int result = MM_ERROR_NONE;
673 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
674 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
676 va_start (var_args, first_attribute_name);
677 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
683 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
685 int result = MM_ERROR_NONE;
688 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
689 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
690 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
692 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
697 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
699 int result = MM_ERROR_NONE;
701 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
702 MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
703 MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
705 result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
710 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
712 int result = MM_ERROR_NONE;
714 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
715 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
717 MMPLAYER_CMD_LOCK( player );
719 result = _mmplayer_get_track_count(player, type, count);
721 MMPLAYER_CMD_UNLOCK( player );
726 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
728 int result = MM_ERROR_NONE;
730 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
732 MMPLAYER_CMD_LOCK( player );
734 result = _mmplayer_select_track(player, type, index);
736 MMPLAYER_CMD_UNLOCK( player );
741 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
743 int result = MM_ERROR_NONE;
745 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
747 MMPLAYER_CMD_LOCK( player );
749 result = _mmplayer_track_add_subtitle_language(player, index);
751 MMPLAYER_CMD_UNLOCK( player );
756 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
758 int result = MM_ERROR_NONE;
760 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
762 MMPLAYER_CMD_LOCK( player );
764 result = _mmplayer_track_remove_subtitle_language(player, index);
766 MMPLAYER_CMD_UNLOCK( player );
772 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
774 int result = MM_ERROR_NONE;
776 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
777 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
779 MMPLAYER_CMD_LOCK( player );
781 result = _mmplayer_get_current_track(player, type, index);
783 MMPLAYER_CMD_UNLOCK( player );
788 int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code)
790 int result = MM_ERROR_NONE;
792 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
794 MMPLAYER_CMD_LOCK( player );
796 result = _mmplayer_get_track_language_code(player, type, index, code);
798 MMPLAYER_CMD_UNLOCK( player );
803 int mm_player_set_display_zoom(MMHandleType player, float level, int x, int y)
805 int result = MM_ERROR_NONE;
807 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
809 MMPLAYER_CMD_LOCK( player );
811 result = _mmplayer_set_display_zoom(player, level, x, y);
813 MMPLAYER_CMD_UNLOCK( player );
818 int mm_player_get_display_zoom(MMHandleType player, float *level, int *x, int *y)
820 int result = MM_ERROR_NONE;
822 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
823 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_COMMON_INVALID_ARGUMENT);
825 MMPLAYER_CMD_LOCK( player );
827 result = _mmplayer_get_display_zoom(player, level, x, y);
829 MMPLAYER_CMD_UNLOCK( player );
834 int mm_player_set_video_share_master_clock(MMHandleType player,
836 long long clock_delta,
837 long long video_time,
838 long long media_clock,
839 long long audio_time)
841 int result = MM_ERROR_NONE;
843 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
845 MMPLAYER_CMD_LOCK( player );
847 result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
849 MMPLAYER_CMD_UNLOCK( player );
854 int mm_player_get_video_share_master_clock(MMHandleType player,
855 long long *video_time,
856 long long *media_clock,
857 long long *audio_time)
859 int result = MM_ERROR_NONE;
861 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
862 MMPLAYER_RETURN_VAL_IF_FAIL(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
863 MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
864 MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
866 MMPLAYER_CMD_LOCK( player );
868 result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
870 MMPLAYER_CMD_UNLOCK( player );
875 int mm_player_get_video_rotate_angle(MMHandleType player, int *angle)
877 int result = MM_ERROR_NONE;
879 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
880 MMPLAYER_RETURN_VAL_IF_FAIL(angle, MM_ERROR_COMMON_INVALID_ARGUMENT);
882 MMPLAYER_CMD_LOCK( player );
884 result = _mmplayer_get_video_rotate_angle(player, angle);
886 MMPLAYER_CMD_UNLOCK( player );
891 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
893 int result = MM_ERROR_NONE;
895 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
897 MMPLAYER_CMD_LOCK( player );
899 result = _mmplayer_set_video_hub_download_mode(player, mode);
901 MMPLAYER_CMD_UNLOCK( player );
906 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
908 int result = MM_ERROR_NONE;
910 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
912 MMPLAYER_CMD_LOCK( player );
914 result = _mmplayer_enable_sync_handler(player, enable);
916 MMPLAYER_CMD_UNLOCK( player );
921 int mm_player_set_uri(MMHandleType player, const char *uri)
923 int result = MM_ERROR_NONE;
925 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
927 MMPLAYER_CMD_LOCK( player );
929 result = _mmplayer_set_uri(player, uri);
931 MMPLAYER_CMD_UNLOCK( player );
937 int mm_player_set_next_uri(MMHandleType player, const char *uri)
939 int result = MM_ERROR_NONE;
941 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
943 MMPLAYER_CMD_LOCK( player );
945 result = _mmplayer_set_next_uri(player, uri, FALSE);
947 MMPLAYER_CMD_UNLOCK( player );
953 int mm_player_get_next_uri(MMHandleType player, char **uri)
955 int result = MM_ERROR_NONE;
957 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
959 MMPLAYER_CMD_LOCK( player );
961 result = _mmplayer_get_next_uri(player, uri);
963 MMPLAYER_CMD_UNLOCK( player );
969 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
971 int result = MM_ERROR_NONE;
973 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
975 MMPLAYER_CMD_LOCK( player );
977 result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
979 MMPLAYER_CMD_UNLOCK( player );
985 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
987 int result = MM_ERROR_NONE;
989 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
990 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
992 MMPLAYER_CMD_LOCK( player );
994 result = _mmplayer_has_closed_caption(player, exist);
996 MMPLAYER_CMD_UNLOCK( player );
1001 void * mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer)
1004 result = _mm_player_media_packet_video_stream_internal_buffer_ref(buffer);
1009 void mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer)
1011 _mm_player_media_packet_video_stream_internal_buffer_unref(buffer);
1014 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
1017 int result = MM_ERROR_NONE;
1019 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1021 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
1022 //MMPLAYER_CMD_LOCK( player );
1024 result = _mmplayer_submit_packet(player, packet);
1026 //MMPLAYER_CMD_UNLOCK( player );
1031 int mm_player_set_video_info (MMHandleType player, media_format_h format)
1033 int result = MM_ERROR_NONE;
1037 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1039 MMPLAYER_CMD_LOCK( player );
1041 result = _mmplayer_set_video_info(player, format);
1043 MMPLAYER_CMD_UNLOCK( player );
1049 int mm_player_set_audio_info (MMHandleType player, media_format_h format)
1051 int result = MM_ERROR_NONE;
1055 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1057 MMPLAYER_CMD_LOCK( player );
1059 result = _mmplayer_set_audio_info(player, format);
1061 MMPLAYER_CMD_UNLOCK( player );
1066 int mm_player_set_subtitle_info (MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
1068 int result = MM_ERROR_NONE;
1072 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1074 MMPLAYER_CMD_LOCK( player );
1076 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
1078 MMPLAYER_CMD_UNLOCK( player );
1083 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
1085 int result = MM_ERROR_NONE;
1089 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1091 MMPLAYER_CMD_LOCK( player );
1093 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
1095 MMPLAYER_CMD_UNLOCK( player );
1100 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1102 int result = MM_ERROR_NONE;
1103 guint64 _max_size = 0;
1107 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1108 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1110 MMPLAYER_CMD_LOCK( player );
1112 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1113 *max_size = _max_size;
1115 MMPLAYER_CMD_UNLOCK( player );
1120 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
1122 int result = MM_ERROR_NONE;
1126 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1128 MMPLAYER_CMD_LOCK( player );
1130 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
1132 MMPLAYER_CMD_UNLOCK( player );
1137 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1139 int result = MM_ERROR_NONE;
1143 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1144 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1146 MMPLAYER_CMD_LOCK( player );
1148 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1150 MMPLAYER_CMD_UNLOCK( player );
1155 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1157 int result = MM_ERROR_NONE;
1161 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1163 MMPLAYER_CMD_LOCK( player );
1165 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1167 MMPLAYER_CMD_UNLOCK( player );
1172 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1174 int result = MM_ERROR_NONE;
1178 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1180 MMPLAYER_CMD_LOCK( player );
1182 result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
1184 MMPLAYER_CMD_UNLOCK( player );
1189 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1191 int result = MM_ERROR_NONE;
1193 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1195 MMPLAYER_CMD_LOCK( player );
1197 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
1199 MMPLAYER_CMD_UNLOCK( player );
1204 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1206 int result = MM_ERROR_NONE;
1208 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1210 MMPLAYER_CMD_LOCK( player );
1212 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1214 MMPLAYER_CMD_UNLOCK( player );
1219 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1221 int result = MM_ERROR_NONE;
1223 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1225 MMPLAYER_CMD_LOCK( player );
1227 result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1229 MMPLAYER_CMD_UNLOCK( player );
1234 int mm_player_get_timeout(MMHandleType player, int *timeout)
1236 int result = MM_ERROR_NONE;
1238 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1239 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1241 MMPLAYER_CMD_LOCK( player );
1243 result = _mmplayer_get_timeout(player, timeout);
1245 MMPLAYER_CMD_UNLOCK( player );
1250 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1252 int result = MM_ERROR_NONE;
1254 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1255 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1257 MMPLAYER_CMD_LOCK( player );
1259 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1261 MMPLAYER_CMD_UNLOCK( player );
1266 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1268 int result = MM_ERROR_NONE;
1270 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1272 MMPLAYER_CMD_LOCK( player );
1274 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1276 MMPLAYER_CMD_UNLOCK( player );
1281 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1283 int result = MM_ERROR_NONE;
1285 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1286 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1287 // MMPLAYER_CMD_LOCK( player );
1289 result = _mmplayer_video_stream_release_bo(player, bo);
1291 // MMPLAYER_CMD_UNLOCK( player );
1295 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1297 int result = MM_ERROR_NONE;
1299 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1301 MMPLAYER_CMD_LOCK( player );
1303 result = _mmplayer_set_file_buffering_path(player, file_path);
1305 MMPLAYER_CMD_UNLOCK( player );
1310 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1312 int result = MM_ERROR_NONE;
1314 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1315 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1317 MMPLAYER_CMD_LOCK( player );
1319 _mmplayer_sound_unregister(&((mm_player_t*)player)->sound_focus);
1320 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1322 MMPLAYER_CMD_UNLOCK( player );
1327 int mm_player_manage_external_storage_state(MMHandleType player, int state)
1329 int result = MM_ERROR_NONE;
1331 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1333 MMPLAYER_CMD_LOCK( player );
1335 result = _mmplayer_manage_external_storage_state(player, state);
1337 MMPLAYER_CMD_UNLOCK( player );