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_360.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));
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)) {
64 LOGE("can't load ini");
68 if (MM_ERROR_NONE != mm_player_audio_effect_ini_load(&new_player->ini)) {
69 LOGE("can't load audio ini");
74 result = _mmplayer_create_player((MMHandleType)new_player);
75 if (result != MM_ERROR_NONE) {
76 LOGE("failed to create player");
77 if (result != MM_ERROR_PLAYER_RESOURCE_LIMIT)
78 result = MM_ERROR_PLAYER_INTERNAL;
82 *player = (MMHandleType)new_player;
89 _mmplayer_destroy((MMHandleType)new_player);
90 g_mutex_clear(&new_player->cmd_lock);
91 g_mutex_clear(&new_player->playback_lock);
93 MMPLAYER_FREEIF(new_player);
96 *player = (MMHandleType)0;
97 return result; /* MM_ERROR_PLAYER_INTERNAL or MM_ERROR_PLAYER_RESOURCE_LIMIT */
100 int mm_player_destroy(MMHandleType player)
102 int result = MM_ERROR_NONE;
104 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
106 /* destroy the gst bus msg thread if it is remained.
107 this funct have to be called before getting cmd lock. */
108 _mmplayer_bus_msg_thread_destroy(player);
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_realize(MMHandleType player)
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_realize(player);
137 MMPLAYER_CMD_UNLOCK(player);
142 int mm_player_unrealize(MMHandleType player)
144 int result = MM_ERROR_NONE;
146 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
148 MMPLAYER_CMD_LOCK(player);
150 result = _mmplayer_unrealize(player);
152 MMPLAYER_CMD_UNLOCK(player);
157 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
159 int result = MM_ERROR_NONE;
161 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
163 MMPLAYER_CMD_LOCK(player);
165 result = _mmplayer_set_message_callback(player, callback, user_param);
167 MMPLAYER_CMD_UNLOCK(player);
172 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
174 int result = MM_ERROR_NONE;
176 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
178 result = _mm_player_set_pd_downloader_message_cb(player, callback, user_param);
183 int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param)
185 int result = MM_ERROR_NONE;
187 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
189 MMPLAYER_CMD_LOCK(player);
191 result = _mmplayer_set_audiostream_cb(player, callback, user_param);
193 MMPLAYER_CMD_UNLOCK(player);
198 int mm_player_set_audio_stream_callback_ex(MMHandleType player, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param)
200 int result = MM_ERROR_NONE;
202 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
204 MMPLAYER_CMD_LOCK(player);
206 result = _mmplayer_set_audiostream_cb_ex(player, sync, callback, user_param);
208 MMPLAYER_CMD_UNLOCK(player);
213 int mm_player_set_video_stream_callback(MMHandleType player, mm_player_video_stream_callback callback, void *user_param)
215 int result = MM_ERROR_NONE;
217 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
219 MMPLAYER_CMD_LOCK(player);
221 result = _mmplayer_set_videostream_cb(player, callback, user_param);
223 MMPLAYER_CMD_UNLOCK(player);
228 int mm_player_do_video_capture(MMHandleType player)
230 int result = MM_ERROR_NONE;
232 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
234 MMPLAYER_CMD_LOCK(player);
236 result = _mmplayer_do_video_capture(player);
238 MMPLAYER_CMD_UNLOCK(player);
243 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume)
245 int result = MM_ERROR_NONE;
247 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
248 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
250 MMPLAYER_CMD_LOCK(player);
252 result = _mmplayer_set_volume(player, *volume);
254 MMPLAYER_CMD_UNLOCK(player);
259 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume)
261 int result = MM_ERROR_NONE;
263 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
264 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
266 MMPLAYER_CMD_LOCK(player);
268 result = _mmplayer_get_volume(player, volume);
270 MMPLAYER_CMD_UNLOCK(player);
275 int mm_player_set_mute(MMHandleType player, int mute)
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_mute(player, mute);
285 MMPLAYER_CMD_UNLOCK(player);
290 int mm_player_get_mute(MMHandleType player, int *mute)
292 int result = MM_ERROR_NONE;
294 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
295 MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
297 MMPLAYER_CMD_LOCK(player);
299 result = _mmplayer_get_mute(player, mute);
301 MMPLAYER_CMD_UNLOCK(player);
306 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state)
308 int result = MM_ERROR_NONE;
310 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
311 MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
313 *state = MM_PLAYER_STATE_NULL;
315 result = _mmplayer_get_state(player, (int*)state);
320 /* NOTE : It does not support some use cases, eg using colorspace converter */
321 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
323 int result = MM_ERROR_NONE;
325 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
327 MMPLAYER_CMD_LOCK(player);
329 result = _mmplayer_change_videosink(player, display_surface_type, display_overlay);
331 MMPLAYER_CMD_UNLOCK(player);
336 int mm_player_start(MMHandleType player)
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_start(player);
346 MMPLAYER_CMD_UNLOCK(player);
351 int mm_player_stop(MMHandleType player)
353 int result = MM_ERROR_NONE;
355 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
357 MMPLAYER_CMD_LOCK(player);
359 result = _mmplayer_stop(player);
361 MMPLAYER_CMD_UNLOCK(player);
366 int mm_player_pause(MMHandleType player)
368 int result = MM_ERROR_NONE;
370 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
372 MMPLAYER_CMD_LOCK(player);
374 result = _mmplayer_pause(player);
376 MMPLAYER_CMD_UNLOCK(player);
381 int mm_player_resume(MMHandleType player)
383 int result = MM_ERROR_NONE;
385 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
387 MMPLAYER_CMD_LOCK(player);
389 result = _mmplayer_resume(player);
391 MMPLAYER_CMD_UNLOCK(player);
396 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
398 int result = MM_ERROR_NONE;
400 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
402 MMPLAYER_CMD_LOCK(player);
404 result = _mmplayer_set_playspeed(player, rate, streaming);
406 MMPLAYER_CMD_UNLOCK(player);
411 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int64_t pos)
413 int result = MM_ERROR_NONE;
415 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
417 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
418 LOGE("wrong format\n");
419 return MM_ERROR_COMMON_INVALID_ARGUMENT;
422 MMPLAYER_CMD_LOCK(player);
424 result = _mmplayer_set_position(player, format, pos);
426 MMPLAYER_CMD_UNLOCK(player);
431 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, int64_t *pos)
433 int result = MM_ERROR_NONE;
435 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
436 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
438 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
439 LOGE("wrong format\n");
440 return MM_ERROR_COMMON_INVALID_ARGUMENT;
443 MMPLAYER_CMD_LOCK(player);
445 result = _mmplayer_get_position(player, (int)format, pos);
447 MMPLAYER_CMD_UNLOCK(player);
452 int mm_player_get_duration(MMHandleType player, int64_t *dur)
454 int result = MM_ERROR_NONE;
456 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
457 MMPLAYER_RETURN_VAL_IF_FAIL(dur, MM_ERROR_COMMON_INVALID_ARGUMENT);
459 MMPLAYER_CMD_LOCK(player);
461 result = _mmplayer_get_duration(player, dur);
463 MMPLAYER_CMD_UNLOCK(player);
469 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
471 int result = MM_ERROR_NONE;
473 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
474 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
476 MMPLAYER_CMD_LOCK(player);
478 result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos);
480 MMPLAYER_CMD_UNLOCK(player);
485 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
487 int result = MM_ERROR_NONE;
489 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
491 MMPLAYER_CMD_LOCK(player);
493 result = _mmplayer_set_external_subtitle_path(player, path);
495 MMPLAYER_CMD_UNLOCK(player);
499 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
501 int result = MM_ERROR_NONE;
503 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
505 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
506 LOGE("wrong format(%d) \n", format);
507 return MM_ERROR_INVALID_ARGUMENT;
510 MMPLAYER_CMD_LOCK(player);
512 result = _mmplayer_adjust_subtitle_postion(player, format, pos);
514 MMPLAYER_CMD_UNLOCK(player);
519 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
521 int result = MM_ERROR_NONE;
523 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
525 MMPLAYER_CMD_LOCK(player);
527 result = _mmplayer_set_subtitle_silent(player, silent);
529 MMPLAYER_CMD_UNLOCK(player);
534 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
536 int result = MM_ERROR_NONE;
538 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
540 MMPLAYER_CMD_LOCK(player);
542 result = _mmplayer_get_subtitle_silent(player, silent);
544 MMPLAYER_CMD_UNLOCK(player);
549 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
551 int result = MM_ERROR_NONE;
554 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
555 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
557 va_start(var_args, first_attribute_name);
558 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
564 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
566 int result = MM_ERROR_NONE;
569 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
570 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
572 va_start(var_args, first_attribute_name);
573 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
579 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
581 int result = MM_ERROR_NONE;
584 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
585 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
586 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
588 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
593 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
595 int result = MM_ERROR_NONE;
597 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
598 MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
599 MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
601 result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
606 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
608 int result = MM_ERROR_NONE;
610 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
611 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
613 MMPLAYER_CMD_LOCK(player);
615 result = _mmplayer_get_track_count(player, type, count);
617 MMPLAYER_CMD_UNLOCK(player);
622 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
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_select_track(player, type, index);
632 MMPLAYER_CMD_UNLOCK(player);
637 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
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_track_add_subtitle_language(player, index);
647 MMPLAYER_CMD_UNLOCK(player);
652 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
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_track_remove_subtitle_language(player, index);
662 MMPLAYER_CMD_UNLOCK(player);
668 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
670 int result = MM_ERROR_NONE;
672 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
673 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
675 MMPLAYER_CMD_LOCK(player);
677 result = _mmplayer_get_current_track(player, type, index);
679 MMPLAYER_CMD_UNLOCK(player);
684 int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code)
686 int result = MM_ERROR_NONE;
688 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
690 MMPLAYER_CMD_LOCK(player);
692 result = _mmplayer_get_track_language_code(player, type, index, code);
694 MMPLAYER_CMD_UNLOCK(player);
699 int mm_player_set_video_share_master_clock(MMHandleType player, int64_t clock, int64_t clock_delta,
700 int64_t video_time, int64_t media_clock, int64_t audio_time)
702 int result = MM_ERROR_NONE;
704 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
706 MMPLAYER_CMD_LOCK(player);
708 result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
710 MMPLAYER_CMD_UNLOCK(player);
715 int mm_player_get_video_share_master_clock(MMHandleType player, int64_t *video_time, int64_t *media_clock, int64_t *audio_time)
717 int result = MM_ERROR_NONE;
719 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
720 MMPLAYER_RETURN_VAL_IF_FAIL(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
721 MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
722 MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
724 MMPLAYER_CMD_LOCK(player);
726 result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
728 MMPLAYER_CMD_UNLOCK(player);
733 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
735 int result = MM_ERROR_NONE;
737 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
739 MMPLAYER_CMD_LOCK(player);
741 result = _mmplayer_set_video_hub_download_mode(player, mode);
743 MMPLAYER_CMD_UNLOCK(player);
748 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
750 int result = MM_ERROR_NONE;
752 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
754 MMPLAYER_CMD_LOCK(player);
756 result = _mmplayer_enable_sync_handler(player, enable);
758 MMPLAYER_CMD_UNLOCK(player);
763 int mm_player_set_uri(MMHandleType player, const char *uri)
765 int result = MM_ERROR_NONE;
767 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
769 MMPLAYER_CMD_LOCK(player);
771 result = _mmplayer_set_uri(player, uri);
773 MMPLAYER_CMD_UNLOCK(player);
779 int mm_player_set_next_uri(MMHandleType player, const char *uri)
781 int result = MM_ERROR_NONE;
783 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
785 MMPLAYER_CMD_LOCK(player);
787 result = _mmplayer_set_next_uri(player, uri, FALSE);
789 MMPLAYER_CMD_UNLOCK(player);
795 int mm_player_get_next_uri(MMHandleType player, char **uri)
797 int result = MM_ERROR_NONE;
799 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
801 MMPLAYER_CMD_LOCK(player);
803 result = _mmplayer_get_next_uri(player, uri);
805 MMPLAYER_CMD_UNLOCK(player);
811 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
813 int result = MM_ERROR_NONE;
815 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
817 MMPLAYER_CMD_LOCK(player);
819 result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
821 MMPLAYER_CMD_UNLOCK(player);
827 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
829 int result = MM_ERROR_NONE;
831 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
832 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
834 MMPLAYER_CMD_LOCK(player);
836 result = _mmplayer_has_closed_caption(player, exist);
838 MMPLAYER_CMD_UNLOCK(player);
843 void mm_player_video_stream_internal_buffer_unref(void *buffer)
845 _mm_player_video_stream_internal_buffer_unref(buffer);
848 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
851 int result = MM_ERROR_NONE;
853 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
855 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
856 //MMPLAYER_CMD_LOCK(player);
858 result = _mmplayer_submit_packet(player, packet);
860 //MMPLAYER_CMD_UNLOCK(player);
865 int mm_player_set_video_info(MMHandleType player, media_format_h format)
867 int result = MM_ERROR_NONE;
871 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
873 MMPLAYER_CMD_LOCK(player);
875 result = _mmplayer_set_video_info(player, format);
877 MMPLAYER_CMD_UNLOCK(player);
883 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
885 int result = MM_ERROR_NONE;
889 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
891 MMPLAYER_CMD_LOCK(player);
893 result = _mmplayer_set_audio_info(player, format);
895 MMPLAYER_CMD_UNLOCK(player);
900 int mm_player_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
902 int result = MM_ERROR_NONE;
906 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
908 MMPLAYER_CMD_LOCK(player);
910 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
912 MMPLAYER_CMD_UNLOCK(player);
917 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
919 int result = MM_ERROR_NONE;
923 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
925 MMPLAYER_CMD_LOCK(player);
927 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
929 MMPLAYER_CMD_UNLOCK(player);
934 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
936 int result = MM_ERROR_NONE;
937 guint64 _max_size = 0;
941 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
942 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
944 MMPLAYER_CMD_LOCK(player);
946 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
947 *max_size = _max_size;
949 MMPLAYER_CMD_UNLOCK(player);
954 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
956 int result = MM_ERROR_NONE;
960 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
962 MMPLAYER_CMD_LOCK(player);
964 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
966 MMPLAYER_CMD_UNLOCK(player);
971 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
973 int result = MM_ERROR_NONE;
977 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
978 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
980 MMPLAYER_CMD_LOCK(player);
982 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
984 MMPLAYER_CMD_UNLOCK(player);
989 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
991 int result = MM_ERROR_NONE;
995 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
997 MMPLAYER_CMD_LOCK(player);
999 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1001 MMPLAYER_CMD_UNLOCK(player);
1006 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1008 int result = MM_ERROR_NONE;
1012 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1014 MMPLAYER_CMD_LOCK(player);
1016 result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
1018 MMPLAYER_CMD_UNLOCK(player);
1023 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1025 int result = MM_ERROR_NONE;
1027 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1029 MMPLAYER_CMD_LOCK(player);
1031 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
1033 MMPLAYER_CMD_UNLOCK(player);
1038 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1040 int result = MM_ERROR_NONE;
1042 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1044 MMPLAYER_CMD_LOCK(player);
1046 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1048 MMPLAYER_CMD_UNLOCK(player);
1053 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1055 int result = MM_ERROR_NONE;
1057 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1059 MMPLAYER_CMD_LOCK(player);
1061 result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1063 MMPLAYER_CMD_UNLOCK(player);
1068 int mm_player_get_timeout(MMHandleType player, int *timeout)
1070 int result = MM_ERROR_NONE;
1072 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1073 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1075 MMPLAYER_CMD_LOCK(player);
1077 result = _mmplayer_get_timeout(player, timeout);
1079 MMPLAYER_CMD_UNLOCK(player);
1084 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1086 int result = MM_ERROR_NONE;
1088 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1089 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1091 MMPLAYER_CMD_LOCK(player);
1093 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1095 MMPLAYER_CMD_UNLOCK(player);
1100 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1102 int result = MM_ERROR_NONE;
1104 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1106 MMPLAYER_CMD_LOCK(player);
1108 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1110 MMPLAYER_CMD_UNLOCK(player);
1115 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1117 int result = MM_ERROR_NONE;
1119 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1120 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1122 //MMPLAYER_CMD_LOCK(player);
1124 result = _mmplayer_video_stream_release_bo(player, bo);
1126 //MMPLAYER_CMD_UNLOCK(player);
1131 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1133 int result = MM_ERROR_NONE;
1135 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1137 MMPLAYER_CMD_LOCK(player);
1139 result = _mmplayer_set_file_buffering_path(player, file_path);
1141 MMPLAYER_CMD_UNLOCK(player);
1146 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1148 int result = MM_ERROR_NONE;
1150 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1151 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1153 MMPLAYER_CMD_LOCK(player);
1155 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1157 MMPLAYER_CMD_UNLOCK(player);
1162 int mm_player_manage_external_storage_state(MMHandleType player, int id, int state)
1164 int result = MM_ERROR_NONE;
1166 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1168 MMPLAYER_CMD_LOCK(player);
1170 result = _mmplayer_manage_external_storage_state(player, id, state);
1172 MMPLAYER_CMD_UNLOCK(player);
1177 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1179 int result = MM_ERROR_NONE;
1181 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1182 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1184 MMPLAYER_CMD_LOCK(player);
1186 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1188 MMPLAYER_CMD_UNLOCK(player);
1193 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1195 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_max_adaptive_variant_limit(player, bandwidth, width, height);
1203 MMPLAYER_CMD_UNLOCK(player);
1208 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1210 int result = MM_ERROR_NONE;
1212 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1213 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1215 MMPLAYER_CMD_LOCK(player);
1217 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1219 MMPLAYER_CMD_UNLOCK(player);
1224 int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, int rebuffer_ms)
1226 int result = MM_ERROR_NONE;
1227 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1229 MMPLAYER_CMD_LOCK(player);
1231 result = _mmplayer_set_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1233 MMPLAYER_CMD_UNLOCK(player);
1238 int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms)
1240 int result = MM_ERROR_NONE;
1242 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1243 MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1245 MMPLAYER_CMD_LOCK(player);
1247 result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1249 MMPLAYER_CMD_UNLOCK(player);
1254 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1256 int result = MM_ERROR_NONE;
1257 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1259 MMPLAYER_CMD_LOCK(player);
1261 result = _mmplayer_set_audio_only(player, audio_only);
1263 MMPLAYER_CMD_UNLOCK(player);
1268 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1270 int result = MM_ERROR_NONE;
1272 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1273 MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1275 MMPLAYER_CMD_LOCK(player);
1277 result = _mmplayer_get_audio_only(player, audio_only);
1279 MMPLAYER_CMD_UNLOCK(player);
1284 int mm_player_360_is_content_spherical(MMHandleType player, bool *is_spherical)
1286 int result = MM_ERROR_NONE;
1288 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1289 MMPLAYER_RETURN_VAL_IF_FAIL(is_spherical, MM_ERROR_INVALID_ARGUMENT);
1291 MMPLAYER_CMD_LOCK(player);
1293 result = _mmplayer_360_is_content_spherical(player, is_spherical);
1295 MMPLAYER_CMD_UNLOCK(player);
1300 int mm_player_360_set_enabled(MMHandleType player, bool enabled)
1302 int result = MM_ERROR_NONE;
1303 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1305 MMPLAYER_CMD_LOCK(player);
1307 result = _mmplayer_360_set_enabled(player, enabled);
1309 MMPLAYER_CMD_UNLOCK(player);
1314 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1316 int result = MM_ERROR_NONE;
1318 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1319 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1321 MMPLAYER_CMD_LOCK(player);
1323 result = _mmplayer_360_is_enabled(player, enabled);
1325 MMPLAYER_CMD_UNLOCK(player);
1330 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1332 int result = MM_ERROR_NONE;
1333 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1335 MMPLAYER_CMD_LOCK(player);
1337 result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1339 MMPLAYER_CMD_UNLOCK(player);
1344 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1346 int result = MM_ERROR_NONE;
1348 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1349 MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1351 MMPLAYER_CMD_LOCK(player);
1353 result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1355 MMPLAYER_CMD_UNLOCK(player);
1360 int mm_player_360_set_zoom(MMHandleType player, float level)
1362 int result = MM_ERROR_NONE;
1363 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1365 MMPLAYER_CMD_LOCK(player);
1367 result = _mmplayer_360_set_zoom(player, level);
1369 MMPLAYER_CMD_UNLOCK(player);
1374 int mm_player_360_get_zoom(MMHandleType player, float *level)
1376 int result = MM_ERROR_NONE;
1378 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1379 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1381 MMPLAYER_CMD_LOCK(player);
1383 result = _mmplayer_360_get_zoom(player, level);
1385 MMPLAYER_CMD_UNLOCK(player);
1390 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1392 int result = MM_ERROR_NONE;
1393 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1395 MMPLAYER_CMD_LOCK(player);
1397 result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1399 MMPLAYER_CMD_UNLOCK(player);
1404 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1406 int result = MM_ERROR_NONE;
1408 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1409 MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1411 MMPLAYER_CMD_LOCK(player);
1413 result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1415 MMPLAYER_CMD_UNLOCK(player);
1420 int mm_player_set_codec_type(MMHandleType player, MMPlayerStreamType stream_type, MMPlayerVideoCodecType codec_type)
1422 int result = MM_ERROR_NONE;
1424 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1426 MMPLAYER_CMD_LOCK(player);
1428 result = _mmplayer_set_codec_type(player, stream_type, codec_type);
1430 MMPLAYER_CMD_UNLOCK(player);
1435 int mm_player_set_replaygain_enabled(MMHandleType player, bool enabled)
1437 int result = MM_ERROR_NONE;
1439 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1441 MMPLAYER_CMD_LOCK(player);
1443 result = _mmplayer_set_replaygain_enabled(player, enabled);
1445 MMPLAYER_CMD_UNLOCK(player);
1450 int mm_player_is_replaygain_enabled(MMHandleType player, bool *enabled)
1452 int result = MM_ERROR_NONE;
1454 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1455 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1457 MMPLAYER_CMD_LOCK(player);
1459 result = _mmplayer_is_replaygain_enabled(player, enabled);
1461 MMPLAYER_CMD_UNLOCK(player);