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"
39 #include "mm_player_gst.h"
41 int mm_player_create(MMHandleType *player)
43 int result = MM_ERROR_PLAYER_INTERNAL;
44 mmplayer_t *new_player = NULL;
46 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
48 /* alloc player structure */
49 new_player = g_try_new0(mmplayer_t, 1);
51 LOGE("Cannot allocate memory for player\n");
52 result = MM_ERROR_PLAYER_RESOURCE_LIMIT;
56 /* create player lock and cond */
57 MMPLAYER_CMD_LOCK_INIT(new_player);
58 g_mutex_init(&new_player->reconfigure_lock);
59 g_cond_init(&new_player->reconfigure_cond);
62 if (MM_ERROR_NONE != mm_player_ini_load(&new_player->ini)) {
63 LOGE("can't load ini");
67 if (MM_ERROR_NONE != mm_player_audio_effect_ini_load(&new_player->ini)) {
68 LOGE("can't load audio ini");
73 result = _mmplayer_create_player((MMHandleType)new_player);
74 if (result != MM_ERROR_NONE) {
75 LOGE("failed to create player");
76 if (result != MM_ERROR_PLAYER_RESOURCE_LIMIT)
77 result = MM_ERROR_PLAYER_INTERNAL;
81 *player = (MMHandleType)new_player;
88 _mmplayer_destroy((MMHandleType)new_player);
89 MMPLAYER_CMD_LOCK_DEINIT(new_player);
90 g_mutex_clear(&new_player->reconfigure_lock);
91 g_cond_clear(&new_player->reconfigure_cond);
92 MMPLAYER_FREEIF(new_player);
95 *player = (MMHandleType)0;
96 return result; /* MM_ERROR_PLAYER_INTERNAL or MM_ERROR_PLAYER_RESOURCE_LIMIT */
99 int mm_player_destroy(MMHandleType player)
101 int result = MM_ERROR_NONE;
103 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
105 _mmplayer_bus_watcher_remove(player);
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 MMPLAYER_CMD_LOCK(player);
117 MMPLAYER_CMD_UNLOCK(player);
119 MMPLAYER_CMD_LOCK_DEINIT(player);
120 g_mutex_clear(&((mmplayer_t *)player)->reconfigure_lock);
121 g_cond_clear(&((mmplayer_t *)player)->reconfigure_cond);
123 memset((mmplayer_t *)player, 0x00, sizeof(mmplayer_t));
126 g_free((void *)player);
131 int mm_player_realize(MMHandleType player)
133 int result = MM_ERROR_NONE;
135 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
137 MMPLAYER_CMD_LOCK(player);
139 result = _mmplayer_realize(player);
141 MMPLAYER_CMD_UNLOCK(player);
146 int mm_player_abort_pause(MMHandleType player)
148 int result = MM_ERROR_NONE;
150 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
152 _mmplayer_bus_watcher_remove(player);
153 /* destroy the gst bus msg thread not to be blocked in pause(without cmd lock). */
154 _mmplayer_bus_msg_thread_destroy(player);
156 /* abort the pause operation for preparing(without cmd lock). */
157 result = _mmplayer_abort_pause(player);
162 int mm_player_unrealize(MMHandleType player)
164 int result = MM_ERROR_NONE;
166 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
168 MMPLAYER_CMD_LOCK(player);
170 result = _mmplayer_unrealize(player);
172 MMPLAYER_CMD_UNLOCK(player);
177 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
179 int result = MM_ERROR_NONE;
181 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
183 MMPLAYER_CMD_LOCK(player);
185 result = _mmplayer_set_message_callback(player, callback, user_param);
187 MMPLAYER_CMD_UNLOCK(player);
192 int mm_player_set_audio_decoded_callback(MMHandleType player, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param)
194 int result = MM_ERROR_NONE;
196 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
198 MMPLAYER_CMD_LOCK(player);
200 result = _mmplayer_set_audio_decoded_cb(player, opt, callback, user_param);
202 MMPLAYER_CMD_UNLOCK(player);
207 int mm_player_set_video_decoded_callback(MMHandleType player, mm_player_video_decoded_callback callback, void *user_param)
209 int result = MM_ERROR_NONE;
211 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
213 MMPLAYER_CMD_LOCK(player);
215 result = _mmplayer_set_video_decoded_cb(player, callback, user_param);
217 MMPLAYER_CMD_UNLOCK(player);
222 int mm_player_do_video_capture(MMHandleType player)
224 int result = MM_ERROR_NONE;
226 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
228 MMPLAYER_CMD_LOCK(player);
230 result = _mmplayer_do_video_capture(player);
232 MMPLAYER_CMD_UNLOCK(player);
237 int mm_player_set_volume(MMHandleType player, float volume)
239 int result = MM_ERROR_NONE;
241 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
243 MMPLAYER_CMD_LOCK(player);
245 result = _mmplayer_set_volume(player, volume);
247 MMPLAYER_CMD_UNLOCK(player);
252 int mm_player_get_volume(MMHandleType player, float *volume)
254 int result = MM_ERROR_NONE;
256 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
257 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
259 MMPLAYER_CMD_LOCK(player);
261 result = _mmplayer_get_volume(player, volume);
263 MMPLAYER_CMD_UNLOCK(player);
268 int mm_player_set_mute(MMHandleType player, bool mute)
270 int result = MM_ERROR_NONE;
272 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
274 MMPLAYER_CMD_LOCK(player);
276 result = _mmplayer_set_mute(player, mute);
278 MMPLAYER_CMD_UNLOCK(player);
283 int mm_player_get_mute(MMHandleType player, bool *mute)
285 int result = MM_ERROR_NONE;
287 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
288 MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
290 MMPLAYER_CMD_LOCK(player);
292 result = _mmplayer_get_mute(player, mute);
294 MMPLAYER_CMD_UNLOCK(player);
299 int mm_player_get_state(MMHandleType player, mmplayer_state_e *state)
301 int result = MM_ERROR_NONE;
303 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
304 MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
306 *state = MM_PLAYER_STATE_NULL;
308 result = _mmplayer_get_state(player, (int *)state);
313 /* NOTE : It does not support some use cases, eg using colorspace converter */
314 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, int wl_surface_id)
316 int result = MM_ERROR_NONE;
318 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
320 MMPLAYER_CMD_LOCK(player);
322 result = _mmplayer_change_videosink(player, display_surface_type, wl_surface_id);
324 MMPLAYER_CMD_UNLOCK(player);
329 int mm_player_start(MMHandleType player)
331 int result = MM_ERROR_NONE;
333 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
335 MMPLAYER_CMD_LOCK(player);
337 result = _mmplayer_start(player);
339 MMPLAYER_CMD_UNLOCK(player);
344 int mm_player_stop(MMHandleType player)
346 int result = MM_ERROR_NONE;
348 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
350 MMPLAYER_CMD_LOCK(player);
352 result = _mmplayer_stop(player);
354 MMPLAYER_CMD_UNLOCK(player);
359 int mm_player_pause(MMHandleType player)
361 int result = MM_ERROR_NONE;
363 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
365 MMPLAYER_CMD_LOCK(player);
367 result = _mmplayer_pause(player);
369 MMPLAYER_CMD_UNLOCK(player);
374 int mm_player_resume(MMHandleType player)
376 int result = MM_ERROR_NONE;
378 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
380 MMPLAYER_CMD_LOCK(player);
382 result = _mmplayer_resume(player);
384 MMPLAYER_CMD_UNLOCK(player);
389 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
391 int result = MM_ERROR_NONE;
393 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
395 MMPLAYER_CMD_LOCK(player);
397 result = _mmplayer_set_playspeed(player, rate, streaming);
399 MMPLAYER_CMD_UNLOCK(player);
404 int mm_player_set_position(MMHandleType player, int64_t pos)
406 int result = MM_ERROR_NONE;
408 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
410 MMPLAYER_CMD_LOCK(player);
412 result = _mmplayer_set_position(player, pos);
414 MMPLAYER_CMD_UNLOCK(player);
419 int mm_player_get_position(MMHandleType player, int64_t *pos)
421 int result = MM_ERROR_NONE;
423 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
424 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
426 MMPLAYER_CMD_LOCK(player);
428 result = _mmplayer_gst_get_position((mmplayer_t *)player, pos);
430 MMPLAYER_CMD_UNLOCK(player);
435 int mm_player_get_duration(MMHandleType player, int64_t *dur)
437 int result = MM_ERROR_NONE;
439 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
440 MMPLAYER_RETURN_VAL_IF_FAIL(dur, MM_ERROR_COMMON_INVALID_ARGUMENT);
442 MMPLAYER_CMD_LOCK(player);
444 result = _mmplayer_get_duration(player, dur);
446 MMPLAYER_CMD_UNLOCK(player);
452 int mm_player_get_buffer_position(MMHandleType player, int *start_pos, int *end_pos)
454 int result = MM_ERROR_NONE;
456 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
457 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && end_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
459 MMPLAYER_CMD_LOCK(player);
461 result = _mmplayer_get_buffer_position(player, start_pos, end_pos);
463 MMPLAYER_CMD_UNLOCK(player);
468 int mm_player_set_external_subtitle_path(MMHandleType player, const char *path)
470 int result = MM_ERROR_NONE;
472 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
474 MMPLAYER_CMD_LOCK(player);
476 result = _mmplayer_set_external_subtitle_path(player, path);
478 MMPLAYER_CMD_UNLOCK(player);
482 int mm_player_adjust_subtitle_position(MMHandleType player, int pos)
484 int result = MM_ERROR_NONE;
486 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
488 MMPLAYER_CMD_LOCK(player);
490 result = _mmplayer_adjust_subtitle_postion(player, pos);
492 MMPLAYER_CMD_UNLOCK(player);
497 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
499 int result = MM_ERROR_NONE;
501 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
503 MMPLAYER_CMD_LOCK(player);
505 result = _mmplayer_set_subtitle_silent(player, silent);
507 MMPLAYER_CMD_UNLOCK(player);
512 int mm_player_get_subtitle_silent(MMHandleType player, int *silent)
514 int result = MM_ERROR_NONE;
516 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
518 MMPLAYER_CMD_LOCK(player);
520 result = _mmplayer_get_subtitle_silent(player, silent);
522 MMPLAYER_CMD_UNLOCK(player);
527 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
529 int result = MM_ERROR_NONE;
532 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
533 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
535 va_start(var_args, first_attribute_name);
536 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
542 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
544 int result = MM_ERROR_NONE;
547 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
548 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
550 va_start(var_args, first_attribute_name);
551 result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
557 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, mmplayer_attrs_info_t *info)
559 int result = MM_ERROR_NONE;
562 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
563 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
564 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
566 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
571 int mm_player_get_track_count(MMHandleType player, mmplayer_track_type_e type, int *count)
573 int result = MM_ERROR_NONE;
575 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
576 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
578 MMPLAYER_CMD_LOCK(player);
580 result = _mmplayer_get_track_count(player, type, count);
582 MMPLAYER_CMD_UNLOCK(player);
587 int mm_player_select_track(MMHandleType player, mmplayer_track_type_e type, int index)
589 int result = MM_ERROR_NONE;
591 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
593 MMPLAYER_CMD_LOCK(player);
595 result = _mmplayer_select_track(player, type, index);
597 MMPLAYER_CMD_UNLOCK(player);
602 int mm_player_get_current_track(MMHandleType player, mmplayer_track_type_e type, int *index)
604 int result = MM_ERROR_NONE;
606 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
607 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
609 MMPLAYER_CMD_LOCK(player);
611 result = _mmplayer_get_current_track(player, type, index);
613 MMPLAYER_CMD_UNLOCK(player);
618 int mm_player_get_track_language_code(MMHandleType player, mmplayer_track_type_e type, int index, char **code)
620 int result = MM_ERROR_NONE;
622 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
624 MMPLAYER_CMD_LOCK(player);
626 result = _mmplayer_get_track_language_code(player, type, index, code);
628 MMPLAYER_CMD_UNLOCK(player);
633 int mm_player_set_uri(MMHandleType player, const char *uri)
635 int result = MM_ERROR_NONE;
637 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
639 MMPLAYER_CMD_LOCK(player);
641 result = _mmplayer_set_uri(player, uri);
643 MMPLAYER_CMD_UNLOCK(player);
649 int mm_player_set_next_uri(MMHandleType player, const char *uri)
651 int result = MM_ERROR_NONE;
653 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
655 MMPLAYER_CMD_LOCK(player);
657 result = _mmplayer_set_next_uri(player, uri, FALSE);
659 MMPLAYER_CMD_UNLOCK(player);
665 int mm_player_get_next_uri(MMHandleType player, char **uri)
667 int result = MM_ERROR_NONE;
669 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
671 MMPLAYER_CMD_LOCK(player);
673 result = _mmplayer_get_next_uri(player, uri);
675 MMPLAYER_CMD_UNLOCK(player);
681 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
683 int result = MM_ERROR_NONE;
685 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
686 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
688 MMPLAYER_CMD_LOCK(player);
690 result = _mmplayer_has_closed_caption(player, exist);
692 MMPLAYER_CMD_UNLOCK(player);
697 void mm_player_video_stream_internal_buffer_unref(void *buffer)
699 _mm_player_video_stream_internal_buffer_unref(buffer);
702 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
705 int result = MM_ERROR_NONE;
707 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
709 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
710 //MMPLAYER_CMD_LOCK(player);
712 result = _mmplayer_submit_packet(player, packet);
714 //MMPLAYER_CMD_UNLOCK(player);
719 int mm_player_set_video_info(MMHandleType player, media_format_h format)
721 int result = MM_ERROR_NONE;
725 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
727 MMPLAYER_CMD_LOCK(player);
729 result = _mmplayer_set_video_info(player, format);
731 MMPLAYER_CMD_UNLOCK(player);
737 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
739 int result = MM_ERROR_NONE;
743 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
745 MMPLAYER_CMD_LOCK(player);
747 result = _mmplayer_set_audio_info(player, format);
749 MMPLAYER_CMD_UNLOCK(player);
754 int mm_player_set_subtitle_info(MMHandleType player, mmplayer_subtitle_stream_info_t *subtitle_stream_info)
756 int result = MM_ERROR_NONE;
760 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
762 MMPLAYER_CMD_LOCK(player);
764 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
766 MMPLAYER_CMD_UNLOCK(player);
771 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long max_size)
773 int result = MM_ERROR_NONE;
777 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
779 MMPLAYER_CMD_LOCK(player);
781 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
783 MMPLAYER_CMD_UNLOCK(player);
788 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long *max_size)
790 int result = MM_ERROR_NONE;
791 guint64 _max_size = 0;
795 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
796 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
798 MMPLAYER_CMD_LOCK(player);
800 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
801 *max_size = _max_size;
803 MMPLAYER_CMD_UNLOCK(player);
808 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned min_percent)
810 int result = MM_ERROR_NONE;
814 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
816 MMPLAYER_CMD_LOCK(player);
818 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
820 MMPLAYER_CMD_UNLOCK(player);
825 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned int *min_percent)
827 int result = MM_ERROR_NONE;
831 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
832 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
834 MMPLAYER_CMD_LOCK(player);
836 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
838 MMPLAYER_CMD_UNLOCK(player);
843 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
845 int result = MM_ERROR_NONE;
847 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
849 MMPLAYER_CMD_LOCK(player);
851 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
853 MMPLAYER_CMD_UNLOCK(player);
858 int mm_player_get_timeout(MMHandleType player, int *timeout)
860 int result = MM_ERROR_NONE;
862 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
863 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
865 MMPLAYER_CMD_LOCK(player);
867 result = _mmplayer_get_timeout(player, timeout);
869 MMPLAYER_CMD_UNLOCK(player);
874 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
876 int result = MM_ERROR_NONE;
878 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
880 MMPLAYER_CMD_LOCK(player);
882 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
884 MMPLAYER_CMD_UNLOCK(player);
889 int mm_player_release_video_stream_bo(MMHandleType player, void *bo)
891 int result = MM_ERROR_NONE;
893 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
894 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
896 //MMPLAYER_CMD_LOCK(player);
898 result = _mmplayer_video_stream_release_bo(player, bo);
900 //MMPLAYER_CMD_UNLOCK(player);
905 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
907 int result = MM_ERROR_NONE;
909 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
910 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
912 MMPLAYER_CMD_LOCK(player);
914 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
916 MMPLAYER_CMD_UNLOCK(player);
921 int mm_player_manage_external_storage_state(MMHandleType player, int id, int state)
923 int result = MM_ERROR_NONE;
925 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
927 MMPLAYER_CMD_LOCK(player);
929 result = _mmplayer_manage_external_storage_state(player, id, state);
931 MMPLAYER_CMD_UNLOCK(player);
936 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
938 int result = MM_ERROR_NONE;
940 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
941 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
943 MMPLAYER_CMD_LOCK(player);
945 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
947 MMPLAYER_CMD_UNLOCK(player);
952 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
954 int result = MM_ERROR_NONE;
956 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
958 MMPLAYER_CMD_LOCK(player);
960 result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
962 MMPLAYER_CMD_UNLOCK(player);
967 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
969 int result = MM_ERROR_NONE;
971 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
972 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
974 MMPLAYER_CMD_LOCK(player);
976 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
978 MMPLAYER_CMD_UNLOCK(player);
983 int mm_player_get_streaming_buffering_time(MMHandleType player, int *prebuffer_ms, int *rebuffer_ms)
985 int result = MM_ERROR_NONE;
987 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
988 MMPLAYER_RETURN_VAL_IF_FAIL(prebuffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
990 MMPLAYER_CMD_LOCK(player);
992 result = _mmplayer_get_streaming_buffering_time(player, prebuffer_ms, rebuffer_ms);
994 MMPLAYER_CMD_UNLOCK(player);
999 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1001 int result = MM_ERROR_NONE;
1002 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1004 MMPLAYER_CMD_LOCK(player);
1006 result = _mmplayer_set_audio_only(player, audio_only);
1008 MMPLAYER_CMD_UNLOCK(player);
1013 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1015 int result = MM_ERROR_NONE;
1017 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1018 MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1020 MMPLAYER_CMD_LOCK(player);
1022 result = _mmplayer_get_audio_only(player, audio_only);
1024 MMPLAYER_CMD_UNLOCK(player);
1029 int mm_player_360_is_content_spherical(MMHandleType player, bool *is_spherical)
1031 int result = MM_ERROR_NONE;
1033 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1034 MMPLAYER_RETURN_VAL_IF_FAIL(is_spherical, MM_ERROR_INVALID_ARGUMENT);
1036 MMPLAYER_CMD_LOCK(player);
1038 result = _mmplayer_360_is_content_spherical(player, is_spherical);
1040 MMPLAYER_CMD_UNLOCK(player);
1045 int mm_player_360_set_enabled(MMHandleType player, bool enabled)
1047 int result = MM_ERROR_NONE;
1048 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1050 MMPLAYER_CMD_LOCK(player);
1052 result = _mmplayer_360_set_enabled(player, enabled);
1054 MMPLAYER_CMD_UNLOCK(player);
1059 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1061 int result = MM_ERROR_NONE;
1063 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1064 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1066 MMPLAYER_CMD_LOCK(player);
1068 result = _mmplayer_360_is_enabled(player, enabled);
1070 MMPLAYER_CMD_UNLOCK(player);
1075 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1077 int result = MM_ERROR_NONE;
1078 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1080 MMPLAYER_CMD_LOCK(player);
1082 result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1084 MMPLAYER_CMD_UNLOCK(player);
1089 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1091 int result = MM_ERROR_NONE;
1093 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1094 MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1096 MMPLAYER_CMD_LOCK(player);
1098 result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1100 MMPLAYER_CMD_UNLOCK(player);
1105 int mm_player_360_set_zoom(MMHandleType player, float level)
1107 int result = MM_ERROR_NONE;
1108 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1110 MMPLAYER_CMD_LOCK(player);
1112 result = _mmplayer_360_set_zoom(player, level);
1114 MMPLAYER_CMD_UNLOCK(player);
1119 int mm_player_360_get_zoom(MMHandleType player, float *level)
1121 int result = MM_ERROR_NONE;
1123 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1124 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1126 MMPLAYER_CMD_LOCK(player);
1128 result = _mmplayer_360_get_zoom(player, level);
1130 MMPLAYER_CMD_UNLOCK(player);
1135 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1137 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_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1144 MMPLAYER_CMD_UNLOCK(player);
1149 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1151 int result = MM_ERROR_NONE;
1153 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1154 MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1156 MMPLAYER_CMD_LOCK(player);
1158 result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1160 MMPLAYER_CMD_UNLOCK(player);
1165 int mm_player_set_codec_type(MMHandleType player, mmplayer_stream_type_e stream_type, mmplayer_codec_type_e codec_type)
1167 int result = MM_ERROR_NONE;
1169 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1171 MMPLAYER_CMD_LOCK(player);
1173 result = _mmplayer_set_codec_type(player, stream_type, codec_type);
1175 MMPLAYER_CMD_UNLOCK(player);
1180 int mm_player_set_replaygain_enabled(MMHandleType player, bool enabled)
1182 int result = MM_ERROR_NONE;
1184 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1186 MMPLAYER_CMD_LOCK(player);
1188 result = _mmplayer_set_replaygain_enabled(player, enabled);
1190 MMPLAYER_CMD_UNLOCK(player);
1195 int mm_player_is_replaygain_enabled(MMHandleType player, bool *enabled)
1197 int result = MM_ERROR_NONE;
1199 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1200 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1202 MMPLAYER_CMD_LOCK(player);
1204 result = _mmplayer_is_replaygain_enabled(player, enabled);
1206 MMPLAYER_CMD_UNLOCK(player);
1211 int mm_player_set_video_roi_area(MMHandleType player, double scale_x, double scale_y, double scale_width, double scale_height)
1213 int result = MM_ERROR_NONE;
1215 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1217 MMPLAYER_CMD_LOCK(player);
1219 result = _mmplayer_set_video_roi_area(player, scale_x, scale_y, scale_width, scale_height);
1221 MMPLAYER_CMD_UNLOCK(player);
1226 int mm_player_get_video_roi_area(MMHandleType player, double *scale_x, double *scale_y, double *scale_width, double *scale_height)
1228 int result = MM_ERROR_NONE;
1230 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1232 MMPLAYER_CMD_LOCK(player);
1234 result = _mmplayer_get_video_roi_area(player, scale_x, scale_y, scale_width, scale_height);
1236 MMPLAYER_CMD_UNLOCK(player);
1241 int mm_player_set_client_pid(MMHandleType player, int pid)
1243 int result = MM_ERROR_NONE;
1245 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1247 MMPLAYER_CMD_LOCK(player);
1249 result = _mmplayer_set_client_pid(player, pid);
1251 MMPLAYER_CMD_UNLOCK(player);
1256 int mm_player_audio_offload_is_activated(MMHandleType player, bool *activated)
1258 int result = MM_ERROR_NONE;
1260 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1261 MMPLAYER_RETURN_VAL_IF_FAIL(activated, MM_ERROR_INVALID_ARGUMENT);
1263 MMPLAYER_CMD_LOCK(player);
1265 result = _mmplayer_audio_offload_is_activated(player, activated);
1267 MMPLAYER_CMD_UNLOCK(player);
1272 int mm_player_is_audio_control_available(MMHandleType player, mmplayer_audio_control_opt_e opt, bool *available)
1274 int result = MM_ERROR_NONE;
1276 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1277 MMPLAYER_RETURN_VAL_IF_FAIL(available, MM_ERROR_INVALID_ARGUMENT);
1279 MMPLAYER_CMD_LOCK(player);
1280 result = _mmplayer_is_audio_control_available(player, opt, available);
1281 MMPLAYER_CMD_UNLOCK(player);