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_PLAYER_INTERNAL;
42 mm_player_t* new_player = NULL;
44 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
46 /* alloc player structure */
47 new_player = g_malloc(sizeof(mm_player_t));
50 LOGE("Cannot allocate memory for player\n");
51 result = MM_ERROR_PLAYER_RESOURCE_LIMIT;
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 if (MM_ERROR_NONE != mm_player_ini_load(&new_player->ini))
65 LOGE("can't load ini");
69 if (MM_ERROR_NONE != mm_player_audio_effect_ini_load(&new_player->ini))
71 LOGE("can't load audio ini");
76 result = _mmplayer_create_player((MMHandleType)new_player);
77 if(result != MM_ERROR_NONE)
79 LOGE("failed to create player");
80 if (result != MM_ERROR_PLAYER_RESOURCE_LIMIT)
81 result = MM_ERROR_PLAYER_INTERNAL;
85 *player = (MMHandleType)new_player;
93 _mmplayer_destroy( (MMHandleType)new_player );
94 g_mutex_clear(&new_player->cmd_lock);
95 g_mutex_clear(&new_player->playback_lock);
97 MMPLAYER_FREEIF( new_player );
100 *player = (MMHandleType)0;
101 return result; /* MM_ERROR_PLAYER_INTERNAL or MM_ERROR_PLAYER_RESOURCE_LIMIT */
104 int mm_player_destroy(MMHandleType player)
106 int result = MM_ERROR_NONE;
108 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
110 MMPLAYER_CMD_LOCK( player );
112 result = _mmplayer_destroy(player);
114 MMPLAYER_CMD_UNLOCK( player );
116 g_mutex_clear(&((mm_player_t*)player)->cmd_lock);
117 g_mutex_clear(&((mm_player_t*)player)->playback_lock);
119 memset( (mm_player_t*)player, 0x00, sizeof(mm_player_t) );
122 g_free( (void*)player );
127 int mm_player_sound_register(MMHandleType player, int pid)
129 int result = MM_ERROR_NONE;
131 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
133 MMPLAYER_CMD_LOCK( player );
135 result = _mmplayer_sound_register_with_pid(player, pid);
137 MMPLAYER_CMD_UNLOCK( player );
142 int mm_player_get_client_pid (MMHandleType player, int* pid)
144 int result = MM_ERROR_NONE;
146 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
147 MMPLAYER_RETURN_VAL_IF_FAIL(pid, MM_ERROR_INVALID_ARGUMENT);
149 MMPLAYER_CMD_LOCK( player );
151 result = _mmplayer_get_client_pid(player, pid);
153 MMPLAYER_CMD_UNLOCK( player );
158 int mm_player_realize(MMHandleType player)
160 int result = MM_ERROR_NONE;
162 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
164 MMPLAYER_CMD_LOCK( player );
166 result = _mmplayer_realize(player);
168 MMPLAYER_CMD_UNLOCK( player );
173 int mm_player_unrealize(MMHandleType player)
175 int result = MM_ERROR_NONE;
177 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
179 MMPLAYER_CMD_LOCK( player );
181 result = _mmplayer_unrealize(player);
183 MMPLAYER_CMD_UNLOCK( player );
188 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
190 int result = MM_ERROR_NONE;
192 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
194 MMPLAYER_CMD_LOCK( player );
196 result = _mmplayer_set_message_callback(player, callback, user_param);
198 MMPLAYER_CMD_UNLOCK( player );
203 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
205 int result = MM_ERROR_NONE;
207 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
209 result = _mm_player_set_pd_downloader_message_cb(player, callback, user_param);
214 int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param)
216 int result = MM_ERROR_NONE;
218 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
220 MMPLAYER_CMD_LOCK( player );
222 result = _mmplayer_set_audiostream_cb(player, callback, user_param);
224 MMPLAYER_CMD_UNLOCK( player );
229 int mm_player_set_audio_stream_callback_ex(MMHandleType player, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param)
231 int result = MM_ERROR_NONE;
233 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
235 MMPLAYER_CMD_LOCK( player );
237 result = _mmplayer_set_audiostream_cb_ex(player, sync, callback, user_param);
239 MMPLAYER_CMD_UNLOCK( player );
244 int mm_player_set_video_stream_callback(MMHandleType player, mm_player_video_stream_callback callback, void *user_param)
246 int result = MM_ERROR_NONE;
248 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
250 MMPLAYER_CMD_LOCK( player );
252 result = _mmplayer_set_videostream_cb(player, callback, user_param);
254 MMPLAYER_CMD_UNLOCK( player );
259 int mm_player_do_video_capture(MMHandleType player)
261 int result = MM_ERROR_NONE;
263 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
265 MMPLAYER_CMD_LOCK( player );
267 result = _mmplayer_do_video_capture(player);
269 MMPLAYER_CMD_UNLOCK( player );
274 int mm_player_set_prepare_buffering_time(MMHandleType player, int second)
276 int result = MM_ERROR_NONE;
278 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
280 MMPLAYER_CMD_LOCK( player );
282 result = _mmplayer_set_prepare_buffering_time(player, second);
284 MMPLAYER_CMD_UNLOCK( player );
289 int mm_player_set_runtime_buffering_mode(MMHandleType player, MMPlayerBufferingMode mode, int second)
291 int result = MM_ERROR_NONE;
293 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
295 MMPLAYER_CMD_LOCK( player );
297 result = _mmplayer_set_runtime_buffering_mode(player, mode, second);
299 MMPLAYER_CMD_UNLOCK( player );
304 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume)
306 int result = MM_ERROR_NONE;
308 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
309 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
311 MMPLAYER_CMD_LOCK( player );
313 result = _mmplayer_set_volume(player, *volume);
315 MMPLAYER_CMD_UNLOCK( player );
320 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume)
322 int result = MM_ERROR_NONE;
324 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
325 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
327 MMPLAYER_CMD_LOCK( player );
329 result = _mmplayer_get_volume(player, volume);
331 MMPLAYER_CMD_UNLOCK( player );
336 int mm_player_set_mute(MMHandleType player, int mute)
338 int result = MM_ERROR_NONE;
340 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
342 MMPLAYER_CMD_LOCK( player );
344 result = _mmplayer_set_mute(player, mute);
346 MMPLAYER_CMD_UNLOCK( player );
351 int mm_player_get_mute(MMHandleType player, int *mute)
353 int result = MM_ERROR_NONE;
355 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
356 MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
358 MMPLAYER_CMD_LOCK( player );
360 result = _mmplayer_get_mute(player, mute);
362 MMPLAYER_CMD_UNLOCK( player );
367 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state)
369 int result = MM_ERROR_NONE;
371 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
372 MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
374 *state = MM_PLAYER_STATE_NULL;
376 result = _mmplayer_get_state(player, (int*)state);
381 /* NOTE : It does not support some use cases, eg using colorspace converter */
382 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
384 int result = MM_ERROR_NONE;
386 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
388 MMPLAYER_CMD_LOCK( player );
390 result = _mmplayer_change_videosink(player, display_surface_type, display_overlay);
392 MMPLAYER_CMD_UNLOCK( player );
397 int mm_player_push_buffer(MMHandleType player, unsigned char *buf, int size)
399 int result = MM_ERROR_NONE;
401 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
403 //MMPLAYER_CMD_LOCK( player );
405 result = _mmplayer_push_buffer(player, buf, size);
407 //MMPLAYER_CMD_UNLOCK( player );
412 int mm_player_start(MMHandleType player)
414 int result = MM_ERROR_NONE;
416 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
418 MMPLAYER_CMD_LOCK( player );
420 result = _mmplayer_start(player);
422 MMPLAYER_CMD_UNLOCK( player );
427 int mm_player_stop(MMHandleType player)
429 int result = MM_ERROR_NONE;
431 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
433 MMPLAYER_CMD_LOCK( player );
435 result = _mmplayer_stop(player);
437 MMPLAYER_CMD_UNLOCK( player );
442 int mm_player_pause(MMHandleType player)
444 int result = MM_ERROR_NONE;
446 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
448 MMPLAYER_CMD_LOCK( player );
450 result = _mmplayer_pause(player);
452 MMPLAYER_CMD_UNLOCK( player );
457 int mm_player_resume(MMHandleType player)
459 int result = MM_ERROR_NONE;
461 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
463 MMPLAYER_CMD_LOCK( player );
465 result = _mmplayer_resume(player);
467 MMPLAYER_CMD_UNLOCK( player );
472 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos)
474 int result = MM_ERROR_NONE;
476 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
478 MMPLAYER_CMD_LOCK( player );
480 result = _mmplayer_activate_section_repeat(player, start_pos, end_pos);
482 MMPLAYER_CMD_UNLOCK( player );
487 int mm_player_deactivate_section_repeat(MMHandleType player)
489 int result = MM_ERROR_NONE;
491 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
493 MMPLAYER_CMD_LOCK( player );
495 result = _mmplayer_deactivate_section_repeat(player);
497 MMPLAYER_CMD_UNLOCK( player );
502 int mm_player_gst_set_audio_channel(MMHandleType player, MMPlayerAudioChannel ch)
504 int result = MM_ERROR_NONE;
506 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
507 MMPLAYER_CMD_LOCK( player );
509 result = _mmplayer_gst_set_audio_channel(player, ch);
511 MMPLAYER_CMD_UNLOCK( player );
515 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
517 int result = MM_ERROR_NONE;
519 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
521 MMPLAYER_CMD_LOCK( player );
523 result = _mmplayer_set_playspeed(player, rate, streaming);
525 MMPLAYER_CMD_UNLOCK( player );
530 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
532 int result = MM_ERROR_NONE;
534 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
536 if (format >= MM_PLAYER_POS_FORMAT_NUM)
538 LOGE("wrong format\n");
539 return MM_ERROR_COMMON_INVALID_ARGUMENT;
542 MMPLAYER_CMD_LOCK( player );
544 result = _mmplayer_set_position(player, format, pos);
546 MMPLAYER_CMD_UNLOCK( player );
551 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *pos)
553 int result = MM_ERROR_NONE;
555 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
556 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
558 if (format >= MM_PLAYER_POS_FORMAT_NUM)
560 LOGE("wrong format\n");
561 return MM_ERROR_COMMON_INVALID_ARGUMENT;
564 MMPLAYER_CMD_LOCK( player );
566 result = _mmplayer_get_position(player, (int)format, pos);
568 MMPLAYER_CMD_UNLOCK( player );
573 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
575 int result = MM_ERROR_NONE;
577 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
578 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
580 MMPLAYER_CMD_LOCK( player );
582 result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos );
584 MMPLAYER_CMD_UNLOCK( player );
589 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
591 int result = MM_ERROR_NONE;
593 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
595 MMPLAYER_CMD_LOCK( player );
597 result = _mmplayer_set_external_subtitle_path(player, path);
599 MMPLAYER_CMD_UNLOCK( player );
603 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
605 int result = MM_ERROR_NONE;
607 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
609 if (format >= MM_PLAYER_POS_FORMAT_NUM)
611 LOGE("wrong format(%d) \n", format);
612 return MM_ERROR_INVALID_ARGUMENT;
615 MMPLAYER_CMD_LOCK( player );
617 result = _mmplayer_adjust_subtitle_postion(player, format, pos);
619 MMPLAYER_CMD_UNLOCK( player );
624 int mm_player_adjust_video_position(MMHandleType player, int offset)
626 int result = MM_ERROR_NONE;
627 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
628 MMPLAYER_CMD_LOCK( player );
630 result = _mmplayer_adjust_video_postion(player, offset);
632 MMPLAYER_CMD_UNLOCK( player );
637 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
639 int result = MM_ERROR_NONE;
641 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
643 MMPLAYER_CMD_LOCK( player );
645 result = _mmplayer_set_subtitle_silent(player, silent);
647 MMPLAYER_CMD_UNLOCK( player );
652 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
654 int result = MM_ERROR_NONE;
656 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
658 MMPLAYER_CMD_LOCK( player );
660 result = _mmplayer_get_subtitle_silent(player, silent);
662 MMPLAYER_CMD_UNLOCK( player );
667 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
669 int result = MM_ERROR_NONE;
672 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
673 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
675 va_start (var_args, first_attribute_name);
676 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
682 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
684 int result = MM_ERROR_NONE;
687 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
688 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
690 va_start (var_args, first_attribute_name);
691 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
697 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
699 int result = MM_ERROR_NONE;
702 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
703 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
704 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
706 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
711 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
713 int result = MM_ERROR_NONE;
715 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
716 MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
717 MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
719 result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
724 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
726 int result = MM_ERROR_NONE;
728 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
729 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
731 MMPLAYER_CMD_LOCK( player );
733 result = _mmplayer_get_track_count(player, type, count);
735 MMPLAYER_CMD_UNLOCK( player );
740 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
742 int result = MM_ERROR_NONE;
744 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
746 MMPLAYER_CMD_LOCK( player );
748 result = _mmplayer_select_track(player, type, index);
750 MMPLAYER_CMD_UNLOCK( player );
755 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
757 int result = MM_ERROR_NONE;
759 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
761 MMPLAYER_CMD_LOCK( player );
763 result = _mmplayer_track_add_subtitle_language(player, index);
765 MMPLAYER_CMD_UNLOCK( player );
770 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
772 int result = MM_ERROR_NONE;
774 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
776 MMPLAYER_CMD_LOCK( player );
778 result = _mmplayer_track_remove_subtitle_language(player, index);
780 MMPLAYER_CMD_UNLOCK( player );
786 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
788 int result = MM_ERROR_NONE;
790 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
791 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
793 MMPLAYER_CMD_LOCK( player );
795 result = _mmplayer_get_current_track(player, type, index);
797 MMPLAYER_CMD_UNLOCK( player );
802 int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code)
804 int result = MM_ERROR_NONE;
806 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
808 MMPLAYER_CMD_LOCK( player );
810 result = _mmplayer_get_track_language_code(player, type, index, code);
812 MMPLAYER_CMD_UNLOCK( player );
817 int mm_player_set_display_zoom(MMHandleType player, float level, int x, int y)
819 int result = MM_ERROR_NONE;
821 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
823 MMPLAYER_CMD_LOCK( player );
825 result = _mmplayer_set_display_zoom(player, level, x, y);
827 MMPLAYER_CMD_UNLOCK( player );
832 int mm_player_get_display_zoom(MMHandleType player, float *level, int *x, int *y)
834 int result = MM_ERROR_NONE;
836 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
837 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_COMMON_INVALID_ARGUMENT);
839 MMPLAYER_CMD_LOCK( player );
841 result = _mmplayer_get_display_zoom(player, level, x, y);
843 MMPLAYER_CMD_UNLOCK( player );
848 int mm_player_set_video_share_master_clock(MMHandleType player,
850 long long clock_delta,
851 long long video_time,
852 long long media_clock,
853 long long audio_time)
855 int result = MM_ERROR_NONE;
857 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
859 MMPLAYER_CMD_LOCK( player );
861 result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
863 MMPLAYER_CMD_UNLOCK( player );
868 int mm_player_get_video_share_master_clock(MMHandleType player,
869 long long *video_time,
870 long long *media_clock,
871 long long *audio_time)
873 int result = MM_ERROR_NONE;
875 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
876 MMPLAYER_RETURN_VAL_IF_FAIL(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
877 MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
878 MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
880 MMPLAYER_CMD_LOCK( player );
882 result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
884 MMPLAYER_CMD_UNLOCK( player );
889 int mm_player_get_video_rotate_angle(MMHandleType player, int *angle)
891 int result = MM_ERROR_NONE;
893 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
894 MMPLAYER_RETURN_VAL_IF_FAIL(angle, MM_ERROR_COMMON_INVALID_ARGUMENT);
896 MMPLAYER_CMD_LOCK( player );
898 result = _mmplayer_get_video_rotate_angle(player, angle);
900 MMPLAYER_CMD_UNLOCK( player );
905 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
907 int result = MM_ERROR_NONE;
909 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
911 MMPLAYER_CMD_LOCK( player );
913 result = _mmplayer_set_video_hub_download_mode(player, mode);
915 MMPLAYER_CMD_UNLOCK( player );
920 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
922 int result = MM_ERROR_NONE;
924 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
926 MMPLAYER_CMD_LOCK( player );
928 result = _mmplayer_enable_sync_handler(player, enable);
930 MMPLAYER_CMD_UNLOCK( player );
935 int mm_player_set_uri(MMHandleType player, const char *uri)
937 int result = MM_ERROR_NONE;
939 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
941 MMPLAYER_CMD_LOCK( player );
943 result = _mmplayer_set_uri(player, uri);
945 MMPLAYER_CMD_UNLOCK( player );
951 int mm_player_set_next_uri(MMHandleType player, const char *uri)
953 int result = MM_ERROR_NONE;
955 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
957 MMPLAYER_CMD_LOCK( player );
959 result = _mmplayer_set_next_uri(player, uri, FALSE);
961 MMPLAYER_CMD_UNLOCK( player );
967 int mm_player_get_next_uri(MMHandleType player, char **uri)
969 int result = MM_ERROR_NONE;
971 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
973 MMPLAYER_CMD_LOCK( player );
975 result = _mmplayer_get_next_uri(player, uri);
977 MMPLAYER_CMD_UNLOCK( player );
983 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
985 int result = MM_ERROR_NONE;
987 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
989 MMPLAYER_CMD_LOCK( player );
991 result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
993 MMPLAYER_CMD_UNLOCK( player );
999 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
1001 int result = MM_ERROR_NONE;
1003 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1004 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
1006 MMPLAYER_CMD_LOCK( player );
1008 result = _mmplayer_has_closed_caption(player, exist);
1010 MMPLAYER_CMD_UNLOCK( player );
1015 int mm_player_enable_media_packet_video_stream(MMHandleType player, bool enable)
1017 int result = MM_ERROR_NONE;
1019 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1020 MMPLAYER_RETURN_VAL_IF_FAIL(enable, MM_ERROR_INVALID_ARGUMENT);
1022 MMPLAYER_CMD_LOCK( player );
1024 result = _mmplayer_enable_media_packet_video_stream(player, enable);
1026 MMPLAYER_CMD_UNLOCK( player );
1031 void * mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer)
1034 result = _mm_player_media_packet_video_stream_internal_buffer_ref(buffer);
1039 void mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer)
1041 _mm_player_media_packet_video_stream_internal_buffer_unref(buffer);
1044 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
1047 int result = MM_ERROR_NONE;
1049 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1051 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
1052 //MMPLAYER_CMD_LOCK( player );
1054 result = _mmplayer_submit_packet(player, packet);
1056 //MMPLAYER_CMD_UNLOCK( player );
1061 int mm_player_set_video_info (MMHandleType player, media_format_h format)
1063 int result = MM_ERROR_NONE;
1067 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1069 MMPLAYER_CMD_LOCK( player );
1071 result = _mmplayer_set_video_info(player, format);
1073 MMPLAYER_CMD_UNLOCK( player );
1079 int mm_player_set_audio_info (MMHandleType player, media_format_h format)
1081 int result = MM_ERROR_NONE;
1085 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1087 MMPLAYER_CMD_LOCK( player );
1089 result = _mmplayer_set_audio_info(player, format);
1091 MMPLAYER_CMD_UNLOCK( player );
1096 int mm_player_set_subtitle_info (MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
1098 int result = MM_ERROR_NONE;
1102 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1104 MMPLAYER_CMD_LOCK( player );
1106 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
1108 MMPLAYER_CMD_UNLOCK( player );
1113 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
1115 int result = MM_ERROR_NONE;
1119 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1121 MMPLAYER_CMD_LOCK( player );
1123 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
1125 MMPLAYER_CMD_UNLOCK( player );
1130 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1132 int result = MM_ERROR_NONE;
1133 guint64 _max_size = 0;
1137 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1138 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1140 MMPLAYER_CMD_LOCK( player );
1142 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1143 *max_size = _max_size;
1145 MMPLAYER_CMD_UNLOCK( player );
1150 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
1152 int result = MM_ERROR_NONE;
1156 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1158 MMPLAYER_CMD_LOCK( player );
1160 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
1162 MMPLAYER_CMD_UNLOCK( player );
1167 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1169 int result = MM_ERROR_NONE;
1173 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1174 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1176 MMPLAYER_CMD_LOCK( player );
1178 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1180 MMPLAYER_CMD_UNLOCK( player );
1185 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1187 int result = MM_ERROR_NONE;
1191 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1193 MMPLAYER_CMD_LOCK( player );
1195 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1197 MMPLAYER_CMD_UNLOCK( player );
1202 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1204 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_media_stream_seek_data_cb(player, type, callback, user_param);
1214 MMPLAYER_CMD_UNLOCK( player );
1219 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
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_audiostream_changed_cb(player, callback, user_param);
1229 MMPLAYER_CMD_UNLOCK( player );
1234 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1236 int result = MM_ERROR_NONE;
1238 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1240 MMPLAYER_CMD_LOCK( player );
1242 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1244 MMPLAYER_CMD_UNLOCK( player );
1249 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1251 int result = MM_ERROR_NONE;
1253 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1255 MMPLAYER_CMD_LOCK( player );
1257 result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1259 MMPLAYER_CMD_UNLOCK( player );
1264 int mm_player_get_timeout(MMHandleType player, int *timeout)
1266 int result = MM_ERROR_NONE;
1268 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1269 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1271 MMPLAYER_CMD_LOCK( player );
1273 result = _mmplayer_get_timeout(player, timeout);
1275 MMPLAYER_CMD_UNLOCK( player );
1280 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1282 int result = MM_ERROR_NONE;
1284 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1285 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1287 MMPLAYER_CMD_LOCK( player );
1289 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1291 MMPLAYER_CMD_UNLOCK( player );
1296 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1298 int result = MM_ERROR_NONE;
1300 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1302 MMPLAYER_CMD_LOCK( player );
1304 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1306 MMPLAYER_CMD_UNLOCK( player );
1311 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1313 int result = MM_ERROR_NONE;
1315 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1316 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1317 // MMPLAYER_CMD_LOCK( player );
1319 result = _mmplayer_video_stream_release_bo(player, bo);
1321 // MMPLAYER_CMD_UNLOCK( player );
1325 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1327 int result = MM_ERROR_NONE;
1329 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1331 MMPLAYER_CMD_LOCK( player );
1333 result = _mmplayer_set_file_buffering_path(player, file_path);
1335 MMPLAYER_CMD_UNLOCK( player );