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_abort_pause(MMHandleType player)
144 int result = MM_ERROR_NONE;
146 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
148 /* destroy the gst bus msg thread not to be blocked in pause(without cmd lock). */
149 __mmplayer_bus_msg_thread_destroy(player);
151 /* abort the pause operation for preparing(without cmd lock). */
152 result = _mmplayer_abort_pause(player);
157 int mm_player_unrealize(MMHandleType player)
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_unrealize(player);
167 MMPLAYER_CMD_UNLOCK(player);
172 int mm_player_set_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 MMPLAYER_CMD_LOCK(player);
180 result = _mmplayer_set_message_callback(player, callback, user_param);
182 MMPLAYER_CMD_UNLOCK(player);
187 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
189 int result = MM_ERROR_NONE;
191 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
193 result = _mm_player_set_pd_downloader_message_cb(player, callback, user_param);
198 int mm_player_set_audio_stream_callback(MMHandleType player, bool sync, mm_player_audio_stream_callback 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(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, int64_t pos)
413 int result = MM_ERROR_NONE;
415 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
417 MMPLAYER_CMD_LOCK(player);
419 result = _mmplayer_set_position(player, pos);
421 MMPLAYER_CMD_UNLOCK(player);
426 int mm_player_get_position(MMHandleType player, int64_t *pos)
428 int result = MM_ERROR_NONE;
430 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
431 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
433 MMPLAYER_CMD_LOCK(player);
435 result = _mmplayer_get_position(player, pos);
437 MMPLAYER_CMD_UNLOCK(player);
442 int mm_player_get_duration(MMHandleType player, int64_t *dur)
444 int result = MM_ERROR_NONE;
446 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
447 MMPLAYER_RETURN_VAL_IF_FAIL(dur, MM_ERROR_COMMON_INVALID_ARGUMENT);
449 MMPLAYER_CMD_LOCK(player);
451 result = _mmplayer_get_duration(player, dur);
453 MMPLAYER_CMD_UNLOCK(player);
459 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
461 int result = MM_ERROR_NONE;
463 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
464 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
466 MMPLAYER_CMD_LOCK(player);
468 result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos);
470 MMPLAYER_CMD_UNLOCK(player);
475 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
477 int result = MM_ERROR_NONE;
479 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
481 MMPLAYER_CMD_LOCK(player);
483 result = _mmplayer_set_external_subtitle_path(player, path);
485 MMPLAYER_CMD_UNLOCK(player);
489 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
491 int result = MM_ERROR_NONE;
493 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
495 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
496 LOGE("wrong format(%d) \n", format);
497 return MM_ERROR_INVALID_ARGUMENT;
500 MMPLAYER_CMD_LOCK(player);
502 result = _mmplayer_adjust_subtitle_postion(player, format, pos);
504 MMPLAYER_CMD_UNLOCK(player);
509 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
511 int result = MM_ERROR_NONE;
513 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
515 MMPLAYER_CMD_LOCK(player);
517 result = _mmplayer_set_subtitle_silent(player, silent);
519 MMPLAYER_CMD_UNLOCK(player);
524 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
526 int result = MM_ERROR_NONE;
528 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
530 MMPLAYER_CMD_LOCK(player);
532 result = _mmplayer_get_subtitle_silent(player, silent);
534 MMPLAYER_CMD_UNLOCK(player);
539 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
541 int result = MM_ERROR_NONE;
544 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
545 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
547 va_start(var_args, first_attribute_name);
548 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
554 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
556 int result = MM_ERROR_NONE;
559 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
560 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
562 va_start(var_args, first_attribute_name);
563 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
569 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
571 int result = MM_ERROR_NONE;
574 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
575 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
576 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
578 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
583 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
585 int result = MM_ERROR_NONE;
587 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
588 MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
589 MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
591 result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
596 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
598 int result = MM_ERROR_NONE;
600 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
601 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
603 MMPLAYER_CMD_LOCK(player);
605 result = _mmplayer_get_track_count(player, type, count);
607 MMPLAYER_CMD_UNLOCK(player);
612 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
614 int result = MM_ERROR_NONE;
616 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
618 MMPLAYER_CMD_LOCK(player);
620 result = _mmplayer_select_track(player, type, index);
622 MMPLAYER_CMD_UNLOCK(player);
627 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
629 int result = MM_ERROR_NONE;
631 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
633 MMPLAYER_CMD_LOCK(player);
635 result = _mmplayer_track_add_subtitle_language(player, index);
637 MMPLAYER_CMD_UNLOCK(player);
642 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
644 int result = MM_ERROR_NONE;
646 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
648 MMPLAYER_CMD_LOCK(player);
650 result = _mmplayer_track_remove_subtitle_language(player, index);
652 MMPLAYER_CMD_UNLOCK(player);
658 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
660 int result = MM_ERROR_NONE;
662 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
663 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
665 MMPLAYER_CMD_LOCK(player);
667 result = _mmplayer_get_current_track(player, type, index);
669 MMPLAYER_CMD_UNLOCK(player);
674 int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code)
676 int result = MM_ERROR_NONE;
678 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
680 MMPLAYER_CMD_LOCK(player);
682 result = _mmplayer_get_track_language_code(player, type, index, code);
684 MMPLAYER_CMD_UNLOCK(player);
689 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
691 int result = MM_ERROR_NONE;
693 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
695 MMPLAYER_CMD_LOCK(player);
697 result = _mmplayer_set_video_hub_download_mode(player, mode);
699 MMPLAYER_CMD_UNLOCK(player);
704 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
706 int result = MM_ERROR_NONE;
708 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
710 MMPLAYER_CMD_LOCK(player);
712 result = _mmplayer_enable_sync_handler(player, enable);
714 MMPLAYER_CMD_UNLOCK(player);
719 int mm_player_set_uri(MMHandleType player, const char *uri)
721 int result = MM_ERROR_NONE;
723 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
725 MMPLAYER_CMD_LOCK(player);
727 result = _mmplayer_set_uri(player, uri);
729 MMPLAYER_CMD_UNLOCK(player);
735 int mm_player_set_next_uri(MMHandleType player, const char *uri)
737 int result = MM_ERROR_NONE;
739 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
741 MMPLAYER_CMD_LOCK(player);
743 result = _mmplayer_set_next_uri(player, uri, FALSE);
745 MMPLAYER_CMD_UNLOCK(player);
751 int mm_player_get_next_uri(MMHandleType player, char **uri)
753 int result = MM_ERROR_NONE;
755 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
757 MMPLAYER_CMD_LOCK(player);
759 result = _mmplayer_get_next_uri(player, uri);
761 MMPLAYER_CMD_UNLOCK(player);
767 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
769 int result = MM_ERROR_NONE;
771 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
773 MMPLAYER_CMD_LOCK(player);
775 result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
777 MMPLAYER_CMD_UNLOCK(player);
783 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
785 int result = MM_ERROR_NONE;
787 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
788 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
790 MMPLAYER_CMD_LOCK(player);
792 result = _mmplayer_has_closed_caption(player, exist);
794 MMPLAYER_CMD_UNLOCK(player);
799 void mm_player_video_stream_internal_buffer_unref(void *buffer)
801 _mm_player_video_stream_internal_buffer_unref(buffer);
804 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
807 int result = MM_ERROR_NONE;
809 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
811 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
812 //MMPLAYER_CMD_LOCK(player);
814 result = _mmplayer_submit_packet(player, packet);
816 //MMPLAYER_CMD_UNLOCK(player);
821 int mm_player_set_video_info(MMHandleType player, media_format_h format)
823 int result = MM_ERROR_NONE;
827 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
829 MMPLAYER_CMD_LOCK(player);
831 result = _mmplayer_set_video_info(player, format);
833 MMPLAYER_CMD_UNLOCK(player);
839 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
841 int result = MM_ERROR_NONE;
845 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
847 MMPLAYER_CMD_LOCK(player);
849 result = _mmplayer_set_audio_info(player, format);
851 MMPLAYER_CMD_UNLOCK(player);
856 int mm_player_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
858 int result = MM_ERROR_NONE;
862 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
864 MMPLAYER_CMD_LOCK(player);
866 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
868 MMPLAYER_CMD_UNLOCK(player);
873 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
875 int result = MM_ERROR_NONE;
879 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
881 MMPLAYER_CMD_LOCK(player);
883 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
885 MMPLAYER_CMD_UNLOCK(player);
890 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
892 int result = MM_ERROR_NONE;
893 guint64 _max_size = 0;
897 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
898 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
900 MMPLAYER_CMD_LOCK(player);
902 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
903 *max_size = _max_size;
905 MMPLAYER_CMD_UNLOCK(player);
910 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
912 int result = MM_ERROR_NONE;
916 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
918 MMPLAYER_CMD_LOCK(player);
920 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
922 MMPLAYER_CMD_UNLOCK(player);
927 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
929 int result = MM_ERROR_NONE;
933 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
934 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
936 MMPLAYER_CMD_LOCK(player);
938 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
940 MMPLAYER_CMD_UNLOCK(player);
945 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
947 int result = MM_ERROR_NONE;
951 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
953 MMPLAYER_CMD_LOCK(player);
955 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
957 MMPLAYER_CMD_UNLOCK(player);
962 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
964 int result = MM_ERROR_NONE;
968 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
970 MMPLAYER_CMD_LOCK(player);
972 result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
974 MMPLAYER_CMD_UNLOCK(player);
979 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
981 int result = MM_ERROR_NONE;
983 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
985 MMPLAYER_CMD_LOCK(player);
987 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
989 MMPLAYER_CMD_UNLOCK(player);
994 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
996 int result = MM_ERROR_NONE;
998 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1000 MMPLAYER_CMD_LOCK(player);
1002 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1004 MMPLAYER_CMD_UNLOCK(player);
1009 int mm_player_get_timeout(MMHandleType player, int *timeout)
1011 int result = MM_ERROR_NONE;
1013 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1014 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1016 MMPLAYER_CMD_LOCK(player);
1018 result = _mmplayer_get_timeout(player, timeout);
1020 MMPLAYER_CMD_UNLOCK(player);
1025 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1027 int result = MM_ERROR_NONE;
1029 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1030 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1032 MMPLAYER_CMD_LOCK(player);
1034 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1036 MMPLAYER_CMD_UNLOCK(player);
1041 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1043 int result = MM_ERROR_NONE;
1045 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1047 MMPLAYER_CMD_LOCK(player);
1049 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1051 MMPLAYER_CMD_UNLOCK(player);
1056 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1058 int result = MM_ERROR_NONE;
1060 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1061 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1063 //MMPLAYER_CMD_LOCK(player);
1065 result = _mmplayer_video_stream_release_bo(player, bo);
1067 //MMPLAYER_CMD_UNLOCK(player);
1072 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1074 int result = MM_ERROR_NONE;
1076 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1078 MMPLAYER_CMD_LOCK(player);
1080 result = _mmplayer_set_file_buffering_path(player, file_path);
1082 MMPLAYER_CMD_UNLOCK(player);
1087 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1089 int result = MM_ERROR_NONE;
1091 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1092 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1094 MMPLAYER_CMD_LOCK(player);
1096 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1098 MMPLAYER_CMD_UNLOCK(player);
1103 int mm_player_manage_external_storage_state(MMHandleType player, int id, int state)
1105 int result = MM_ERROR_NONE;
1107 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1109 MMPLAYER_CMD_LOCK(player);
1111 result = _mmplayer_manage_external_storage_state(player, id, state);
1113 MMPLAYER_CMD_UNLOCK(player);
1118 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1120 int result = MM_ERROR_NONE;
1122 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1123 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1125 MMPLAYER_CMD_LOCK(player);
1127 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1129 MMPLAYER_CMD_UNLOCK(player);
1134 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1136 int result = MM_ERROR_NONE;
1138 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1140 MMPLAYER_CMD_LOCK(player);
1142 result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
1144 MMPLAYER_CMD_UNLOCK(player);
1149 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1151 int result = MM_ERROR_NONE;
1153 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1154 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1156 MMPLAYER_CMD_LOCK(player);
1158 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1160 MMPLAYER_CMD_UNLOCK(player);
1165 int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, int rebuffer_ms)
1167 int result = MM_ERROR_NONE;
1168 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1170 MMPLAYER_CMD_LOCK(player);
1172 result = _mmplayer_set_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1174 MMPLAYER_CMD_UNLOCK(player);
1179 int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms)
1181 int result = MM_ERROR_NONE;
1183 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1184 MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1186 MMPLAYER_CMD_LOCK(player);
1188 result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1190 MMPLAYER_CMD_UNLOCK(player);
1195 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1197 int result = MM_ERROR_NONE;
1198 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1200 MMPLAYER_CMD_LOCK(player);
1202 result = _mmplayer_set_audio_only(player, audio_only);
1204 MMPLAYER_CMD_UNLOCK(player);
1209 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1211 int result = MM_ERROR_NONE;
1213 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1214 MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1216 MMPLAYER_CMD_LOCK(player);
1218 result = _mmplayer_get_audio_only(player, audio_only);
1220 MMPLAYER_CMD_UNLOCK(player);
1225 int mm_player_360_is_content_spherical(MMHandleType player, bool *is_spherical)
1227 int result = MM_ERROR_NONE;
1229 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1230 MMPLAYER_RETURN_VAL_IF_FAIL(is_spherical, MM_ERROR_INVALID_ARGUMENT);
1232 MMPLAYER_CMD_LOCK(player);
1234 result = _mmplayer_360_is_content_spherical(player, is_spherical);
1236 MMPLAYER_CMD_UNLOCK(player);
1241 int mm_player_360_set_enabled(MMHandleType player, bool enabled)
1243 int result = MM_ERROR_NONE;
1244 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1246 MMPLAYER_CMD_LOCK(player);
1248 result = _mmplayer_360_set_enabled(player, enabled);
1250 MMPLAYER_CMD_UNLOCK(player);
1255 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1257 int result = MM_ERROR_NONE;
1259 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1260 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1262 MMPLAYER_CMD_LOCK(player);
1264 result = _mmplayer_360_is_enabled(player, enabled);
1266 MMPLAYER_CMD_UNLOCK(player);
1271 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1273 int result = MM_ERROR_NONE;
1274 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1276 MMPLAYER_CMD_LOCK(player);
1278 result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1280 MMPLAYER_CMD_UNLOCK(player);
1285 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1287 int result = MM_ERROR_NONE;
1289 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1290 MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1292 MMPLAYER_CMD_LOCK(player);
1294 result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1296 MMPLAYER_CMD_UNLOCK(player);
1301 int mm_player_360_set_zoom(MMHandleType player, float level)
1303 int result = MM_ERROR_NONE;
1304 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1306 MMPLAYER_CMD_LOCK(player);
1308 result = _mmplayer_360_set_zoom(player, level);
1310 MMPLAYER_CMD_UNLOCK(player);
1315 int mm_player_360_get_zoom(MMHandleType player, float *level)
1317 int result = MM_ERROR_NONE;
1319 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1320 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1322 MMPLAYER_CMD_LOCK(player);
1324 result = _mmplayer_360_get_zoom(player, level);
1326 MMPLAYER_CMD_UNLOCK(player);
1331 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1333 int result = MM_ERROR_NONE;
1334 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1336 MMPLAYER_CMD_LOCK(player);
1338 result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1340 MMPLAYER_CMD_UNLOCK(player);
1345 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1347 int result = MM_ERROR_NONE;
1349 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1350 MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1352 MMPLAYER_CMD_LOCK(player);
1354 result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1356 MMPLAYER_CMD_UNLOCK(player);
1361 int mm_player_set_codec_type(MMHandleType player, MMPlayerStreamType stream_type, MMPlayerVideoCodecType codec_type)
1363 int result = MM_ERROR_NONE;
1365 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1367 MMPLAYER_CMD_LOCK(player);
1369 result = _mmplayer_set_codec_type(player, stream_type, codec_type);
1371 MMPLAYER_CMD_UNLOCK(player);
1376 int mm_player_set_replaygain_enabled(MMHandleType player, bool enabled)
1378 int result = MM_ERROR_NONE;
1380 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1382 MMPLAYER_CMD_LOCK(player);
1384 result = _mmplayer_set_replaygain_enabled(player, enabled);
1386 MMPLAYER_CMD_UNLOCK(player);
1391 int mm_player_is_replaygain_enabled(MMHandleType player, bool *enabled)
1393 int result = MM_ERROR_NONE;
1395 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1396 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1398 MMPLAYER_CMD_LOCK(player);
1400 result = _mmplayer_is_replaygain_enabled(player, enabled);
1402 MMPLAYER_CMD_UNLOCK(player);
1407 int mm_player_set_video_roi_area(MMHandleType player, double scale_x, double scale_y, double scale_width, double scale_height)
1409 int result = MM_ERROR_NONE;
1411 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1413 MMPLAYER_CMD_LOCK(player);
1415 result = _mmplayer_set_video_roi_area(player, scale_x, scale_y, scale_width, scale_height);
1417 MMPLAYER_CMD_UNLOCK(player);
1422 int mm_player_get_video_roi_area(MMHandleType player, double *scale_x, double *scale_y, double *scale_width, double *scale_height)
1424 int result = MM_ERROR_NONE;
1426 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1428 MMPLAYER_CMD_LOCK(player);
1430 result = _mmplayer_get_video_roi_area(player, scale_x, scale_y, scale_width, scale_height);
1432 MMPLAYER_CMD_UNLOCK(player);