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 g_mutex_init(&new_player->cmd_lock);
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 g_mutex_clear(&new_player->cmd_lock);
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 g_mutex_clear(&((mmplayer_t *)player)->cmd_lock);
117 g_mutex_clear(&((mmplayer_t *)player)->reconfigure_lock);
118 g_cond_clear(&((mmplayer_t *)player)->reconfigure_cond);
120 memset((mmplayer_t *)player, 0x00, sizeof(mmplayer_t));
123 g_free((void *)player);
128 int mm_player_realize(MMHandleType player)
130 int result = MM_ERROR_NONE;
132 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
134 MMPLAYER_CMD_LOCK(player);
136 result = _mmplayer_realize(player);
138 MMPLAYER_CMD_UNLOCK(player);
143 int mm_player_abort_pause(MMHandleType player)
145 int result = MM_ERROR_NONE;
147 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
149 _mmplayer_bus_watcher_remove(player);
150 /* destroy the gst bus msg thread not to be blocked in pause(without cmd lock). */
151 _mmplayer_bus_msg_thread_destroy(player);
153 /* abort the pause operation for preparing(without cmd lock). */
154 result = _mmplayer_abort_pause(player);
159 int mm_player_unrealize(MMHandleType player)
161 int result = MM_ERROR_NONE;
163 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
165 MMPLAYER_CMD_LOCK(player);
167 result = _mmplayer_unrealize(player);
169 MMPLAYER_CMD_UNLOCK(player);
174 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
176 int result = MM_ERROR_NONE;
178 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
180 MMPLAYER_CMD_LOCK(player);
182 result = _mmplayer_set_message_callback(player, callback, user_param);
184 MMPLAYER_CMD_UNLOCK(player);
189 int mm_player_set_audio_decoded_callback(MMHandleType player, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param)
191 int result = MM_ERROR_NONE;
193 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
195 MMPLAYER_CMD_LOCK(player);
197 result = _mmplayer_set_audio_decoded_cb(player, opt, callback, user_param);
199 MMPLAYER_CMD_UNLOCK(player);
204 int mm_player_set_video_decoded_callback(MMHandleType player, mm_player_video_decoded_callback callback, void *user_param)
206 int result = MM_ERROR_NONE;
208 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
210 MMPLAYER_CMD_LOCK(player);
212 result = _mmplayer_set_video_decoded_cb(player, callback, user_param);
214 MMPLAYER_CMD_UNLOCK(player);
219 int mm_player_do_video_capture(MMHandleType player)
221 int result = MM_ERROR_NONE;
223 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
225 MMPLAYER_CMD_LOCK(player);
227 result = _mmplayer_do_video_capture(player);
229 MMPLAYER_CMD_UNLOCK(player);
234 int mm_player_set_volume(MMHandleType player, float volume)
236 int result = MM_ERROR_NONE;
238 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
240 MMPLAYER_CMD_LOCK(player);
242 result = _mmplayer_set_volume(player, volume);
244 MMPLAYER_CMD_UNLOCK(player);
249 int mm_player_get_volume(MMHandleType player, float *volume)
251 int result = MM_ERROR_NONE;
253 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
254 MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
256 MMPLAYER_CMD_LOCK(player);
258 result = _mmplayer_get_volume(player, volume);
260 MMPLAYER_CMD_UNLOCK(player);
265 int mm_player_set_mute(MMHandleType player, bool mute)
267 int result = MM_ERROR_NONE;
269 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
271 MMPLAYER_CMD_LOCK(player);
273 result = _mmplayer_set_mute(player, mute);
275 MMPLAYER_CMD_UNLOCK(player);
280 int mm_player_get_mute(MMHandleType player, bool *mute)
282 int result = MM_ERROR_NONE;
284 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
285 MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
287 MMPLAYER_CMD_LOCK(player);
289 result = _mmplayer_get_mute(player, mute);
291 MMPLAYER_CMD_UNLOCK(player);
296 int mm_player_get_state(MMHandleType player, mmplayer_state_e *state)
298 int result = MM_ERROR_NONE;
300 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
301 MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
303 *state = MM_PLAYER_STATE_NULL;
305 result = _mmplayer_get_state(player, (int *)state);
310 /* NOTE : It does not support some use cases, eg using colorspace converter */
311 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, int wl_surface_id)
313 int result = MM_ERROR_NONE;
315 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
317 MMPLAYER_CMD_LOCK(player);
319 result = _mmplayer_change_videosink(player, display_surface_type, wl_surface_id);
321 MMPLAYER_CMD_UNLOCK(player);
326 int mm_player_start(MMHandleType player)
328 int result = MM_ERROR_NONE;
330 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
332 MMPLAYER_CMD_LOCK(player);
334 result = _mmplayer_start(player);
336 MMPLAYER_CMD_UNLOCK(player);
341 int mm_player_stop(MMHandleType player)
343 int result = MM_ERROR_NONE;
345 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
347 MMPLAYER_CMD_LOCK(player);
349 result = _mmplayer_stop(player);
351 MMPLAYER_CMD_UNLOCK(player);
356 int mm_player_pause(MMHandleType player)
358 int result = MM_ERROR_NONE;
360 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
362 MMPLAYER_CMD_LOCK(player);
364 result = _mmplayer_pause(player);
366 MMPLAYER_CMD_UNLOCK(player);
371 int mm_player_resume(MMHandleType player)
373 int result = MM_ERROR_NONE;
375 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
377 MMPLAYER_CMD_LOCK(player);
379 result = _mmplayer_resume(player);
381 MMPLAYER_CMD_UNLOCK(player);
386 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
388 int result = MM_ERROR_NONE;
390 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
392 MMPLAYER_CMD_LOCK(player);
394 result = _mmplayer_set_playspeed(player, rate, streaming);
396 MMPLAYER_CMD_UNLOCK(player);
401 int mm_player_set_position(MMHandleType player, int64_t pos)
403 int result = MM_ERROR_NONE;
405 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
407 MMPLAYER_CMD_LOCK(player);
409 result = _mmplayer_set_position(player, pos);
411 MMPLAYER_CMD_UNLOCK(player);
416 int mm_player_get_position(MMHandleType player, int64_t *pos)
418 int result = MM_ERROR_NONE;
420 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
421 MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
423 MMPLAYER_CMD_LOCK(player);
425 result = _mmplayer_gst_get_position((mmplayer_t *)player, pos);
427 MMPLAYER_CMD_UNLOCK(player);
432 int mm_player_get_duration(MMHandleType player, int64_t *dur)
434 int result = MM_ERROR_NONE;
436 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
437 MMPLAYER_RETURN_VAL_IF_FAIL(dur, MM_ERROR_COMMON_INVALID_ARGUMENT);
439 MMPLAYER_CMD_LOCK(player);
441 result = _mmplayer_get_duration(player, dur);
443 MMPLAYER_CMD_UNLOCK(player);
449 int mm_player_get_buffer_position(MMHandleType player, int *start_pos, int *end_pos)
451 int result = MM_ERROR_NONE;
453 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
454 MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && end_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
456 MMPLAYER_CMD_LOCK(player);
458 result = _mmplayer_get_buffer_position(player, start_pos, end_pos);
460 MMPLAYER_CMD_UNLOCK(player);
465 int mm_player_set_external_subtitle_path(MMHandleType player, const char *path)
467 int result = MM_ERROR_NONE;
469 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
471 MMPLAYER_CMD_LOCK(player);
473 result = _mmplayer_set_external_subtitle_path(player, path);
475 MMPLAYER_CMD_UNLOCK(player);
479 int mm_player_adjust_subtitle_position(MMHandleType player, int pos)
481 int result = MM_ERROR_NONE;
483 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
485 MMPLAYER_CMD_LOCK(player);
487 result = _mmplayer_adjust_subtitle_postion(player, pos);
489 MMPLAYER_CMD_UNLOCK(player);
494 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
496 int result = MM_ERROR_NONE;
498 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
500 MMPLAYER_CMD_LOCK(player);
502 result = _mmplayer_set_subtitle_silent(player, silent);
504 MMPLAYER_CMD_UNLOCK(player);
509 int mm_player_get_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_get_subtitle_silent(player, silent);
519 MMPLAYER_CMD_UNLOCK(player);
524 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)
526 int result = MM_ERROR_NONE;
529 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
530 MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
532 va_start(var_args, first_attribute_name);
533 result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
539 int mm_player_get_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_get_attribute(player, err_attr_name, first_attribute_name, var_args);
554 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, mmplayer_attrs_info_t *info)
556 int result = MM_ERROR_NONE;
559 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
560 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
561 MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
563 result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
568 int mm_player_get_track_count(MMHandleType player, mmplayer_track_type_e type, int *count)
570 int result = MM_ERROR_NONE;
572 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
573 MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
575 MMPLAYER_CMD_LOCK(player);
577 result = _mmplayer_get_track_count(player, type, count);
579 MMPLAYER_CMD_UNLOCK(player);
584 int mm_player_select_track(MMHandleType player, mmplayer_track_type_e type, int index)
586 int result = MM_ERROR_NONE;
588 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
590 MMPLAYER_CMD_LOCK(player);
592 result = _mmplayer_select_track(player, type, index);
594 MMPLAYER_CMD_UNLOCK(player);
599 int mm_player_get_current_track(MMHandleType player, mmplayer_track_type_e type, int *index)
601 int result = MM_ERROR_NONE;
603 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
604 MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
606 MMPLAYER_CMD_LOCK(player);
608 result = _mmplayer_get_current_track(player, type, index);
610 MMPLAYER_CMD_UNLOCK(player);
615 int mm_player_get_track_language_code(MMHandleType player, mmplayer_track_type_e type, int index, char **code)
617 int result = MM_ERROR_NONE;
619 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
621 MMPLAYER_CMD_LOCK(player);
623 result = _mmplayer_get_track_language_code(player, type, index, code);
625 MMPLAYER_CMD_UNLOCK(player);
630 int mm_player_set_uri(MMHandleType player, const char *uri)
632 int result = MM_ERROR_NONE;
634 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
636 MMPLAYER_CMD_LOCK(player);
638 result = _mmplayer_set_uri(player, uri);
640 MMPLAYER_CMD_UNLOCK(player);
646 int mm_player_set_next_uri(MMHandleType player, const char *uri)
648 int result = MM_ERROR_NONE;
650 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
652 MMPLAYER_CMD_LOCK(player);
654 result = _mmplayer_set_next_uri(player, uri, FALSE);
656 MMPLAYER_CMD_UNLOCK(player);
662 int mm_player_get_next_uri(MMHandleType player, char **uri)
664 int result = MM_ERROR_NONE;
666 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
668 MMPLAYER_CMD_LOCK(player);
670 result = _mmplayer_get_next_uri(player, uri);
672 MMPLAYER_CMD_UNLOCK(player);
678 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
680 int result = MM_ERROR_NONE;
682 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
683 MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
685 MMPLAYER_CMD_LOCK(player);
687 result = _mmplayer_has_closed_caption(player, exist);
689 MMPLAYER_CMD_UNLOCK(player);
694 void mm_player_video_stream_internal_buffer_unref(void *buffer)
696 _mm_player_video_stream_internal_buffer_unref(buffer);
699 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
702 int result = MM_ERROR_NONE;
704 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
706 /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
707 //MMPLAYER_CMD_LOCK(player);
709 result = _mmplayer_submit_packet(player, packet);
711 //MMPLAYER_CMD_UNLOCK(player);
716 int mm_player_set_video_info(MMHandleType player, media_format_h format)
718 int result = MM_ERROR_NONE;
722 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
724 MMPLAYER_CMD_LOCK(player);
726 result = _mmplayer_set_video_info(player, format);
728 MMPLAYER_CMD_UNLOCK(player);
734 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
736 int result = MM_ERROR_NONE;
740 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
742 MMPLAYER_CMD_LOCK(player);
744 result = _mmplayer_set_audio_info(player, format);
746 MMPLAYER_CMD_UNLOCK(player);
751 int mm_player_set_subtitle_info(MMHandleType player, mmplayer_subtitle_stream_info_t *subtitle_stream_info)
753 int result = MM_ERROR_NONE;
757 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
759 MMPLAYER_CMD_LOCK(player);
761 result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
763 MMPLAYER_CMD_UNLOCK(player);
768 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long max_size)
770 int result = MM_ERROR_NONE;
774 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
776 MMPLAYER_CMD_LOCK(player);
778 result = _mmplayer_set_media_stream_max_size(player, type, max_size);
780 MMPLAYER_CMD_UNLOCK(player);
785 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long *max_size)
787 int result = MM_ERROR_NONE;
788 guint64 _max_size = 0;
792 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
793 MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
795 MMPLAYER_CMD_LOCK(player);
797 result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
798 *max_size = _max_size;
800 MMPLAYER_CMD_UNLOCK(player);
805 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned min_percent)
807 int result = MM_ERROR_NONE;
811 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
813 MMPLAYER_CMD_LOCK(player);
815 result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
817 MMPLAYER_CMD_UNLOCK(player);
822 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned int *min_percent)
824 int result = MM_ERROR_NONE;
828 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
829 MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
831 MMPLAYER_CMD_LOCK(player);
833 result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
835 MMPLAYER_CMD_UNLOCK(player);
840 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
842 int result = MM_ERROR_NONE;
844 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
846 MMPLAYER_CMD_LOCK(player);
848 result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
850 MMPLAYER_CMD_UNLOCK(player);
855 int mm_player_get_timeout(MMHandleType player, int *timeout)
857 int result = MM_ERROR_NONE;
859 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
860 MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
862 MMPLAYER_CMD_LOCK(player);
864 result = _mmplayer_get_timeout(player, timeout);
866 MMPLAYER_CMD_UNLOCK(player);
871 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
873 int result = MM_ERROR_NONE;
875 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
877 MMPLAYER_CMD_LOCK(player);
879 result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
881 MMPLAYER_CMD_UNLOCK(player);
886 int mm_player_release_video_stream_bo(MMHandleType player, void *bo)
888 int result = MM_ERROR_NONE;
890 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
891 MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
893 //MMPLAYER_CMD_LOCK(player);
895 result = _mmplayer_video_stream_release_bo(player, bo);
897 //MMPLAYER_CMD_UNLOCK(player);
902 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
904 int result = MM_ERROR_NONE;
906 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
907 MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
909 MMPLAYER_CMD_LOCK(player);
911 result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
913 MMPLAYER_CMD_UNLOCK(player);
918 int mm_player_manage_external_storage_state(MMHandleType player, int id, int state)
920 int result = MM_ERROR_NONE;
922 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
924 MMPLAYER_CMD_LOCK(player);
926 result = _mmplayer_manage_external_storage_state(player, id, state);
928 MMPLAYER_CMD_UNLOCK(player);
933 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
935 int result = MM_ERROR_NONE;
937 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
938 MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
940 MMPLAYER_CMD_LOCK(player);
942 result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
944 MMPLAYER_CMD_UNLOCK(player);
949 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
951 int result = MM_ERROR_NONE;
953 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
955 MMPLAYER_CMD_LOCK(player);
957 result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
959 MMPLAYER_CMD_UNLOCK(player);
964 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
966 int result = MM_ERROR_NONE;
968 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
969 MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
971 MMPLAYER_CMD_LOCK(player);
973 result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
975 MMPLAYER_CMD_UNLOCK(player);
980 int mm_player_get_streaming_buffering_time(MMHandleType player, int *prebuffer_ms, int *rebuffer_ms)
982 int result = MM_ERROR_NONE;
984 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
985 MMPLAYER_RETURN_VAL_IF_FAIL(prebuffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
987 MMPLAYER_CMD_LOCK(player);
989 result = _mmplayer_get_streaming_buffering_time(player, prebuffer_ms, rebuffer_ms);
991 MMPLAYER_CMD_UNLOCK(player);
996 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
998 int result = MM_ERROR_NONE;
999 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1001 MMPLAYER_CMD_LOCK(player);
1003 result = _mmplayer_set_audio_only(player, audio_only);
1005 MMPLAYER_CMD_UNLOCK(player);
1010 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1012 int result = MM_ERROR_NONE;
1014 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1015 MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1017 MMPLAYER_CMD_LOCK(player);
1019 result = _mmplayer_get_audio_only(player, audio_only);
1021 MMPLAYER_CMD_UNLOCK(player);
1026 int mm_player_360_is_content_spherical(MMHandleType player, bool *is_spherical)
1028 int result = MM_ERROR_NONE;
1030 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1031 MMPLAYER_RETURN_VAL_IF_FAIL(is_spherical, MM_ERROR_INVALID_ARGUMENT);
1033 MMPLAYER_CMD_LOCK(player);
1035 result = _mmplayer_360_is_content_spherical(player, is_spherical);
1037 MMPLAYER_CMD_UNLOCK(player);
1042 int mm_player_360_set_enabled(MMHandleType player, bool enabled)
1044 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_360_set_enabled(player, enabled);
1051 MMPLAYER_CMD_UNLOCK(player);
1056 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1058 int result = MM_ERROR_NONE;
1060 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1061 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1063 MMPLAYER_CMD_LOCK(player);
1065 result = _mmplayer_360_is_enabled(player, enabled);
1067 MMPLAYER_CMD_UNLOCK(player);
1072 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1074 int result = MM_ERROR_NONE;
1075 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1077 MMPLAYER_CMD_LOCK(player);
1079 result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1081 MMPLAYER_CMD_UNLOCK(player);
1086 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1088 int result = MM_ERROR_NONE;
1090 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1091 MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1093 MMPLAYER_CMD_LOCK(player);
1095 result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1097 MMPLAYER_CMD_UNLOCK(player);
1102 int mm_player_360_set_zoom(MMHandleType player, float level)
1104 int result = MM_ERROR_NONE;
1105 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1107 MMPLAYER_CMD_LOCK(player);
1109 result = _mmplayer_360_set_zoom(player, level);
1111 MMPLAYER_CMD_UNLOCK(player);
1116 int mm_player_360_get_zoom(MMHandleType player, float *level)
1118 int result = MM_ERROR_NONE;
1120 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1121 MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1123 MMPLAYER_CMD_LOCK(player);
1125 result = _mmplayer_360_get_zoom(player, level);
1127 MMPLAYER_CMD_UNLOCK(player);
1132 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1134 int result = MM_ERROR_NONE;
1135 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1137 MMPLAYER_CMD_LOCK(player);
1139 result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1141 MMPLAYER_CMD_UNLOCK(player);
1146 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1148 int result = MM_ERROR_NONE;
1150 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1151 MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1153 MMPLAYER_CMD_LOCK(player);
1155 result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1157 MMPLAYER_CMD_UNLOCK(player);
1162 int mm_player_set_codec_type(MMHandleType player, mmplayer_stream_type_e stream_type, mmplayer_codec_type_e codec_type)
1164 int result = MM_ERROR_NONE;
1166 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1168 MMPLAYER_CMD_LOCK(player);
1170 result = _mmplayer_set_codec_type(player, stream_type, codec_type);
1172 MMPLAYER_CMD_UNLOCK(player);
1177 int mm_player_set_replaygain_enabled(MMHandleType player, bool enabled)
1179 int result = MM_ERROR_NONE;
1181 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1183 MMPLAYER_CMD_LOCK(player);
1185 result = _mmplayer_set_replaygain_enabled(player, enabled);
1187 MMPLAYER_CMD_UNLOCK(player);
1192 int mm_player_is_replaygain_enabled(MMHandleType player, bool *enabled)
1194 int result = MM_ERROR_NONE;
1196 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1197 MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1199 MMPLAYER_CMD_LOCK(player);
1201 result = _mmplayer_is_replaygain_enabled(player, enabled);
1203 MMPLAYER_CMD_UNLOCK(player);
1208 int mm_player_set_video_roi_area(MMHandleType player, double scale_x, double scale_y, double scale_width, double scale_height)
1210 int result = MM_ERROR_NONE;
1212 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1214 MMPLAYER_CMD_LOCK(player);
1216 result = _mmplayer_set_video_roi_area(player, scale_x, scale_y, scale_width, scale_height);
1218 MMPLAYER_CMD_UNLOCK(player);
1223 int mm_player_get_video_roi_area(MMHandleType player, double *scale_x, double *scale_y, double *scale_width, double *scale_height)
1225 int result = MM_ERROR_NONE;
1227 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1229 MMPLAYER_CMD_LOCK(player);
1231 result = _mmplayer_get_video_roi_area(player, scale_x, scale_y, scale_width, scale_height);
1233 MMPLAYER_CMD_UNLOCK(player);
1238 int mm_player_set_client_pid(MMHandleType player, int pid)
1240 int result = MM_ERROR_NONE;
1242 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1244 MMPLAYER_CMD_LOCK(player);
1246 result = _mmplayer_set_client_pid(player, pid);
1248 MMPLAYER_CMD_UNLOCK(player);
1253 int mm_player_audio_offload_is_activated(MMHandleType player, bool *activated)
1255 int result = MM_ERROR_NONE;
1257 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1258 MMPLAYER_RETURN_VAL_IF_FAIL(activated, MM_ERROR_INVALID_ARGUMENT);
1260 MMPLAYER_CMD_LOCK(player);
1262 result = _mmplayer_audio_offload_is_activated(player, activated);
1264 MMPLAYER_CMD_UNLOCK(player);
1269 int mm_player_is_audio_control_available(MMHandleType player, mmplayer_audio_control_opt_e opt, bool *available)
1271 int result = MM_ERROR_NONE;
1273 MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1274 MMPLAYER_RETURN_VAL_IF_FAIL(available, MM_ERROR_INVALID_ARGUMENT);
1276 MMPLAYER_CMD_LOCK(player);
1277 result = _mmplayer_is_audio_control_available(player, opt, available);
1278 MMPLAYER_CMD_UNLOCK(player);