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 volume)
977 legacy_player_t *handle = (legacy_player_t *)player;
978 int ret = MM_ERROR_NONE;
979 PLAYER_INSTANCE_CHECK(player);
980 PLAYER_CHECK_CONDITION(volume >= 0 && volume <= 1.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
982 ret = mm_player_set_volume(handle->mm_handle, volume);
983 if (ret != MM_ERROR_NONE)
984 return __player_convert_error_code(ret, (char *)__FUNCTION__);
986 return PLAYER_ERROR_NONE;
989 int legacy_player_get_volume(legacy_player_h player, float *volume)
991 legacy_player_t *handle = (legacy_player_t *)player;
992 int ret = MM_ERROR_NONE;
993 PLAYER_INSTANCE_CHECK(player);
994 PLAYER_NULL_ARG_CHECK(volume);
996 ret = mm_player_get_volume(handle->mm_handle, volume);
997 if (ret != MM_ERROR_NONE) {
998 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1001 return PLAYER_ERROR_NONE;
1004 int legacy_player_set_sound_stream_info(legacy_player_h player, sound_stream_info_h stream_info)
1006 legacy_player_t *handle = (legacy_player_t *)player;
1007 int ret = MM_ERROR_NONE;
1008 bool is_available = false;
1009 PLAYER_INSTANCE_CHECK(player);
1010 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
1012 /* check if stream_info is valid */
1013 ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_PLAYER, &is_available);
1014 if (ret != MM_ERROR_NONE)
1015 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1018 char *stream_type = NULL;
1019 int stream_index = 0;
1020 ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
1021 ret = sound_manager_get_index_from_stream_information(stream_info, &stream_index);
1022 if (ret == SOUND_MANAGER_ERROR_NONE)
1023 ret = mm_player_set_sound_stream_info(handle->mm_handle, stream_type, stream_index);
1025 ret = MM_ERROR_PLAYER_INTERNAL;
1027 ret = MM_ERROR_NOT_SUPPORT_API;
1030 if (ret != MM_ERROR_NONE)
1031 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1033 return PLAYER_ERROR_NONE;
1036 int legacy_player_set_audio_latency_mode(legacy_player_h player, audio_latency_mode_e latency_mode)
1038 legacy_player_t *handle = (legacy_player_t *)player;
1039 int ret = MM_ERROR_NONE;
1040 PLAYER_INSTANCE_CHECK(player);
1042 ret = mm_player_set_attribute(handle->mm_handle, NULL, "sound_latency_mode", latency_mode, (char *)NULL);
1043 if (ret != MM_ERROR_NONE)
1044 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1046 return PLAYER_ERROR_NONE;
1049 int legacy_player_get_audio_latency_mode(legacy_player_h player, audio_latency_mode_e *latency_mode)
1051 legacy_player_t *handle = (legacy_player_t *)player;
1052 int ret = MM_ERROR_NONE;
1053 PLAYER_INSTANCE_CHECK(player);
1054 PLAYER_NULL_ARG_CHECK(latency_mode);
1056 ret = mm_player_get_attribute(handle->mm_handle, NULL, "sound_latency_mode", latency_mode, (char *)NULL);
1057 if (ret != MM_ERROR_NONE)
1058 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1060 return PLAYER_ERROR_NONE;
1063 int legacy_player_start(legacy_player_h player)
1065 legacy_player_t *handle = (legacy_player_t *)player;
1066 int ret = MM_ERROR_NONE;
1069 PLAYER_INSTANCE_CHECK(player);
1071 if (handle->state > PLAYER_STATE_IDLE) {
1072 if (handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY && handle->is_display_visible) {
1073 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", 1, (char *)NULL);
1074 if (ret != MM_ERROR_NONE)
1075 LOGW("Failed to set display_visible '1' (0x%x)", ret);
1077 if (handle->internal_state == PLAYER_INTERNAL_STATE_STOPPED) {
1078 ret = mm_player_start(handle->mm_handle);
1079 LOGI("stop -> start() ");
1081 if (handle->state == PLAYER_STATE_READY)
1082 ret = mm_player_start(handle->mm_handle);
1084 ret = mm_player_resume(handle->mm_handle);
1087 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1088 return PLAYER_ERROR_INVALID_STATE;
1091 if (ret != MM_ERROR_NONE)
1092 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1094 __player_update_state(handle, PLAYER_INTERNAL_STATE_PLAYING);
1097 return PLAYER_ERROR_NONE;
1100 int legacy_player_stop(legacy_player_h player)
1102 legacy_player_t *handle = (legacy_player_t *)player;
1103 int ret = MM_ERROR_NONE;
1106 PLAYER_INSTANCE_CHECK(player);
1108 if (handle->state == PLAYER_STATE_PLAYING || handle->state == PLAYER_STATE_PAUSED) {
1109 if (handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1110 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", 0, (char *)NULL);
1111 if (ret != MM_ERROR_NONE)
1112 LOGW("Failed to set display_visible '0' (0x%x)", ret);
1115 ret = mm_player_stop(handle->mm_handle);
1116 if (ret != MM_ERROR_NONE) {
1117 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1120 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) {
1121 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
1122 handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
1125 __player_update_state(handle, PLAYER_INTERNAL_STATE_STOPPED);
1128 return PLAYER_ERROR_NONE;
1131 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1132 return PLAYER_ERROR_INVALID_STATE;
1135 int legacy_player_pause(legacy_player_h player)
1137 legacy_player_t *handle = (legacy_player_t *)player;
1138 int ret = MM_ERROR_NONE;
1141 PLAYER_INSTANCE_CHECK(player);
1142 PLAYER_STATE_CHECK(handle, PLAYER_STATE_PLAYING);
1144 ret = mm_player_pause(handle->mm_handle);
1145 if (ret != MM_ERROR_NONE)
1146 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1148 __player_update_state(handle, PLAYER_INTERNAL_STATE_PAUSED);
1151 return PLAYER_ERROR_NONE;
1154 int legacy_player_set_play_position(legacy_player_h player, int64_t nanoseconds, bool accurate, player_seek_completed_cb callback, void *user_data)
1156 legacy_player_t *handle = (legacy_player_t *)player;
1157 int ret = MM_ERROR_NONE;
1158 int accurated = accurate ? 1 : 0;
1161 PLAYER_INSTANCE_CHECK(player);
1162 PLAYER_CHECK_CONDITION(nanoseconds >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1164 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1165 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1166 return PLAYER_ERROR_INVALID_STATE;
1169 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] && !handle->is_media_stream) {
1170 LOGE("previous seeking request is in processing.");
1171 return PLAYER_ERROR_SEEK_FAILED;
1174 LOGI("Event type : %d, pos : %"PRId64, MUSE_PLAYER_EVENT_TYPE_SEEK, nanoseconds);
1175 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = callback;
1176 handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = user_data;
1178 ret = mm_player_set_attribute(handle->mm_handle, NULL, "accurate_seek", accurated, (char *)NULL);
1179 if (ret != MM_ERROR_NONE)
1180 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1182 ret = mm_player_set_position(handle->mm_handle, nanoseconds);
1183 if (ret != MM_ERROR_NONE) {
1184 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
1185 handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
1186 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1190 return PLAYER_ERROR_NONE;
1193 int legacy_player_get_play_position(legacy_player_h player, int64_t *nanoseconds)
1195 legacy_player_t *handle = (legacy_player_t *)player;
1196 int ret = MM_ERROR_NONE;
1198 PLAYER_INSTANCE_CHECK(player);
1199 PLAYER_NULL_ARG_CHECK(nanoseconds);
1201 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
1202 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1203 return PLAYER_ERROR_INVALID_STATE;
1206 ret = mm_player_get_position(handle->mm_handle, &pos);
1207 if (ret != MM_ERROR_NONE) {
1208 if (ret == MM_ERROR_PLAYER_NOT_INITIALIZED) {
1209 /* During playbak if a interrupt is occurred, the player can be destroyed internally.
1210 libmm-player will post position msg with last playback position before destory pipeline */
1211 if (handle->state == PLAYER_STATE_IDLE) {
1212 if (handle->last_play_position > 0)
1213 *nanoseconds = handle->last_play_position;
1216 LOGD("position %"PRId64, *nanoseconds);
1217 return PLAYER_ERROR_NONE;
1220 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1224 return PLAYER_ERROR_NONE;
1227 int legacy_player_set_mute(legacy_player_h player, bool muted)
1229 legacy_player_t *handle = (legacy_player_t *)player;
1230 int ret = MM_ERROR_NONE;
1231 PLAYER_INSTANCE_CHECK(player);
1233 ret = mm_player_set_mute(handle->mm_handle, muted);
1234 if (ret != MM_ERROR_NONE)
1235 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1237 return PLAYER_ERROR_NONE;
1240 int legacy_player_is_muted(legacy_player_h player, bool *muted)
1242 legacy_player_t *handle = (legacy_player_t *)player;
1243 int ret = MM_ERROR_NONE;
1244 PLAYER_INSTANCE_CHECK(player);
1245 PLAYER_NULL_ARG_CHECK(muted);
1247 ret = mm_player_get_mute(handle->mm_handle, muted);
1248 if (ret != MM_ERROR_NONE)
1249 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1251 return PLAYER_ERROR_NONE;
1254 int legacy_player_set_looping(legacy_player_h player, bool looping)
1256 legacy_player_t *handle = (legacy_player_t *)player;
1257 int ret = MM_ERROR_NONE;
1259 PLAYER_INSTANCE_CHECK(player);
1264 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_PLAYBACK_COUNT, value, (char *)NULL);
1265 if (ret != MM_ERROR_NONE)
1266 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1268 return PLAYER_ERROR_NONE;
1271 int legacy_player_is_looping(legacy_player_h player, bool *looping)
1273 legacy_player_t *handle = (legacy_player_t *)player;
1274 int ret = MM_ERROR_NONE;
1276 PLAYER_INSTANCE_CHECK(player);
1277 PLAYER_NULL_ARG_CHECK(looping);
1279 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_PLAYBACK_COUNT, &count, (char *)NULL);
1280 if (ret != MM_ERROR_NONE)
1281 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1283 *looping = (count == -1) ? true : false;
1285 return PLAYER_ERROR_NONE;
1288 int legacy_player_get_duration(legacy_player_h player, int64_t *duration)
1290 legacy_player_t *handle = (legacy_player_t *)player;
1291 int ret = MM_ERROR_NONE;
1292 PLAYER_INSTANCE_CHECK(player);
1293 PLAYER_NULL_ARG_CHECK(duration);
1295 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1296 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1297 return PLAYER_ERROR_INVALID_STATE;
1300 ret = mm_player_get_duration(handle->mm_handle, duration);
1301 if (ret != MM_ERROR_NONE)
1302 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1304 LOGD("content dur: %"PRId64, *duration);
1305 return PLAYER_ERROR_NONE;
1308 int legacy_player_set_display_mode(legacy_player_h player, player_display_mode_e mode)
1310 legacy_player_t *handle = (legacy_player_t *)player;
1311 int ret = MM_ERROR_NONE;
1313 LOGI("<ENTER: mode:%d>", mode);
1314 PLAYER_INSTANCE_CHECK(player);
1316 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_method", mode, (char *)NULL);
1317 if (ret != MM_ERROR_NONE)
1318 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1320 return PLAYER_ERROR_NONE;
1323 int legacy_player_get_display_mode(legacy_player_h player, player_display_mode_e *mode)
1325 legacy_player_t *handle = (legacy_player_t *)player;
1326 int ret = MM_ERROR_NONE;
1327 PLAYER_INSTANCE_CHECK(player);
1328 PLAYER_NULL_ARG_CHECK(mode);
1330 ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_method", mode, (char *)NULL);
1331 if (ret != MM_ERROR_NONE)
1332 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1334 return PLAYER_ERROR_NONE;
1337 int legacy_player_set_playback_rate(legacy_player_h player, float rate)
1339 legacy_player_t *handle = (legacy_player_t *)player;
1340 int ret = MM_ERROR_NONE;
1341 LOGI("<ENTER: rate %0.1f>", rate);
1342 PLAYER_INSTANCE_CHECK(player);
1343 PLAYER_CHECK_CONDITION(rate >= -5.0 && rate <= 5.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1345 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1346 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1347 return PLAYER_ERROR_INVALID_STATE;
1350 ret = mm_player_set_play_speed(handle->mm_handle, rate, false);
1353 case MM_ERROR_PLAYER_NO_OP:
1354 ret = PLAYER_ERROR_NONE;
1356 case MM_ERROR_NOT_SUPPORT_API:
1357 case MM_ERROR_PLAYER_SEEK:
1358 LOGE("PLAYER_ERROR_INVALID_OPERATION : seek error");
1359 ret = PLAYER_ERROR_INVALID_OPERATION;
1362 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1368 int legacy_player_set_display_rotation(legacy_player_h player, player_display_rotation_e rotation)
1370 legacy_player_t *handle = (legacy_player_t *)player;
1371 int ret = MM_ERROR_NONE;
1372 PLAYER_INSTANCE_CHECK(player);
1374 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_ROTATION, rotation, (char *)NULL);
1375 if (ret != MM_ERROR_NONE)
1376 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1378 return PLAYER_ERROR_NONE;
1381 int legacy_player_get_display_rotation(legacy_player_h player, player_display_rotation_e *rotation)
1383 legacy_player_t *handle = (legacy_player_t *)player;
1384 int ret = MM_ERROR_NONE;
1385 PLAYER_INSTANCE_CHECK(player);
1386 PLAYER_NULL_ARG_CHECK(rotation);
1388 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_ROTATION, rotation, (char *)NULL);
1389 if (ret != MM_ERROR_NONE)
1390 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1392 return PLAYER_ERROR_NONE;
1395 int legacy_player_set_display_visible(legacy_player_h player, bool visible)
1397 legacy_player_t *handle = (legacy_player_t *)player;
1398 int ret = MM_ERROR_NONE;
1400 PLAYER_INSTANCE_CHECK(player);
1405 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", value, (char *)NULL);
1406 if (ret != MM_ERROR_NONE)
1407 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1409 handle->is_display_visible = visible;
1410 return PLAYER_ERROR_NONE;
1413 int legacy_player_is_display_visible(legacy_player_h player, bool *visible)
1415 legacy_player_t *handle = (legacy_player_t *)player;
1416 int ret = MM_ERROR_NONE;
1418 PLAYER_INSTANCE_CHECK(player);
1419 PLAYER_NULL_ARG_CHECK(visible);
1421 ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_visible", &value, (char *)NULL);
1422 if (ret != MM_ERROR_NONE)
1423 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1425 *visible = (value == 0) ? false : true;
1427 return PLAYER_ERROR_NONE;
1430 int legacy_player_get_content_info(legacy_player_h player, player_content_info_e key, char **value)
1432 legacy_player_t *handle = (legacy_player_t *)player;
1433 int ret = MM_ERROR_NONE;
1437 PLAYER_INSTANCE_CHECK(player);
1438 PLAYER_NULL_ARG_CHECK(value);
1440 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1441 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1442 return PLAYER_ERROR_INVALID_STATE;
1446 case PLAYER_CONTENT_INFO_ALBUM:
1447 attr = MM_PLAYER_TAG_ALBUM;
1449 case PLAYER_CONTENT_INFO_ARTIST:
1450 attr = MM_PLAYER_TAG_ARTIST;
1452 case PLAYER_CONTENT_INFO_AUTHOR:
1453 attr = MM_PLAYER_TAG_AUTHOUR;
1455 case PLAYER_CONTENT_INFO_GENRE:
1456 attr = MM_PLAYER_TAG_GENRE;
1458 case PLAYER_CONTENT_INFO_TITLE:
1459 attr = MM_PLAYER_TAG_TITLE;
1461 case PLAYER_CONTENT_INFO_YEAR:
1462 attr = MM_PLAYER_TAG_DATE;
1468 ret = mm_player_get_attribute(handle->mm_handle, NULL, attr, &val, &val_len, (char *)NULL);
1469 if (ret != MM_ERROR_NONE)
1470 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1474 *value = strndup(val, val_len);
1476 *value = strndup("", 0);
1478 if (*value == NULL) {
1479 LOGE("PLAYER_ERROR_OUT_OF_MEMORY : fail to strdup");
1480 return PLAYER_ERROR_OUT_OF_MEMORY;
1483 return PLAYER_ERROR_NONE;
1486 int legacy_player_get_codec_info(legacy_player_h player, char **audio_codec, char **video_codec)
1488 legacy_player_t *handle = (legacy_player_t *)player;
1489 int ret = MM_ERROR_NONE;
1494 PLAYER_INSTANCE_CHECK(player);
1495 PLAYER_NULL_ARG_CHECK(audio_codec);
1496 PLAYER_NULL_ARG_CHECK(video_codec);
1498 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1499 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1500 return PLAYER_ERROR_INVALID_STATE;
1503 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);
1504 if (ret != MM_ERROR_NONE)
1505 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1507 *audio_codec = NULL;
1509 *audio_codec = strndup(audio, audio_len);
1511 *audio_codec = strndup("", 0);
1513 *video_codec = NULL;
1515 *video_codec = strndup(video, video_len);
1517 *video_codec = strndup("", 0);
1519 LOGD("codec info: %s, %s", *audio_codec, *video_codec);
1520 return PLAYER_ERROR_NONE;
1523 int legacy_player_get_audio_stream_info(legacy_player_h player, int *sample_rate, int *channel, int *bit_rate)
1525 legacy_player_t *handle = (legacy_player_t *)player;
1526 int ret = MM_ERROR_NONE;
1527 PLAYER_INSTANCE_CHECK(player);
1528 PLAYER_NULL_ARG_CHECK(sample_rate);
1529 PLAYER_NULL_ARG_CHECK(channel);
1530 PLAYER_NULL_ARG_CHECK(bit_rate);
1532 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1533 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1534 return PLAYER_ERROR_INVALID_STATE;
1536 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);
1537 if (ret != MM_ERROR_NONE)
1538 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1540 return PLAYER_ERROR_NONE;
1543 int legacy_player_get_video_stream_info(legacy_player_h player, int *fps, int *bit_rate)
1545 legacy_player_t *handle = (legacy_player_t *)player;
1546 int ret = MM_ERROR_NONE;
1547 PLAYER_INSTANCE_CHECK(player);
1548 PLAYER_NULL_ARG_CHECK(fps);
1549 PLAYER_NULL_ARG_CHECK(bit_rate);
1551 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1552 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1553 return PLAYER_ERROR_INVALID_STATE;
1555 ret = mm_player_get_attribute(handle->mm_handle, NULL, "content_video_fps", fps, "content_video_bitrate", bit_rate, (char *)NULL);
1556 if (ret != MM_ERROR_NONE)
1557 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1559 return PLAYER_ERROR_NONE;
1562 int legacy_player_get_video_size(legacy_player_h player, int *width, int *height)
1564 legacy_player_t *handle = (legacy_player_t *)player;
1565 int ret = MM_ERROR_NONE;
1568 PLAYER_INSTANCE_CHECK(player);
1569 PLAYER_NULL_ARG_CHECK(width);
1570 PLAYER_NULL_ARG_CHECK(height);
1571 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1572 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1573 return PLAYER_ERROR_INVALID_STATE;
1575 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_WIDTH, &w, MM_PLAYER_VIDEO_HEIGHT, &h, (char *)NULL);
1576 if (ret != MM_ERROR_NONE)
1577 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1581 LOGI("width : %d, height : %d", w, h);
1582 return PLAYER_ERROR_NONE;
1585 int legacy_player_get_album_art(legacy_player_h player, void **album_art, int *size)
1587 legacy_player_t *handle = (legacy_player_t *)player;
1588 int ret = MM_ERROR_NONE;
1589 PLAYER_INSTANCE_CHECK(player);
1590 PLAYER_NULL_ARG_CHECK(size);
1591 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1592 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1593 return PLAYER_ERROR_INVALID_STATE;
1596 ret = mm_player_get_attribute(handle->mm_handle, NULL, "tag_album_cover", album_art, size, (char *)NULL);
1597 if (ret != MM_ERROR_NONE)
1598 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1600 return PLAYER_ERROR_NONE;
1603 int legacy_player_audio_effect_get_equalizer_bands_count(legacy_player_h player, int *count)
1605 legacy_player_t *handle = (legacy_player_t *)player;
1606 int ret = MM_ERROR_NONE;
1607 PLAYER_INSTANCE_CHECK(player);
1608 PLAYER_NULL_ARG_CHECK(count);
1610 ret = mm_player_audio_effect_custom_get_eq_bands_number(handle->mm_handle, count);
1611 if (ret != MM_ERROR_NONE)
1612 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1614 return PLAYER_ERROR_NONE;
1617 int legacy_player_audio_effect_set_equalizer_all_bands(legacy_player_h player, int *band_levels, int length)
1619 legacy_player_t *handle = (legacy_player_t *)player;
1620 int ret = MM_ERROR_NONE;
1621 PLAYER_INSTANCE_CHECK(player);
1622 PLAYER_NULL_ARG_CHECK(band_levels);
1624 ret = mm_player_audio_effect_custom_set_level_eq_from_list(handle->mm_handle, band_levels, length);
1625 if (ret != MM_ERROR_NONE)
1626 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1628 ret = mm_player_audio_effect_custom_apply(handle->mm_handle);
1629 return (ret == MM_ERROR_NONE) ? PLAYER_ERROR_NONE : __player_convert_error_code(ret, (char *)__FUNCTION__);
1632 int legacy_player_audio_effect_set_equalizer_band_level(legacy_player_h player, int index, int level)
1634 legacy_player_t *handle = (legacy_player_t *)player;
1635 int ret = MM_ERROR_NONE;
1636 PLAYER_INSTANCE_CHECK(player);
1638 ret = mm_player_audio_effect_custom_set_level(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, index, level);
1639 if (ret != MM_ERROR_NONE)
1640 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1642 ret = mm_player_audio_effect_custom_apply(handle->mm_handle);
1643 if (ret != MM_ERROR_NONE)
1644 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1646 return PLAYER_ERROR_NONE;
1649 int legacy_player_audio_effect_get_equalizer_band_level(legacy_player_h player, int index, int *level)
1651 legacy_player_t *handle = (legacy_player_t *)player;
1652 int ret = MM_ERROR_NONE;
1653 PLAYER_INSTANCE_CHECK(player);
1654 PLAYER_NULL_ARG_CHECK(level);
1656 ret = mm_player_audio_effect_custom_get_level(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, index, level);
1657 if (ret != MM_ERROR_NONE)
1658 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1660 return PLAYER_ERROR_NONE;
1663 int legacy_player_audio_effect_get_equalizer_level_range(legacy_player_h player, int *min, int *max)
1665 legacy_player_t *handle = (legacy_player_t *)player;
1666 int ret = MM_ERROR_NONE;
1667 PLAYER_INSTANCE_CHECK(player);
1668 PLAYER_NULL_ARG_CHECK(min);
1669 PLAYER_NULL_ARG_CHECK(max);
1671 ret = mm_player_audio_effect_custom_get_level_range(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, min, max);
1672 if (ret != MM_ERROR_NONE)
1673 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1675 return PLAYER_ERROR_NONE;
1678 int legacy_player_audio_effect_get_equalizer_band_frequency(legacy_player_h player, int index, int *frequency)
1680 legacy_player_t *handle = (legacy_player_t *)player;
1681 int ret = MM_ERROR_NONE;
1682 PLAYER_INSTANCE_CHECK(player);
1683 PLAYER_NULL_ARG_CHECK(frequency);
1685 ret = mm_player_audio_effect_custom_get_eq_bands_freq(handle->mm_handle, index, frequency);
1686 if (ret != MM_ERROR_NONE)
1687 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1689 return PLAYER_ERROR_NONE;
1692 int legacy_player_audio_effect_get_equalizer_band_frequency_range(legacy_player_h player, int index, int *range)
1694 legacy_player_t *handle = (legacy_player_t *)player;
1695 int ret = MM_ERROR_NONE;
1696 PLAYER_INSTANCE_CHECK(player);
1697 PLAYER_NULL_ARG_CHECK(range);
1699 ret = mm_player_audio_effect_custom_get_eq_bands_width(handle->mm_handle, index, range);
1700 if (ret != MM_ERROR_NONE)
1701 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1703 return PLAYER_ERROR_NONE;
1706 int legacy_player_audio_effect_equalizer_clear(legacy_player_h player)
1708 legacy_player_t *handle = (legacy_player_t *)player;
1709 int ret = MM_ERROR_NONE;
1710 PLAYER_INSTANCE_CHECK(player);
1712 ret = mm_player_audio_effect_custom_clear_eq_all(handle->mm_handle);
1713 if (ret != MM_ERROR_NONE)
1714 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1716 ret = mm_player_audio_effect_custom_apply(handle->mm_handle);
1717 if (ret != MM_ERROR_NONE)
1718 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1720 return PLAYER_ERROR_NONE;
1723 int legacy_player_audio_effect_equalizer_is_available(legacy_player_h player, bool *available)
1725 legacy_player_t *handle = (legacy_player_t *)player;
1726 int ret = MM_ERROR_NONE;
1727 PLAYER_INSTANCE_CHECK(player);
1728 PLAYER_NULL_ARG_CHECK(available);
1729 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
1730 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1731 return PLAYER_ERROR_INVALID_STATE;
1734 ret = mm_player_is_supported_custom_effect_type(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ);
1735 if (ret != MM_ERROR_NONE)
1740 return PLAYER_ERROR_NONE;
1743 int legacy_player_set_subtitle_path(legacy_player_h player, const char *path)
1745 legacy_player_t *handle = (legacy_player_t *)player;
1746 int ret = MM_ERROR_NONE;
1749 PLAYER_INSTANCE_CHECK(player);
1751 if ((path == NULL) && (handle->state != PLAYER_STATE_IDLE))
1752 return PLAYER_ERROR_INVALID_PARAMETER;
1754 ret = mm_player_set_external_subtitle_path(handle->mm_handle, path);
1755 if (ret != MM_ERROR_NONE)
1756 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1759 return PLAYER_ERROR_NONE;
1762 int legacy_player_set_subtitle_position_offset(legacy_player_h player, int millisecond)
1764 /* PLAYER_CHECK_CONDITION(millisecond>=0 ,PLAYER_ERROR_INVALID_PARAMETER ,"PLAYER_ERROR_INVALID_PARAMETER" ); */
1765 legacy_player_t *handle = (legacy_player_t *)player;
1766 int ret = MM_ERROR_NONE;
1767 PLAYER_INSTANCE_CHECK(player);
1768 if (!__player_state_validate(handle, PLAYER_STATE_PLAYING)) {
1769 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1770 return PLAYER_ERROR_INVALID_STATE;
1773 ret = mm_player_adjust_subtitle_position(handle->mm_handle, millisecond);
1774 if (ret != MM_ERROR_NONE)
1775 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1777 return PLAYER_ERROR_NONE;
1780 int legacy_player_capture_video(legacy_player_h player, player_video_captured_cb callback, void *user_data)
1782 legacy_player_t *handle = (legacy_player_t *)player;
1783 int ret = MM_ERROR_NONE;
1786 PLAYER_INSTANCE_CHECK(player);
1787 PLAYER_NULL_ARG_CHECK(callback);
1788 if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) {
1789 LOGE("previous capturing request is in processing.");
1790 return PLAYER_ERROR_VIDEO_CAPTURE_FAILED;
1793 LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_CAPTURE);
1794 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = callback;
1795 handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = user_data;
1797 if (handle->state >= PLAYER_STATE_READY) {
1798 ret = mm_player_do_video_capture(handle->mm_handle);
1799 if (ret == MM_ERROR_PLAYER_NO_OP) {
1800 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
1801 handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
1802 LOGE("PLAYER_ERROR_INVALID_OPERATION : video display must be set : %d", handle->display_type);
1803 return PLAYER_ERROR_INVALID_OPERATION;
1805 if (ret != MM_ERROR_NONE) {
1806 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
1807 handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
1808 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1810 return PLAYER_ERROR_NONE;
1813 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
1814 handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
1815 handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
1818 return PLAYER_ERROR_INVALID_STATE;
1821 int legacy_player_set_streaming_cookie(legacy_player_h player, const char *cookie, int size)
1823 legacy_player_t *handle = (legacy_player_t *)player;
1824 int ret = MM_ERROR_NONE;
1825 PLAYER_INSTANCE_CHECK(player);
1826 PLAYER_NULL_ARG_CHECK(cookie);
1827 PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1828 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
1830 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_STREAMING_COOKIE, cookie, size, (char *)NULL);
1831 if (ret != MM_ERROR_NONE)
1832 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1834 return PLAYER_ERROR_NONE;
1837 int legacy_player_set_streaming_user_agent(legacy_player_h player, const char *user_agent, int size)
1839 legacy_player_t *handle = (legacy_player_t *)player;
1840 int ret = MM_ERROR_NONE;
1841 PLAYER_INSTANCE_CHECK(player);
1842 PLAYER_NULL_ARG_CHECK(user_agent);
1843 PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1844 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
1846 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_STREAMING_USER_AGENT, user_agent, size, (char *)NULL);
1847 if (ret != MM_ERROR_NONE)
1848 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1850 return PLAYER_ERROR_NONE;
1853 int legacy_player_get_streaming_download_progress(legacy_player_h player, int *start_pos, int *end_pos)
1855 legacy_player_t *handle = (legacy_player_t *)player;
1856 int ret = MM_ERROR_NONE;
1857 PLAYER_INSTANCE_CHECK(player);
1858 PLAYER_NULL_ARG_CHECK(start_pos && end_pos);
1859 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
1860 LOGE("invalid state error, current state - %d", handle->state);
1861 return PLAYER_ERROR_INVALID_STATE;
1864 ret = mm_player_get_buffer_position(handle->mm_handle, start_pos, end_pos);
1865 if (ret != MM_ERROR_NONE)
1866 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1868 return PLAYER_ERROR_NONE;
1871 int legacy_player_set_completed_cb(legacy_player_h player, player_completed_cb callback, void *user_data)
1873 return __set_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player, callback, user_data);
1876 int legacy_player_unset_completed_cb(legacy_player_h player)
1878 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player);
1881 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1882 int legacy_player_set_retrieve_buffer_cb(legacy_player_h player, player_retrieve_buffer_cb callback, void *user_data)
1884 return __set_callback(MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER, player, callback, user_data);
1887 int legacy_player_unset_retrieve_buffer_cb(legacy_player_h player)
1889 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER, player);
1893 int legacy_player_set_interrupted_cb(legacy_player_h player, player_interrupted_cb callback, void *user_data)
1895 return __set_callback(MUSE_PLAYER_EVENT_TYPE_INTERRUPT, player, callback, user_data);
1898 int legacy_player_unset_interrupted_cb(legacy_player_h player)
1900 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_INTERRUPT, player);
1903 int legacy_player_set_error_cb(legacy_player_h player, player_error_cb callback, void *user_data)
1905 return __set_callback(MUSE_PLAYER_EVENT_TYPE_ERROR, player, callback, user_data);
1908 int legacy_player_unset_error_cb(legacy_player_h player)
1910 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_ERROR, player);
1913 int legacy_player_set_buffering_cb(legacy_player_h player, player_buffering_cb callback, void *user_data)
1915 return __set_callback(MUSE_PLAYER_EVENT_TYPE_BUFFERING, player, callback, user_data);
1918 int legacy_player_unset_buffering_cb(legacy_player_h player)
1920 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_BUFFERING, player);
1923 int legacy_player_set_subtitle_updated_cb(legacy_player_h player, player_subtitle_updated_cb callback, void *user_data)
1925 return __set_callback(MUSE_PLAYER_EVENT_TYPE_SUBTITLE, player, callback, user_data);
1928 int legacy_player_unset_subtitle_updated_cb(legacy_player_h player)
1930 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_SUBTITLE, player);
1933 int legacy_player_release_video_stream_bo(legacy_player_h player, void *bo)
1935 legacy_player_t *handle = (legacy_player_t *)player;
1936 PLAYER_INSTANCE_CHECK(player);
1938 LOGD("ENTER %p %p", player, bo);
1940 mm_player_release_video_stream_bo(handle->mm_handle, bo);
1944 return PLAYER_ERROR_NONE;
1947 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)
1949 legacy_player_t *handle = (legacy_player_t *)player;
1950 int ret = MM_ERROR_NONE;
1951 PLAYER_INSTANCE_CHECK(player);
1952 PLAYER_NULL_ARG_CHECK(callback);
1953 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
1955 ret = mm_player_set_video_decoded_callback(handle->mm_handle, (mm_player_video_decoded_callback)callback, user_data);
1956 if (ret != MM_ERROR_NONE)
1957 return __player_convert_error_code(ret, (char *)__FUNCTION__);
1959 return PLAYER_ERROR_NONE;
1962 static bool __video_stream_changed_callback(void *user_data)
1964 legacy_player_t *handle = (legacy_player_t *)user_data;
1965 int ret = MM_ERROR_NONE;
1966 muse_player_event_e event_type = MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
1968 LOGE("event type %d", event_type);
1970 if (handle->user_cb[event_type]) {
1971 int width = 0, height = 0, fps = 0, bit_rate = 0;
1972 ret = mm_player_get_attribute(handle->mm_handle, NULL,
1973 MM_PLAYER_VIDEO_WIDTH, &width,
1974 MM_PLAYER_VIDEO_HEIGHT, &height,
1975 "content_video_fps", &fps,
1976 "content_video_bitrate", &bit_rate, (char *)NULL);
1978 if (ret != MM_ERROR_NONE) {
1979 LOGE("get attr is failed");
1982 ((player_video_stream_changed_cb)handle->user_cb[event_type])(width, height, fps, bit_rate, handle->user_data[event_type]);
1986 LOGE("video stream changed cb was not set.");
1990 int legacy_player_set_video_stream_changed_cb(legacy_player_h player, player_video_stream_changed_cb callback, void *user_data)
1992 legacy_player_t *handle = (legacy_player_t *)player;
1993 int ret = MM_ERROR_NONE;
1994 PLAYER_INSTANCE_CHECK(player);
1995 PLAYER_NULL_ARG_CHECK(callback);
1996 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
1998 ret = mm_player_set_video_stream_changed_callback(handle->mm_handle, (mm_player_stream_changed_callback)__video_stream_changed_callback, (void *)handle);
1999 if (ret != MM_ERROR_NONE)
2000 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2002 return __set_callback(MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, player, callback, user_data);
2005 int legacy_player_unset_video_stream_changed_cb(legacy_player_h player)
2007 PLAYER_INSTANCE_CHECK(player);
2009 __unset_callback(MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, player);
2011 return PLAYER_ERROR_NONE;
2014 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)
2016 legacy_player_t *handle = (legacy_player_t *)user_data;
2017 muse_player_event_e event_type;
2019 if (type == PLAYER_STREAM_TYPE_AUDIO)
2020 event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
2021 else if (type == PLAYER_STREAM_TYPE_VIDEO)
2022 event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
2026 LOGE("event type %d", event_type);
2028 if (handle->user_cb[event_type]) {
2029 ((player_media_stream_buffer_status_cb)handle->user_cb[event_type])(status, handle->user_data[event_type]);
2031 LOGE("[type:%d] buffer status cb was not set.", type);
2038 static bool __media_stream_seek_data_callback(player_stream_type_e type, unsigned long long offset, void *user_data)
2040 legacy_player_t *handle = (legacy_player_t *)user_data;
2041 muse_player_event_e event_type;
2043 if (type == PLAYER_STREAM_TYPE_AUDIO)
2044 event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
2045 else if (type == PLAYER_STREAM_TYPE_VIDEO)
2046 event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
2050 LOGE("event type %d", event_type);
2052 if (handle->user_cb[event_type]) {
2053 ((player_media_stream_seek_cb)handle->user_cb[event_type])(offset, handle->user_data[event_type]);
2055 LOGE("[type:%d] seek cb was not set.", type);
2062 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)
2064 legacy_player_t *handle = (legacy_player_t *)player;
2065 int ret = MM_ERROR_NONE;
2066 PLAYER_INSTANCE_CHECK(player);
2067 PLAYER_NULL_ARG_CHECK(callback);
2068 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2070 /* the type can be expaned with default and text. */
2071 if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) {
2072 LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", type);
2073 return PLAYER_ERROR_INVALID_PARAMETER;
2076 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);
2078 if (ret != MM_ERROR_NONE)
2079 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2081 if (type == PLAYER_STREAM_TYPE_VIDEO)
2082 return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, player, callback, user_data);
2084 return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, player, callback, user_data);
2087 int legacy_player_unset_media_stream_buffer_status_cb(legacy_player_h player, player_stream_type_e type)
2089 PLAYER_INSTANCE_CHECK(player);
2091 if (type == PLAYER_STREAM_TYPE_VIDEO)
2092 __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, player);
2093 else if (type == PLAYER_STREAM_TYPE_AUDIO)
2094 __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, player);
2096 return PLAYER_ERROR_INVALID_PARAMETER;
2098 return PLAYER_ERROR_NONE;
2101 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)
2103 legacy_player_t *handle = (legacy_player_t *)player;
2104 int ret = MM_ERROR_NONE;
2105 PLAYER_INSTANCE_CHECK(player);
2106 PLAYER_NULL_ARG_CHECK(callback);
2107 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2109 /* the type can be expaned with default and text. */
2110 if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) {
2111 LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", type);
2112 return PLAYER_ERROR_INVALID_PARAMETER;
2115 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);
2116 if (ret != MM_ERROR_NONE)
2117 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2119 if (type == PLAYER_STREAM_TYPE_VIDEO)
2120 return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, player, callback, user_data);
2122 return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, player, callback, user_data);
2125 int legacy_player_unset_media_stream_seek_cb(legacy_player_h player, player_stream_type_e type)
2127 PLAYER_INSTANCE_CHECK(player);
2129 if (type == PLAYER_STREAM_TYPE_VIDEO)
2130 __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, player);
2131 else if (type == PLAYER_STREAM_TYPE_AUDIO)
2132 __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, player);
2134 return PLAYER_ERROR_INVALID_PARAMETER;
2136 return PLAYER_ERROR_NONE;
2139 int legacy_player_push_media_stream(legacy_player_h player, media_packet_h packet)
2141 legacy_player_t *handle = (legacy_player_t *)player;
2142 int ret = MM_ERROR_NONE;
2143 PLAYER_INSTANCE_CHECK(player);
2145 PLAYER_CHECK_CONDITION(handle->error_code == PLAYER_ERROR_NONE, PLAYER_ERROR_NOT_SUPPORTED_FILE, "can't support this format");
2147 ret = mm_player_submit_packet(handle->mm_handle, packet);
2148 if (ret != MM_ERROR_NONE)
2149 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2151 return PLAYER_ERROR_NONE;
2154 int legacy_player_set_media_stream_info(legacy_player_h player, player_stream_type_e type, media_format_h format)
2156 legacy_player_t *handle = (legacy_player_t *)player;
2157 int ret = MM_ERROR_NONE;
2158 PLAYER_INSTANCE_CHECK(player);
2159 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2161 handle->is_media_stream = true;
2163 if (type == PLAYER_STREAM_TYPE_VIDEO)
2164 ret = mm_player_set_video_info(handle->mm_handle, format);
2165 else if (type == PLAYER_STREAM_TYPE_AUDIO)
2166 ret = mm_player_set_audio_info(handle->mm_handle, format);
2168 return PLAYER_ERROR_INVALID_PARAMETER;
2170 if (ret != MM_ERROR_NONE)
2171 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2173 return PLAYER_ERROR_NONE;
2176 int legacy_player_set_media_stream_buffer_max_size(legacy_player_h player, player_stream_type_e type, unsigned long long max_size)
2178 legacy_player_t *handle = (legacy_player_t *)player;
2179 int ret = MM_ERROR_NONE;
2180 PLAYER_INSTANCE_CHECK(player);
2181 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2182 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2183 return PLAYER_ERROR_INVALID_STATE;
2186 ret = mm_player_set_media_stream_buffer_max_size(handle->mm_handle, type, max_size);
2187 if (ret != MM_ERROR_NONE)
2188 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2190 return PLAYER_ERROR_NONE;
2193 int legacy_player_get_media_stream_buffer_max_size(legacy_player_h player, player_stream_type_e type, unsigned long long *max_size)
2195 legacy_player_t *handle = (legacy_player_t *)player;
2196 int ret = MM_ERROR_NONE;
2197 unsigned long long _max_size;
2198 PLAYER_INSTANCE_CHECK(player);
2199 PLAYER_NULL_ARG_CHECK(max_size);
2201 ret = mm_player_get_media_stream_buffer_max_size(handle->mm_handle, type, &_max_size);
2202 if (ret != MM_ERROR_NONE)
2203 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2205 *max_size = _max_size;
2206 return PLAYER_ERROR_NONE;
2209 int legacy_player_set_media_stream_buffer_min_threshold(legacy_player_h player, player_stream_type_e type, unsigned int percent)
2211 legacy_player_t *handle = (legacy_player_t *)player;
2212 int ret = MM_ERROR_NONE;
2213 PLAYER_INSTANCE_CHECK(player);
2214 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2215 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2216 return PLAYER_ERROR_INVALID_STATE;
2219 ret = mm_player_set_media_stream_buffer_min_percent(handle->mm_handle, type, percent);
2220 if (ret != MM_ERROR_NONE)
2221 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2223 return PLAYER_ERROR_NONE;
2226 int legacy_player_get_media_stream_buffer_min_threshold(legacy_player_h player, player_stream_type_e type, unsigned int *percent)
2228 legacy_player_t *handle = (legacy_player_t *)player;
2229 int ret = MM_ERROR_NONE;
2230 unsigned int _value;
2231 PLAYER_INSTANCE_CHECK(player);
2232 PLAYER_NULL_ARG_CHECK(percent);
2234 ret = mm_player_get_media_stream_buffer_min_percent(handle->mm_handle, type, &_value);
2235 if (ret != MM_ERROR_NONE)
2236 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2239 return PLAYER_ERROR_NONE;
2242 int legacy_player_get_track_count(legacy_player_h player, player_stream_type_e type, int *count)
2244 legacy_player_t *handle = (legacy_player_t *)player;
2245 int ret = MM_ERROR_NONE;
2246 mmplayer_track_type_e track_type = 0;
2247 PLAYER_INSTANCE_CHECK(player);
2248 PLAYER_NULL_ARG_CHECK(count);
2250 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2251 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2252 return PLAYER_ERROR_INVALID_STATE;
2256 case PLAYER_STREAM_TYPE_AUDIO:
2257 track_type = MM_PLAYER_TRACK_TYPE_AUDIO;
2259 case PLAYER_STREAM_TYPE_TEXT:
2260 track_type = MM_PLAYER_TRACK_TYPE_TEXT;
2263 LOGE("invalid stream type %d", type);
2264 return PLAYER_ERROR_INVALID_PARAMETER;
2267 ret = mm_player_get_track_count(handle->mm_handle, track_type, count);
2268 if (ret != MM_ERROR_NONE)
2269 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2271 return PLAYER_ERROR_NONE;
2274 int legacy_player_get_current_track(legacy_player_h player, player_stream_type_e type, int *index)
2276 legacy_player_t *handle = (legacy_player_t *)player;
2277 int ret = MM_ERROR_NONE;
2278 mmplayer_track_type_e track_type = 0;
2279 PLAYER_INSTANCE_CHECK(player);
2280 PLAYER_NULL_ARG_CHECK(index);
2281 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2282 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2283 return PLAYER_ERROR_INVALID_STATE;
2287 case PLAYER_STREAM_TYPE_AUDIO:
2288 track_type = MM_PLAYER_TRACK_TYPE_AUDIO;
2290 case PLAYER_STREAM_TYPE_TEXT:
2291 track_type = MM_PLAYER_TRACK_TYPE_TEXT;
2294 LOGE("invalid stream type %d", type);
2295 return PLAYER_ERROR_INVALID_PARAMETER;
2298 ret = mm_player_get_current_track(handle->mm_handle, track_type, index);
2299 if (ret != MM_ERROR_NONE)
2300 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2302 return PLAYER_ERROR_NONE;
2305 int legacy_player_select_track(legacy_player_h player, player_stream_type_e type, int index)
2307 legacy_player_t *handle = (legacy_player_t *)player;
2308 int ret = MM_ERROR_NONE;
2309 mmplayer_track_type_e track_type = 0;
2312 PLAYER_INSTANCE_CHECK(player);
2313 PLAYER_CHECK_CONDITION(index >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
2314 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2315 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2316 return PLAYER_ERROR_INVALID_STATE;
2320 case PLAYER_STREAM_TYPE_AUDIO:
2321 track_type = MM_PLAYER_TRACK_TYPE_AUDIO;
2323 case PLAYER_STREAM_TYPE_TEXT:
2324 track_type = MM_PLAYER_TRACK_TYPE_TEXT;
2327 LOGE("invalid stream type %d", type);
2328 return PLAYER_ERROR_INVALID_PARAMETER;
2331 ret = mm_player_select_track(handle->mm_handle, track_type, index);
2332 if (ret != MM_ERROR_NONE)
2333 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2336 return PLAYER_ERROR_NONE;
2339 int legacy_player_get_track_language_code(legacy_player_h player, player_stream_type_e type, int index, char **code, int *len)
2341 legacy_player_t *handle = (legacy_player_t *)player;
2342 int ret = MM_ERROR_NONE;
2343 mmplayer_track_type_e track_type = 0;
2344 PLAYER_INSTANCE_CHECK(player);
2345 PLAYER_NULL_ARG_CHECK(code);
2346 PLAYER_NULL_ARG_CHECK(len);
2347 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2348 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2349 return PLAYER_ERROR_INVALID_STATE;
2353 case PLAYER_STREAM_TYPE_AUDIO:
2354 track_type = MM_PLAYER_TRACK_TYPE_AUDIO;
2356 case PLAYER_STREAM_TYPE_VIDEO:
2357 track_type = MM_PLAYER_TRACK_TYPE_VIDEO;
2359 case PLAYER_STREAM_TYPE_TEXT:
2360 track_type = MM_PLAYER_TRACK_TYPE_TEXT;
2363 LOGE("invalid stream type %d", type);
2364 return PLAYER_ERROR_INVALID_PARAMETER;
2368 ret = mm_player_get_track_language_code(handle->mm_handle, track_type, index, code);
2369 if (ret != MM_ERROR_NONE)
2370 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2372 LOGD("idx %d, lang code %s", index, *code);
2373 *len = strlen(*code);
2374 return PLAYER_ERROR_NONE;
2377 int legacy_player_set_video_roi_area(legacy_player_h player, double scale_x,
2378 double scale_y, double scale_width, double scale_heights)
2380 legacy_player_t *handle = (legacy_player_t *)player;
2381 int ret = MM_ERROR_NONE;
2382 PLAYER_INSTANCE_CHECK(player);
2386 if (handle->display_type != PLAYER_DISPLAY_TYPE_OVERLAY) {
2387 LOGE("not supportable display type %d", handle->display_type);
2388 return PLAYER_ERROR_INVALID_OPERATION;
2391 ret = mm_player_set_video_roi_area(handle->mm_handle, scale_x, scale_y, scale_width, scale_heights);
2392 if (ret != PLAYER_ERROR_NONE)
2393 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2395 return PLAYER_ERROR_NONE;
2398 int legacy_player_get_video_roi_area(legacy_player_h player, double *scale_x,
2399 double *scale_y, double *scale_width, double *scale_height)
2401 legacy_player_t *handle = (legacy_player_t *)player;
2402 int ret = MM_ERROR_NONE;
2403 PLAYER_INSTANCE_CHECK(player);
2404 PLAYER_NULL_ARG_CHECK(scale_x);
2405 PLAYER_NULL_ARG_CHECK(scale_y);
2406 PLAYER_NULL_ARG_CHECK(scale_width);
2407 PLAYER_NULL_ARG_CHECK(scale_height);
2411 ret = mm_player_get_video_roi_area(handle->mm_handle, scale_x, scale_y, scale_width, scale_height);
2412 if (ret != PLAYER_ERROR_NONE)
2413 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2415 return PLAYER_ERROR_NONE;
2418 int legacy_player_set_roi_area(legacy_player_h player, int x, int y, int w, int h)
2420 legacy_player_t *handle = (legacy_player_t *)player;
2421 int ret = MM_ERROR_NONE;
2422 PLAYER_INSTANCE_CHECK(player);
2427 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);
2428 if (ret != MM_ERROR_NONE)
2429 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2431 return PLAYER_ERROR_NONE;
2434 int legacy_player_set_display(legacy_player_h player, player_display_type_e type, unsigned int wl_surface_id)
2436 legacy_player_t *handle = (legacy_player_t *)player;
2437 int ret = MM_ERROR_NONE;
2438 void *set_handle = NULL;
2440 MMDisplaySurfaceType mmType = __player_convert_display_type(type);
2441 PLAYER_INSTANCE_CHECK(player);
2442 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2443 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2444 return PLAYER_ERROR_INVALID_STATE;
2447 if (type == PLAYER_DISPLAY_TYPE_NONE) {
2449 handle->display_handle = 0;
2450 handle->display_type = type;
2453 /* get handle from overlay or evas surface */
2454 temp = handle->display_handle;
2455 if (type == PLAYER_DISPLAY_TYPE_OVERLAY) {
2456 LOGI("Wayland overlay surface type");
2457 LOGI("wl_surface_id %d", wl_surface_id);
2458 handle->display_handle = (void *)(uintptr_t)wl_surface_id;
2459 set_handle = &(handle->display_handle);
2460 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2461 } else if (type == PLAYER_DISPLAY_TYPE_EVAS) {
2462 LOGI("Evas surface type");
2463 set_handle = &(handle->display_handle);
2466 LOGE("invalid surface type");
2467 return PLAYER_ERROR_INVALID_PARAMETER;
2471 /* set display handle */
2472 if (handle->display_type == PLAYER_DISPLAY_TYPE_NONE || type == handle->display_type) {
2473 /* first time or same type */
2474 LOGW("first time or same type");
2475 ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", mmType, "display_overlay", set_handle, sizeof(wl_surface_id), NULL);
2477 if (ret != MM_ERROR_NONE) {
2478 handle->display_handle = temp;
2479 LOGE("Failed to display surface change: %d", ret);
2481 if (type != PLAYER_DISPLAY_TYPE_NONE) {
2482 handle->display_type = type;
2483 LOGI("video display has been changed- type: %d, addr: %p", handle->display_type, handle->display_handle);
2485 LOGI("NULL surface");
2489 /* changing surface case */
2490 ret = mm_player_change_videosink(handle->mm_handle, mmType, set_handle);
2491 if (ret != MM_ERROR_NONE) {
2492 handle->display_handle = temp;
2493 if (ret == MM_ERROR_NOT_SUPPORT_API) {
2494 LOGE("change video sink is not available.");
2495 ret = PLAYER_ERROR_NONE;
2497 LOGE("Failed to display surface change: %d", ret);
2500 handle->display_type = type;
2501 LOGI("video display has been changed- type: %d, addr: %p", handle->display_type, handle->display_handle);
2505 if (ret != MM_ERROR_NONE) {
2506 handle->display_type = PLAYER_DISPLAY_TYPE_NONE;
2507 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2510 return PLAYER_ERROR_NONE;
2513 int legacy_player_set_sound_stream_info_for_mused(legacy_player_h player, char *stream_type, int stream_index)
2515 legacy_player_t *handle = (legacy_player_t *)player;
2516 int ret = MM_ERROR_NONE;
2517 PLAYER_INSTANCE_CHECK(player);
2518 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2520 if (stream_type == NULL || stream_index < 0) {
2521 LOGE("invalid parameter %p %d", stream_type, stream_index);
2522 return PLAYER_ERROR_INVALID_PARAMETER;
2525 ret = mm_player_set_sound_stream_info(handle->mm_handle, stream_type, stream_index);
2526 if (ret != MM_ERROR_NONE)
2527 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2529 return PLAYER_ERROR_NONE;
2532 int legacy_player_get_timeout_for_muse(legacy_player_h player, int *timeout)
2534 legacy_player_t *handle = (legacy_player_t *)player;
2535 int ret = MM_ERROR_NONE;
2536 PLAYER_INSTANCE_CHECK(player);
2538 ret = mm_player_get_timeout(handle->mm_handle, timeout);
2539 if (ret != MM_ERROR_NONE)
2540 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2542 return PLAYER_ERROR_NONE;
2545 int legacy_player_get_num_of_video_out_buffers(legacy_player_h player, int *num, int *extra_num)
2547 legacy_player_t *handle = (legacy_player_t *)player;
2548 int ret = MM_ERROR_NONE;
2549 PLAYER_INSTANCE_CHECK(player);
2550 PLAYER_NULL_ARG_CHECK(num);
2551 PLAYER_NULL_ARG_CHECK(extra_num);
2553 ret = mm_player_get_num_of_video_out_buffers(handle->mm_handle, num, extra_num);
2554 if (ret != MM_ERROR_NONE)
2555 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2557 return PLAYER_ERROR_NONE;
2560 int legacy_player_manage_external_storage_state(legacy_player_h player, int id, int state)
2562 legacy_player_t *handle = (legacy_player_t *)player;
2563 int ret = MM_ERROR_NONE;
2564 PLAYER_INSTANCE_CHECK(player);
2566 ret = mm_player_manage_external_storage_state(handle->mm_handle, id, state);
2567 if (ret != MM_ERROR_NONE)
2568 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2570 return PLAYER_ERROR_NONE;
2573 int legacy_player_get_adaptive_variant_info(legacy_player_h player, int *num, char **var_info)
2575 int ret = MM_ERROR_NONE;
2576 legacy_player_t *handle = (legacy_player_t *)player;
2577 PLAYER_INSTANCE_CHECK(player);
2578 PLAYER_NULL_ARG_CHECK(num);
2579 PLAYER_NULL_ARG_CHECK(var_info);
2581 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2582 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2583 return PLAYER_ERROR_INVALID_STATE;
2586 ret = mm_player_get_adaptive_variant_info(handle->mm_handle, num, var_info);
2587 if (ret != MM_ERROR_NONE)
2588 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2590 return PLAYER_ERROR_NONE;
2593 int legacy_player_set_max_adaptive_variant_limit(legacy_player_h player, int bandwidth, int width, int height)
2595 int ret = MM_ERROR_NONE;
2596 legacy_player_t *handle = (legacy_player_t *)player;
2597 PLAYER_INSTANCE_CHECK(player);
2599 ret = mm_player_set_max_adaptive_variant_limit(handle->mm_handle, bandwidth, width, height);
2600 if (ret != MM_ERROR_NONE)
2601 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2603 return PLAYER_ERROR_NONE;
2606 int legacy_player_get_max_adaptive_variant_limit(legacy_player_h player, int *bandwidth, int *width, int *height)
2608 legacy_player_t *handle = (legacy_player_t *)player;
2609 int ret = MM_ERROR_NONE;
2610 PLAYER_INSTANCE_CHECK(player);
2611 PLAYER_NULL_ARG_CHECK(bandwidth);
2612 PLAYER_NULL_ARG_CHECK(width);
2613 PLAYER_NULL_ARG_CHECK(height);
2615 ret = mm_player_get_max_adaptive_variant_limit(handle->mm_handle, bandwidth, width, height);
2616 if (ret != MM_ERROR_NONE)
2617 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2619 return PLAYER_ERROR_NONE;
2622 int legacy_player_set_audio_only(legacy_player_h player, bool audio_only)
2624 legacy_player_t *handle = (legacy_player_t *)player;
2625 int ret = MM_ERROR_NONE;
2626 PLAYER_INSTANCE_CHECK(player);
2628 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2629 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2630 return PLAYER_ERROR_INVALID_STATE;
2633 ret = mm_player_set_audio_only(handle->mm_handle, audio_only);
2634 if (ret != MM_ERROR_NONE)
2635 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2637 return PLAYER_ERROR_NONE;
2640 int legacy_player_is_audio_only(legacy_player_h player, bool *paudio_only)
2642 legacy_player_t *handle = (legacy_player_t *)player;
2643 int ret = MM_ERROR_NONE;
2644 bool audio_only = false;
2645 PLAYER_INSTANCE_CHECK(player);
2646 PLAYER_NULL_ARG_CHECK(paudio_only);
2648 ret = mm_player_get_audio_only(handle->mm_handle, &audio_only);
2649 if (ret != MM_ERROR_NONE)
2650 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2652 *paudio_only = audio_only;
2653 return PLAYER_ERROR_NONE;
2656 int legacy_player_set_streaming_buffering_time(legacy_player_h player, int prebuffer_ms, int rebuffer_ms)
2658 legacy_player_t *handle = (legacy_player_t *)player;
2659 int ret = MM_ERROR_NONE;
2660 PLAYER_INSTANCE_CHECK(player);
2661 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2663 LOGD("set buffering time : %d ms, %d ms", prebuffer_ms, rebuffer_ms);
2665 /* set streaming buffering time */
2666 if (prebuffer_ms >= MIN_BUFFERING_TIME_MS)
2667 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_PREBUFFER_MS, prebuffer_ms, (char *)NULL);
2669 if ((ret == MM_ERROR_NONE) && (rebuffer_ms >= MIN_BUFFERING_TIME_MS))
2670 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_REBUFFER_MS, rebuffer_ms, (char *)NULL);
2672 if (ret != MM_ERROR_NONE)
2673 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2675 return PLAYER_ERROR_NONE;
2678 int legacy_player_get_streaming_buffering_time(legacy_player_h player, int *prebuffer_ms, int *rebuffer_ms)
2680 legacy_player_t *handle = (legacy_player_t *)player;
2681 int ret = MM_ERROR_NONE;
2682 PLAYER_INSTANCE_CHECK(player);
2683 PLAYER_NULL_ARG_CHECK(prebuffer_ms && rebuffer_ms);
2685 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2686 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2687 return PLAYER_ERROR_INVALID_STATE;
2690 if (handle->state < PLAYER_STATE_READY) {
2691 ret = mm_player_get_attribute(handle->mm_handle, NULL,
2692 MM_PLAYER_PREBUFFER_MS, prebuffer_ms, MM_PLAYER_REBUFFER_MS, rebuffer_ms, (char *)NULL);
2693 if (ret != MM_ERROR_NONE)
2694 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2696 LOGD("pre: %d ms, re: %d ms", *prebuffer_ms, *rebuffer_ms);
2697 return PLAYER_ERROR_NONE;
2700 ret = mm_player_get_streaming_buffering_time(handle->mm_handle, prebuffer_ms, rebuffer_ms);
2701 if (ret != MM_ERROR_NONE)
2702 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2704 LOGD("pre: %d ms, re: %d ms", *prebuffer_ms, *rebuffer_ms);
2706 if (*prebuffer_ms < MIN_BUFFERING_TIME_MS) *prebuffer_ms = MIN_BUFFERING_TIME_MS;
2707 if (*rebuffer_ms < MIN_BUFFERING_TIME_MS) *rebuffer_ms = MIN_BUFFERING_TIME_MS;
2709 return PLAYER_ERROR_NONE;
2712 int legacy_player_360_is_content_spherical(legacy_player_h player, bool *is_spherical)
2714 legacy_player_t *handle = (legacy_player_t *)player;
2715 int ret = MM_ERROR_NONE;
2716 PLAYER_INSTANCE_CHECK(player);
2717 PLAYER_NULL_ARG_CHECK(is_spherical);
2719 if (!__player_state_validate(handle, PLAYER_STATE_READY)) {
2720 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2721 return PLAYER_ERROR_INVALID_STATE;
2724 ret = mm_player_360_is_content_spherical(handle->mm_handle, is_spherical);
2725 if (ret != MM_ERROR_NONE)
2726 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2728 return PLAYER_ERROR_NONE;
2731 int legacy_player_360_set_enabled(legacy_player_h player, bool enabled)
2733 legacy_player_t *handle = (legacy_player_t *)player;
2734 int ret = MM_ERROR_NONE;
2735 PLAYER_INSTANCE_CHECK(player);
2737 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2738 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2739 return PLAYER_ERROR_INVALID_STATE;
2742 ret = mm_player_360_set_enabled(handle->mm_handle, enabled);
2743 if (ret != MM_ERROR_NONE)
2744 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2746 return PLAYER_ERROR_NONE;
2749 int legacy_player_360_is_enabled(legacy_player_h player, bool *enabled)
2751 legacy_player_t *handle = (legacy_player_t *)player;
2752 int ret = MM_ERROR_NONE;
2753 PLAYER_INSTANCE_CHECK(player);
2754 PLAYER_NULL_ARG_CHECK(enabled);
2755 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2756 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2757 return PLAYER_ERROR_INVALID_STATE;
2760 ret = mm_player_360_is_enabled(handle->mm_handle, enabled);
2761 if (ret != MM_ERROR_NONE)
2762 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2764 return PLAYER_ERROR_NONE;
2767 int legacy_player_360_set_direction_of_view(legacy_player_h player, float yaw, float pitch)
2769 legacy_player_t *handle = (legacy_player_t *)player;
2770 int ret = MM_ERROR_NONE;
2771 PLAYER_INSTANCE_CHECK(player);
2773 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2774 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2775 return PLAYER_ERROR_INVALID_STATE;
2778 ret = mm_player_360_set_direction_of_view(handle->mm_handle, yaw, pitch);
2779 if (ret != MM_ERROR_NONE)
2780 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2782 return PLAYER_ERROR_NONE;
2785 int legacy_player_360_get_direction_of_view(legacy_player_h player, float *yaw, float *pitch)
2787 legacy_player_t *handle = (legacy_player_t *)player;
2788 int ret = MM_ERROR_NONE;
2789 PLAYER_INSTANCE_CHECK(player);
2790 PLAYER_NULL_ARG_CHECK(yaw);
2791 PLAYER_NULL_ARG_CHECK(pitch);
2793 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2794 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2795 return PLAYER_ERROR_INVALID_STATE;
2798 ret = mm_player_360_get_direction_of_view(handle->mm_handle, yaw, pitch);
2799 if (ret != MM_ERROR_NONE)
2800 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2802 return PLAYER_ERROR_NONE;
2805 int legacy_player_360_set_zoom(legacy_player_h player, float level)
2807 legacy_player_t *handle = (legacy_player_t *)player;
2808 int ret = MM_ERROR_NONE;
2809 PLAYER_INSTANCE_CHECK(player);
2811 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2812 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2813 return PLAYER_ERROR_INVALID_STATE;
2816 ret = mm_player_360_set_zoom(handle->mm_handle, level);
2817 if (ret != MM_ERROR_NONE)
2818 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2820 return PLAYER_ERROR_NONE;
2823 int legacy_player_360_get_zoom(legacy_player_h player, float *level)
2825 legacy_player_t *handle = (legacy_player_t *)player;
2826 int ret = MM_ERROR_NONE;
2827 PLAYER_INSTANCE_CHECK(player);
2829 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2830 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2831 return PLAYER_ERROR_INVALID_STATE;
2834 ret = mm_player_360_get_zoom(handle->mm_handle, level);
2835 if (ret != MM_ERROR_NONE)
2836 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2838 return PLAYER_ERROR_NONE;
2841 int legacy_player_360_set_field_of_view(legacy_player_h player, int horizontal_degrees, int vertical_degrees)
2843 legacy_player_t *handle = (legacy_player_t *)player;
2844 int ret = MM_ERROR_NONE;
2845 PLAYER_INSTANCE_CHECK(player);
2847 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2848 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2849 return PLAYER_ERROR_INVALID_STATE;
2852 ret = mm_player_360_set_field_of_view(handle->mm_handle, horizontal_degrees, vertical_degrees);
2853 if (ret != MM_ERROR_NONE)
2854 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2856 return PLAYER_ERROR_NONE;
2859 int legacy_player_360_get_field_of_view(legacy_player_h player, int *horizontal_degrees, int *vertical_degrees)
2861 legacy_player_t *handle = (legacy_player_t *)player;
2862 int ret = MM_ERROR_NONE;
2863 PLAYER_INSTANCE_CHECK(player);
2864 PLAYER_NULL_ARG_CHECK(horizontal_degrees);
2865 PLAYER_NULL_ARG_CHECK(vertical_degrees);
2867 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2868 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2869 return PLAYER_ERROR_INVALID_STATE;
2872 ret = mm_player_360_get_field_of_view(handle->mm_handle, horizontal_degrees, vertical_degrees);
2873 if (ret != MM_ERROR_NONE)
2874 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2876 return PLAYER_ERROR_NONE;
2879 int legacy_player_set_replaygain_enabled(legacy_player_h player, bool enabled)
2881 legacy_player_t *handle = (legacy_player_t *)player;
2882 int ret = MM_ERROR_NONE;
2883 PLAYER_INSTANCE_CHECK(player);
2885 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2886 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2887 return PLAYER_ERROR_INVALID_STATE;
2890 ret = mm_player_set_replaygain_enabled(handle->mm_handle, enabled);
2891 if (ret != MM_ERROR_NONE)
2892 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2894 return PLAYER_ERROR_NONE;
2897 int legacy_player_is_replaygain_enabled(legacy_player_h player, bool *enabled)
2899 legacy_player_t *handle = (legacy_player_t *)player;
2900 int ret = MM_ERROR_NONE;
2902 PLAYER_INSTANCE_CHECK(player);
2903 PLAYER_NULL_ARG_CHECK(enabled);
2905 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2906 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2907 return PLAYER_ERROR_INVALID_STATE;
2910 ret = mm_player_is_replaygain_enabled(handle->mm_handle, &_enable);
2911 if (ret != MM_ERROR_NONE)
2912 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2915 return PLAYER_ERROR_NONE;
2918 int legacy_player_set_audio_offload_enabled(legacy_player_h player, bool enabled)
2920 legacy_player_t *handle = (legacy_player_t *)player;
2921 int ret = MM_ERROR_NONE;
2922 PLAYER_INSTANCE_CHECK(player);
2923 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2925 LOGD("set audio offload %d", enabled);
2927 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_AUDIO_OFFLOAD, (int)enabled, (char *)NULL);
2928 if (ret != MM_ERROR_NONE)
2929 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2931 return PLAYER_ERROR_NONE;
2934 int legacy_player_is_audio_offload_enabled(legacy_player_h player, bool *enabled)
2936 legacy_player_t *handle = (legacy_player_t *)player;
2937 int ret = MM_ERROR_NONE;
2939 PLAYER_INSTANCE_CHECK(player);
2940 PLAYER_NULL_ARG_CHECK(enabled);
2942 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2943 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2944 return PLAYER_ERROR_INVALID_STATE;
2947 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_AUDIO_OFFLOAD, &val, (char *)NULL);
2948 if (ret != MM_ERROR_NONE)
2949 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2951 *enabled = (bool)val;
2952 LOGD("get audio offload %d", *enabled);
2953 return PLAYER_ERROR_NONE;
2956 int legacy_player_pitch_set_enabled(legacy_player_h player, bool enabled)
2958 legacy_player_t *handle = (legacy_player_t *)player;
2959 int ret = MM_ERROR_NONE;
2960 PLAYER_INSTANCE_CHECK(player);
2961 PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
2963 LOGD("set pitch control %d", enabled);
2964 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_PITCH_CONTROL, (int)enabled, (char *)NULL);
2966 if (ret != MM_ERROR_NONE)
2967 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2969 return PLAYER_ERROR_NONE;
2972 int legacy_player_pitch_is_enabled(legacy_player_h player, bool *enabled)
2974 legacy_player_t *handle = (legacy_player_t *)player;
2975 int ret = MM_ERROR_NONE;
2977 PLAYER_INSTANCE_CHECK(player);
2978 PLAYER_NULL_ARG_CHECK(enabled);
2980 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
2981 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
2982 return PLAYER_ERROR_INVALID_STATE;
2985 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_PITCH_CONTROL, &val, (char *)NULL);
2986 if (ret != MM_ERROR_NONE)
2987 return __player_convert_error_code(ret, (char *)__FUNCTION__);
2989 *enabled = (bool)val;
2990 LOGD("get pitch control %d", *enabled);
2991 return PLAYER_ERROR_NONE;
2994 int legacy_player_pitch_set_value(legacy_player_h player, float pitch)
2996 legacy_player_t *handle = (legacy_player_t *)player;
2997 int ret = MM_ERROR_NONE;
3000 PLAYER_INSTANCE_CHECK(player);
3002 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
3003 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
3004 return PLAYER_ERROR_INVALID_STATE;
3007 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_PITCH_CONTROL, &is_enabled, (char *)NULL);
3008 if (ret != MM_ERROR_NONE)
3009 return __player_convert_error_code(ret, (char *)__FUNCTION__);
3012 LOGE("pitch is not enabled");
3013 return PLAYER_ERROR_INVALID_OPERATION;
3016 LOGD("set pitch value %1.3f", pitch);
3017 ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_PITCH_VALUE, (double)pitch, (char *)NULL);
3018 if (ret != MM_ERROR_NONE)
3019 return __player_convert_error_code(ret, (char *)__FUNCTION__);
3021 return PLAYER_ERROR_NONE;
3024 int legacy_player_pitch_get_value(legacy_player_h player, float *pitch)
3026 legacy_player_t *handle = (legacy_player_t *)player;
3027 int ret = MM_ERROR_NONE;
3029 PLAYER_INSTANCE_CHECK(player);
3030 PLAYER_NULL_ARG_CHECK(pitch);
3032 if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) {
3033 LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
3034 return PLAYER_ERROR_INVALID_STATE;
3037 ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_PITCH_VALUE, &value, (char *)NULL);
3038 if (ret != MM_ERROR_NONE)
3039 return __player_convert_error_code(ret, (char *)__FUNCTION__);
3041 *pitch = (float)value;
3042 LOGD("get pitch value %1.3f", *pitch);
3044 return PLAYER_ERROR_NONE;