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_audio_stream_callback(MMHandleType player, bool sync, mm_player_audio_stream_callback callback, void *user_param)
189 int result = MM_ERROR_NONE;
191 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
193 MMPLAYER_CMD_LOCK(player);
195 result = _mmplayer_set_audiostream_cb(player, sync, callback, user_param);
197 MMPLAYER_CMD_UNLOCK(player);
202 int mm_player_set_video_stream_callback(MMHandleType player, mm_player_video_stream_callback callback, void *user_param)
204 int result = MM_ERROR_NONE;
206 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
208 MMPLAYER_CMD_LOCK(player);
210 result = _mmplayer_set_videostream_cb(player, callback, user_param);
212 MMPLAYER_CMD_UNLOCK(player);
217 int mm_player_do_video_capture(MMHandleType player)
219 int result = MM_ERROR_NONE;
221 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
223 MMPLAYER_CMD_LOCK(player);
225 result = _mmplayer_do_video_capture(player);
227 MMPLAYER_CMD_UNLOCK(player);
232 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume)
234 int result = MM_ERROR_NONE;
236 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
237 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
239 MMPLAYER_CMD_LOCK(player);
241 result = _mmplayer_set_volume(player, *volume);
243 MMPLAYER_CMD_UNLOCK(player);
248 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume)
250 int result = MM_ERROR_NONE;
252 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
253 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
255 MMPLAYER_CMD_LOCK(player);
257 result = _mmplayer_get_volume(player, volume);
259 MMPLAYER_CMD_UNLOCK(player);
264 int mm_player_set_mute(MMHandleType player, int mute)
266 int result = MM_ERROR_NONE;
268 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
270 MMPLAYER_CMD_LOCK(player);
272 result = _mmplayer_set_mute(player, mute);
274 MMPLAYER_CMD_UNLOCK(player);
279 int mm_player_get_mute(MMHandleType player, int *mute)
281 int result = MM_ERROR_NONE;
283 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
284 MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
286 MMPLAYER_CMD_LOCK(player);
288 result = _mmplayer_get_mute(player, mute);
290 MMPLAYER_CMD_UNLOCK(player);
295 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state)
297 int result = MM_ERROR_NONE;
299 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
300 MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
302 *state = MM_PLAYER_STATE_NULL;
304 result = _mmplayer_get_state(player, (int*)state);
309 /* NOTE : It does not support some use cases, eg using colorspace converter */
310 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
312 int result = MM_ERROR_NONE;
314 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
316 MMPLAYER_CMD_LOCK(player);
318 result = _mmplayer_change_videosink(player, display_surface_type, display_overlay);
320 MMPLAYER_CMD_UNLOCK(player);
325 int mm_player_start(MMHandleType player)
327 int result = MM_ERROR_NONE;
329 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
331 MMPLAYER_CMD_LOCK(player);
333 result = _mmplayer_start(player);
335 MMPLAYER_CMD_UNLOCK(player);
340 int mm_player_stop(MMHandleType player)
342 int result = MM_ERROR_NONE;
344 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
346 MMPLAYER_CMD_LOCK(player);
348 result = _mmplayer_stop(player);
350 MMPLAYER_CMD_UNLOCK(player);
355 int mm_player_pause(MMHandleType player)
357 int result = MM_ERROR_NONE;
359 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
361 MMPLAYER_CMD_LOCK(player);
363 result = _mmplayer_pause(player);
365 MMPLAYER_CMD_UNLOCK(player);
370 int mm_player_resume(MMHandleType player)
372 int result = MM_ERROR_NONE;
374 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
376 MMPLAYER_CMD_LOCK(player);
378 result = _mmplayer_resume(player);
380 MMPLAYER_CMD_UNLOCK(player);
385 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
387 int result = MM_ERROR_NONE;
389 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
391 MMPLAYER_CMD_LOCK(player);
393 result = _mmplayer_set_playspeed(player, rate, streaming);
395 MMPLAYER_CMD_UNLOCK(player);
400 int mm_player_set_position(MMHandleType player, int64_t pos)
402 int result = MM_ERROR_NONE;
404 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
406 MMPLAYER_CMD_LOCK(player);
408 result = _mmplayer_set_position(player, pos);
410 MMPLAYER_CMD_UNLOCK(player);
415 int mm_player_get_position(MMHandleType player, int64_t *pos)
417 int result = MM_ERROR_NONE;
419 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
420 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
422 MMPLAYER_CMD_LOCK(player);
424 result = _mmplayer_get_position(player, pos);
426 MMPLAYER_CMD_UNLOCK(player);
431 int mm_player_get_duration(MMHandleType player, int64_t *dur)
433 int result = MM_ERROR_NONE;
435 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
436 MMPLAYER_RETURN_VAL_IF_FAIL(dur, MM_ERROR_COMMON_INVALID_ARGUMENT);
438 MMPLAYER_CMD_LOCK(player);
440 result = _mmplayer_get_duration(player, dur);
442 MMPLAYER_CMD_UNLOCK(player);
448 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
450 int result = MM_ERROR_NONE;
452 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
453 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
455 MMPLAYER_CMD_LOCK(player);
457 result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos);
459 MMPLAYER_CMD_UNLOCK(player);
464 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
466 int result = MM_ERROR_NONE;
468 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
470 MMPLAYER_CMD_LOCK(player);
472 result = _mmplayer_set_external_subtitle_path(player, path);
474 MMPLAYER_CMD_UNLOCK(player);
478 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
480 int result = MM_ERROR_NONE;
482 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
484 if (format >= MM_PLAYER_POS_FORMAT_NUM) {
485 LOGE("wrong format(%d) \n", format);
486 return MM_ERROR_INVALID_ARGUMENT;
489 MMPLAYER_CMD_LOCK(player);
491 result = _mmplayer_adjust_subtitle_postion(player, format, pos);
493 MMPLAYER_CMD_UNLOCK(player);
498 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
500 int result = MM_ERROR_NONE;
502 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
504 MMPLAYER_CMD_LOCK(player);
506 result = _mmplayer_set_subtitle_silent(player, silent);
508 MMPLAYER_CMD_UNLOCK(player);
513 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
515 int result = MM_ERROR_NONE;
517 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
519 MMPLAYER_CMD_LOCK(player);
521 result = _mmplayer_get_subtitle_silent(player, silent);
523 MMPLAYER_CMD_UNLOCK(player);
528 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
530 int result = MM_ERROR_NONE;
533 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
534 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
536 va_start(var_args, first_attribute_name);
537 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
543 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
545 int result = MM_ERROR_NONE;
548 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
549 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
551 va_start(var_args, first_attribute_name);
552 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
558 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info)
560 int result = MM_ERROR_NONE;
563 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
564 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
565 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
567 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
572 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
574 int result = MM_ERROR_NONE;
576 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
577 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
579 MMPLAYER_CMD_LOCK(player);
581 result = _mmplayer_get_track_count(player, type, count);
583 MMPLAYER_CMD_UNLOCK(player);
588 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
590 int result = MM_ERROR_NONE;
592 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
594 MMPLAYER_CMD_LOCK(player);
596 result = _mmplayer_select_track(player, type, index);
598 MMPLAYER_CMD_UNLOCK(player);
603 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
605 int result = MM_ERROR_NONE;
607 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
608 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
610 MMPLAYER_CMD_LOCK(player);
612 result = _mmplayer_get_current_track(player, type, index);
614 MMPLAYER_CMD_UNLOCK(player);
619 int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code)
621 int result = MM_ERROR_NONE;
623 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
625 MMPLAYER_CMD_LOCK(player);
627 result = _mmplayer_get_track_language_code(player, type, index, code);
629 MMPLAYER_CMD_UNLOCK(player);
634 int mm_player_set_uri(MMHandleType player, const char *uri)
636 int result = MM_ERROR_NONE;
638 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
640 MMPLAYER_CMD_LOCK(player);
642 result = _mmplayer_set_uri(player, uri);
644 MMPLAYER_CMD_UNLOCK(player);
650 int mm_player_set_next_uri(MMHandleType player, const char *uri)
652 int result = MM_ERROR_NONE;
654 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
656 MMPLAYER_CMD_LOCK(player);
658 result = _mmplayer_set_next_uri(player, uri, FALSE);
660 MMPLAYER_CMD_UNLOCK(player);
666 int mm_player_get_next_uri(MMHandleType player, char **uri)
668 int result = MM_ERROR_NONE;
670 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
672 MMPLAYER_CMD_LOCK(player);
674 result = _mmplayer_get_next_uri(player, uri);
676 MMPLAYER_CMD_UNLOCK(player);
682 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
684 int result = MM_ERROR_NONE;
686 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
687 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
689 MMPLAYER_CMD_LOCK(player);
691 result = _mmplayer_has_closed_caption(player, exist);
693 MMPLAYER_CMD_UNLOCK(player);
698 void mm_player_video_stream_internal_buffer_unref(void *buffer)
700 _mm_player_video_stream_internal_buffer_unref(buffer);
703 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
706 int result = MM_ERROR_NONE;
708 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
710 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
711 //MMPLAYER_CMD_LOCK(player);
713 result = _mmplayer_submit_packet(player, packet);
715 //MMPLAYER_CMD_UNLOCK(player);
720 int mm_player_set_video_info(MMHandleType player, media_format_h format)
722 int result = MM_ERROR_NONE;
726 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
728 MMPLAYER_CMD_LOCK(player);
730 result = _mmplayer_set_video_info(player, format);
732 MMPLAYER_CMD_UNLOCK(player);
738 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
740 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_set_audio_info(player, format);
750 MMPLAYER_CMD_UNLOCK(player);
755 int mm_player_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
757 int result = MM_ERROR_NONE;
761 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
763 MMPLAYER_CMD_LOCK(player);
765 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
767 MMPLAYER_CMD_UNLOCK(player);
772 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
774 int result = MM_ERROR_NONE;
778 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
780 MMPLAYER_CMD_LOCK(player);
782 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
784 MMPLAYER_CMD_UNLOCK(player);
789 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
791 int result = MM_ERROR_NONE;
792 guint64 _max_size = 0;
796 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
797 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
799 MMPLAYER_CMD_LOCK(player);
801 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
802 *max_size = _max_size;
804 MMPLAYER_CMD_UNLOCK(player);
809 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
811 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_set_media_stream_min_percent(player, type, min_percent);
821 MMPLAYER_CMD_UNLOCK(player);
826 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
828 int result = MM_ERROR_NONE;
832 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
833 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
835 MMPLAYER_CMD_LOCK(player);
837 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
839 MMPLAYER_CMD_UNLOCK(player);
844 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
846 int result = MM_ERROR_NONE;
850 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
852 MMPLAYER_CMD_LOCK(player);
854 result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
856 MMPLAYER_CMD_UNLOCK(player);
861 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
863 int result = MM_ERROR_NONE;
867 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
869 MMPLAYER_CMD_LOCK(player);
871 result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
873 MMPLAYER_CMD_UNLOCK(player);
878 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
880 int result = MM_ERROR_NONE;
882 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
884 MMPLAYER_CMD_LOCK(player);
886 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
888 MMPLAYER_CMD_UNLOCK(player);
893 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
895 int result = MM_ERROR_NONE;
897 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
899 MMPLAYER_CMD_LOCK(player);
901 result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
903 MMPLAYER_CMD_UNLOCK(player);
908 int mm_player_get_timeout(MMHandleType player, int *timeout)
910 int result = MM_ERROR_NONE;
912 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
913 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
915 MMPLAYER_CMD_LOCK(player);
917 result = _mmplayer_get_timeout(player, timeout);
919 MMPLAYER_CMD_UNLOCK(player);
924 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
926 int result = MM_ERROR_NONE;
928 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
929 MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
931 MMPLAYER_CMD_LOCK(player);
933 result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
935 MMPLAYER_CMD_UNLOCK(player);
940 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
942 int result = MM_ERROR_NONE;
944 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
946 MMPLAYER_CMD_LOCK(player);
948 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
950 MMPLAYER_CMD_UNLOCK(player);
955 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
957 int result = MM_ERROR_NONE;
959 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
960 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
962 //MMPLAYER_CMD_LOCK(player);
964 result = _mmplayer_video_stream_release_bo(player, bo);
966 //MMPLAYER_CMD_UNLOCK(player);
971 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
973 int result = MM_ERROR_NONE;
975 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
977 MMPLAYER_CMD_LOCK(player);
979 result = _mmplayer_set_file_buffering_path(player, file_path);
981 MMPLAYER_CMD_UNLOCK(player);
986 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
988 int result = MM_ERROR_NONE;
990 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
991 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
993 MMPLAYER_CMD_LOCK(player);
995 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
997 MMPLAYER_CMD_UNLOCK(player);
1002 int mm_player_manage_external_storage_state(MMHandleType player, int id, int state)
1004 int result = MM_ERROR_NONE;
1006 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1008 MMPLAYER_CMD_LOCK(player);
1010 result = _mmplayer_manage_external_storage_state(player, id, state);
1012 MMPLAYER_CMD_UNLOCK(player);
1017 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1019 int result = MM_ERROR_NONE;
1021 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1022 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1024 MMPLAYER_CMD_LOCK(player);
1026 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1028 MMPLAYER_CMD_UNLOCK(player);
1033 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1035 int result = MM_ERROR_NONE;
1037 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1039 MMPLAYER_CMD_LOCK(player);
1041 result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
1043 MMPLAYER_CMD_UNLOCK(player);
1048 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1050 int result = MM_ERROR_NONE;
1052 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1053 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1055 MMPLAYER_CMD_LOCK(player);
1057 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1059 MMPLAYER_CMD_UNLOCK(player);
1064 int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, int rebuffer_ms)
1066 int result = MM_ERROR_NONE;
1067 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1069 MMPLAYER_CMD_LOCK(player);
1071 result = _mmplayer_set_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1073 MMPLAYER_CMD_UNLOCK(player);
1078 int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms)
1080 int result = MM_ERROR_NONE;
1082 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1083 MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1085 MMPLAYER_CMD_LOCK(player);
1087 result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1089 MMPLAYER_CMD_UNLOCK(player);
1094 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1096 int result = MM_ERROR_NONE;
1097 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1099 MMPLAYER_CMD_LOCK(player);
1101 result = _mmplayer_set_audio_only(player, audio_only);
1103 MMPLAYER_CMD_UNLOCK(player);
1108 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1110 int result = MM_ERROR_NONE;
1112 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1113 MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1115 MMPLAYER_CMD_LOCK(player);
1117 result = _mmplayer_get_audio_only(player, audio_only);
1119 MMPLAYER_CMD_UNLOCK(player);
1124 int mm_player_360_is_content_spherical(MMHandleType player, bool *is_spherical)
1126 int result = MM_ERROR_NONE;
1128 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1129 MMPLAYER_RETURN_VAL_IF_FAIL(is_spherical, MM_ERROR_INVALID_ARGUMENT);
1131 MMPLAYER_CMD_LOCK(player);
1133 result = _mmplayer_360_is_content_spherical(player, is_spherical);
1135 MMPLAYER_CMD_UNLOCK(player);
1140 int mm_player_360_set_enabled(MMHandleType player, bool enabled)
1142 int result = MM_ERROR_NONE;
1143 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1145 MMPLAYER_CMD_LOCK(player);
1147 result = _mmplayer_360_set_enabled(player, enabled);
1149 MMPLAYER_CMD_UNLOCK(player);
1154 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1156 int result = MM_ERROR_NONE;
1158 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1159 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1161 MMPLAYER_CMD_LOCK(player);
1163 result = _mmplayer_360_is_enabled(player, enabled);
1165 MMPLAYER_CMD_UNLOCK(player);
1170 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1172 int result = MM_ERROR_NONE;
1173 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1175 MMPLAYER_CMD_LOCK(player);
1177 result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1179 MMPLAYER_CMD_UNLOCK(player);
1184 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1186 int result = MM_ERROR_NONE;
1188 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1189 MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1191 MMPLAYER_CMD_LOCK(player);
1193 result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1195 MMPLAYER_CMD_UNLOCK(player);
1200 int mm_player_360_set_zoom(MMHandleType player, float level)
1202 int result = MM_ERROR_NONE;
1203 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1205 MMPLAYER_CMD_LOCK(player);
1207 result = _mmplayer_360_set_zoom(player, level);
1209 MMPLAYER_CMD_UNLOCK(player);
1214 int mm_player_360_get_zoom(MMHandleType player, float *level)
1216 int result = MM_ERROR_NONE;
1218 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1219 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1221 MMPLAYER_CMD_LOCK(player);
1223 result = _mmplayer_360_get_zoom(player, level);
1225 MMPLAYER_CMD_UNLOCK(player);
1230 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1232 int result = MM_ERROR_NONE;
1233 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1235 MMPLAYER_CMD_LOCK(player);
1237 result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1239 MMPLAYER_CMD_UNLOCK(player);
1244 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1246 int result = MM_ERROR_NONE;
1248 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1249 MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1251 MMPLAYER_CMD_LOCK(player);
1253 result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1255 MMPLAYER_CMD_UNLOCK(player);
1260 int mm_player_set_codec_type(MMHandleType player, MMPlayerStreamType stream_type, MMPlayerVideoCodecType codec_type)
1262 int result = MM_ERROR_NONE;
1264 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1266 MMPLAYER_CMD_LOCK(player);
1268 result = _mmplayer_set_codec_type(player, stream_type, codec_type);
1270 MMPLAYER_CMD_UNLOCK(player);
1275 int mm_player_set_replaygain_enabled(MMHandleType player, bool enabled)
1277 int result = MM_ERROR_NONE;
1279 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1281 MMPLAYER_CMD_LOCK(player);
1283 result = _mmplayer_set_replaygain_enabled(player, enabled);
1285 MMPLAYER_CMD_UNLOCK(player);
1290 int mm_player_is_replaygain_enabled(MMHandleType player, bool *enabled)
1292 int result = MM_ERROR_NONE;
1294 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1295 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1297 MMPLAYER_CMD_LOCK(player);
1299 result = _mmplayer_is_replaygain_enabled(player, enabled);
1301 MMPLAYER_CMD_UNLOCK(player);
1306 int mm_player_set_video_roi_area(MMHandleType player, double scale_x, double scale_y, double scale_width, double scale_height)
1308 int result = MM_ERROR_NONE;
1310 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1312 MMPLAYER_CMD_LOCK(player);
1314 result = _mmplayer_set_video_roi_area(player, scale_x, scale_y, scale_width, scale_height);
1316 MMPLAYER_CMD_UNLOCK(player);
1321 int mm_player_get_video_roi_area(MMHandleType player, double *scale_x, double *scale_y, double *scale_width, double *scale_height)
1323 int result = MM_ERROR_NONE;
1325 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1327 MMPLAYER_CMD_LOCK(player);
1329 result = _mmplayer_get_video_roi_area(player, scale_x, scale_y, scale_width, scale_height);
1331 MMPLAYER_CMD_UNLOCK(player);