2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <mm_player.h>
23 #include <mm_player_audioeffect.h>
24 #include <mm_player_internal.h>
26 #include <sound_manager.h>
27 #include <sound_manager_internal.h>
29 #include "muse_player.h"
30 #include "legacy_player.h"
31 #include "legacy_player_private.h"
33 #define MIN_BUFFERING_TIME_MS 0 /* use platform default value */
35 #define __RELEASEIF_PREPARE_THREAD(thread_id) \
38 pthread_join(thread_id, NULL); \
40 LOGI("prepare thread released\n"); \
44 #define __RELEASEIF_MESSAGE_THREAD(thread_id) \
47 pthread_join(thread_id, NULL); \
49 LOGI("message thread released\n"); \
53 #define __GET_MESSAGE(handle) \
55 if (handle && handle->message_queue) { \
56 g_mutex_lock(&handle->message_queue_lock); \
57 if (g_queue_is_empty(handle->message_queue)) { \
58 g_cond_wait(&handle->message_queue_cond, &handle->message_queue_lock); \
60 handle->current_message = (int)(intptr_t)g_queue_pop_head(handle->message_queue); \
61 g_mutex_unlock(&handle->message_queue_lock); \
62 LOGI("Retrieved message [%d] from queue", handle->current_message); \
64 LOGI("Failed to retrieve message from queue"); \
65 handle->current_message = PLAYER_MESSAGE_NONE; \
69 #define __ADD_MESSAGE(handle, message) \
71 if (handle && handle->message_queue) { \
72 g_mutex_lock(&handle->message_queue_lock); \
73 if (message == PLAYER_MESSAGE_LOOP_EXIT) \
74 g_queue_clear(handle->message_queue); \
75 g_queue_push_tail(handle->message_queue, (gpointer)message); \
76 g_cond_signal(&handle->message_queue_cond); \
77 g_mutex_unlock(&handle->message_queue_lock); \
78 LOGI("Adding message [%d] to queue", message); \
80 LOGI("Failed to add message [%d] to queue", message); \
85 * Internal Implementation
87 int __player_convert_error_code(int code, char *func_name)
89 int ret = PLAYER_ERROR_INVALID_OPERATION;
90 char *msg = "PLAYER_ERROR_INVALID_OPERATION";
93 ret = PLAYER_ERROR_NONE;
94 msg = "PLAYER_ERROR_NONE";
96 case MM_ERROR_PLAYER_AUDIO_CODEC_NOT_FOUND:
97 ret = PLAYER_ERROR_NOT_SUPPORTED_AUDIO_CODEC;
98 msg = "PLAYER_ERROR_NOT_SUPPORTED_AUDIO_CODEC";
100 case MM_ERROR_PLAYER_VIDEO_CODEC_NOT_FOUND:
101 ret = PLAYER_ERROR_NOT_SUPPORTED_VIDEO_CODEC;
102 msg = "PLAYER_ERROR_NOT_SUPPORTED_VIDEO_CODEC";
104 case MM_ERROR_PLAYER_NOT_SUPPORTED_SUBTITLE:
105 ret = PLAYER_ERROR_NOT_SUPPORTED_SUBTITLE;
106 msg = "PLAYER_ERROR_NOT_SUPPORTED_SUBTITLE";
108 case MM_ERROR_INVALID_ARGUMENT:
109 case MM_ERROR_COMMON_INVALID_ARGUMENT:
110 ret = PLAYER_ERROR_INVALID_PARAMETER;
111 msg = "PLAYER_ERROR_INVALID_PARAMETER";
113 case MM_ERROR_PLAYER_CODEC_NOT_FOUND:
114 case MM_ERROR_PLAYER_STREAMING_UNSUPPORTED_AUDIO:
115 case MM_ERROR_PLAYER_STREAMING_UNSUPPORTED_VIDEO:
116 case MM_ERROR_PLAYER_STREAMING_UNSUPPORTED_MEDIA_TYPE:
117 case MM_ERROR_PLAYER_NOT_SUPPORTED_FORMAT:
118 ret = PLAYER_ERROR_NOT_SUPPORTED_FILE;
119 msg = "PLAYER_ERROR_NOT_SUPPORTED_FILE";
121 case MM_ERROR_PLAYER_INVALID_STATE:
122 case MM_ERROR_PLAYER_NOT_INITIALIZED:
123 ret = PLAYER_ERROR_INVALID_STATE;
124 msg = "PLAYER_ERROR_INVALID_STATE";
126 case MM_ERROR_PLAYER_INTERNAL:
127 case MM_ERROR_PLAYER_INVALID_STREAM:
128 case MM_ERROR_PLAYER_STREAMING_FAIL:
129 case MM_ERROR_PLAYER_NO_OP:
130 ret = PLAYER_ERROR_INVALID_OPERATION;
131 msg = "PLAYER_ERROR_INVALID_OPERATION";
133 case MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS:
134 case MM_ERROR_NOT_SUPPORT_API:
135 case MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER:
136 ret = PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
137 msg = "PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE";
139 case MM_ERROR_PLAYER_NO_FREE_SPACE:
140 ret = PLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE;
141 msg = "PLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE";
143 case MM_ERROR_PLAYER_FILE_NOT_FOUND:
144 ret = PLAYER_ERROR_NO_SUCH_FILE;
145 msg = "PLAYER_ERROR_NO_SUCH_FILE";
147 case MM_ERROR_PLAYER_SEEK:
148 ret = PLAYER_ERROR_SEEK_FAILED;
149 msg = "PLAYER_ERROR_SEEK_FAILED";
151 case MM_ERROR_PLAYER_INVALID_URI:
152 case MM_ERROR_PLAYER_STREAMING_INVALID_URL:
153 ret = PLAYER_ERROR_INVALID_URI;
154 msg = "PLAYER_ERROR_INVALID_URI";
156 case MM_ERROR_PLAYER_STREAMING_CONNECTION_FAIL:
157 case MM_ERROR_PLAYER_STREAMING_DNS_FAIL:
158 case MM_ERROR_PLAYER_STREAMING_SERVER_DISCONNECTED:
159 case MM_ERROR_PLAYER_STREAMING_INVALID_PROTOCOL:
160 case MM_ERROR_PLAYER_STREAMING_UNEXPECTED_MSG:
161 case MM_ERROR_PLAYER_STREAMING_OUT_OF_MEMORIES:
162 case MM_ERROR_PLAYER_STREAMING_RTSP_TIMEOUT:
163 case MM_ERROR_PLAYER_STREAMING_BAD_REQUEST:
164 case MM_ERROR_PLAYER_STREAMING_NOT_AUTHORIZED:
165 case MM_ERROR_PLAYER_STREAMING_PAYMENT_REQUIRED:
166 case MM_ERROR_PLAYER_STREAMING_FORBIDDEN:
167 case MM_ERROR_PLAYER_STREAMING_CONTENT_NOT_FOUND:
168 case MM_ERROR_PLAYER_STREAMING_METHOD_NOT_ALLOWED:
169 case MM_ERROR_PLAYER_STREAMING_NOT_ACCEPTABLE:
170 case MM_ERROR_PLAYER_STREAMING_PROXY_AUTHENTICATION_REQUIRED:
171 case MM_ERROR_PLAYER_STREAMING_SERVER_TIMEOUT:
172 case MM_ERROR_PLAYER_STREAMING_GONE:
173 case MM_ERROR_PLAYER_STREAMING_LENGTH_REQUIRED:
174 case MM_ERROR_PLAYER_STREAMING_PRECONDITION_FAILED:
175 case MM_ERROR_PLAYER_STREAMING_REQUEST_ENTITY_TOO_LARGE:
176 case MM_ERROR_PLAYER_STREAMING_REQUEST_URI_TOO_LARGE:
177 case MM_ERROR_PLAYER_STREAMING_PARAMETER_NOT_UNDERSTOOD:
178 case MM_ERROR_PLAYER_STREAMING_CONFERENCE_NOT_FOUND:
179 case MM_ERROR_PLAYER_STREAMING_NOT_ENOUGH_BANDWIDTH:
180 case MM_ERROR_PLAYER_STREAMING_NO_SESSION_ID:
181 case MM_ERROR_PLAYER_STREAMING_METHOD_NOT_VALID_IN_THIS_STATE:
182 case MM_ERROR_PLAYER_STREAMING_HEADER_FIELD_NOT_VALID_FOR_SOURCE:
183 case MM_ERROR_PLAYER_STREAMING_INVALID_RANGE:
184 case MM_ERROR_PLAYER_STREAMING_PARAMETER_IS_READONLY:
185 case MM_ERROR_PLAYER_STREAMING_AGGREGATE_OP_NOT_ALLOWED:
186 case MM_ERROR_PLAYER_STREAMING_ONLY_AGGREGATE_OP_ALLOWED:
187 case MM_ERROR_PLAYER_STREAMING_BAD_TRANSPORT:
188 case MM_ERROR_PLAYER_STREAMING_DESTINATION_UNREACHABLE:
189 case MM_ERROR_PLAYER_STREAMING_INTERNAL_SERVER_ERROR:
190 case MM_ERROR_PLAYER_STREAMING_NOT_IMPLEMENTED:
191 case MM_ERROR_PLAYER_STREAMING_BAD_GATEWAY:
192 case MM_ERROR_PLAYER_STREAMING_SERVICE_UNAVAILABLE:
193 case MM_ERROR_PLAYER_STREAMING_GATEWAY_TIME_OUT:
194 case MM_ERROR_PLAYER_STREAMING_OPTION_NOT_SUPPORTED:
195 ret = PLAYER_ERROR_CONNECTION_FAILED;
196 msg = "PLAYER_ERROR_CONNECTION_FAILED";
198 case MM_ERROR_POLICY_BLOCKED:
199 case MM_ERROR_POLICY_INTERRUPTED:
200 case MM_ERROR_POLICY_INTERNAL:
201 case MM_ERROR_POLICY_DUPLICATED:
202 ret = PLAYER_ERROR_SOUND_POLICY;
203 msg = "PLAYER_ERROR_SOUND_POLICY";
205 case MM_ERROR_PLAYER_DRM_EXPIRED:
206 ret = PLAYER_ERROR_DRM_EXPIRED;
207 msg = "PLAYER_ERROR_DRM_EXPIRED";
209 case MM_ERROR_PLAYER_DRM_NOT_AUTHORIZED:
210 case MM_ERROR_PLAYER_DRM_NO_LICENSE:
211 ret = PLAYER_ERROR_DRM_NO_LICENSE;
212 msg = "PLAYER_ERROR_DRM_NO_LICENSE";
214 case MM_ERROR_PLAYER_DRM_FUTURE_USE:
215 ret = PLAYER_ERROR_DRM_FUTURE_USE;
216 msg = "PLAYER_ERROR_DRM_FUTURE_USE";
218 case MM_ERROR_PLAYER_DRM_OUTPUT_PROTECTION:
219 ret = PLAYER_ERROR_DRM_NOT_PERMITTED;
220 msg = "PLAYER_ERROR_DRM_NOT_PERMITTED";
222 case MM_ERROR_PLAYER_RESOURCE_LIMIT:
223 ret = PLAYER_ERROR_RESOURCE_LIMIT;
224 msg = "PLAYER_ERROR_RESOURCE_LIMIT";
226 case MM_ERROR_PLAYER_PERMISSION_DENIED:
227 ret = PLAYER_ERROR_PERMISSION_DENIED;
228 msg = "PLAYER_ERROR_PERMISSION_DENIED";
230 case MM_ERROR_PLAYER_BUFFER_SPACE:
231 ret = PLAYER_ERROR_BUFFER_SPACE;
232 msg = "PLAYER_ERROR_BUFFER_SPACE";
237 LOGE("[%s] %s(0x%08x) : core fw error(0x%x)", func_name, msg, ret, code);
241 static void __player_update_state(legacy_player_t *handle, player_internal_state_e state)
244 case PLAYER_INTERNAL_STATE_NONE:
245 handle->state = PLAYER_STATE_NONE;
246 handle->internal_state = PLAYER_INTERNAL_STATE_IDLE;
248 case PLAYER_INTERNAL_STATE_IDLE:
249 handle->state = PLAYER_STATE_IDLE;
250 handle->internal_state = PLAYER_INTERNAL_STATE_IDLE;
252 case PLAYER_INTERNAL_STATE_PRE_READY:
253 handle->internal_state = PLAYER_INTERNAL_STATE_PRE_READY;
255 case PLAYER_INTERNAL_STATE_READY:
256 handle->state = PLAYER_STATE_READY;
257 handle->internal_state = PLAYER_INTERNAL_STATE_READY;
259 case PLAYER_INTERNAL_STATE_PLAYING:
260 handle->internal_state = PLAYER_INTERNAL_STATE_PLAYING;
261 handle->state = PLAYER_STATE_PLAYING;
263 case PLAYER_INTERNAL_STATE_PAUSED:
264 handle->internal_state = PLAYER_INTERNAL_STATE_PAUSED;
265 handle->state = PLAYER_STATE_PAUSED;
267 case PLAYER_INTERNAL_STATE_STOPPED:
268 handle->state = PLAYER_STATE_READY;
269 handle->internal_state = PLAYER_INTERNAL_STATE_STOPPED;
275 LOGD("player state is updated to 0x%X, 0x%X", handle->state, handle->internal_state);
279 bool __player_state_validate(legacy_player_t *handle, player_state_e threshold)
281 if (handle->state < threshold)
287 static int __set_callback(muse_player_event_e type, legacy_player_h player, void *callback, void *user_data)
289 legacy_player_t *handle = (legacy_player_t *)player;
290 PLAYER_INSTANCE_CHECK(player);
291 PLAYER_NULL_ARG_CHECK(callback);
293 handle->user_cb[type] = callback;
294 handle->user_data[type] = user_data;
295 LOGI("Event type : %d ", type);
296 return PLAYER_ERROR_NONE;
299 static int __unset_callback(muse_player_event_e type, legacy_player_h player)
301 legacy_player_t *handle = (legacy_player_t *)player;
302 PLAYER_INSTANCE_CHECK(player);
303 handle->user_cb[type] = NULL;
304 handle->user_data[type] = NULL;
305 LOGI("Event type : %d ", type);
306 return PLAYER_ERROR_NONE;
309 static void __message_cb_loop(void *data)
312 legacy_player_t *handle = (legacy_player_t *)data;
314 LOGE("null handle in __message_cb_loop");
318 __GET_MESSAGE(handle);
319 switch (handle->current_message) {
320 case PLAYER_MESSAGE_NONE:
322 LOGW("PLAYER_MESSAGE_NONE");
326 case PLAYER_MESSAGE_PREPARED:
328 LOGW("PLAYER_MESSAGE_PREPARED");
330 LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
331 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
332 __player_update_state(handle, PLAYER_INTERNAL_STATE_READY);
333 ((player_prepared_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]);
334 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
335 handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
337 LOGE("null handle in PLAYER_MESSAGE_PREPARED");
339 LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
342 case PLAYER_MESSAGE_ERROR:
344 LOGW("PLAYER_MESSAGE_ERROR");
345 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])
346 ((player_error_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])(handle->error_code, handle->user_data[MUSE_PLAYER_EVENT_TYPE_ERROR]);
348 LOGE("null handle in PLAYER_MESSAGE_ERROR");
351 case PLAYER_MESSAGE_SEEK_DONE:
353 LOGW("PLAYER_MESSAGE_SEEK_DONE");
354 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) {
355 ((player_seek_completed_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK]);
356 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
357 handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
359 LOGE("null handle in PLAYER_MESSAGE_SEEK_DONE");
363 case PLAYER_MESSAGE_EOS:
365 LOGW("PLAYER_MESSAGE_EOS");
366 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE])
367 ((player_completed_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_COMPLETE]);
369 LOGE("null handle in PLAYER_MESSAGE_EOS");
372 #ifdef TIZEN_FEATURE_EVAS_RENDERER
373 case PLAYER_MESSAGE_GAPLESS_CONSTRUCTION:
375 LOGW("PLAYER_MESSAGE_GAPLESS_CONSTRUCTION");
376 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER])
377 ((player_retrieve_buffer_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER]);
379 LOGE("null handle in PLAYER_MESSAGE_GAPLESS_CONSTRUCTION");
383 case PLAYER_MESSAGE_LOOP_EXIT:
385 LOGW("PLAYER_MESSAGE_LOOP_EXIT");
389 case PLAYER_MESSAGE_MAX:
391 LOGW("PLAYER_MESSAGE_MAX");
402 static player_state_e __convert_player_state(mmplayer_state_e state)
404 if (state == MM_PLAYER_STATE_NONE)
405 return PLAYER_STATE_NONE;
410 static int __msg_callback(int message, void *param, void *user_data)
412 legacy_player_t *handle = (legacy_player_t *)user_data;
413 MMMessageParamType *msg = (MMMessageParamType *)param;
414 player_error_e err_code = PLAYER_ERROR_NONE;
416 LOGW("Got message type : 0x%x", message);
418 case MM_MESSAGE_ERROR: /* 0x01 */
419 err_code = __player_convert_error_code(msg->code, (char *)__FUNCTION__);
421 LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
422 if (PLAYER_ERROR_NOT_SUPPORTED_FILE == err_code && handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
423 LOGW("Failed to pause, so prepare cb will be released soon");
424 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
425 if (handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
426 g_free(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]);
427 handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
430 LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
432 case MM_MESSAGE_STATE_CHANGED: /* 0x03 */
433 LOGI("STATE CHANGED INTERNALLY - from : %d, to : %d (CAPI State : %d)", msg->state.previous, msg->state.current, handle->state);
434 if (msg->state.previous == MM_PLAYER_STATE_READY && msg->state.current == MM_PLAYER_STATE_PAUSED) {
435 LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
436 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
437 /* asyc && prepared cb has been set */
438 LOGI("Prepared! [current state : %d]", handle->state);
439 PLAYER_TRACE_ASYNC_END("MM:PLAYER:PREPARE_ASYNC", *(int *)handle);
440 __ADD_MESSAGE(handle, PLAYER_MESSAGE_PREPARED);
442 LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
445 case MM_MESSAGE_BEGIN_OF_STREAM: /* 0x104 */
446 LOGI("Ready to streaming information (BOS) [current state : %d]", handle->state);
448 case MM_MESSAGE_END_OF_STREAM: /* 0x105 */
449 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE])
450 __ADD_MESSAGE(handle, PLAYER_MESSAGE_EOS);
452 #ifdef TIZEN_FEATURE_EVAS_RENDERER
453 case MM_MESSAGE_GAPLESS_CONSTRUCTION: /* 0x105 */
454 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER])
455 __ADD_MESSAGE(handle, PLAYER_MESSAGE_GAPLESS_CONSTRUCTION);
458 case MM_MESSAGE_BUFFERING: /* 0x103 */
459 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_BUFFERING])
460 ((player_buffering_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_BUFFERING])(msg->connection.buffering, handle->user_data[MUSE_PLAYER_EVENT_TYPE_BUFFERING]);
462 case MM_MESSAGE_STATE_INTERRUPTED: /* 0x04 */
463 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_INTERRUPT]) {
464 if (msg->union_type == MM_MSG_UNION_STATE) {
465 LOGW("received mm state msg prev:%d, curr:%d", msg->state.previous, msg->state.current);
466 handle->state = __convert_player_state(msg->state.current);
467 LOGW("player state is changed to %d by resource conflict", handle->state);
469 ((player_interrupted_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_INTERRUPT])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_INTERRUPT]);
472 case MM_MESSAGE_CONNECTION_TIMEOUT: /* 0x102 */
473 LOGE("PLAYER_ERROR_CONNECTION_FAILED : CONNECTION_TIMEOUT");
474 err_code = PLAYER_ERROR_CONNECTION_FAILED;
476 case MM_MESSAGE_UPDATE_SUBTITLE: /* 0x109 */
477 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SUBTITLE])
478 ((player_subtitle_updated_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SUBTITLE])(msg->subtitle.duration, (char *)msg->data, handle->user_data[MUSE_PLAYER_EVENT_TYPE_SUBTITLE]);
480 case MM_MESSAGE_VIDEO_NOT_CAPTURED: /* 0x113 */
481 LOGE("PLAYER_ERROR_VIDEO_CAPTURE_FAILED");
482 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])
483 ((player_error_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])(PLAYER_ERROR_VIDEO_CAPTURE_FAILED, handle->user_data[MUSE_PLAYER_EVENT_TYPE_ERROR]);
485 case MM_MESSAGE_VIDEO_CAPTURED: /* 0x110 */
487 mmplayer_video_capture_t *capture = (mmplayer_video_capture_t *)msg->data;
489 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) {
490 if (!capture || !capture->data) {
491 LOGE("PLAYER_ERROR_VIDEO_CAPTURE_FAILED : Failed to get capture data");
492 err_code = PLAYER_ERROR_VIDEO_CAPTURE_FAILED;
494 LOGI("captured image ori: %d, width: %d, height: %d, size: %d",
495 capture->orientation, capture->width, capture->height, capture->size);
497 /* call application callback */
498 ((player_video_captured_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE])
499 (capture->data, capture->width, capture->height, capture->size, handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE]);
502 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
503 handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
506 /* capure->data have to be released to avoid mem leak in all cases. */
508 g_free(capture->data);
509 capture->data = NULL;
513 case MM_MESSAGE_FILE_NOT_SUPPORTED: /* 0x10f */
514 LOGE("PLAYER_ERROR_NOT_SUPPORTED_FILE : FILE_NOT_SUPPORTED");
515 err_code = PLAYER_ERROR_NOT_SUPPORTED_FILE;
517 case MM_MESSAGE_FILE_NOT_FOUND: /* 0x110 */
518 LOGE("PLAYER_ERROR_NOT_SUPPORTED_FILE : FILE_NOT_FOUND");
519 err_code = PLAYER_ERROR_NOT_SUPPORTED_FILE;
521 case MM_MESSAGE_SEEK_COMPLETED: /* 0x114 */
522 if (handle->display_type != PLAYER_DISPLAY_TYPE_NONE && handle->state == PLAYER_STATE_READY) {
523 if (handle->is_display_visible) {
524 int ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", 1, (char *)NULL);
525 if (ret != MM_ERROR_NONE)
526 LOGW("Failed to set display_visible '1' (0x%x)", ret);
529 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) {
530 __ADD_MESSAGE(handle, PLAYER_MESSAGE_SEEK_DONE);
533 case MM_MESSAGE_PLAY_POSITION:
534 LOGI("MM_MESSAGE_PLAY_POSITION (%"PRId64" ns)", msg->time.elapsed);
535 handle->last_play_position = msg->time.elapsed;
537 case MM_MESSAGE_UNKNOWN: /* 0x00 */
538 case MM_MESSAGE_WARNING: /* 0x02 */
539 case MM_MESSAGE_CONNECTING: /* 0x100 */
540 case MM_MESSAGE_CONNECTED: /* 0x101 */
541 case MM_MESSAGE_BLUETOOTH_ON: /* 0x106 */
542 case MM_MESSAGE_BLUETOOTH_OFF: /* 0x107 */
543 case MM_MESSAGE_RTP_SENDER_REPORT: /* 0x10a */
544 case MM_MESSAGE_RTP_RECEIVER_REPORT: /* 0x10b */
545 case MM_MESSAGE_RTP_SESSION_STATUS: /* 0x10c */
546 case MM_MESSAGE_SENDER_STATE: /* 0x10d */
547 case MM_MESSAGE_RECEIVER_STATE: /* 0x10e */
552 if (err_code != PLAYER_ERROR_NONE && handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR]) {
553 handle->error_code = err_code;
554 __ADD_MESSAGE(handle, PLAYER_MESSAGE_ERROR);
561 static MMDisplaySurfaceType __player_convert_display_type(player_display_type_e type)
564 case PLAYER_DISPLAY_TYPE_OVERLAY:
565 return MM_DISPLAY_SURFACE_OVERLAY;
566 case PLAYER_DISPLAY_TYPE_EVAS: /* fall through ifndef TIZEN_FEATURE_EVAS_RENDERER */
567 #ifdef TIZEN_FEATURE_EVAS_RENDERER
568 return MM_DISPLAY_SURFACE_REMOTE;
570 case PLAYER_DISPLAY_TYPE_NONE: /* fall through */
572 return MM_DISPLAY_SURFACE_NULL;
576 bool _check_enabled_user_cb_lock(int type)
579 case MUSE_PLAYER_EVENT_TYPE_PREPARE: /* fall through */
580 case MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO: /* fall through */
581 case MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO: /* fall through */
589 * Public Implementation
592 int legacy_player_create(legacy_player_h *player)
594 legacy_player_t *handle;
595 int ret = MM_ERROR_NONE;
597 PLAYER_INSTANCE_CHECK(player);
598 PLAYER_TRACE_BEGIN("MM:PLAYER:CREATE");
600 handle = g_try_new0(legacy_player_t, 1);
602 LOGE("PLAYER_ERROR_OUT_OF_MEMORY");
603 return PLAYER_ERROR_OUT_OF_MEMORY;
605 ret = mm_player_create(&handle->mm_handle);
606 if (ret != MM_ERROR_NONE) {
607 LOGE("Failed to create player 0x%X", ret);
608 __player_update_state(handle, PLAYER_INTERNAL_STATE_NONE);
611 return __player_convert_error_code(ret, (char *)__FUNCTION__);
614 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE;
616 *player = (legacy_player_h)handle;
617 __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
618 handle->display_type = PLAYER_DISPLAY_TYPE_NONE;
619 handle->is_display_visible = true;
620 handle->is_media_stream = false;
622 for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) {
623 if (_check_enabled_user_cb_lock(type))
624 g_mutex_init(&handle->user_cb_lock[type]);
627 handle->message_queue = g_queue_new();
628 g_mutex_init(&handle->message_queue_lock);
629 g_cond_init(&handle->message_queue_cond);
630 ret = pthread_create(&handle->message_thread, NULL, (void *)__message_cb_loop, (void *)handle);
632 LOGE("Failed to create message thread 0x%X", ret);
633 return PLAYER_ERROR_OUT_OF_MEMORY;
636 LOGI("new handle : %p", *player);
638 return PLAYER_ERROR_NONE;
641 int legacy_player_destroy(legacy_player_h player)
643 legacy_player_t *handle = (legacy_player_t *)player;
644 int ret = MM_ERROR_NONE;
646 LOGI("<Enter: %p>", player);
647 PLAYER_TRACE_BEGIN("MM:PLAYER:DESTROY");
648 PLAYER_INSTANCE_CHECK(player);
650 handle->is_shutdown = true;
652 __ADD_MESSAGE(handle, PLAYER_MESSAGE_LOOP_EXIT);
654 LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
655 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
656 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
657 g_free(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]);
658 handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
660 LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
662 /* stop the pause state trasition to release prepare thread */
663 if (handle->internal_state == PLAYER_INTERNAL_STATE_PRE_READY)
664 mm_player_abort_pause(handle->mm_handle);
666 __RELEASEIF_PREPARE_THREAD(handle->prepare_async_thread);
667 __RELEASEIF_MESSAGE_THREAD(handle->message_thread);
669 ret = mm_player_destroy(handle->mm_handle);
670 if (ret != MM_ERROR_NONE) {
671 LOGE("Failed to player destroy 0x%X", ret);
672 return PLAYER_ERROR_INVALID_OPERATION;
674 LOGI("Done mm_player_destroy");
676 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE;
678 __player_update_state(handle, PLAYER_INTERNAL_STATE_NONE);
680 for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) {
681 if (_check_enabled_user_cb_lock(type))
682 g_mutex_clear(&handle->user_cb_lock[type]);
685 if (handle->message_queue) {
686 g_queue_free(handle->message_queue);
687 handle->message_queue = NULL;
690 g_cond_broadcast(&handle->message_queue_cond);
691 g_mutex_clear(&handle->message_queue_lock);
692 g_cond_clear(&handle->message_queue_cond);
699 return PLAYER_ERROR_NONE;
702 static void *__prepare_async_thread_func(void *data)
704 legacy_player_t *handle = data;
705 int ret = MM_ERROR_NONE;
708 ret = mm_player_pause(handle->mm_handle);
709 if (ret != MM_ERROR_NONE) {
710 LOGE("Failed to pause - core fw error(0x%x)", ret);
711 __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
713 if (handle->error_code == PLAYER_ERROR_NONE) {
714 /* if there is no received error msg, it has to be posted here. */
715 MMMessageParamType msg_param;
716 msg_param.code = ret;
717 __msg_callback(MM_MESSAGE_ERROR, (void *)&msg_param, (void *)handle);
720 if (!handle->is_shutdown) {
721 ret = mm_player_unrealize(handle->mm_handle);
722 if (ret != MM_ERROR_NONE)
723 LOGE("Failed to unrealize - 0x%x", ret);
731 int legacy_player_prepare_async(legacy_player_h player, player_prepared_cb callback, void *user_data)
733 legacy_player_t *handle = (legacy_player_t *)player;
734 int ret = MM_ERROR_NONE;
739 PLAYER_INSTANCE_CHECK(player);
740 PLAYER_TRACE_ASYNC_BEGIN("MM:PLAYER:PREPARE_ASYNC", *(int *)handle);
741 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
743 __player_update_state(handle, PLAYER_INTERNAL_STATE_PRE_READY);
744 LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
746 handle->last_play_position = 0;
747 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
748 LOGE("player is already prepareing");
749 LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
750 __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
751 return PLAYER_ERROR_INVALID_OPERATION;
754 /* LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_PREPARE); */
755 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = callback;
756 handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = user_data;
758 LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
760 ret = mm_player_set_message_callback(handle->mm_handle, __msg_callback, (void *)handle);
761 if (ret != MM_ERROR_NONE)
762 LOGW("Failed to set message callback function (0x%x)", ret);
764 if (handle->display_type == PLAYER_DISPLAY_TYPE_NONE) {
765 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", MM_DISPLAY_SURFACE_NULL, (char *)NULL);
766 if (ret != MM_ERROR_NONE)
767 LOGW("Failed to set display surface type 'MM_DISPLAY_SURFACE_NULL' (0x%x)", ret);
770 /* FIXME : new funct path is needed to update video instead of set attr again */
771 ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_visible", &visible, (char *)NULL);
772 if (ret != MM_ERROR_NONE) goto ERROR;
779 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", value, (char *)NULL);
780 if (ret != MM_ERROR_NONE) goto ERROR;
783 ret = mm_player_realize(handle->mm_handle);
784 if (ret != MM_ERROR_NONE) {
785 LOGE("Failed to realize - 0x%x", ret);
789 ret = pthread_create(&handle->prepare_async_thread, NULL, (void *)__prepare_async_thread_func, (void *)handle);
792 LOGE("Failed to create thread ret = %d", ret);
793 LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
794 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
795 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
796 /* user_data will be free at player_disp_prepare_async() */
797 handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
799 LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
800 __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
801 return PLAYER_ERROR_OUT_OF_MEMORY;
805 return PLAYER_ERROR_NONE;
808 LOGW("prepare cb is released");
809 LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
810 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
811 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
812 /* user_data will be free at player_disp_prepare_async() */
813 handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
815 LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
816 __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
818 LOGE("LEAVE 0x%X", ret);
819 return __player_convert_error_code(ret, (char *)__FUNCTION__);
822 int legacy_player_prepare(legacy_player_h player)
824 int ret = MM_ERROR_NONE;
826 legacy_player_t *handle = (legacy_player_t *)player;
829 PLAYER_TRACE_BEGIN("MM:PLAYER:PREPARE");
830 PLAYER_INSTANCE_CHECK(player);
831 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
832 __player_update_state(handle, PLAYER_INTERNAL_STATE_PRE_READY);
834 handle->last_play_position = 0;
835 ret = mm_player_set_message_callback(handle->mm_handle, __msg_callback, (void *)handle);
836 if (ret != MM_ERROR_NONE)
837 LOGW("Failed to set message callback function (0x%x)", ret);
839 if (handle->display_type == PLAYER_DISPLAY_TYPE_NONE) {
840 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", MM_DISPLAY_SURFACE_NULL, (char *)NULL);
841 if (ret != MM_ERROR_NONE)
842 LOGW("Failed to set display surface type 'MM_DISPLAY_SURFACE_NULL' (0x%x)", ret);
844 ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_visible", &visible, (char *)NULL);
845 if (ret != MM_ERROR_NONE) {
846 __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
847 return __player_convert_error_code(ret, (char *)__FUNCTION__);
850 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", visible, (char *)NULL);
851 if (ret != MM_ERROR_NONE)
852 LOGW("Failed to set display display_visible '%d' (0x%x)", visible, ret);
855 ret = mm_player_realize(handle->mm_handle);
856 if (ret != MM_ERROR_NONE) {
857 LOGE("Failed to realize - 0x%x", ret);
858 __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
859 return __player_convert_error_code(ret, (char *)__FUNCTION__);
862 ret = mm_player_pause(handle->mm_handle);
863 if (ret != MM_ERROR_NONE) {
865 uret = mm_player_unrealize(handle->mm_handle);
866 if (uret != MM_ERROR_NONE)
867 LOGE("Failed to unrealize - 0x%x", uret);
869 LOGE("Failed to pause - 0x%x", ret);
870 __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
871 return __player_convert_error_code(ret, (char *)__FUNCTION__);
874 __player_update_state(handle, PLAYER_INTERNAL_STATE_READY);
878 return PLAYER_ERROR_NONE;
881 int legacy_player_unprepare(legacy_player_h player)
883 legacy_player_t *handle = (legacy_player_t *)player;
884 int ret = MM_ERROR_NONE;
887 PLAYER_TRACE_BEGIN("MM:PLAYER:UNPREPARE");
888 PLAYER_INSTANCE_CHECK(player);
890 handle->is_shutdown = true;
892 /* Initialize the setting regardless of error return */
893 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) {
894 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
895 handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
898 if (!__player_state_validate(handle, PLAYER_STATE_READY) && !handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
899 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
900 return PLAYER_ERROR_INVALID_STATE;
903 LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
904 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
905 LOGW("Need to check. prepare cb have to be reset before");
906 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
907 g_free(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]);
908 handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
910 LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
912 /* stop the pause state trasition to release prepare thread */
913 if (handle->internal_state == PLAYER_INTERNAL_STATE_PRE_READY)
914 mm_player_abort_pause(handle->mm_handle);
916 __RELEASEIF_PREPARE_THREAD(handle->prepare_async_thread);
918 ret = mm_player_unrealize(handle->mm_handle);
919 if (ret != MM_ERROR_NONE)
920 return __player_convert_error_code(ret, (char *)__FUNCTION__);
922 __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
923 handle->is_display_visible = true;
927 return PLAYER_ERROR_NONE;
930 int legacy_player_set_uri(legacy_player_h player, const char *uri)
932 legacy_player_t *handle = (legacy_player_t *)player;
933 int ret = MM_ERROR_NONE;
934 PLAYER_INSTANCE_CHECK(player);
935 PLAYER_NULL_ARG_CHECK(uri);
936 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
938 handle->is_media_stream = false;
939 ret = mm_player_set_uri(handle->mm_handle, uri);
940 if (ret != MM_ERROR_NONE)
941 return __player_convert_error_code(ret, (char *)__FUNCTION__);
943 return PLAYER_ERROR_NONE;
946 int legacy_player_set_memory_buffer(legacy_player_h player, const void *data, int size)
948 legacy_player_t *handle = (legacy_player_t *)player;
950 int ret = MM_ERROR_NONE;
951 PLAYER_INSTANCE_CHECK(player);
952 PLAYER_NULL_ARG_CHECK(data);
953 PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
954 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
956 handle->is_media_stream = FALSE;
958 snprintf(uri, sizeof(uri), "mem:///ext=%s,size=%d", "", size);
959 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_CONTENT_URI, uri, strlen(uri), MM_PLAYER_MEMORY_SRC, data, size, (char *)NULL);
960 if (ret != MM_ERROR_NONE)
961 return __player_convert_error_code(ret, (char *)__FUNCTION__);
963 return PLAYER_ERROR_NONE;
966 int legacy_player_get_state(legacy_player_h player, player_state_e *state)
968 legacy_player_t *handle = (legacy_player_t *)player;
969 PLAYER_INSTANCE_CHECK(player);
970 PLAYER_NULL_ARG_CHECK(state);
971 *state = handle->state;
972 return PLAYER_ERROR_NONE;
975 int legacy_player_set_volume(legacy_player_h player, float left, float right)
977 legacy_player_t *handle = (legacy_player_t *)player;
978 mmplayer_volume_type_t vol;
979 int ret = MM_ERROR_NONE;
980 PLAYER_INSTANCE_CHECK(player);
981 PLAYER_CHECK_CONDITION(left >= 0 && left <= 1.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
982 PLAYER_CHECK_CONDITION(right >= 0 && right <= 1.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
984 vol.level[MM_VOLUME_CHANNEL_LEFT] = left;
985 vol.level[MM_VOLUME_CHANNEL_RIGHT] = right;
986 ret = mm_player_set_volume(handle->mm_handle, &vol);
987 if (ret != MM_ERROR_NONE)
988 return __player_convert_error_code(ret, (char *)__FUNCTION__);
990 return PLAYER_ERROR_NONE;
993 int legacy_player_get_volume(legacy_player_h player, float *left, float *right)
995 legacy_player_t *handle = (legacy_player_t *)player;
996 mmplayer_volume_type_t vol;
997 int ret = MM_ERROR_NONE;
998 PLAYER_INSTANCE_CHECK(player);
999 PLAYER_NULL_ARG_CHECK(left);
1000 PLAYER_NULL_ARG_CHECK(right);
1002 ret = mm_player_get_volume(handle->mm_handle, &vol);
1003 if (ret != MM_ERROR_NONE) {
1004 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1007 *left = vol.level[MM_VOLUME_CHANNEL_LEFT];
1008 *right = vol.level[MM_VOLUME_CHANNEL_RIGHT];
1009 return PLAYER_ERROR_NONE;
1012 int legacy_player_set_sound_stream_info(legacy_player_h player, sound_stream_info_h stream_info)
1014 legacy_player_t *handle = (legacy_player_t *)player;
1015 int ret = MM_ERROR_NONE;
1016 bool is_available = false;
1017 PLAYER_INSTANCE_CHECK(player);
1018 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
1020 /* check if stream_info is valid */
1021 ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_PLAYER, &is_available);
1022 if (ret != MM_ERROR_NONE)
1023 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1026 char *stream_type = NULL;
1027 int stream_index = 0;
1028 ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
1029 ret = sound_manager_get_index_from_stream_information(stream_info, &stream_index);
1030 if (ret == SOUND_MANAGER_ERROR_NONE)
1031 ret = mm_player_set_sound_stream_info(handle->mm_handle, stream_type, stream_index);
1033 ret = MM_ERROR_PLAYER_INTERNAL;
1035 ret = MM_ERROR_NOT_SUPPORT_API;
1038 if (ret != MM_ERROR_NONE)
1039 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1041 return PLAYER_ERROR_NONE;
1044 int legacy_player_set_audio_latency_mode(legacy_player_h player, audio_latency_mode_e latency_mode)
1046 legacy_player_t *handle = (legacy_player_t *)player;
1047 int ret = MM_ERROR_NONE;
1048 PLAYER_INSTANCE_CHECK(player);
1050 ret = mm_player_set_attribute(handle->mm_handle, NULL, "sound_latency_mode", latency_mode, (char *)NULL);
1051 if (ret != MM_ERROR_NONE)
1052 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1054 return PLAYER_ERROR_NONE;
1057 int legacy_player_get_audio_latency_mode(legacy_player_h player, audio_latency_mode_e *latency_mode)
1059 legacy_player_t *handle = (legacy_player_t *)player;
1060 int ret = MM_ERROR_NONE;
1061 PLAYER_INSTANCE_CHECK(player);
1062 PLAYER_NULL_ARG_CHECK(latency_mode);
1064 ret = mm_player_get_attribute(handle->mm_handle, NULL, "sound_latency_mode", latency_mode, (char *)NULL);
1065 if (ret != MM_ERROR_NONE)
1066 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1068 return PLAYER_ERROR_NONE;
1071 int legacy_player_start(legacy_player_h player)
1073 legacy_player_t *handle = (legacy_player_t *)player;
1074 int ret = MM_ERROR_NONE;
1077 PLAYER_INSTANCE_CHECK(player);
1079 if (handle->state > PLAYER_STATE_IDLE) {
1080 if (handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY && handle->is_display_visible) {
1081 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", 1, (char *)NULL);
1082 if (ret != MM_ERROR_NONE)
1083 LOGW("Failed to set display_visible '1' (0x%x)", ret);
1085 if (handle->internal_state == PLAYER_INTERNAL_STATE_STOPPED) {
1086 ret = mm_player_start(handle->mm_handle);
1087 LOGI("stop -> start() ");
1089 if (handle->state == PLAYER_STATE_READY)
1090 ret = mm_player_start(handle->mm_handle);
1092 ret = mm_player_resume(handle->mm_handle);
1095 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1096 return PLAYER_ERROR_INVALID_STATE;
1099 if (ret != MM_ERROR_NONE)
1100 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1102 __player_update_state(handle, PLAYER_INTERNAL_STATE_PLAYING);
1105 return PLAYER_ERROR_NONE;
1108 int legacy_player_stop(legacy_player_h player)
1110 legacy_player_t *handle = (legacy_player_t *)player;
1111 int ret = MM_ERROR_NONE;
1114 PLAYER_INSTANCE_CHECK(player);
1116 if (handle->state == PLAYER_STATE_PLAYING || handle->state == PLAYER_STATE_PAUSED) {
1117 if (handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1118 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", 0, (char *)NULL);
1119 if (ret != MM_ERROR_NONE)
1120 LOGW("Failed to set display_visible '0' (0x%x)", ret);
1123 ret = mm_player_stop(handle->mm_handle);
1124 if (ret != MM_ERROR_NONE) {
1125 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1128 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) {
1129 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
1130 handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
1133 __player_update_state(handle, PLAYER_INTERNAL_STATE_STOPPED);
1136 return PLAYER_ERROR_NONE;
1139 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1140 return PLAYER_ERROR_INVALID_STATE;
1143 int legacy_player_pause(legacy_player_h player)
1145 legacy_player_t *handle = (legacy_player_t *)player;
1146 int ret = MM_ERROR_NONE;
1149 PLAYER_INSTANCE_CHECK(player);
1150 PLAYER_STATE_CHECK(handle, PLAYER_STATE_PLAYING);
1152 ret = mm_player_pause(handle->mm_handle);
1153 if (ret != MM_ERROR_NONE)
1154 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1156 __player_update_state(handle, PLAYER_INTERNAL_STATE_PAUSED);
1159 return PLAYER_ERROR_NONE;
1162 int legacy_player_set_play_position(legacy_player_h player, int64_t nanoseconds, bool accurate, player_seek_completed_cb callback, void *user_data)
1164 legacy_player_t *handle = (legacy_player_t *)player;
1165 int ret = MM_ERROR_NONE;
1166 int accurated = accurate ? 1 : 0;
1169 PLAYER_INSTANCE_CHECK(player);
1170 PLAYER_CHECK_CONDITION(nanoseconds >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1172 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1173 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1174 return PLAYER_ERROR_INVALID_STATE;
1177 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] && !handle->is_media_stream) {
1178 LOGE("previous seeking request is in processing.");
1179 return PLAYER_ERROR_SEEK_FAILED;
1182 LOGI("Event type : %d, pos : %"PRId64, MUSE_PLAYER_EVENT_TYPE_SEEK, nanoseconds);
1183 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = callback;
1184 handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = user_data;
1186 ret = mm_player_set_attribute(handle->mm_handle, NULL, "accurate_seek", accurated, (char *)NULL);
1187 if (ret != MM_ERROR_NONE)
1188 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1190 ret = mm_player_set_position(handle->mm_handle, nanoseconds);
1191 if (ret != MM_ERROR_NONE) {
1192 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
1193 handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
1194 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1198 return PLAYER_ERROR_NONE;
1201 int legacy_player_get_play_position(legacy_player_h player, int64_t *nanoseconds)
1203 legacy_player_t *handle = (legacy_player_t *)player;
1204 int ret = MM_ERROR_NONE;
1206 PLAYER_INSTANCE_CHECK(player);
1207 PLAYER_NULL_ARG_CHECK(nanoseconds);
1209 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
1210 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1211 return PLAYER_ERROR_INVALID_STATE;
1214 ret = mm_player_get_position(handle->mm_handle, &pos);
1215 if (ret != MM_ERROR_NONE) {
1216 if (ret == MM_ERROR_PLAYER_NOT_INITIALIZED) {
1217 /* During playbak if a interrupt is occurred, the player can be destroyed internally.
1218 libmm-player will post position msg with last playback position before destory pipeline */
1219 if (handle->state == PLAYER_STATE_IDLE) {
1220 if (handle->last_play_position > 0)
1221 *nanoseconds = handle->last_play_position;
1224 LOGD("position %"PRId64, *nanoseconds);
1225 return PLAYER_ERROR_NONE;
1228 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1232 return PLAYER_ERROR_NONE;
1235 int legacy_player_set_mute(legacy_player_h player, bool muted)
1237 legacy_player_t *handle = (legacy_player_t *)player;
1238 int ret = MM_ERROR_NONE;
1239 PLAYER_INSTANCE_CHECK(player);
1241 ret = mm_player_set_mute(handle->mm_handle, muted);
1242 if (ret != MM_ERROR_NONE)
1243 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1245 return PLAYER_ERROR_NONE;
1248 int legacy_player_is_muted(legacy_player_h player, bool *muted)
1250 legacy_player_t *handle = (legacy_player_t *)player;
1252 int ret = MM_ERROR_NONE;
1253 PLAYER_INSTANCE_CHECK(player);
1254 PLAYER_NULL_ARG_CHECK(muted);
1256 ret = mm_player_get_mute(handle->mm_handle, &_mute);
1257 if (ret != MM_ERROR_NONE)
1258 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1260 *muted = (bool)_mute;
1262 return PLAYER_ERROR_NONE;
1265 int legacy_player_set_looping(legacy_player_h player, bool looping)
1267 legacy_player_t *handle = (legacy_player_t *)player;
1268 int ret = MM_ERROR_NONE;
1270 PLAYER_INSTANCE_CHECK(player);
1275 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_PLAYBACK_COUNT, value, (char *)NULL);
1276 if (ret != MM_ERROR_NONE)
1277 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1279 return PLAYER_ERROR_NONE;
1282 int legacy_player_is_looping(legacy_player_h player, bool *looping)
1284 legacy_player_t *handle = (legacy_player_t *)player;
1285 int ret = MM_ERROR_NONE;
1287 PLAYER_INSTANCE_CHECK(player);
1288 PLAYER_NULL_ARG_CHECK(looping);
1290 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_PLAYBACK_COUNT, &count, (char *)NULL);
1291 if (ret != MM_ERROR_NONE)
1292 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1294 *looping = (count == -1) ? true : false;
1296 return PLAYER_ERROR_NONE;
1299 int legacy_player_get_duration(legacy_player_h player, int64_t *duration)
1301 legacy_player_t *handle = (legacy_player_t *)player;
1302 int ret = MM_ERROR_NONE;
1303 PLAYER_INSTANCE_CHECK(player);
1304 PLAYER_NULL_ARG_CHECK(duration);
1306 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1307 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1308 return PLAYER_ERROR_INVALID_STATE;
1311 ret = mm_player_get_duration(handle->mm_handle, duration);
1312 if (ret != MM_ERROR_NONE)
1313 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1315 LOGD("content dur: %"PRId64, *duration);
1316 return PLAYER_ERROR_NONE;
1319 int legacy_player_set_display_mode(legacy_player_h player, player_display_mode_e mode)
1321 legacy_player_t *handle = (legacy_player_t *)player;
1322 int ret = MM_ERROR_NONE;
1324 LOGI("<ENTER: mode:%d>", mode);
1325 PLAYER_INSTANCE_CHECK(player);
1327 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_method", mode, (char *)NULL);
1328 if (ret != MM_ERROR_NONE)
1329 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1331 return PLAYER_ERROR_NONE;
1334 int legacy_player_get_display_mode(legacy_player_h player, player_display_mode_e *mode)
1336 legacy_player_t *handle = (legacy_player_t *)player;
1337 int ret = MM_ERROR_NONE;
1338 PLAYER_INSTANCE_CHECK(player);
1339 PLAYER_NULL_ARG_CHECK(mode);
1341 ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_method", mode, (char *)NULL);
1342 if (ret != MM_ERROR_NONE)
1343 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1345 return PLAYER_ERROR_NONE;
1348 int legacy_player_set_playback_rate(legacy_player_h player, float rate)
1350 legacy_player_t *handle = (legacy_player_t *)player;
1351 int ret = MM_ERROR_NONE;
1352 LOGI("<ENTER: rate %0.1f>", rate);
1353 PLAYER_INSTANCE_CHECK(player);
1354 PLAYER_CHECK_CONDITION(rate >= -5.0 && rate <= 5.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1356 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1357 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1358 return PLAYER_ERROR_INVALID_STATE;
1361 ret = mm_player_set_play_speed(handle->mm_handle, rate, false);
1364 case MM_ERROR_PLAYER_NO_OP:
1365 ret = PLAYER_ERROR_NONE;
1367 case MM_ERROR_NOT_SUPPORT_API:
1368 case MM_ERROR_PLAYER_SEEK:
1369 LOGE("PLAYER_ERROR_INVALID_OPERATION : seek error");
1370 ret = PLAYER_ERROR_INVALID_OPERATION;
1373 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1379 int legacy_player_set_display_rotation(legacy_player_h player, player_display_rotation_e rotation)
1381 legacy_player_t *handle = (legacy_player_t *)player;
1382 int ret = MM_ERROR_NONE;
1383 PLAYER_INSTANCE_CHECK(player);
1385 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_ROTATION, rotation, (char *)NULL);
1386 if (ret != MM_ERROR_NONE)
1387 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1389 return PLAYER_ERROR_NONE;
1392 int legacy_player_get_display_rotation(legacy_player_h player, player_display_rotation_e *rotation)
1394 legacy_player_t *handle = (legacy_player_t *)player;
1395 int ret = MM_ERROR_NONE;
1396 PLAYER_INSTANCE_CHECK(player);
1397 PLAYER_NULL_ARG_CHECK(rotation);
1399 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_ROTATION, rotation, (char *)NULL);
1400 if (ret != MM_ERROR_NONE)
1401 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1403 return PLAYER_ERROR_NONE;
1406 int legacy_player_set_display_visible(legacy_player_h player, bool visible)
1408 legacy_player_t *handle = (legacy_player_t *)player;
1409 int ret = MM_ERROR_NONE;
1411 PLAYER_INSTANCE_CHECK(player);
1416 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", value, (char *)NULL);
1417 if (ret != MM_ERROR_NONE)
1418 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1420 handle->is_display_visible = visible;
1421 return PLAYER_ERROR_NONE;
1424 int legacy_player_is_display_visible(legacy_player_h player, bool *visible)
1426 legacy_player_t *handle = (legacy_player_t *)player;
1427 int ret = MM_ERROR_NONE;
1429 PLAYER_INSTANCE_CHECK(player);
1430 PLAYER_NULL_ARG_CHECK(visible);
1432 ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_visible", &value, (char *)NULL);
1433 if (ret != MM_ERROR_NONE)
1434 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1436 *visible = (value == 0) ? false : true;
1438 return PLAYER_ERROR_NONE;
1441 int legacy_player_get_content_info(legacy_player_h player, player_content_info_e key, char **value)
1443 legacy_player_t *handle = (legacy_player_t *)player;
1444 int ret = MM_ERROR_NONE;
1448 PLAYER_INSTANCE_CHECK(player);
1449 PLAYER_NULL_ARG_CHECK(value);
1451 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1452 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1453 return PLAYER_ERROR_INVALID_STATE;
1457 case PLAYER_CONTENT_INFO_ALBUM:
1458 attr = MM_PLAYER_TAG_ALBUM;
1460 case PLAYER_CONTENT_INFO_ARTIST:
1461 attr = MM_PLAYER_TAG_ARTIST;
1463 case PLAYER_CONTENT_INFO_AUTHOR:
1464 attr = MM_PLAYER_TAG_AUTHOUR;
1466 case PLAYER_CONTENT_INFO_GENRE:
1467 attr = MM_PLAYER_TAG_GENRE;
1469 case PLAYER_CONTENT_INFO_TITLE:
1470 attr = MM_PLAYER_TAG_TITLE;
1472 case PLAYER_CONTENT_INFO_YEAR:
1473 attr = MM_PLAYER_TAG_DATE;
1479 ret = mm_player_get_attribute(handle->mm_handle, NULL, attr, &val, &val_len, (char *)NULL);
1480 if (ret != MM_ERROR_NONE)
1481 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1485 *value = strndup(val, val_len);
1487 *value = strndup("", 0);
1489 if (*value == NULL) {
1490 LOGE("PLAYER_ERROR_OUT_OF_MEMORY : fail to strdup");
1491 return PLAYER_ERROR_OUT_OF_MEMORY;
1494 return PLAYER_ERROR_NONE;
1497 int legacy_player_get_codec_info(legacy_player_h player, char **audio_codec, char **video_codec)
1499 legacy_player_t *handle = (legacy_player_t *)player;
1500 int ret = MM_ERROR_NONE;
1505 PLAYER_INSTANCE_CHECK(player);
1506 PLAYER_NULL_ARG_CHECK(audio_codec);
1507 PLAYER_NULL_ARG_CHECK(video_codec);
1509 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1510 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1511 return PLAYER_ERROR_INVALID_STATE;
1514 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_AUDIO_CODEC, &audio, &audio_len, MM_PLAYER_VIDEO_CODEC, &video, &video_len, (char *)NULL);
1515 if (ret != MM_ERROR_NONE)
1516 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1518 *audio_codec = NULL;
1520 *audio_codec = strndup(audio, audio_len);
1522 *audio_codec = strndup("", 0);
1524 *video_codec = NULL;
1526 *video_codec = strndup(video, video_len);
1528 *video_codec = strndup("", 0);
1530 LOGD("codec info: %s, %s", *audio_codec, *video_codec);
1531 return PLAYER_ERROR_NONE;
1534 int legacy_player_get_audio_stream_info(legacy_player_h player, int *sample_rate, int *channel, int *bit_rate)
1536 legacy_player_t *handle = (legacy_player_t *)player;
1537 int ret = MM_ERROR_NONE;
1538 PLAYER_INSTANCE_CHECK(player);
1539 PLAYER_NULL_ARG_CHECK(sample_rate);
1540 PLAYER_NULL_ARG_CHECK(channel);
1541 PLAYER_NULL_ARG_CHECK(bit_rate);
1543 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1544 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1545 return PLAYER_ERROR_INVALID_STATE;
1547 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_AUDIO_SAMPLERATE, sample_rate, MM_PLAYER_AUDIO_CHANNEL, channel, MM_PLAYER_AUDIO_BITRATE, bit_rate, (char *)NULL);
1548 if (ret != MM_ERROR_NONE)
1549 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1551 return PLAYER_ERROR_NONE;
1554 int legacy_player_get_video_stream_info(legacy_player_h player, int *fps, int *bit_rate)
1556 legacy_player_t *handle = (legacy_player_t *)player;
1557 int ret = MM_ERROR_NONE;
1558 PLAYER_INSTANCE_CHECK(player);
1559 PLAYER_NULL_ARG_CHECK(fps);
1560 PLAYER_NULL_ARG_CHECK(bit_rate);
1562 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1563 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1564 return PLAYER_ERROR_INVALID_STATE;
1566 ret = mm_player_get_attribute(handle->mm_handle, NULL, "content_video_fps", fps, "content_video_bitrate", bit_rate, (char *)NULL);
1567 if (ret != MM_ERROR_NONE)
1568 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1570 return PLAYER_ERROR_NONE;
1573 int legacy_player_get_video_size(legacy_player_h player, int *width, int *height)
1575 legacy_player_t *handle = (legacy_player_t *)player;
1576 int ret = MM_ERROR_NONE;
1579 PLAYER_INSTANCE_CHECK(player);
1580 PLAYER_NULL_ARG_CHECK(width);
1581 PLAYER_NULL_ARG_CHECK(height);
1582 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1583 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1584 return PLAYER_ERROR_INVALID_STATE;
1586 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_WIDTH, &w, MM_PLAYER_VIDEO_HEIGHT, &h, (char *)NULL);
1587 if (ret != MM_ERROR_NONE)
1588 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1592 LOGI("width : %d, height : %d", w, h);
1593 return PLAYER_ERROR_NONE;
1596 int legacy_player_get_album_art(legacy_player_h player, void **album_art, int *size)
1598 legacy_player_t *handle = (legacy_player_t *)player;
1599 int ret = MM_ERROR_NONE;
1600 PLAYER_INSTANCE_CHECK(player);
1601 PLAYER_NULL_ARG_CHECK(size);
1602 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1603 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1604 return PLAYER_ERROR_INVALID_STATE;
1607 ret = mm_player_get_attribute(handle->mm_handle, NULL, "tag_album_cover", album_art, size, (char *)NULL);
1608 if (ret != MM_ERROR_NONE)
1609 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1611 return PLAYER_ERROR_NONE;
1614 int legacy_player_audio_effect_get_equalizer_bands_count(legacy_player_h player, int *count)
1616 legacy_player_t *handle = (legacy_player_t *)player;
1617 int ret = MM_ERROR_NONE;
1618 PLAYER_INSTANCE_CHECK(player);
1619 PLAYER_NULL_ARG_CHECK(count);
1621 ret = mm_player_audio_effect_custom_get_eq_bands_number(handle->mm_handle, count);
1622 if (ret != MM_ERROR_NONE)
1623 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1625 return PLAYER_ERROR_NONE;
1628 int legacy_player_audio_effect_set_equalizer_all_bands(legacy_player_h player, int *band_levels, int length)
1630 legacy_player_t *handle = (legacy_player_t *)player;
1631 int ret = MM_ERROR_NONE;
1632 PLAYER_INSTANCE_CHECK(player);
1633 PLAYER_NULL_ARG_CHECK(band_levels);
1635 ret = mm_player_audio_effect_custom_set_level_eq_from_list(handle->mm_handle, band_levels, length);
1636 if (ret != MM_ERROR_NONE)
1637 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1639 ret = mm_player_audio_effect_custom_apply(handle->mm_handle);
1640 return (ret == MM_ERROR_NONE) ? PLAYER_ERROR_NONE : __player_convert_error_code(ret, (char *)__FUNCTION__);
1643 int legacy_player_audio_effect_set_equalizer_band_level(legacy_player_h player, int index, int level)
1645 legacy_player_t *handle = (legacy_player_t *)player;
1646 int ret = MM_ERROR_NONE;
1647 PLAYER_INSTANCE_CHECK(player);
1649 ret = mm_player_audio_effect_custom_set_level(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, index, level);
1650 if (ret != MM_ERROR_NONE)
1651 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1653 ret = mm_player_audio_effect_custom_apply(handle->mm_handle);
1654 if (ret != MM_ERROR_NONE)
1655 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1657 return PLAYER_ERROR_NONE;
1660 int legacy_player_audio_effect_get_equalizer_band_level(legacy_player_h player, int index, int *level)
1662 legacy_player_t *handle = (legacy_player_t *)player;
1663 int ret = MM_ERROR_NONE;
1664 PLAYER_INSTANCE_CHECK(player);
1665 PLAYER_NULL_ARG_CHECK(level);
1667 ret = mm_player_audio_effect_custom_get_level(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, index, level);
1668 if (ret != MM_ERROR_NONE)
1669 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1671 return PLAYER_ERROR_NONE;
1674 int legacy_player_audio_effect_get_equalizer_level_range(legacy_player_h player, int *min, int *max)
1676 legacy_player_t *handle = (legacy_player_t *)player;
1677 int ret = MM_ERROR_NONE;
1678 PLAYER_INSTANCE_CHECK(player);
1679 PLAYER_NULL_ARG_CHECK(min);
1680 PLAYER_NULL_ARG_CHECK(max);
1682 ret = mm_player_audio_effect_custom_get_level_range(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, min, max);
1683 if (ret != MM_ERROR_NONE)
1684 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1686 return PLAYER_ERROR_NONE;
1689 int legacy_player_audio_effect_get_equalizer_band_frequency(legacy_player_h player, int index, int *frequency)
1691 legacy_player_t *handle = (legacy_player_t *)player;
1692 int ret = MM_ERROR_NONE;
1693 PLAYER_INSTANCE_CHECK(player);
1694 PLAYER_NULL_ARG_CHECK(frequency);
1696 ret = mm_player_audio_effect_custom_get_eq_bands_freq(handle->mm_handle, index, frequency);
1697 if (ret != MM_ERROR_NONE)
1698 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1700 return PLAYER_ERROR_NONE;
1703 int legacy_player_audio_effect_get_equalizer_band_frequency_range(legacy_player_h player, int index, int *range)
1705 legacy_player_t *handle = (legacy_player_t *)player;
1706 int ret = MM_ERROR_NONE;
1707 PLAYER_INSTANCE_CHECK(player);
1708 PLAYER_NULL_ARG_CHECK(range);
1710 ret = mm_player_audio_effect_custom_get_eq_bands_width(handle->mm_handle, index, range);
1711 if (ret != MM_ERROR_NONE)
1712 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1714 return PLAYER_ERROR_NONE;
1717 int legacy_player_audio_effect_equalizer_clear(legacy_player_h player)
1719 legacy_player_t *handle = (legacy_player_t *)player;
1720 int ret = MM_ERROR_NONE;
1721 PLAYER_INSTANCE_CHECK(player);
1723 ret = mm_player_audio_effect_custom_clear_eq_all(handle->mm_handle);
1724 if (ret != MM_ERROR_NONE)
1725 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1727 ret = mm_player_audio_effect_custom_apply(handle->mm_handle);
1728 if (ret != MM_ERROR_NONE)
1729 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1731 return PLAYER_ERROR_NONE;
1734 int legacy_player_audio_effect_equalizer_is_available(legacy_player_h player, bool *available)
1736 legacy_player_t *handle = (legacy_player_t *)player;
1737 int ret = MM_ERROR_NONE;
1738 PLAYER_INSTANCE_CHECK(player);
1739 PLAYER_NULL_ARG_CHECK(available);
1740 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
1741 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1742 return PLAYER_ERROR_INVALID_STATE;
1745 ret = mm_player_is_supported_custom_effect_type(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ);
1746 if (ret != MM_ERROR_NONE)
1751 return PLAYER_ERROR_NONE;
1754 int legacy_player_set_subtitle_path(legacy_player_h player, const char *path)
1756 legacy_player_t *handle = (legacy_player_t *)player;
1757 int ret = MM_ERROR_NONE;
1760 PLAYER_INSTANCE_CHECK(player);
1762 if ((path == NULL) && (handle->state != PLAYER_STATE_IDLE))
1763 return PLAYER_ERROR_INVALID_PARAMETER;
1765 ret = mm_player_set_external_subtitle_path(handle->mm_handle, path);
1766 if (ret != MM_ERROR_NONE)
1767 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1770 return PLAYER_ERROR_NONE;
1773 int legacy_player_set_subtitle_position_offset(legacy_player_h player, int millisecond)
1775 /* PLAYER_CHECK_CONDITION(millisecond>=0 ,PLAYER_ERROR_INVALID_PARAMETER ,"PLAYER_ERROR_INVALID_PARAMETER" ); */
1776 legacy_player_t *handle = (legacy_player_t *)player;
1777 int ret = MM_ERROR_NONE;
1778 PLAYER_INSTANCE_CHECK(player);
1779 if (!__player_state_validate(handle, PLAYER_STATE_PLAYING)) {
1780 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1781 return PLAYER_ERROR_INVALID_STATE;
1784 ret = mm_player_adjust_subtitle_position(handle->mm_handle, millisecond);
1785 if (ret != MM_ERROR_NONE)
1786 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1788 return PLAYER_ERROR_NONE;
1791 int legacy_player_capture_video(legacy_player_h player, player_video_captured_cb callback, void *user_data)
1793 legacy_player_t *handle = (legacy_player_t *)player;
1794 int ret = MM_ERROR_NONE;
1797 PLAYER_INSTANCE_CHECK(player);
1798 PLAYER_NULL_ARG_CHECK(callback);
1799 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) {
1800 LOGE("previous capturing request is in processing.");
1801 return PLAYER_ERROR_VIDEO_CAPTURE_FAILED;
1804 LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_CAPTURE);
1805 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = callback;
1806 handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = user_data;
1808 if (handle->state >= PLAYER_STATE_READY) {
1809 ret = mm_player_do_video_capture(handle->mm_handle);
1810 if (ret == MM_ERROR_PLAYER_NO_OP) {
1811 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
1812 handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
1813 LOGE("PLAYER_ERROR_INVALID_OPERATION : video display must be set : %d", handle->display_type);
1814 return PLAYER_ERROR_INVALID_OPERATION;
1816 if (ret != MM_ERROR_NONE) {
1817 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
1818 handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
1819 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1821 return PLAYER_ERROR_NONE;
1824 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1825 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
1826 handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
1829 return PLAYER_ERROR_INVALID_STATE;
1832 int legacy_player_set_streaming_cookie(legacy_player_h player, const char *cookie, int size)
1834 legacy_player_t *handle = (legacy_player_t *)player;
1835 int ret = MM_ERROR_NONE;
1836 PLAYER_INSTANCE_CHECK(player);
1837 PLAYER_NULL_ARG_CHECK(cookie);
1838 PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1839 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
1841 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_STREAMING_COOKIE, cookie, size, (char *)NULL);
1842 if (ret != MM_ERROR_NONE)
1843 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1845 return PLAYER_ERROR_NONE;
1848 int legacy_player_set_streaming_user_agent(legacy_player_h player, const char *user_agent, int size)
1850 legacy_player_t *handle = (legacy_player_t *)player;
1851 int ret = MM_ERROR_NONE;
1852 PLAYER_INSTANCE_CHECK(player);
1853 PLAYER_NULL_ARG_CHECK(user_agent);
1854 PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1855 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
1857 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_STREAMING_USER_AGENT, user_agent, size, (char *)NULL);
1858 if (ret != MM_ERROR_NONE)
1859 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1861 return PLAYER_ERROR_NONE;
1864 int legacy_player_get_streaming_download_progress(legacy_player_h player, int *start_pos, int *end_pos)
1866 legacy_player_t *handle = (legacy_player_t *)player;
1867 int ret = MM_ERROR_NONE;
1868 PLAYER_INSTANCE_CHECK(player);
1869 PLAYER_NULL_ARG_CHECK(start_pos && end_pos);
1870 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1871 LOGE("invalid state error, current state - %d", handle->state);
1872 return PLAYER_ERROR_INVALID_STATE;
1875 ret = mm_player_get_buffer_position(handle->mm_handle, start_pos, end_pos);
1876 if (ret != MM_ERROR_NONE)
1877 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1879 return PLAYER_ERROR_NONE;
1882 int legacy_player_set_completed_cb(legacy_player_h player, player_completed_cb callback, void *user_data)
1884 return __set_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player, callback, user_data);
1887 int legacy_player_unset_completed_cb(legacy_player_h player)
1889 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player);
1892 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1893 int legacy_player_set_retrieve_buffer_cb(legacy_player_h player, player_retrieve_buffer_cb callback, void *user_data)
1895 return __set_callback(MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER, player, callback, user_data);
1898 int legacy_player_unset_retrieve_buffer_cb(legacy_player_h player)
1900 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER, player);
1904 int legacy_player_set_interrupted_cb(legacy_player_h player, player_interrupted_cb callback, void *user_data)
1906 return __set_callback(MUSE_PLAYER_EVENT_TYPE_INTERRUPT, player, callback, user_data);
1909 int legacy_player_unset_interrupted_cb(legacy_player_h player)
1911 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_INTERRUPT, player);
1914 int legacy_player_set_error_cb(legacy_player_h player, player_error_cb callback, void *user_data)
1916 return __set_callback(MUSE_PLAYER_EVENT_TYPE_ERROR, player, callback, user_data);
1919 int legacy_player_unset_error_cb(legacy_player_h player)
1921 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_ERROR, player);
1924 int legacy_player_set_buffering_cb(legacy_player_h player, player_buffering_cb callback, void *user_data)
1926 return __set_callback(MUSE_PLAYER_EVENT_TYPE_BUFFERING, player, callback, user_data);
1929 int legacy_player_unset_buffering_cb(legacy_player_h player)
1931 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_BUFFERING, player);
1934 int legacy_player_set_subtitle_updated_cb(legacy_player_h player, player_subtitle_updated_cb callback, void *user_data)
1936 return __set_callback(MUSE_PLAYER_EVENT_TYPE_SUBTITLE, player, callback, user_data);
1939 int legacy_player_unset_subtitle_updated_cb(legacy_player_h player)
1941 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_SUBTITLE, player);
1944 int legacy_player_release_video_stream_bo(legacy_player_h player, void *bo)
1946 legacy_player_t *handle = (legacy_player_t *)player;
1947 PLAYER_INSTANCE_CHECK(player);
1949 LOGD("ENTER %p %p", player, bo);
1951 mm_player_release_video_stream_bo(handle->mm_handle, bo);
1955 return PLAYER_ERROR_NONE;
1958 int legacy_player_set_media_packet_video_frame_decoded_cb(legacy_player_h player, legacy_player_media_packet_video_decoded_cb callback, void *user_data)
1960 legacy_player_t *handle = (legacy_player_t *)player;
1961 int ret = MM_ERROR_NONE;
1962 PLAYER_INSTANCE_CHECK(player);
1963 PLAYER_NULL_ARG_CHECK(callback);
1964 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
1966 ret = mm_player_set_video_decoded_callback(handle->mm_handle, (mm_player_video_decoded_callback)callback, user_data);
1967 if (ret != MM_ERROR_NONE)
1968 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1970 return PLAYER_ERROR_NONE;
1973 static bool __video_stream_changed_callback(void *user_data)
1975 legacy_player_t *handle = (legacy_player_t *)user_data;
1976 int ret = MM_ERROR_NONE;
1977 muse_player_event_e event_type = MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
1979 LOGE("event type %d", event_type);
1981 if (handle->user_cb[event_type]) {
1982 int width = 0, height = 0, fps = 0, bit_rate = 0;
1983 ret = mm_player_get_attribute(handle->mm_handle, NULL,
1984 MM_PLAYER_VIDEO_WIDTH, &width,
1985 MM_PLAYER_VIDEO_HEIGHT, &height,
1986 "content_video_fps", &fps,
1987 "content_video_bitrate", &bit_rate, (char *)NULL);
1989 if (ret != MM_ERROR_NONE) {
1990 LOGE("get attr is failed");
1993 ((player_video_stream_changed_cb)handle->user_cb[event_type])(width, height, fps, bit_rate, handle->user_data[event_type]);
1997 LOGE("video stream changed cb was not set.");
2001 int legacy_player_set_video_stream_changed_cb(legacy_player_h player, player_video_stream_changed_cb callback, void *user_data)
2003 legacy_player_t *handle = (legacy_player_t *)player;
2004 int ret = MM_ERROR_NONE;
2005 PLAYER_INSTANCE_CHECK(player);
2006 PLAYER_NULL_ARG_CHECK(callback);
2007 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2009 ret = mm_player_set_video_stream_changed_callback(handle->mm_handle, (mm_player_stream_changed_callback)__video_stream_changed_callback, (void *)handle);
2010 if (ret != MM_ERROR_NONE)
2011 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2013 return __set_callback(MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, player, callback, user_data);
2016 int legacy_player_unset_video_stream_changed_cb(legacy_player_h player)
2018 PLAYER_INSTANCE_CHECK(player);
2020 __unset_callback(MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, player);
2022 return PLAYER_ERROR_NONE;
2025 static bool __media_stream_buffer_status_callback(player_stream_type_e type, player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
2027 legacy_player_t *handle = (legacy_player_t *)user_data;
2028 muse_player_event_e event_type;
2030 if (type == PLAYER_STREAM_TYPE_AUDIO)
2031 event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
2032 else if (type == PLAYER_STREAM_TYPE_VIDEO)
2033 event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
2037 LOGE("event type %d", event_type);
2039 if (handle->user_cb[event_type]) {
2040 ((player_media_stream_buffer_status_cb)handle->user_cb[event_type])(status, handle->user_data[event_type]);
2042 LOGE("[type:%d] buffer status cb was not set.", type);
2049 static bool __media_stream_seek_data_callback(player_stream_type_e type, unsigned long long offset, void *user_data)
2051 legacy_player_t *handle = (legacy_player_t *)user_data;
2052 muse_player_event_e event_type;
2054 if (type == PLAYER_STREAM_TYPE_AUDIO)
2055 event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
2056 else if (type == PLAYER_STREAM_TYPE_VIDEO)
2057 event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
2061 LOGE("event type %d", event_type);
2063 if (handle->user_cb[event_type]) {
2064 ((player_media_stream_seek_cb)handle->user_cb[event_type])(offset, handle->user_data[event_type]);
2066 LOGE("[type:%d] seek cb was not set.", type);
2073 int legacy_player_set_media_stream_buffer_status_cb(legacy_player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb callback, void *user_data)
2075 legacy_player_t *handle = (legacy_player_t *)player;
2076 int ret = MM_ERROR_NONE;
2077 PLAYER_INSTANCE_CHECK(player);
2078 PLAYER_NULL_ARG_CHECK(callback);
2079 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2081 /* the type can be expaned with default and text. */
2082 if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) {
2083 LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", type);
2084 return PLAYER_ERROR_INVALID_PARAMETER;
2087 ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, (mm_player_media_stream_buffer_status_callback)__media_stream_buffer_status_callback, (void *)handle);
2089 if (ret != MM_ERROR_NONE)
2090 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2092 if (type == PLAYER_STREAM_TYPE_VIDEO)
2093 return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, player, callback, user_data);
2095 return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, player, callback, user_data);
2098 int legacy_player_unset_media_stream_buffer_status_cb(legacy_player_h player, player_stream_type_e type)
2100 PLAYER_INSTANCE_CHECK(player);
2102 if (type == PLAYER_STREAM_TYPE_VIDEO)
2103 __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, player);
2104 else if (type == PLAYER_STREAM_TYPE_AUDIO)
2105 __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, player);
2107 return PLAYER_ERROR_INVALID_PARAMETER;
2109 return PLAYER_ERROR_NONE;
2112 int legacy_player_set_media_stream_seek_cb(legacy_player_h player, player_stream_type_e type, player_media_stream_seek_cb callback, void *user_data)
2114 legacy_player_t *handle = (legacy_player_t *)player;
2115 int ret = MM_ERROR_NONE;
2116 PLAYER_INSTANCE_CHECK(player);
2117 PLAYER_NULL_ARG_CHECK(callback);
2118 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2120 /* the type can be expaned with default and text. */
2121 if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) {
2122 LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", type);
2123 return PLAYER_ERROR_INVALID_PARAMETER;
2126 ret = mm_player_set_media_stream_seek_data_callback(handle->mm_handle, type, (mm_player_media_stream_seek_data_callback)__media_stream_seek_data_callback, (void *)handle);
2127 if (ret != MM_ERROR_NONE)
2128 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2130 if (type == PLAYER_STREAM_TYPE_VIDEO)
2131 return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, player, callback, user_data);
2133 return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, player, callback, user_data);
2136 int legacy_player_unset_media_stream_seek_cb(legacy_player_h player, player_stream_type_e type)
2138 PLAYER_INSTANCE_CHECK(player);
2140 if (type == PLAYER_STREAM_TYPE_VIDEO)
2141 __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, player);
2142 else if (type == PLAYER_STREAM_TYPE_AUDIO)
2143 __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, player);
2145 return PLAYER_ERROR_INVALID_PARAMETER;
2147 return PLAYER_ERROR_NONE;
2150 int legacy_player_push_media_stream(legacy_player_h player, media_packet_h packet)
2152 legacy_player_t *handle = (legacy_player_t *)player;
2153 int ret = MM_ERROR_NONE;
2154 PLAYER_INSTANCE_CHECK(player);
2156 PLAYER_CHECK_CONDITION(handle->error_code == PLAYER_ERROR_NONE, PLAYER_ERROR_NOT_SUPPORTED_FILE, "can't support this format");
2158 ret = mm_player_submit_packet(handle->mm_handle, packet);
2159 if (ret != MM_ERROR_NONE)
2160 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2162 return PLAYER_ERROR_NONE;
2165 int legacy_player_set_media_stream_info(legacy_player_h player, player_stream_type_e type, media_format_h format)
2167 legacy_player_t *handle = (legacy_player_t *)player;
2168 int ret = MM_ERROR_NONE;
2169 PLAYER_INSTANCE_CHECK(player);
2170 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2172 handle->is_media_stream = true;
2174 if (type == PLAYER_STREAM_TYPE_VIDEO)
2175 ret = mm_player_set_video_info(handle->mm_handle, format);
2176 else if (type == PLAYER_STREAM_TYPE_AUDIO)
2177 ret = mm_player_set_audio_info(handle->mm_handle, format);
2179 return PLAYER_ERROR_INVALID_PARAMETER;
2181 if (ret != MM_ERROR_NONE)
2182 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2184 return PLAYER_ERROR_NONE;
2187 int legacy_player_set_media_stream_buffer_max_size(legacy_player_h player, player_stream_type_e type, unsigned long long max_size)
2189 legacy_player_t *handle = (legacy_player_t *)player;
2190 int ret = MM_ERROR_NONE;
2191 PLAYER_INSTANCE_CHECK(player);
2192 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2193 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2194 return PLAYER_ERROR_INVALID_STATE;
2197 ret = mm_player_set_media_stream_buffer_max_size(handle->mm_handle, type, max_size);
2198 if (ret != MM_ERROR_NONE)
2199 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2201 return PLAYER_ERROR_NONE;
2204 int legacy_player_get_media_stream_buffer_max_size(legacy_player_h player, player_stream_type_e type, unsigned long long *max_size)
2206 legacy_player_t *handle = (legacy_player_t *)player;
2207 int ret = MM_ERROR_NONE;
2208 unsigned long long _max_size;
2209 PLAYER_INSTANCE_CHECK(player);
2210 PLAYER_NULL_ARG_CHECK(max_size);
2212 ret = mm_player_get_media_stream_buffer_max_size(handle->mm_handle, type, &_max_size);
2213 if (ret != MM_ERROR_NONE)
2214 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2216 *max_size = _max_size;
2217 return PLAYER_ERROR_NONE;
2220 int legacy_player_set_media_stream_buffer_min_threshold(legacy_player_h player, player_stream_type_e type, unsigned int percent)
2222 legacy_player_t *handle = (legacy_player_t *)player;
2223 int ret = MM_ERROR_NONE;
2224 PLAYER_INSTANCE_CHECK(player);
2225 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2226 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2227 return PLAYER_ERROR_INVALID_STATE;
2230 ret = mm_player_set_media_stream_buffer_min_percent(handle->mm_handle, type, percent);
2231 if (ret != MM_ERROR_NONE)
2232 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2234 return PLAYER_ERROR_NONE;
2237 int legacy_player_get_media_stream_buffer_min_threshold(legacy_player_h player, player_stream_type_e type, unsigned int *percent)
2239 legacy_player_t *handle = (legacy_player_t *)player;
2240 int ret = MM_ERROR_NONE;
2241 unsigned int _value;
2242 PLAYER_INSTANCE_CHECK(player);
2243 PLAYER_NULL_ARG_CHECK(percent);
2245 ret = mm_player_get_media_stream_buffer_min_percent(handle->mm_handle, type, &_value);
2246 if (ret != MM_ERROR_NONE)
2247 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2250 return PLAYER_ERROR_NONE;
2253 int legacy_player_get_track_count(legacy_player_h player, player_stream_type_e type, int *count)
2255 legacy_player_t *handle = (legacy_player_t *)player;
2256 int ret = MM_ERROR_NONE;
2257 mmplayer_track_type_e track_type = 0;
2258 PLAYER_INSTANCE_CHECK(player);
2259 PLAYER_NULL_ARG_CHECK(count);
2261 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2262 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2263 return PLAYER_ERROR_INVALID_STATE;
2267 case PLAYER_STREAM_TYPE_AUDIO:
2268 track_type = MM_PLAYER_TRACK_TYPE_AUDIO;
2270 case PLAYER_STREAM_TYPE_TEXT:
2271 track_type = MM_PLAYER_TRACK_TYPE_TEXT;
2274 LOGE("invalid stream type %d", type);
2275 return PLAYER_ERROR_INVALID_PARAMETER;
2278 ret = mm_player_get_track_count(handle->mm_handle, track_type, count);
2279 if (ret != MM_ERROR_NONE)
2280 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2282 return PLAYER_ERROR_NONE;
2285 int legacy_player_get_current_track(legacy_player_h player, player_stream_type_e type, int *index)
2287 legacy_player_t *handle = (legacy_player_t *)player;
2288 int ret = MM_ERROR_NONE;
2289 mmplayer_track_type_e track_type = 0;
2290 PLAYER_INSTANCE_CHECK(player);
2291 PLAYER_NULL_ARG_CHECK(index);
2292 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2293 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2294 return PLAYER_ERROR_INVALID_STATE;
2298 case PLAYER_STREAM_TYPE_AUDIO:
2299 track_type = MM_PLAYER_TRACK_TYPE_AUDIO;
2301 case PLAYER_STREAM_TYPE_TEXT:
2302 track_type = MM_PLAYER_TRACK_TYPE_TEXT;
2305 LOGE("invalid stream type %d", type);
2306 return PLAYER_ERROR_INVALID_PARAMETER;
2309 ret = mm_player_get_current_track(handle->mm_handle, track_type, index);
2310 if (ret != MM_ERROR_NONE)
2311 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2313 return PLAYER_ERROR_NONE;
2316 int legacy_player_select_track(legacy_player_h player, player_stream_type_e type, int index)
2318 legacy_player_t *handle = (legacy_player_t *)player;
2319 int ret = MM_ERROR_NONE;
2320 mmplayer_track_type_e track_type = 0;
2323 PLAYER_INSTANCE_CHECK(player);
2324 PLAYER_CHECK_CONDITION(index >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
2325 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2326 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2327 return PLAYER_ERROR_INVALID_STATE;
2331 case PLAYER_STREAM_TYPE_AUDIO:
2332 track_type = MM_PLAYER_TRACK_TYPE_AUDIO;
2334 case PLAYER_STREAM_TYPE_TEXT:
2335 track_type = MM_PLAYER_TRACK_TYPE_TEXT;
2338 LOGE("invalid stream type %d", type);
2339 return PLAYER_ERROR_INVALID_PARAMETER;
2342 ret = mm_player_select_track(handle->mm_handle, track_type, index);
2343 if (ret != MM_ERROR_NONE)
2344 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2347 return PLAYER_ERROR_NONE;
2350 int legacy_player_get_track_language_code(legacy_player_h player, player_stream_type_e type, int index, char **code, int *len)
2352 legacy_player_t *handle = (legacy_player_t *)player;
2353 int ret = MM_ERROR_NONE;
2354 mmplayer_track_type_e track_type = 0;
2355 PLAYER_INSTANCE_CHECK(player);
2356 PLAYER_NULL_ARG_CHECK(code);
2357 PLAYER_NULL_ARG_CHECK(len);
2358 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2359 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2360 return PLAYER_ERROR_INVALID_STATE;
2364 case PLAYER_STREAM_TYPE_AUDIO:
2365 track_type = MM_PLAYER_TRACK_TYPE_AUDIO;
2367 case PLAYER_STREAM_TYPE_VIDEO:
2368 track_type = MM_PLAYER_TRACK_TYPE_VIDEO;
2370 case PLAYER_STREAM_TYPE_TEXT:
2371 track_type = MM_PLAYER_TRACK_TYPE_TEXT;
2374 LOGE("invalid stream type %d", type);
2375 return PLAYER_ERROR_INVALID_PARAMETER;
2379 ret = mm_player_get_track_language_code(handle->mm_handle, track_type, index, code);
2380 if (ret != MM_ERROR_NONE)
2381 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2383 LOGD("idx %d, lang code %s", index, *code);
2384 *len = strlen(*code);
2385 return PLAYER_ERROR_NONE;
2388 int legacy_player_set_video_roi_area(legacy_player_h player, double scale_x,
2389 double scale_y, double scale_width, double scale_heights)
2391 legacy_player_t *handle = (legacy_player_t *)player;
2392 int ret = MM_ERROR_NONE;
2393 PLAYER_INSTANCE_CHECK(player);
2397 if (handle->display_type != PLAYER_DISPLAY_TYPE_OVERLAY) {
2398 LOGE("not supportable display type %d", handle->display_type);
2399 return PLAYER_ERROR_INVALID_OPERATION;
2402 ret = mm_player_set_video_roi_area(handle->mm_handle, scale_x, scale_y, scale_width, scale_heights);
2403 if (ret != PLAYER_ERROR_NONE)
2404 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2406 return PLAYER_ERROR_NONE;
2409 int legacy_player_get_video_roi_area(legacy_player_h player, double *scale_x,
2410 double *scale_y, double *scale_width, double *scale_height)
2412 legacy_player_t *handle = (legacy_player_t *)player;
2413 int ret = MM_ERROR_NONE;
2414 PLAYER_INSTANCE_CHECK(player);
2415 PLAYER_NULL_ARG_CHECK(scale_x);
2416 PLAYER_NULL_ARG_CHECK(scale_y);
2417 PLAYER_NULL_ARG_CHECK(scale_width);
2418 PLAYER_NULL_ARG_CHECK(scale_height);
2422 ret = mm_player_get_video_roi_area(handle->mm_handle, scale_x, scale_y, scale_width, scale_height);
2423 if (ret != PLAYER_ERROR_NONE)
2424 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2426 return PLAYER_ERROR_NONE;
2429 int legacy_player_set_roi_area(legacy_player_h player, int x, int y, int w, int h)
2431 legacy_player_t *handle = (legacy_player_t *)player;
2432 int ret = MM_ERROR_NONE;
2433 PLAYER_INSTANCE_CHECK(player);
2438 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_win_roi_x", x, "display_win_roi_y", y, "display_win_roi_width", w, "display_win_roi_height", h, (char *)NULL);
2439 if (ret != MM_ERROR_NONE)
2440 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2442 return PLAYER_ERROR_NONE;
2445 int legacy_player_set_display(legacy_player_h player, player_display_type_e type, unsigned int wl_surface_id)
2447 legacy_player_t *handle = (legacy_player_t *)player;
2448 int ret = MM_ERROR_NONE;
2449 void *set_handle = NULL;
2451 MMDisplaySurfaceType mmType = __player_convert_display_type(type);
2452 PLAYER_INSTANCE_CHECK(player);
2453 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2454 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2455 return PLAYER_ERROR_INVALID_STATE;
2458 if (type == PLAYER_DISPLAY_TYPE_NONE) {
2460 handle->display_handle = 0;
2461 handle->display_type = type;
2464 /* get handle from overlay or evas surface */
2465 temp = handle->display_handle;
2466 if (type == PLAYER_DISPLAY_TYPE_OVERLAY) {
2467 LOGI("Wayland overlay surface type");
2468 LOGI("wl_surface_id %d", wl_surface_id);
2469 handle->display_handle = (void *)(uintptr_t)wl_surface_id;
2470 set_handle = &(handle->display_handle);
2471 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2472 } else if (type == PLAYER_DISPLAY_TYPE_EVAS) {
2473 LOGI("Evas surface type");
2474 set_handle = &(handle->display_handle);
2477 LOGE("invalid surface type");
2478 return PLAYER_ERROR_INVALID_PARAMETER;
2482 /* set display handle */
2483 if (handle->display_type == PLAYER_DISPLAY_TYPE_NONE || type == handle->display_type) {
2484 /* first time or same type */
2485 LOGW("first time or same type");
2486 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", mmType, "display_overlay", set_handle, sizeof(wl_surface_id), NULL);
2488 if (ret != MM_ERROR_NONE) {
2489 handle->display_handle = temp;
2490 LOGE("Failed to display surface change: %d", ret);
2492 if (type != PLAYER_DISPLAY_TYPE_NONE) {
2493 handle->display_type = type;
2494 LOGI("video display has been changed- type: %d, addr: %p", handle->display_type, handle->display_handle);
2496 LOGI("NULL surface");
2500 /* changing surface case */
2501 ret = mm_player_change_videosink(handle->mm_handle, mmType, set_handle);
2502 if (ret != MM_ERROR_NONE) {
2503 handle->display_handle = temp;
2504 if (ret == MM_ERROR_NOT_SUPPORT_API) {
2505 LOGE("change video sink is not available.");
2506 ret = PLAYER_ERROR_NONE;
2508 LOGE("Failed to display surface change: %d", ret);
2511 handle->display_type = type;
2512 LOGI("video display has been changed- type: %d, addr: %p", handle->display_type, handle->display_handle);
2516 if (ret != MM_ERROR_NONE) {
2517 handle->display_type = PLAYER_DISPLAY_TYPE_NONE;
2518 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2521 return PLAYER_ERROR_NONE;
2524 int legacy_player_set_sound_stream_info_for_mused(legacy_player_h player, char *stream_type, int stream_index)
2526 legacy_player_t *handle = (legacy_player_t *)player;
2527 int ret = MM_ERROR_NONE;
2528 PLAYER_INSTANCE_CHECK(player);
2529 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2531 if (stream_type == NULL || stream_index < 0) {
2532 LOGE("invalid parameter %p %d", stream_type, stream_index);
2533 return PLAYER_ERROR_INVALID_PARAMETER;
2536 ret = mm_player_set_sound_stream_info(handle->mm_handle, stream_type, stream_index);
2537 if (ret != MM_ERROR_NONE)
2538 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2540 return PLAYER_ERROR_NONE;
2543 int legacy_player_get_timeout_for_muse(legacy_player_h player, int *timeout)
2545 legacy_player_t *handle = (legacy_player_t *)player;
2546 int ret = MM_ERROR_NONE;
2547 PLAYER_INSTANCE_CHECK(player);
2549 ret = mm_player_get_timeout(handle->mm_handle, timeout);
2550 if (ret != MM_ERROR_NONE)
2551 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2553 return PLAYER_ERROR_NONE;
2556 int legacy_player_get_num_of_video_out_buffers(legacy_player_h player, int *num, int *extra_num)
2558 legacy_player_t *handle = (legacy_player_t *)player;
2559 int ret = MM_ERROR_NONE;
2560 PLAYER_INSTANCE_CHECK(player);
2561 PLAYER_NULL_ARG_CHECK(num);
2562 PLAYER_NULL_ARG_CHECK(extra_num);
2564 ret = mm_player_get_num_of_video_out_buffers(handle->mm_handle, num, extra_num);
2565 if (ret != MM_ERROR_NONE)
2566 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2568 return PLAYER_ERROR_NONE;
2571 int legacy_player_manage_external_storage_state(legacy_player_h player, int id, int state)
2573 legacy_player_t *handle = (legacy_player_t *)player;
2574 int ret = MM_ERROR_NONE;
2575 PLAYER_INSTANCE_CHECK(player);
2577 ret = mm_player_manage_external_storage_state(handle->mm_handle, id, state);
2578 if (ret != MM_ERROR_NONE)
2579 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2581 return PLAYER_ERROR_NONE;
2584 int legacy_player_get_adaptive_variant_info(legacy_player_h player, int *num, char **var_info)
2586 int ret = MM_ERROR_NONE;
2587 legacy_player_t *handle = (legacy_player_t *)player;
2588 PLAYER_INSTANCE_CHECK(player);
2589 PLAYER_NULL_ARG_CHECK(num);
2590 PLAYER_NULL_ARG_CHECK(var_info);
2592 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2593 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2594 return PLAYER_ERROR_INVALID_STATE;
2597 ret = mm_player_get_adaptive_variant_info(handle->mm_handle, num, var_info);
2598 if (ret != MM_ERROR_NONE)
2599 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2601 return PLAYER_ERROR_NONE;
2604 int legacy_player_set_max_adaptive_variant_limit(legacy_player_h player, int bandwidth, int width, int height)
2606 int ret = MM_ERROR_NONE;
2607 legacy_player_t *handle = (legacy_player_t *)player;
2608 PLAYER_INSTANCE_CHECK(player);
2610 ret = mm_player_set_max_adaptive_variant_limit(handle->mm_handle, bandwidth, width, height);
2611 if (ret != MM_ERROR_NONE)
2612 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2614 return PLAYER_ERROR_NONE;
2617 int legacy_player_get_max_adaptive_variant_limit(legacy_player_h player, int *bandwidth, int *width, int *height)
2619 legacy_player_t *handle = (legacy_player_t *)player;
2620 int ret = MM_ERROR_NONE;
2621 PLAYER_INSTANCE_CHECK(player);
2622 PLAYER_NULL_ARG_CHECK(bandwidth);
2623 PLAYER_NULL_ARG_CHECK(width);
2624 PLAYER_NULL_ARG_CHECK(height);
2626 ret = mm_player_get_max_adaptive_variant_limit(handle->mm_handle, bandwidth, width, height);
2627 if (ret != MM_ERROR_NONE)
2628 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2630 return PLAYER_ERROR_NONE;
2633 int legacy_player_set_audio_only(legacy_player_h player, bool audio_only)
2635 legacy_player_t *handle = (legacy_player_t *)player;
2636 int ret = MM_ERROR_NONE;
2637 PLAYER_INSTANCE_CHECK(player);
2639 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2640 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2641 return PLAYER_ERROR_INVALID_STATE;
2644 ret = mm_player_set_audio_only(handle->mm_handle, audio_only);
2645 if (ret != MM_ERROR_NONE)
2646 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2648 return PLAYER_ERROR_NONE;
2651 int legacy_player_is_audio_only(legacy_player_h player, bool *paudio_only)
2653 legacy_player_t *handle = (legacy_player_t *)player;
2654 int ret = MM_ERROR_NONE;
2655 bool audio_only = false;
2656 PLAYER_INSTANCE_CHECK(player);
2657 PLAYER_NULL_ARG_CHECK(paudio_only);
2659 ret = mm_player_get_audio_only(handle->mm_handle, &audio_only);
2660 if (ret != MM_ERROR_NONE)
2661 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2663 *paudio_only = audio_only;
2664 return PLAYER_ERROR_NONE;
2667 int legacy_player_set_streaming_buffering_time(legacy_player_h player, int prebuffer_ms, int rebuffer_ms)
2669 legacy_player_t *handle = (legacy_player_t *)player;
2670 int ret = MM_ERROR_NONE;
2671 PLAYER_INSTANCE_CHECK(player);
2672 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2674 LOGD("set buffering time : %d ms, %d ms", prebuffer_ms, rebuffer_ms);
2676 /* set streaming buffering time */
2677 if (prebuffer_ms >= MIN_BUFFERING_TIME_MS)
2678 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_PREBUFFER_MS, prebuffer_ms, (char *)NULL);
2680 if ((ret == MM_ERROR_NONE) && (rebuffer_ms >= MIN_BUFFERING_TIME_MS))
2681 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_REBUFFER_MS, rebuffer_ms, (char *)NULL);
2683 if (ret != MM_ERROR_NONE)
2684 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2686 return PLAYER_ERROR_NONE;
2689 int legacy_player_get_streaming_buffering_time(legacy_player_h player, int *prebuffer_ms, int *rebuffer_ms)
2691 legacy_player_t *handle = (legacy_player_t *)player;
2692 int ret = MM_ERROR_NONE;
2693 PLAYER_INSTANCE_CHECK(player);
2694 PLAYER_NULL_ARG_CHECK(prebuffer_ms && rebuffer_ms);
2696 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2697 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2698 return PLAYER_ERROR_INVALID_STATE;
2701 if (handle->state < PLAYER_STATE_READY) {
2702 ret = mm_player_get_attribute(handle->mm_handle, NULL,
2703 MM_PLAYER_PREBUFFER_MS, prebuffer_ms, MM_PLAYER_REBUFFER_MS, rebuffer_ms, (char *)NULL);
2704 if (ret != MM_ERROR_NONE)
2705 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2707 LOGD("pre: %d ms, re: %d ms", *prebuffer_ms, *rebuffer_ms);
2708 return PLAYER_ERROR_NONE;
2711 ret = mm_player_get_streaming_buffering_time(handle->mm_handle, prebuffer_ms, rebuffer_ms);
2712 if (ret != MM_ERROR_NONE)
2713 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2715 LOGD("pre: %d ms, re: %d ms", *prebuffer_ms, *rebuffer_ms);
2717 if (*prebuffer_ms < MIN_BUFFERING_TIME_MS) *prebuffer_ms = MIN_BUFFERING_TIME_MS;
2718 if (*rebuffer_ms < MIN_BUFFERING_TIME_MS) *rebuffer_ms = MIN_BUFFERING_TIME_MS;
2720 return PLAYER_ERROR_NONE;
2723 int legacy_player_360_is_content_spherical(legacy_player_h player, bool *is_spherical)
2725 legacy_player_t *handle = (legacy_player_t *)player;
2726 int ret = MM_ERROR_NONE;
2727 PLAYER_INSTANCE_CHECK(player);
2728 PLAYER_NULL_ARG_CHECK(is_spherical);
2730 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2731 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2732 return PLAYER_ERROR_INVALID_STATE;
2735 ret = mm_player_360_is_content_spherical(handle->mm_handle, is_spherical);
2736 if (ret != MM_ERROR_NONE)
2737 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2739 return PLAYER_ERROR_NONE;
2742 int legacy_player_360_set_enabled(legacy_player_h player, bool enabled)
2744 legacy_player_t *handle = (legacy_player_t *)player;
2745 int ret = MM_ERROR_NONE;
2746 PLAYER_INSTANCE_CHECK(player);
2748 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2749 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2750 return PLAYER_ERROR_INVALID_STATE;
2753 ret = mm_player_360_set_enabled(handle->mm_handle, enabled);
2754 if (ret != MM_ERROR_NONE)
2755 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2757 return PLAYER_ERROR_NONE;
2760 int legacy_player_360_is_enabled(legacy_player_h player, bool *enabled)
2762 legacy_player_t *handle = (legacy_player_t *)player;
2763 int ret = MM_ERROR_NONE;
2764 PLAYER_INSTANCE_CHECK(player);
2765 PLAYER_NULL_ARG_CHECK(enabled);
2766 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2767 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2768 return PLAYER_ERROR_INVALID_STATE;
2771 ret = mm_player_360_is_enabled(handle->mm_handle, enabled);
2772 if (ret != MM_ERROR_NONE)
2773 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2775 return PLAYER_ERROR_NONE;
2778 int legacy_player_360_set_direction_of_view(legacy_player_h player, float yaw, float pitch)
2780 legacy_player_t *handle = (legacy_player_t *)player;
2781 int ret = MM_ERROR_NONE;
2782 PLAYER_INSTANCE_CHECK(player);
2784 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2785 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2786 return PLAYER_ERROR_INVALID_STATE;
2789 ret = mm_player_360_set_direction_of_view(handle->mm_handle, yaw, pitch);
2790 if (ret != MM_ERROR_NONE)
2791 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2793 return PLAYER_ERROR_NONE;
2796 int legacy_player_360_get_direction_of_view(legacy_player_h player, float *yaw, float *pitch)
2798 legacy_player_t *handle = (legacy_player_t *)player;
2799 int ret = MM_ERROR_NONE;
2800 PLAYER_INSTANCE_CHECK(player);
2801 PLAYER_NULL_ARG_CHECK(yaw);
2802 PLAYER_NULL_ARG_CHECK(pitch);
2804 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2805 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2806 return PLAYER_ERROR_INVALID_STATE;
2809 ret = mm_player_360_get_direction_of_view(handle->mm_handle, yaw, pitch);
2810 if (ret != MM_ERROR_NONE)
2811 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2813 return PLAYER_ERROR_NONE;
2816 int legacy_player_360_set_zoom(legacy_player_h player, float level)
2818 legacy_player_t *handle = (legacy_player_t *)player;
2819 int ret = MM_ERROR_NONE;
2820 PLAYER_INSTANCE_CHECK(player);
2822 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2823 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2824 return PLAYER_ERROR_INVALID_STATE;
2827 ret = mm_player_360_set_zoom(handle->mm_handle, level);
2828 if (ret != MM_ERROR_NONE)
2829 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2831 return PLAYER_ERROR_NONE;
2834 int legacy_player_360_get_zoom(legacy_player_h player, float *level)
2836 legacy_player_t *handle = (legacy_player_t *)player;
2837 int ret = MM_ERROR_NONE;
2838 PLAYER_INSTANCE_CHECK(player);
2840 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2841 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2842 return PLAYER_ERROR_INVALID_STATE;
2845 ret = mm_player_360_get_zoom(handle->mm_handle, level);
2846 if (ret != MM_ERROR_NONE)
2847 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2849 return PLAYER_ERROR_NONE;
2852 int legacy_player_360_set_field_of_view(legacy_player_h player, int horizontal_degrees, int vertical_degrees)
2854 legacy_player_t *handle = (legacy_player_t *)player;
2855 int ret = MM_ERROR_NONE;
2856 PLAYER_INSTANCE_CHECK(player);
2858 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2859 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2860 return PLAYER_ERROR_INVALID_STATE;
2863 ret = mm_player_360_set_field_of_view(handle->mm_handle, horizontal_degrees, vertical_degrees);
2864 if (ret != MM_ERROR_NONE)
2865 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2867 return PLAYER_ERROR_NONE;
2870 int legacy_player_360_get_field_of_view(legacy_player_h player, int *horizontal_degrees, int *vertical_degrees)
2872 legacy_player_t *handle = (legacy_player_t *)player;
2873 int ret = MM_ERROR_NONE;
2874 PLAYER_INSTANCE_CHECK(player);
2875 PLAYER_NULL_ARG_CHECK(horizontal_degrees);
2876 PLAYER_NULL_ARG_CHECK(vertical_degrees);
2878 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2879 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2880 return PLAYER_ERROR_INVALID_STATE;
2883 ret = mm_player_360_get_field_of_view(handle->mm_handle, horizontal_degrees, vertical_degrees);
2884 if (ret != MM_ERROR_NONE)
2885 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2887 return PLAYER_ERROR_NONE;
2890 int legacy_player_set_replaygain_enabled(legacy_player_h player, bool enabled)
2892 legacy_player_t *handle = (legacy_player_t *)player;
2893 int ret = MM_ERROR_NONE;
2894 PLAYER_INSTANCE_CHECK(player);
2896 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2897 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2898 return PLAYER_ERROR_INVALID_STATE;
2901 ret = mm_player_set_replaygain_enabled(handle->mm_handle, enabled);
2902 if (ret != MM_ERROR_NONE)
2903 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2905 return PLAYER_ERROR_NONE;
2908 int legacy_player_is_replaygain_enabled(legacy_player_h player, bool *enabled)
2910 legacy_player_t *handle = (legacy_player_t *)player;
2911 int ret = MM_ERROR_NONE;
2913 PLAYER_INSTANCE_CHECK(player);
2914 PLAYER_NULL_ARG_CHECK(enabled);
2916 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2917 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2918 return PLAYER_ERROR_INVALID_STATE;
2921 ret = mm_player_is_replaygain_enabled(handle->mm_handle, &_enable);
2922 if (ret != MM_ERROR_NONE)
2923 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2926 return PLAYER_ERROR_NONE;
2929 int legacy_player_set_audio_offload_enabled(legacy_player_h player, bool enabled)
2931 legacy_player_t *handle = (legacy_player_t *)player;
2932 int ret = MM_ERROR_NONE;
2933 PLAYER_INSTANCE_CHECK(player);
2934 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2936 LOGD("set audio offload %d", enabled);
2938 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_AUDIO_OFFLOAD, (int)enabled, (char *)NULL);
2939 if (ret != MM_ERROR_NONE)
2940 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2942 return PLAYER_ERROR_NONE;
2945 int legacy_player_is_audio_offload_enabled(legacy_player_h player, bool *enabled)
2947 legacy_player_t *handle = (legacy_player_t *)player;
2948 int ret = MM_ERROR_NONE;
2950 PLAYER_INSTANCE_CHECK(player);
2951 PLAYER_NULL_ARG_CHECK(enabled);
2953 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2954 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2955 return PLAYER_ERROR_INVALID_STATE;
2958 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_AUDIO_OFFLOAD, &val, (char *)NULL);
2959 if (ret != MM_ERROR_NONE)
2960 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2962 *enabled = (bool)val;
2963 LOGD("get audio offload %d", *enabled);
2964 return PLAYER_ERROR_NONE;
2967 int legacy_player_pitch_set_enabled(legacy_player_h player, bool enabled)
2969 legacy_player_t *handle = (legacy_player_t *)player;
2970 int ret = MM_ERROR_NONE;
2971 PLAYER_INSTANCE_CHECK(player);
2972 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2974 LOGD("set pitch control %d", enabled);
2975 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_PITCH_CONTROL, (int)enabled, (char *)NULL);
2977 if (ret != MM_ERROR_NONE)
2978 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2980 return PLAYER_ERROR_NONE;
2983 int legacy_player_pitch_is_enabled(legacy_player_h player, bool *enabled)
2985 legacy_player_t *handle = (legacy_player_t *)player;
2986 int ret = MM_ERROR_NONE;
2988 PLAYER_INSTANCE_CHECK(player);
2989 PLAYER_NULL_ARG_CHECK(enabled);
2991 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2992 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2993 return PLAYER_ERROR_INVALID_STATE;
2996 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_PITCH_CONTROL, &val, (char *)NULL);
2997 if (ret != MM_ERROR_NONE)
2998 return __player_convert_error_code(ret, (char *)__FUNCTION__);
3000 *enabled = (bool)val;
3001 LOGD("get pitch control %d", *enabled);
3002 return PLAYER_ERROR_NONE;
3005 int legacy_player_pitch_set_value(legacy_player_h player, float pitch)
3007 legacy_player_t *handle = (legacy_player_t *)player;
3008 int ret = MM_ERROR_NONE;
3011 PLAYER_INSTANCE_CHECK(player);
3013 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
3014 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
3015 return PLAYER_ERROR_INVALID_STATE;
3018 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_PITCH_CONTROL, &is_enabled, (char *)NULL);
3019 if (ret != MM_ERROR_NONE)
3020 return __player_convert_error_code(ret, (char *)__FUNCTION__);
3023 LOGE("pitch is not enabled");
3024 return PLAYER_ERROR_INVALID_OPERATION;
3027 LOGD("set pitch value %1.3f", pitch);
3028 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_PITCH_VALUE, (double)pitch, (char *)NULL);
3029 if (ret != MM_ERROR_NONE)
3030 return __player_convert_error_code(ret, (char *)__FUNCTION__);
3032 return PLAYER_ERROR_NONE;
3035 int legacy_player_pitch_get_value(legacy_player_h player, float *pitch)
3037 legacy_player_t *handle = (legacy_player_t *)player;
3038 int ret = MM_ERROR_NONE;
3040 PLAYER_INSTANCE_CHECK(player);
3041 PLAYER_NULL_ARG_CHECK(pitch);
3043 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
3044 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
3045 return PLAYER_ERROR_INVALID_STATE;
3048 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_PITCH_VALUE, &value, (char *)NULL);
3049 if (ret != MM_ERROR_NONE)
3050 return __player_convert_error_code(ret, (char *)__FUNCTION__);
3052 *pitch = (float)value;
3053 LOGD("get pitch value %1.3f", *pitch);
3055 return PLAYER_ERROR_NONE;