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_start(MMHandleType player)
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_start(player);
407 MMPLAYER_CMD_UNLOCK( player );
412 int mm_player_stop(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_stop(player);
422 MMPLAYER_CMD_UNLOCK( player );
427 int mm_player_pause(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_pause(player);
437 MMPLAYER_CMD_UNLOCK( player );
442 int mm_player_resume(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_resume(player);
452 MMPLAYER_CMD_UNLOCK( player );
457 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos)
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_activate_section_repeat(player, start_pos, end_pos);
467 MMPLAYER_CMD_UNLOCK( player );
472 int mm_player_deactivate_section_repeat(MMHandleType player)
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_deactivate_section_repeat(player);
482 MMPLAYER_CMD_UNLOCK( player );
487 int mm_player_gst_set_audio_channel(MMHandleType player, MMPlayerAudioChannel ch)
489 int result = MM_ERROR_NONE;
491 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
492 MMPLAYER_CMD_LOCK( player );
494 result = _mmplayer_gst_set_audio_channel(player, ch);
496 MMPLAYER_CMD_UNLOCK( player );
500 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
502 int result = MM_ERROR_NONE;
504 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
506 MMPLAYER_CMD_LOCK( player );
508 result = _mmplayer_set_playspeed(player, rate, streaming);
510 MMPLAYER_CMD_UNLOCK( player );
515 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
517 int result = MM_ERROR_NONE;
519 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
521 if (format >= MM_PLAYER_POS_FORMAT_NUM)
523 LOGE("wrong format\n");
524 return MM_ERROR_COMMON_INVALID_ARGUMENT;
527 MMPLAYER_CMD_LOCK( player );
529 result = _mmplayer_set_position(player, format, pos);
531 MMPLAYER_CMD_UNLOCK( player );
536 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *pos)
538 int result = MM_ERROR_NONE;
540 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
541 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
543 if (format >= MM_PLAYER_POS_FORMAT_NUM)
545 LOGE("wrong format\n");
546 return MM_ERROR_COMMON_INVALID_ARGUMENT;
549 MMPLAYER_CMD_LOCK( player );
551 result = _mmplayer_get_position(player, (int)format, pos);
553 MMPLAYER_CMD_UNLOCK( player );
558 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
560 int result = MM_ERROR_NONE;
562 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
563 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
565 MMPLAYER_CMD_LOCK( player );
567 result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos );
569 MMPLAYER_CMD_UNLOCK( player );
574 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
576 int result = MM_ERROR_NONE;
578 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
580 MMPLAYER_CMD_LOCK( player );
582 result = _mmplayer_set_external_subtitle_path(player, path);
584 MMPLAYER_CMD_UNLOCK( player );
588 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
590 int result = MM_ERROR_NONE;
592 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
594 if (format >= MM_PLAYER_POS_FORMAT_NUM)
596 LOGE("wrong format(%d) \n", format);
597 return MM_ERROR_INVALID_ARGUMENT;
600 MMPLAYER_CMD_LOCK( player );
602 result = _mmplayer_adjust_subtitle_postion(player, format, pos);
604 MMPLAYER_CMD_UNLOCK( player );
609 int mm_player_adjust_video_position(MMHandleType player, int offset)
611 int result = MM_ERROR_NONE;
612 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
613 MMPLAYER_CMD_LOCK( player );
615 result = _mmplayer_adjust_video_postion(player, offset);
617 MMPLAYER_CMD_UNLOCK( player );
622 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
624 int result = MM_ERROR_NONE;
626 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
628 MMPLAYER_CMD_LOCK( player );
630 result = _mmplayer_set_subtitle_silent(player, silent);
632 MMPLAYER_CMD_UNLOCK( player );
637 int mm_player_get_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_get_subtitle_silent(player, silent);
647 MMPLAYER_CMD_UNLOCK( player );
652 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
654 int result = MM_ERROR_NONE;
657 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
658 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
660 va_start (var_args, first_attribute_name);
661 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
667 int mm_player_get_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_get_attribute(player, err_attr_name, first_attribute_name, var_args);
682 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
684 int result = MM_ERROR_NONE;
687 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
688 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
689 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
691 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
696 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
698 int result = MM_ERROR_NONE;
700 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
701 MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
702 MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
704 result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
709 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
711 int result = MM_ERROR_NONE;
713 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
714 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
716 MMPLAYER_CMD_LOCK( player );
718 result = _mmplayer_get_track_count(player, type, count);
720 MMPLAYER_CMD_UNLOCK( player );
725 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
727 int result = MM_ERROR_NONE;
729 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
731 MMPLAYER_CMD_LOCK( player );
733 result = _mmplayer_select_track(player, type, index);
735 MMPLAYER_CMD_UNLOCK( player );
740 int mm_player_track_add_subtitle_language(MMHandleType player, 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_track_add_subtitle_language(player, index);
750 MMPLAYER_CMD_UNLOCK( player );
755 int mm_player_track_remove_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_remove_subtitle_language(player, index);
765 MMPLAYER_CMD_UNLOCK( player );
771 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
773 int result = MM_ERROR_NONE;
775 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
776 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
778 MMPLAYER_CMD_LOCK( player );
780 result = _mmplayer_get_current_track(player, type, index);
782 MMPLAYER_CMD_UNLOCK( player );
787 int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code)
789 int result = MM_ERROR_NONE;
791 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
793 MMPLAYER_CMD_LOCK( player );
795 result = _mmplayer_get_track_language_code(player, type, index, code);
797 MMPLAYER_CMD_UNLOCK( player );
802 int mm_player_set_display_zoom(MMHandleType player, float level, int x, int y)
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_set_display_zoom(player, level, x, y);
812 MMPLAYER_CMD_UNLOCK( player );
817 int mm_player_get_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);
822 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_COMMON_INVALID_ARGUMENT);
824 MMPLAYER_CMD_LOCK( player );
826 result = _mmplayer_get_display_zoom(player, level, x, y);
828 MMPLAYER_CMD_UNLOCK( player );
833 int mm_player_set_video_share_master_clock(MMHandleType player,
835 long long clock_delta,
836 long long video_time,
837 long long media_clock,
838 long long audio_time)
840 int result = MM_ERROR_NONE;
842 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
844 MMPLAYER_CMD_LOCK( player );
846 result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
848 MMPLAYER_CMD_UNLOCK( player );
853 int mm_player_get_video_share_master_clock(MMHandleType player,
854 long long *video_time,
855 long long *media_clock,
856 long long *audio_time)
858 int result = MM_ERROR_NONE;
860 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
861 MMPLAYER_RETURN_VAL_IF_FAIL(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
862 MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
863 MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
865 MMPLAYER_CMD_LOCK( player );
867 result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
869 MMPLAYER_CMD_UNLOCK( player );
874 int mm_player_get_video_rotate_angle(MMHandleType player, int *angle)
876 int result = MM_ERROR_NONE;
878 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
879 MMPLAYER_RETURN_VAL_IF_FAIL(angle, MM_ERROR_COMMON_INVALID_ARGUMENT);
881 MMPLAYER_CMD_LOCK( player );
883 result = _mmplayer_get_video_rotate_angle(player, angle);
885 MMPLAYER_CMD_UNLOCK( player );
890 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
892 int result = MM_ERROR_NONE;
894 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
896 MMPLAYER_CMD_LOCK( player );
898 result = _mmplayer_set_video_hub_download_mode(player, mode);
900 MMPLAYER_CMD_UNLOCK( player );
905 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
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_enable_sync_handler(player, enable);
915 MMPLAYER_CMD_UNLOCK( player );
920 int mm_player_set_uri(MMHandleType player, const char *uri)
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_set_uri(player, uri);
930 MMPLAYER_CMD_UNLOCK( player );
936 int mm_player_set_next_uri(MMHandleType player, const char *uri)
938 int result = MM_ERROR_NONE;
940 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
942 MMPLAYER_CMD_LOCK( player );
944 result = _mmplayer_set_next_uri(player, uri, FALSE);
946 MMPLAYER_CMD_UNLOCK( player );
952 int mm_player_get_next_uri(MMHandleType player, char **uri)
954 int result = MM_ERROR_NONE;
956 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
958 MMPLAYER_CMD_LOCK( player );
960 result = _mmplayer_get_next_uri(player, uri);
962 MMPLAYER_CMD_UNLOCK( player );
968 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
970 int result = MM_ERROR_NONE;
972 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
974 MMPLAYER_CMD_LOCK( player );
976 result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
978 MMPLAYER_CMD_UNLOCK( player );
984 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
986 int result = MM_ERROR_NONE;
988 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
989 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
991 MMPLAYER_CMD_LOCK( player );
993 result = _mmplayer_has_closed_caption(player, exist);
995 MMPLAYER_CMD_UNLOCK( player );
1000 void * mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer)
1003 result = _mm_player_media_packet_video_stream_internal_buffer_ref(buffer);
1008 void mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer)
1010 _mm_player_media_packet_video_stream_internal_buffer_unref(buffer);
1013 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
1016 int result = MM_ERROR_NONE;
1018 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1020 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
1021 //MMPLAYER_CMD_LOCK( player );
1023 result = _mmplayer_submit_packet(player, packet);
1025 //MMPLAYER_CMD_UNLOCK( player );
1030 int mm_player_set_video_info (MMHandleType player, media_format_h format)
1032 int result = MM_ERROR_NONE;
1036 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1038 MMPLAYER_CMD_LOCK( player );
1040 result = _mmplayer_set_video_info(player, format);
1042 MMPLAYER_CMD_UNLOCK( player );
1048 int mm_player_set_audio_info (MMHandleType player, media_format_h format)
1050 int result = MM_ERROR_NONE;
1054 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1056 MMPLAYER_CMD_LOCK( player );
1058 result = _mmplayer_set_audio_info(player, format);
1060 MMPLAYER_CMD_UNLOCK( player );
1065 int mm_player_set_subtitle_info (MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
1067 int result = MM_ERROR_NONE;
1071 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1073 MMPLAYER_CMD_LOCK( player );
1075 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
1077 MMPLAYER_CMD_UNLOCK( player );
1082 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
1084 int result = MM_ERROR_NONE;
1088 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1090 MMPLAYER_CMD_LOCK( player );
1092 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
1094 MMPLAYER_CMD_UNLOCK( player );
1099 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1101 int result = MM_ERROR_NONE;
1102 guint64 _max_size = 0;
1106 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1107 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1109 MMPLAYER_CMD_LOCK( player );
1111 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1112 *max_size = _max_size;
1114 MMPLAYER_CMD_UNLOCK( player );
1119 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
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_min_percent(player, type, min_percent);
1131 MMPLAYER_CMD_UNLOCK( player );
1136 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1138 int result = MM_ERROR_NONE;
1142 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1143 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1145 MMPLAYER_CMD_LOCK( player );
1147 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1149 MMPLAYER_CMD_UNLOCK( player );
1154 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1156 int result = MM_ERROR_NONE;
1160 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1162 MMPLAYER_CMD_LOCK( player );
1164 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1166 MMPLAYER_CMD_UNLOCK( player );
1171 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1173 int result = MM_ERROR_NONE;
1177 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1179 MMPLAYER_CMD_LOCK( player );
1181 result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
1183 MMPLAYER_CMD_UNLOCK( player );
1188 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1190 int result = MM_ERROR_NONE;
1192 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1194 MMPLAYER_CMD_LOCK( player );
1196 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
1198 MMPLAYER_CMD_UNLOCK( player );
1203 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1205 int result = MM_ERROR_NONE;
1207 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1209 MMPLAYER_CMD_LOCK( player );
1211 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1213 MMPLAYER_CMD_UNLOCK( player );
1218 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1220 int result = MM_ERROR_NONE;
1222 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1224 MMPLAYER_CMD_LOCK( player );
1226 result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1228 MMPLAYER_CMD_UNLOCK( player );
1233 int mm_player_get_timeout(MMHandleType player, int *timeout)
1235 int result = MM_ERROR_NONE;
1237 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1238 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1240 MMPLAYER_CMD_LOCK( player );
1242 result = _mmplayer_get_timeout(player, timeout);
1244 MMPLAYER_CMD_UNLOCK( player );
1249 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1251 int result = MM_ERROR_NONE;
1253 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1254 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1256 MMPLAYER_CMD_LOCK( player );
1258 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1260 MMPLAYER_CMD_UNLOCK( player );
1265 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1267 int result = MM_ERROR_NONE;
1269 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1271 MMPLAYER_CMD_LOCK( player );
1273 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1275 MMPLAYER_CMD_UNLOCK( player );
1280 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1282 int result = MM_ERROR_NONE;
1284 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1285 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1286 // MMPLAYER_CMD_LOCK( player );
1288 result = _mmplayer_video_stream_release_bo(player, bo);
1290 // MMPLAYER_CMD_UNLOCK( player );
1294 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1296 int result = MM_ERROR_NONE;
1298 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1300 MMPLAYER_CMD_LOCK( player );
1302 result = _mmplayer_set_file_buffering_path(player, file_path);
1304 MMPLAYER_CMD_UNLOCK( player );