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"
39 int mm_player_create(MMHandleType *player)
41 int result = MM_ERROR_NONE;
42 mm_player_t* new_player = NULL;
44 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");
54 memset(new_player, 0, sizeof(mm_player_t));
56 /* create player lock */
57 g_mutex_init(&new_player->cmd_lock);
59 /* create player lock */
60 g_mutex_init(&new_player->playback_lock);
63 /* create msg callback lock */
64 g_mutex_init(&new_player->msg_cb_lock);
67 result = mm_player_ini_load(&new_player->ini);
68 if(result != MM_ERROR_NONE)
70 LOGE("can't load ini");
74 result = mm_player_audio_effect_ini_load(&new_player->ini);
75 if(result != MM_ERROR_NONE)
77 LOGE("can't load audio ini");
83 result = _mmplayer_create_player((MMHandleType)new_player);
85 if(result != MM_ERROR_NONE)
87 LOGE("failed to create player");
91 *player = (MMHandleType)new_player;
99 _mmplayer_destroy( (MMHandleType)new_player );
100 g_mutex_clear(&new_player->cmd_lock);
101 g_mutex_clear(&new_player->playback_lock);
103 MMPLAYER_FREEIF( new_player );
106 *player = (MMHandleType)0;
107 return MM_ERROR_PLAYER_NO_FREE_SPACE; // are you sure?
110 int mm_player_destroy(MMHandleType player)
112 int result = MM_ERROR_NONE;
114 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
116 MMPLAYER_CMD_LOCK( player );
118 result = _mmplayer_destroy(player);
120 MMPLAYER_CMD_UNLOCK( player );
122 g_mutex_clear(&((mm_player_t*)player)->cmd_lock);
123 g_mutex_clear(&((mm_player_t*)player)->playback_lock);
125 memset( (mm_player_t*)player, 0x00, sizeof(mm_player_t) );
128 g_free( (void*)player );
133 int mm_player_sound_register(MMHandleType player, int pid)
135 int result = MM_ERROR_NONE;
137 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
139 MMPLAYER_CMD_LOCK( player );
141 result = _mmplayer_sound_register_with_pid(player, pid);
143 MMPLAYER_CMD_UNLOCK( player );
148 int mm_player_get_client_pid (MMHandleType player, int* pid)
150 int result = MM_ERROR_NONE;
152 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
153 MMPLAYER_RETURN_VAL_IF_FAIL(pid, MM_ERROR_INVALID_ARGUMENT);
155 MMPLAYER_CMD_LOCK( player );
157 result = _mmplayer_get_client_pid(player, pid);
159 MMPLAYER_CMD_UNLOCK( player );
164 int mm_player_realize(MMHandleType player)
166 int result = MM_ERROR_NONE;
168 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
170 MMPLAYER_CMD_LOCK( player );
172 result = _mmplayer_realize(player);
174 MMPLAYER_CMD_UNLOCK( player );
179 int mm_player_unrealize(MMHandleType player)
181 int result = MM_ERROR_NONE;
183 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
185 MMPLAYER_CMD_LOCK( player );
187 result = _mmplayer_unrealize(player);
189 MMPLAYER_CMD_UNLOCK( player );
194 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
196 int result = MM_ERROR_NONE;
198 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
200 MMPLAYER_CMD_LOCK( player );
202 result = _mmplayer_set_message_callback(player, callback, user_param);
204 MMPLAYER_CMD_UNLOCK( player );
209 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
211 int result = MM_ERROR_NONE;
213 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
215 result = _mm_player_set_pd_downloader_message_cb(player, callback, user_param);
220 int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param)
222 int result = MM_ERROR_NONE;
224 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
226 MMPLAYER_CMD_LOCK( player );
228 result = _mmplayer_set_audiostream_cb(player, callback, user_param);
230 MMPLAYER_CMD_UNLOCK( player );
235 int mm_player_set_audio_stream_callback_ex(MMHandleType player, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param)
237 int result = MM_ERROR_NONE;
239 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
241 MMPLAYER_CMD_LOCK( player );
243 result = _mmplayer_set_audiostream_cb_ex(player, sync, callback, user_param);
245 MMPLAYER_CMD_UNLOCK( player );
250 int mm_player_set_video_stream_callback(MMHandleType player, mm_player_video_stream_callback callback, void *user_param)
252 int result = MM_ERROR_NONE;
254 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
256 MMPLAYER_CMD_LOCK( player );
258 result = _mmplayer_set_videostream_cb(player, callback, user_param);
260 MMPLAYER_CMD_UNLOCK( player );
265 int mm_player_do_video_capture(MMHandleType player)
267 int result = MM_ERROR_NONE;
269 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
271 MMPLAYER_CMD_LOCK( player );
273 result = _mmplayer_do_video_capture(player);
275 MMPLAYER_CMD_UNLOCK( player );
280 int mm_player_set_prepare_buffering_time(MMHandleType player, int second)
282 int result = MM_ERROR_NONE;
284 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
286 MMPLAYER_CMD_LOCK( player );
288 result = _mmplayer_set_prepare_buffering_time(player, second);
290 MMPLAYER_CMD_UNLOCK( player );
295 int mm_player_set_runtime_buffering_mode(MMHandleType player, MMPlayerBufferingMode mode, int second)
297 int result = MM_ERROR_NONE;
299 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
301 MMPLAYER_CMD_LOCK( player );
303 result = _mmplayer_set_runtime_buffering_mode(player, mode, second);
305 MMPLAYER_CMD_UNLOCK( player );
310 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume)
312 int result = MM_ERROR_NONE;
314 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
315 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
317 MMPLAYER_CMD_LOCK( player );
319 result = _mmplayer_set_volume(player, *volume);
321 MMPLAYER_CMD_UNLOCK( player );
326 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume)
328 int result = MM_ERROR_NONE;
330 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
331 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
333 MMPLAYER_CMD_LOCK( player );
335 result = _mmplayer_get_volume(player, volume);
337 MMPLAYER_CMD_UNLOCK( player );
342 int mm_player_set_mute(MMHandleType player, int mute)
344 int result = MM_ERROR_NONE;
346 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
348 MMPLAYER_CMD_LOCK( player );
350 result = _mmplayer_set_mute(player, mute);
352 MMPLAYER_CMD_UNLOCK( player );
357 int mm_player_get_mute(MMHandleType player, int *mute)
359 int result = MM_ERROR_NONE;
361 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
362 MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
364 MMPLAYER_CMD_LOCK( player );
366 result = _mmplayer_get_mute(player, mute);
368 MMPLAYER_CMD_UNLOCK( player );
373 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state)
375 int result = MM_ERROR_NONE;
377 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
378 MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
380 *state = MM_PLAYER_STATE_NULL;
382 result = _mmplayer_get_state(player, (int*)state);
387 /* NOTE : It does not support some use cases, eg using colorspace converter */
388 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
390 int result = MM_ERROR_NONE;
392 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
394 MMPLAYER_CMD_LOCK( player );
396 result = _mmplayer_change_videosink(player, display_surface_type, display_overlay);
398 MMPLAYER_CMD_UNLOCK( player );
403 int mm_player_push_buffer(MMHandleType player, unsigned char *buf, int size)
405 int result = MM_ERROR_NONE;
407 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
409 //MMPLAYER_CMD_LOCK( player );
411 result = _mmplayer_push_buffer(player, buf, size);
413 //MMPLAYER_CMD_UNLOCK( player );
418 int mm_player_start(MMHandleType player)
420 int result = MM_ERROR_NONE;
422 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
424 MMPLAYER_CMD_LOCK( player );
426 result = _mmplayer_start(player);
428 MMPLAYER_CMD_UNLOCK( player );
433 int mm_player_stop(MMHandleType player)
435 int result = MM_ERROR_NONE;
437 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
439 MMPLAYER_CMD_LOCK( player );
441 result = _mmplayer_stop(player);
443 MMPLAYER_CMD_UNLOCK( player );
448 int mm_player_pause(MMHandleType player)
450 int result = MM_ERROR_NONE;
452 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
454 MMPLAYER_CMD_LOCK( player );
456 result = _mmplayer_pause(player);
458 MMPLAYER_CMD_UNLOCK( player );
463 int mm_player_resume(MMHandleType player)
465 int result = MM_ERROR_NONE;
467 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
469 MMPLAYER_CMD_LOCK( player );
471 result = _mmplayer_resume(player);
473 MMPLAYER_CMD_UNLOCK( player );
478 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos)
480 int result = MM_ERROR_NONE;
482 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
484 MMPLAYER_CMD_LOCK( player );
486 result = _mmplayer_activate_section_repeat(player, start_pos, end_pos);
488 MMPLAYER_CMD_UNLOCK( player );
493 int mm_player_deactivate_section_repeat(MMHandleType player)
495 int result = MM_ERROR_NONE;
497 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
499 MMPLAYER_CMD_LOCK( player );
501 result = _mmplayer_deactivate_section_repeat(player);
503 MMPLAYER_CMD_UNLOCK( player );
508 int mm_player_gst_set_audio_channel(MMHandleType player, MMPlayerAudioChannel ch)
510 int result = MM_ERROR_NONE;
512 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
513 MMPLAYER_CMD_LOCK( player );
515 result = _mmplayer_gst_set_audio_channel(player, ch);
517 MMPLAYER_CMD_UNLOCK( player );
521 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
523 int result = MM_ERROR_NONE;
525 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
527 MMPLAYER_CMD_LOCK( player );
529 result = _mmplayer_set_playspeed(player, rate, streaming);
531 MMPLAYER_CMD_UNLOCK( player );
536 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
538 int result = MM_ERROR_NONE;
540 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
542 if (format >= MM_PLAYER_POS_FORMAT_NUM)
544 LOGE("wrong format\n");
545 return MM_ERROR_COMMON_INVALID_ARGUMENT;
548 MMPLAYER_CMD_LOCK( player );
550 result = _mmplayer_set_position(player, format, pos);
552 MMPLAYER_CMD_UNLOCK( player );
557 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *pos)
559 int result = MM_ERROR_NONE;
561 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
562 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
564 if (format >= MM_PLAYER_POS_FORMAT_NUM)
566 LOGE("wrong format\n");
567 return MM_ERROR_COMMON_INVALID_ARGUMENT;
570 MMPLAYER_CMD_LOCK( player );
572 result = _mmplayer_get_position(player, (int)format, pos);
574 MMPLAYER_CMD_UNLOCK( player );
579 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
581 int result = MM_ERROR_NONE;
583 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
584 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
586 MMPLAYER_CMD_LOCK( player );
588 result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos );
590 MMPLAYER_CMD_UNLOCK( player );
595 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
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_set_external_subtitle_path(player, path);
605 MMPLAYER_CMD_UNLOCK( player );
609 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
611 int result = MM_ERROR_NONE;
613 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
615 if (format >= MM_PLAYER_POS_FORMAT_NUM)
617 LOGE("wrong format(%d) \n", format);
618 return MM_ERROR_INVALID_ARGUMENT;
621 MMPLAYER_CMD_LOCK( player );
623 result = _mmplayer_adjust_subtitle_postion(player, format, pos);
625 MMPLAYER_CMD_UNLOCK( player );
630 int mm_player_adjust_video_position(MMHandleType player, int offset)
632 int result = MM_ERROR_NONE;
633 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
634 MMPLAYER_CMD_LOCK( player );
636 result = _mmplayer_adjust_video_postion(player, offset);
638 MMPLAYER_CMD_UNLOCK( player );
643 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
645 int result = MM_ERROR_NONE;
647 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
649 MMPLAYER_CMD_LOCK( player );
651 result = _mmplayer_set_subtitle_silent(player, silent);
653 MMPLAYER_CMD_UNLOCK( player );
658 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
660 int result = MM_ERROR_NONE;
662 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
664 MMPLAYER_CMD_LOCK( player );
666 result = _mmplayer_get_subtitle_silent(player, silent);
668 MMPLAYER_CMD_UNLOCK( player );
673 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
675 int result = MM_ERROR_NONE;
678 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
679 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
681 va_start (var_args, first_attribute_name);
682 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
688 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
690 int result = MM_ERROR_NONE;
693 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
694 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
696 va_start (var_args, first_attribute_name);
697 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
703 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
705 int result = MM_ERROR_NONE;
708 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
709 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
710 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
712 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
717 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
719 int result = MM_ERROR_NONE;
721 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
722 MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
723 MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
725 result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
730 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
732 int result = MM_ERROR_NONE;
734 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
735 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
737 MMPLAYER_CMD_LOCK( player );
739 result = _mmplayer_get_track_count(player, type, count);
741 MMPLAYER_CMD_UNLOCK( player );
746 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
748 int result = MM_ERROR_NONE;
750 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
752 MMPLAYER_CMD_LOCK( player );
754 result = _mmplayer_select_track(player, type, index);
756 MMPLAYER_CMD_UNLOCK( player );
761 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
763 int result = MM_ERROR_NONE;
765 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
767 MMPLAYER_CMD_LOCK( player );
769 result = _mmplayer_track_add_subtitle_language(player, index);
771 MMPLAYER_CMD_UNLOCK( player );
776 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
778 int result = MM_ERROR_NONE;
780 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
782 MMPLAYER_CMD_LOCK( player );
784 result = _mmplayer_track_remove_subtitle_language(player, index);
786 MMPLAYER_CMD_UNLOCK( player );
792 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
794 int result = MM_ERROR_NONE;
796 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
797 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
799 MMPLAYER_CMD_LOCK( player );
801 result = _mmplayer_get_current_track(player, type, index);
803 MMPLAYER_CMD_UNLOCK( player );
808 int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code)
810 int result = MM_ERROR_NONE;
812 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
814 MMPLAYER_CMD_LOCK( player );
816 result = _mmplayer_get_track_language_code(player, type, index, code);
818 MMPLAYER_CMD_UNLOCK( player );
823 int mm_player_set_display_zoom(MMHandleType player, float level, int x, int y)
825 int result = MM_ERROR_NONE;
827 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
829 MMPLAYER_CMD_LOCK( player );
831 result = _mmplayer_set_display_zoom(player, level, x, y);
833 MMPLAYER_CMD_UNLOCK( player );
838 int mm_player_get_display_zoom(MMHandleType player, float *level, int *x, int *y)
840 int result = MM_ERROR_NONE;
842 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
843 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_COMMON_INVALID_ARGUMENT);
845 MMPLAYER_CMD_LOCK( player );
847 result = _mmplayer_get_display_zoom(player, level, x, y);
849 MMPLAYER_CMD_UNLOCK( player );
854 int mm_player_set_video_share_master_clock(MMHandleType player,
856 long long clock_delta,
857 long long video_time,
858 long long media_clock,
859 long long audio_time)
861 int result = MM_ERROR_NONE;
863 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
865 MMPLAYER_CMD_LOCK( player );
867 result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
869 MMPLAYER_CMD_UNLOCK( player );
874 int mm_player_get_video_share_master_clock(MMHandleType player,
875 long long *video_time,
876 long long *media_clock,
877 long long *audio_time)
879 int result = MM_ERROR_NONE;
881 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
882 MMPLAYER_RETURN_VAL_IF_FAIL(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
883 MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
884 MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
886 MMPLAYER_CMD_LOCK( player );
888 result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
890 MMPLAYER_CMD_UNLOCK( player );
895 int mm_player_get_video_rotate_angle(MMHandleType player, int *angle)
897 int result = MM_ERROR_NONE;
899 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
900 MMPLAYER_RETURN_VAL_IF_FAIL(angle, MM_ERROR_COMMON_INVALID_ARGUMENT);
902 MMPLAYER_CMD_LOCK( player );
904 result = _mmplayer_get_video_rotate_angle(player, angle);
906 MMPLAYER_CMD_UNLOCK( player );
911 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
913 int result = MM_ERROR_NONE;
915 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
917 MMPLAYER_CMD_LOCK( player );
919 result = _mmplayer_set_video_hub_download_mode(player, mode);
921 MMPLAYER_CMD_UNLOCK( player );
926 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
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_enable_sync_handler(player, enable);
936 MMPLAYER_CMD_UNLOCK( player );
941 int mm_player_set_uri(MMHandleType player, const char *uri)
943 int result = MM_ERROR_NONE;
945 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
947 MMPLAYER_CMD_LOCK( player );
949 result = _mmplayer_set_uri(player, uri);
951 MMPLAYER_CMD_UNLOCK( player );
957 int mm_player_set_next_uri(MMHandleType player, const char *uri)
959 int result = MM_ERROR_NONE;
961 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
963 MMPLAYER_CMD_LOCK( player );
965 result = _mmplayer_set_next_uri(player, uri, FALSE);
967 MMPLAYER_CMD_UNLOCK( player );
973 int mm_player_get_next_uri(MMHandleType player, char **uri)
975 int result = MM_ERROR_NONE;
977 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
979 MMPLAYER_CMD_LOCK( player );
981 result = _mmplayer_get_next_uri(player, uri);
983 MMPLAYER_CMD_UNLOCK( player );
989 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
991 int result = MM_ERROR_NONE;
993 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
995 MMPLAYER_CMD_LOCK( player );
997 result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
999 MMPLAYER_CMD_UNLOCK( player );
1005 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
1007 int result = MM_ERROR_NONE;
1009 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1010 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
1012 MMPLAYER_CMD_LOCK( player );
1014 result = _mmplayer_has_closed_caption(player, exist);
1016 MMPLAYER_CMD_UNLOCK( player );
1021 int mm_player_enable_media_packet_video_stream(MMHandleType player, bool enable)
1023 int result = MM_ERROR_NONE;
1025 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1026 MMPLAYER_RETURN_VAL_IF_FAIL(enable, MM_ERROR_INVALID_ARGUMENT);
1028 MMPLAYER_CMD_LOCK( player );
1030 result = _mmplayer_enable_media_packet_video_stream(player, enable);
1032 MMPLAYER_CMD_UNLOCK( player );
1037 void * mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer)
1040 result = _mm_player_media_packet_video_stream_internal_buffer_ref(buffer);
1045 void mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer)
1047 _mm_player_media_packet_video_stream_internal_buffer_unref(buffer);
1050 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
1053 int result = MM_ERROR_NONE;
1055 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1057 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
1058 //MMPLAYER_CMD_LOCK( player );
1060 result = _mmplayer_submit_packet(player, packet);
1062 //MMPLAYER_CMD_UNLOCK( player );
1067 int mm_player_set_video_info (MMHandleType player, media_format_h format)
1069 int result = MM_ERROR_NONE;
1073 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1075 MMPLAYER_CMD_LOCK( player );
1077 result = _mmplayer_set_video_info(player, format);
1079 MMPLAYER_CMD_UNLOCK( player );
1085 int mm_player_set_audio_info (MMHandleType player, media_format_h format)
1087 int result = MM_ERROR_NONE;
1091 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1093 MMPLAYER_CMD_LOCK( player );
1095 result = _mmplayer_set_audio_info(player, format);
1097 MMPLAYER_CMD_UNLOCK( player );
1102 int mm_player_set_subtitle_info (MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
1104 int result = MM_ERROR_NONE;
1108 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1110 MMPLAYER_CMD_LOCK( player );
1112 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
1114 MMPLAYER_CMD_UNLOCK( player );
1119 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
1121 int result = MM_ERROR_NONE;
1125 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1127 MMPLAYER_CMD_LOCK( player );
1129 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
1131 MMPLAYER_CMD_UNLOCK( player );
1136 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1138 int result = MM_ERROR_NONE;
1139 guint64 _max_size = 0;
1143 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1144 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1146 MMPLAYER_CMD_LOCK( player );
1148 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1149 *max_size = _max_size;
1151 MMPLAYER_CMD_UNLOCK( player );
1156 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
1158 int result = MM_ERROR_NONE;
1162 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1164 MMPLAYER_CMD_LOCK( player );
1166 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
1168 MMPLAYER_CMD_UNLOCK( player );
1173 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1175 int result = MM_ERROR_NONE;
1179 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1180 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1182 MMPLAYER_CMD_LOCK( player );
1184 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1186 MMPLAYER_CMD_UNLOCK( player );
1191 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1193 int result = MM_ERROR_NONE;
1197 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1199 MMPLAYER_CMD_LOCK( player );
1201 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1203 MMPLAYER_CMD_UNLOCK( player );
1208 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1210 int result = MM_ERROR_NONE;
1214 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1216 MMPLAYER_CMD_LOCK( player );
1218 result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
1220 MMPLAYER_CMD_UNLOCK( player );
1225 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1227 int result = MM_ERROR_NONE;
1229 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1231 MMPLAYER_CMD_LOCK( player );
1233 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
1235 MMPLAYER_CMD_UNLOCK( player );
1240 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1242 int result = MM_ERROR_NONE;
1244 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1246 MMPLAYER_CMD_LOCK( player );
1248 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1250 MMPLAYER_CMD_UNLOCK( player );
1255 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1257 int result = MM_ERROR_NONE;
1259 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1261 MMPLAYER_CMD_LOCK( player );
1263 result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1265 MMPLAYER_CMD_UNLOCK( player );
1270 int mm_player_get_timeout(MMHandleType player, int *timeout)
1272 int result = MM_ERROR_NONE;
1274 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1275 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1277 MMPLAYER_CMD_LOCK( player );
1279 result = _mmplayer_get_timeout(player, timeout);
1281 MMPLAYER_CMD_UNLOCK( player );
1286 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1288 int result = MM_ERROR_NONE;
1290 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1291 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1293 MMPLAYER_CMD_LOCK( player );
1295 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1297 MMPLAYER_CMD_UNLOCK( player );
1302 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1304 int result = MM_ERROR_NONE;
1306 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1308 MMPLAYER_CMD_LOCK( player );
1310 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1312 MMPLAYER_CMD_UNLOCK( player );