From: NAMJEONGYOON Date: Fri, 8 Apr 2016 05:35:57 +0000 (+0900) Subject: apply mm-evas-renderer X-Git-Tag: submit/tizen/20160412.064533^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a3a7132543a8e9b25253e42c294e44e98d532b48;p=platform%2Fcore%2Fapi%2Fplayer.git apply mm-evas-renderer Change-Id: I77d3e282b1b98a418539841a08645e32872595f7 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 284f5ad..596a24b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ SET(INC_COM_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}, ${INC_COM_DIR}) -SET(dependents "dlog glib-2.0 libtbm capi-media-tool capi-media-sound-manager capi-base-common mused mm-common tizen-extension-client evas ecore elementary") +SET(dependents "dlog glib-2.0 libtbm capi-media-tool capi-media-sound-manager capi-base-common mused mm-common tizen-extension-client evas ecore elementary mm-evas-renderer") SET(pc_dependents "libtbm capi-media-tool capi-base-common capi-media-sound-manager") INCLUDE(FindPkgConfig) diff --git a/include/player_evas.h b/include/player_evas.h deleted file mode 100644 index 98ba911..0000000 --- a/include/player_evas.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * libmm-player - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: JongHyuk Choi - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef __TIZEN_MEDIA_PLAYER_EVASCLIENT_H__ -#define __TIZEN_MEDIA_PLAYER_EVASCLIENT_H__ - -/*=========================================================================================== -| | -| INCLUDE FILES | -| | -========================================================================================== */ -#include - -#include -#include - -#include -#include -#include - -#include "mm_types.h" -#include "mm_debug.h" - -#include -#include - -#define MAX_PACKET_NUM 20 - -/*=========================================================================================== -| | -| GLOBAL DEFINITIONS AND DECLARATIONS FOR MODULE | -| | -========================================================================================== */ - -/*--------------------------------------------------------------------------- -| GLOBAL #defines: | ----------------------------------------------------------------------------*/ - -#ifdef __cplusplus - extern "C" { -#endif - typedef enum - { - UPDATE_VISIBILITY, - UPDATE_TBM_SURF - } update_info; - - typedef enum - { - VISIBLE_NONE, /* if user dont set visibility, it will be changed to true */ - VISIBLE_TRUE, - VISIBLE_FALSE - } visible_info; - - typedef struct { - gint x; - gint y; - gint w; - gint h; - } rect_info; - - /* evas info for evas surface type */ - typedef struct - { - Evas_Object *eo; - Ecore_Pipe *epipe; - - /* video width & height */ - gint w; - gint h; - - visible_info visible; - - /* geometry information */ - rect_info eo_size; - gboolean use_ratio; - guint rotate_angle; - guint display_geometry_method; - guint flip; - - tbm_surface_h tbm_surf; - - /* media packet */ - media_packet_h prev_mp; - media_packet_h cur_mp; - media_packet_h pkt[MAX_PACKET_NUM]; - gint prev_idx; - gint cur_idx; - - /* count undestroyed media packet */ - guint sent_buffer_cnt; - - /* lock */ - GMutex free_lock; - } mm_evas_info; - -int player_set_evas_info(MMHandleType *player, Evas_Object *eo); -int player_unset_evas_info(MMHandleType player); -int player_set_visible_evas_info (MMHandleType player, bool visible); -int player_get_visible_evas_info (MMHandleType player, bool *visible); -int player_set_rotation_evas_info (MMHandleType player, int rotate); -int player_get_rotation_evas_info (MMHandleType player, int *rotate); -int player_set_geometry_evas_info (MMHandleType player, int mode); -int player_get_geometry_evas_info (MMHandleType player, int *mode); -int player_update_video_param(MMHandleType player); -void decoded_callback_for_evas (media_packet_h packet, void *data); -#ifdef __cplusplus - } -#endif - -#endif /* __TIZEN_MEDIA_PLAYER_EVASCLIENT_H__ */ - diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index c2bb29a..c2d7931 100644 --- a/packaging/capi-media-player.spec +++ b/packaging/capi-media-player.spec @@ -32,6 +32,7 @@ BuildRequires: pkgconfig(mmsvc-player) BuildRequires: pkgconfig(json-c) BuildRequires: pkgconfig(libtbm) BuildRequires: pkgconfig(eom) +BuildRequires: pkgconfig(mm-evas-renderer) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig diff --git a/src/player.c b/src/player.c index 21a655a..03f741e 100644 --- a/src/player.c +++ b/src/player.c @@ -40,7 +40,7 @@ #include #include "player_internal.h" #include "player_private.h" -#include "player_evas.h" +#include typedef struct { int int_data; @@ -1242,7 +1242,7 @@ int player_unprepare(player_h player) _player_deinit_memory_buffer(pc); } - if (player_unset_evas_info(INT_HANDLE(pc)) != MM_ERROR_NONE) + if (mm_evas_renderer_destroy(&INT_HANDLE(pc)) != MM_ERROR_NONE) LOGW("fail to unset evas client"); g_free(ret_buf); @@ -1504,7 +1504,7 @@ int player_start(player_h player) LOGD("ENTER"); if (INT_HANDLE(pc)) { - ret = player_update_video_param(INT_HANDLE(pc)); + ret = mm_evas_renderer_update_param(INT_HANDLE(pc)); if (ret != PLAYER_ERROR_NONE) return ret; } @@ -1782,13 +1782,13 @@ int player_set_display(player_h player, player_display_type_e type, player_displ if (INT_HANDLE(pc)) { LOGW("evas client already exists"); - if (player_unset_evas_info(INT_HANDLE(pc)) != MM_ERROR_NONE) + if (mm_evas_renderer_destroy(&INT_HANDLE(pc)) != MM_ERROR_NONE) LOGW("fail to unset evas client"); } - if (player_set_evas_info(&INT_HANDLE(pc), obj) != MM_ERROR_NONE) { + if(mm_evas_renderer_create(&INT_HANDLE(pc), obj) != MM_ERROR_NONE) { LOGW("fail to set evas client"); } - if (player_set_media_packet_video_frame_decoded_cb(player, decoded_callback_for_evas, (void *)INT_HANDLE(pc)) != PLAYER_ERROR_NONE) { + if (player_set_media_packet_video_frame_decoded_cb(player, mm_evas_renderer_write, (void *)INT_HANDLE(pc)) != PLAYER_ERROR_NONE) { LOGW("fail to set decoded callback"); } } @@ -1826,7 +1826,7 @@ int player_set_display_mode(player_h player, player_display_mode_e mode) LOGD("ENTER"); - ret = player_set_geometry_evas_info(INT_HANDLE(pc), mode); + ret = mm_evas_renderer_set_geometry(INT_HANDLE(pc), mode); /* FIXME : devide server and client and consider which error code will be returned */ if (ret == PLAYER_ERROR_NONE) { return ret; @@ -1849,7 +1849,7 @@ int player_get_display_mode(player_h player, player_display_mode_e * pmode) LOGD("ENTER"); - ret = player_get_geometry_evas_info(INT_HANDLE(pc), &mode); + ret = mm_evas_renderer_get_geometry(INT_HANDLE(pc), &mode); if (ret == PLAYER_ERROR_NONE && mode != -1) { *pmode = (player_display_mode_e) mode; return ret; @@ -1891,7 +1891,7 @@ int player_set_display_rotation(player_h player, player_display_rotation_e rotat LOGD("ENTER"); - ret = player_set_rotation_evas_info(INT_HANDLE(pc), rotation); + ret = mm_evas_renderer_set_rotation(INT_HANDLE(pc), rotation); if (ret == PLAYER_ERROR_NONE) { return ret; } @@ -1913,7 +1913,7 @@ int player_get_display_rotation(player_h player, player_display_rotation_e * pro LOGD("ENTER"); - ret = player_get_rotation_evas_info(INT_HANDLE(pc), &rotation); + ret = mm_evas_renderer_get_rotation(INT_HANDLE(pc), &rotation); if (ret == PLAYER_ERROR_NONE && rotation != -1) { *protation = (player_display_rotation_e) rotation; return ret; @@ -1939,7 +1939,7 @@ int player_set_display_visible(player_h player, bool visible) LOGD("ENTER"); - ret = player_set_visible_evas_info(INT_HANDLE(pc), visible); + ret = mm_evas_renderer_set_visible(INT_HANDLE(pc), visible); if (ret == PLAYER_ERROR_NONE) { return ret; } @@ -1962,7 +1962,7 @@ int player_is_display_visible(player_h player, bool * pvisible) LOGD("ENTER"); - ret = player_get_visible_evas_info(INT_HANDLE(pc), &visible); + ret = mm_evas_renderer_get_visible(INT_HANDLE(pc), &visible); if (ret == PLAYER_ERROR_NONE) { if (visible) *pvisible = TRUE; diff --git a/src/player_evas.c b/src/player_evas.c deleted file mode 100644 index 1cc6a9a..0000000 --- a/src/player_evas.c +++ /dev/null @@ -1,881 +0,0 @@ -/* -* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "player_evas.h" - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "TIZEN_N_PLAYER_EVAS" - -#define MMPLAYER_CHECK_NULL( x_var ) \ -if ( ! x_var ) \ -{ \ - LOGE("[%s] is NULL\n", #x_var ); \ - return MM_ERROR_COMMON_INVALID_ARGUMENT; \ -} - -#define SET_EVAS_OBJECT_EVENT_CALLBACK( x_evas_image_object, x_usr_data ) \ - do \ - { \ - if (x_evas_image_object) { \ - LOGD("object callback add"); \ - evas_object_event_callback_add (x_evas_image_object, EVAS_CALLBACK_DEL, _evas_del_cb, x_usr_data); \ - evas_object_event_callback_add (x_evas_image_object, EVAS_CALLBACK_RESIZE, _evas_resize_cb, x_usr_data); \ - } \ - } while(0) - -#define UNSET_EVAS_OBJECT_EVENT_CALLBACK( x_evas_image_object ) \ - do \ - { \ - if (x_evas_image_object) { \ - LOGD("object callback del"); \ - evas_object_event_callback_del (x_evas_image_object, EVAS_CALLBACK_DEL, _evas_del_cb); \ - evas_object_event_callback_del (x_evas_image_object, EVAS_CALLBACK_RESIZE, _evas_resize_cb); \ - } \ - } while(0) - -#define SET_EVAS_EVENT_CALLBACK( x_evas, x_usr_data ) \ - do \ - { \ - if (x_evas) { \ - LOGD("callback add... evas_callback_render_pre.. evas : %p evas_info : %p", x_evas, x_usr_data); \ - evas_event_callback_add (x_evas, EVAS_CALLBACK_RENDER_PRE, _evas_render_pre_cb, x_usr_data); \ - } \ - } while(0) - -#define UNSET_EVAS_EVENT_CALLBACK( x_evas ) \ - do \ - { \ - if (x_evas) { \ - LOGD("callback del... evas_callback_render_pre"); \ - evas_event_callback_del (x_evas, EVAS_CALLBACK_RENDER_PRE, _evas_render_pre_cb); \ - } \ - } while(0) - -enum -{ - DISP_GEO_METHOD_LETTER_BOX = 0, - DISP_GEO_METHOD_ORIGIN_SIZE, - DISP_GEO_METHOD_FULL_SCREEN, - DISP_GEO_METHOD_CROPPED_FULL_SCREEN, - DISP_GEO_METHOD_ORIGIN_SIZE_OR_LETTER_BOX, - DISP_GEO_METHOD_NUM, -}; - -enum -{ - DEGREE_0 = 0, - DEGREE_90, - DEGREE_180, - DEGREE_270, - DEGREE_NUM, -}; - -enum -{ - FLIP_NONE = 0, - FLIP_HORIZONTAL, - FLIP_VERTICAL, - FLIP_BOTH, - FLIP_NUM, -}; -int _player_create_evas_info (mm_evas_info ** evas_info); -int _player_destroy_evas_info (mm_evas_info * evas_info); -int _player_set_evas_info (mm_evas_info * evas_info, Evas_Object *eo); -int _player_reset_evas_info (mm_evas_info * evas_info); -void _player_update_geometry_evas_info (mm_evas_info *evas_info, rect_info *result); -int _player_apply_geometry_evas_info (mm_evas_info *evas_info); -static void _set_evas_callback (mm_evas_info * evas_info); -static void _unset_evas_callback (mm_evas_info * evas_info); - -static void -_evas_resize_cb (void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - int x, y, w, h, ret; - x = y = w = h = 0; - - mm_evas_info *evas_info = data; - LOGD ("[ENTER]"); - - if (!evas_info || !evas_info->eo) { - return; - } - - evas_object_geometry_get(evas_info->eo, &x, &y, &w, &h); - if (!w || !h) { - LOGW ("evas object size (w:%d,h:%d) was not set", w, h); - } else { - evas_info->eo_size.x = x; - evas_info->eo_size.y = y; - evas_info->eo_size.w = w; - evas_info->eo_size.h = h; - LOGW ("resize (x:%d, y:%d, w:%d, h:%d)", x, y, w, h) - ; - ret = _player_apply_geometry_evas_info(evas_info); - if(ret != MM_ERROR_NONE) - LOGW("fail to apply geometry info"); - } - LOGD ("[LEAVE]"); -} - -static void -_evas_render_pre_cb (void *data, Evas *e, void *event_info) -{ - mm_evas_info *evas_info = data; - if (!evas_info || !evas_info->eo) { - LOGW("there is no esink info.... esink : %p, or eo is NULL returning", evas_info); - return; - } - //LOGI("- test -"); //@@@@@ pre_cb will be deleted. actually it is useless -} - -static void -_evas_del_cb (void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - mm_evas_info *evas_info = data; - LOGD ("[ENTER]"); - if (!evas_info || !evas_info->eo) { - return; - } - if (evas_info->eo) { - _unset_evas_callback(evas_info); - evas_object_image_data_set(evas_info->eo, NULL); - evas_info->eo = NULL; - } - LOGD ("[LEAVE]"); -} - -void -evas_pipe_cb (void *data, void *buffer, update_info info) -{ - mm_evas_info *evas_info = data; - int ret; - LOGD ("[ENTER]"); - - if (!evas_info) { - LOGW ("evas_info is NULL", evas_info); - return; - } - - g_mutex_lock (&evas_info->free_lock); - - if (!evas_info->eo) { - LOGW ("evas_info %p", evas_info); - goto ERROR; - } - - LOGD("evas_info : %p, evas_info->eo : %p", evas_info, evas_info->eo); - if (info == UPDATE_VISIBILITY) { - if(evas_info->visible == VISIBLE_FALSE) { - evas_object_hide(evas_info->eo); - LOGI ("object hide.."); - } else { - evas_object_show(evas_info->eo); - LOGI ("object show.. %d", evas_info->visible); - } - LOGD ("[LEAVE]"); - g_mutex_unlock (&evas_info->free_lock); - return; - } - - if (info!=UPDATE_TBM_SURF) { - LOGW ("invalid info type : %d", info); - goto ERROR; - } - - /* normally get tbm surf in pipe callback. if not, we can get changed tbm surf by other threads */ - ret = media_packet_get_tbm_surface(evas_info->pkt[evas_info->cur_idx], &evas_info->tbm_surf); - if(ret != MEDIA_PACKET_ERROR_NONE || !evas_info->tbm_surf) { - LOGW("get_tbm_surface is failed"); - goto ERROR; - } - /* it is needed to skip setting when state is pause */ - LOGD("received (tbm_surf %p)", evas_info->tbm_surf); - - Evas_Native_Surface surf; - surf.type = EVAS_NATIVE_SURFACE_TBM; - surf.version = EVAS_NATIVE_SURFACE_VERSION; - surf.data.tbm.buffer = evas_info->tbm_surf; -// surf.data.tbm.rot = evas_info->rotate_angle; -// surf.data.tbm.flip = evas_info->flip; - - rect_info result = {0}; - - evas_object_geometry_get(evas_info->eo, &evas_info->eo_size.x, &evas_info->eo_size.y, &evas_info->eo_size.w, &evas_info->eo_size.h); - if (!evas_info->eo_size.w || !evas_info->eo_size.h) { - LOGE ("there is no information for evas object size"); - goto ERROR; - } - _player_update_geometry_evas_info(evas_info, &result); - if(!result.w || !result.h) - { - LOGE("no information about geometry (%d, %d)", result.w, result.h); - goto ERROR; - } - - if(evas_info->use_ratio) - { -// surf.data.tbm.ratio = (float) evas_info->w / evas_info->h; - LOGD("set ratio for letter mode"); - } - evas_object_size_hint_align_set(evas_info->eo, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(evas_info->eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - if (evas_info->w > 0 && evas_info->h > 0) - evas_object_image_size_set(evas_info->eo, evas_info->w, evas_info->h); - - evas_object_image_native_surface_set(evas_info->eo, &surf); - LOGD("native surface set finish"); - - if(result.x || result.y) - LOGD("coordinate x, y (%d, %d) for locating video to center", result.x, result.y); - evas_object_image_fill_set(evas_info->eo, result.x, result.y, result.w, result.h); - - evas_object_image_pixels_dirty_set(evas_info->eo, EINA_TRUE); - LOGD ("GEO_METHOD : src(%dx%d), dst(%dx%d), dst_x(%d), dst_y(%d), rotate(%d), flip(%d)", - evas_info->w, evas_info->h, evas_info->eo_size.w, evas_info->eo_size.h, evas_info->eo_size.x, evas_info->eo_size.y, evas_info->rotate_angle, evas_info->flip); - - /* when evas_pipe_cb is called sequentially, previous packet and current packet will be the same */ - if((evas_info->prev_idx!=-1) && evas_info->pkt[evas_info->prev_idx] && (evas_info->prev_idx!=evas_info->cur_idx)) { - LOGD("destroy previous packet [%p] idx %d", evas_info->pkt[evas_info->prev_idx], evas_info->prev_idx); - if(media_packet_destroy(evas_info->pkt[evas_info->prev_idx]) != MEDIA_PACKET_ERROR_NONE) - LOGE("media_packet_destroy failed %p", evas_info->pkt[evas_info->prev_idx]); - evas_info->pkt[evas_info->prev_idx] = NULL; - evas_info->sent_buffer_cnt--; - LOGD("sent packet %d", evas_info->sent_buffer_cnt); - } - evas_info->prev_idx = evas_info->cur_idx; - - LOGD ("[LEAVE]"); - g_mutex_unlock (&evas_info->free_lock); - - return; - -ERROR: - if((evas_info->prev_idx!=-1) && evas_info->pkt[evas_info->prev_idx]) { - LOGD("cant render. destroy previous packet [%p] idx %d", evas_info->pkt[evas_info->prev_idx], evas_info->prev_idx); - if(media_packet_destroy(evas_info->pkt[evas_info->prev_idx]) != MEDIA_PACKET_ERROR_NONE) - LOGE("media_packet_destroy failed %p", evas_info->pkt[evas_info->prev_idx]); - evas_info->pkt[evas_info->prev_idx] = NULL; - evas_info->sent_buffer_cnt--; - } - evas_info->prev_idx = evas_info->cur_idx; - g_mutex_unlock (&evas_info->free_lock); -} - -static void -_set_evas_callback (mm_evas_info * evas_info) -{ - if(evas_info->eo) - { - SET_EVAS_OBJECT_EVENT_CALLBACK (evas_info->eo, evas_info); - SET_EVAS_EVENT_CALLBACK (evas_object_evas_get(evas_info->eo), evas_info); - } -} - -static void -_unset_evas_callback (mm_evas_info * evas_info) -{ - if(evas_info->eo) - { - UNSET_EVAS_OBJECT_EVENT_CALLBACK (evas_info->eo); - UNSET_EVAS_EVENT_CALLBACK (evas_object_evas_get(evas_info->eo)); - } -} - -static int -_get_video_size(media_packet_h packet, mm_evas_info * evas_info) -{ - media_format_h fmt; - if (media_packet_get_format(packet, &fmt) == MEDIA_PACKET_ERROR_NONE) { - int w, h; - if (media_format_get_video_info(fmt, NULL, &w, &h, NULL, NULL) == MEDIA_PACKET_ERROR_NONE) { - LOGD("video width = %d, height =%d", w, h); - evas_info->w = w; - evas_info->h = h; - return true; - } - else - LOGW("media_format_get_video_info is failed."); - } else { - LOGW("media_packet_get_format is failed."); - } - return false; -} - -int _find_empty_index (mm_evas_info * evas_info) -{ - int i; - for(i=0; ipkt[i]) - { - LOGD("selected idx %d", i); - return i; - } - } - LOGE("there is no empty idx"); - - return -1; -} - -void _reset_pipe (mm_evas_info * evas_info) -{ - int i = 0; - int ret = MEDIA_PACKET_ERROR_NONE; - - /* delete old pipe */ - if (evas_info->epipe) { - LOGD("pipe %p will be deleted", evas_info->epipe); - ecore_pipe_del (evas_info->epipe); - evas_info->epipe = NULL; - } - - /* destroy all packets */ - for(i=0; ipkt[i]) - { - LOGD("destroy packet [%p]", evas_info->pkt[i]); - ret = media_packet_destroy(evas_info->pkt[i]); - if (ret != MEDIA_PACKET_ERROR_NONE) - LOGW("media_packet_destroy failed %p", evas_info->pkt[i]); - else - evas_info->sent_buffer_cnt--; - evas_info->pkt[i] = NULL; - } - } - - /* make new pipe */ - if (!evas_info->epipe) { - evas_info->epipe = ecore_pipe_add ((Ecore_Pipe_Cb)evas_pipe_cb, evas_info); - if (!evas_info->epipe) { - LOGE("pipe is not created"); - } - LOGD("created pipe %p", evas_info->epipe); - } - - return; -} - -void decoded_callback_for_evas (media_packet_h packet, void *data) -{ - if (!packet) { - LOGE ("packet %p is NULL", packet); - return; - } - mm_evas_info* handle = (mm_evas_info*) data; - int ret = MEDIA_PACKET_ERROR_NONE; - bool has; - - LOGD("packet [%p]", packet); - - if (!data || !handle) { - LOGE("handle %p or evas_info %p is NULL", data, handle); - goto ERROR; - } - - ret = media_packet_has_tbm_surface_buffer(packet, &has); - if(ret != MEDIA_PACKET_ERROR_NONE) { - LOGW("has_tbm_surface is failed"); - goto ERROR; - } - /* FIXME: when setCaps occurs, _get_video_size should be called */ - /* currently we are always checking it */ - if(has && _get_video_size(packet, handle)) { - /* Attention! if this error occurs, we need to consider managing buffer */ - if(handle->sent_buffer_cnt>14) { - LOGE("too many buffers are not released %d", handle->sent_buffer_cnt); - goto ERROR; -#if 0 - /* FIXME: fix this logic */ - /* destroy all media packets and reset pipe at present */ - g_mutex_lock (&handle->free_lock); - _reset_pipe(handle); - g_mutex_unlock (&handle->free_lock); -#endif - } - handle->cur_idx = _find_empty_index(handle); - if(handle->cur_idx == -1) - goto ERROR; - handle->pkt[handle->cur_idx] = packet; - handle->sent_buffer_cnt++; - LOGD("sent packet %d", handle->sent_buffer_cnt); - ret = ecore_pipe_write(handle->epipe, handle, UPDATE_TBM_SURF); - if (!ret) { - handle->pkt[handle->cur_idx] = NULL; - handle->cur_idx = handle->prev_idx; - handle->sent_buffer_cnt--; - LOGW ("Failed to ecore_pipe_write() for updating tbm surf\n"); - goto ERROR; - } - } else { - LOGW ("no tbm_surf"); - goto ERROR; - } - - return; - -ERROR: - /* destroy media_packet immediately */ - if(packet) { - g_mutex_lock (&handle->free_lock); - LOGD("cant write. destroy packet [%p]", packet); - if(media_packet_destroy(packet) != MEDIA_PACKET_ERROR_NONE) - LOGE("media_packet_destroy failed %p", packet); - packet = NULL; - g_mutex_unlock (&handle->free_lock); - } - return; -} - -int -_player_create_evas_info (mm_evas_info ** evas_info) -{ - mm_evas_info *ptr = NULL; - ptr = g_malloc0 (sizeof (mm_evas_info)); - - if (!ptr) { - LOGE ("Cannot allocate memory for evas_info\n"); - goto ERROR; - } else { - *evas_info = ptr; - LOGD ("Success create evas_info(%p)", *evas_info); - } - - return MM_ERROR_NONE; - -ERROR: - *evas_info = NULL; - return MM_ERROR_PLAYER_NO_FREE_SPACE; -} - -int -_player_destroy_evas_info (mm_evas_info * evas_info) -{ - MMPLAYER_CHECK_NULL(evas_info); - - LOGD ("finalize evas_info"); - - _player_reset_evas_info(evas_info); - - g_free(evas_info); - evas_info = NULL; - - return MM_ERROR_NONE; -} - -int -_player_set_evas_info (mm_evas_info * evas_info, Evas_Object *eo) -{ - MMPLAYER_CHECK_NULL(evas_info); - MMPLAYER_CHECK_NULL(eo); - - LOGD ("set evas_info"); - - evas_info->prev_idx = evas_info->cur_idx = -1; - evas_info->eo = eo; - evas_info->epipe = ecore_pipe_add ((Ecore_Pipe_Cb)evas_pipe_cb, evas_info); - if (!evas_info->epipe) { - LOGE("pipe is not created"); - return MM_ERROR_PLAYER_NO_OP; - } - LOGD("created pipe %p", evas_info->epipe); - g_mutex_init (&evas_info->free_lock); - _set_evas_callback(evas_info); - - evas_object_geometry_get(evas_info->eo, &evas_info->eo_size.x, &evas_info->eo_size.y, - &evas_info->eo_size.w, &evas_info->eo_size.h); - LOGI("evas object %p (%d ,%d ,%d ,%d)", evas_info->eo, evas_info->eo_size.x, evas_info->eo_size.y, - evas_info->eo_size.w, evas_info->eo_size.h); - - return MM_ERROR_NONE; -} - -int -_player_reset_evas_info (mm_evas_info * evas_info) -{ - MMPLAYER_CHECK_NULL(evas_info); - - int i; - int ret = MEDIA_PACKET_ERROR_NONE; - - if (evas_info->eo) { - _unset_evas_callback(evas_info); - evas_object_image_data_set(evas_info->eo, NULL); - evas_info->eo = NULL; - } - if (evas_info->epipe) { - LOGD("pipe %p will be deleted", evas_info->epipe); - ecore_pipe_del (evas_info->epipe); - evas_info->epipe = NULL; - } - - evas_info->eo_size.x = evas_info->eo_size.y = - evas_info->eo_size.w = evas_info->eo_size.h = 0; - evas_info->w = evas_info->h = 0; - evas_info->tbm_surf = NULL; - - g_mutex_lock (&evas_info->free_lock); - for(i=0; ipkt[i]) - { - /* destroy all packets */ - LOGD("destroy packet [%p]", evas_info->pkt[i]); - ret = media_packet_destroy(evas_info->pkt[i]); - if (ret != MEDIA_PACKET_ERROR_NONE) - LOGW("media_packet_destroy failed %p", evas_info->pkt[i]); - else - evas_info->sent_buffer_cnt--; - evas_info->pkt[i] = NULL; - } - } - g_mutex_unlock (&evas_info->free_lock); - - LOGW("it should be 0 --> [%d]", evas_info->sent_buffer_cnt); - evas_info->sent_buffer_cnt = 0; - evas_info->prev_idx = evas_info->cur_idx = -1; - g_mutex_clear (&evas_info->free_lock); - - return MM_ERROR_NONE; -} - -void -_player_update_geometry_evas_info (mm_evas_info *evas_info, rect_info *result) -{ - if (!evas_info || !evas_info->eo) { - LOGW("there is no evas_info or evas object"); - return; - } - - result->x = 0; - result->y = 0; - - switch (evas_info->display_geometry_method) - { - case DISP_GEO_METHOD_LETTER_BOX: - /* set black padding for letter box mode */ - LOGD("letter box mode"); - evas_info->use_ratio = TRUE; - result->w = evas_info->eo_size.w; - result->h = evas_info->eo_size.h; - break; - case DISP_GEO_METHOD_ORIGIN_SIZE: - LOGD("origin size mode"); - evas_info->use_ratio = FALSE; - /* set coordinate for each case */ - result->x = (evas_info->eo_size.w-evas_info->w) / 2; - result->y = (evas_info->eo_size.h-evas_info->h) / 2; - result->w = evas_info->w; - result->h = evas_info->h; - break; - case DISP_GEO_METHOD_FULL_SCREEN: - LOGD("full screen mode"); - evas_info->use_ratio = FALSE; - result->w = evas_info->eo_size.w; - result->h = evas_info->eo_size.h; - break; - case DISP_GEO_METHOD_CROPPED_FULL_SCREEN: - LOGD("cropped full screen mode"); - evas_info->use_ratio = FALSE; - /* compare evas object's ratio with video's */ - if((evas_info->eo_size.w/evas_info->eo_size.h) > (evas_info->w/evas_info->h)) - { - result->w = evas_info->eo_size.w; - result->h = evas_info->eo_size.w * evas_info->h / evas_info->w; - result->y = -(result->h-evas_info->eo_size.h) / 2; - } - else - { - result->w = evas_info->eo_size.h * evas_info->w / evas_info->h; - result->h = evas_info->eo_size.h; - result->x = -(result->w-evas_info->eo_size.w) / 2; - } - break; - case DISP_GEO_METHOD_ORIGIN_SIZE_OR_LETTER_BOX: - LOGD("origin size or letter box mode"); - /* if video size is smaller than evas object's, it will be set to origin size mode */ - if((evas_info->eo_size.w > evas_info->w) && (evas_info->eo_size.h > evas_info->h)) - { - LOGD("origin size mode"); - evas_info->use_ratio = FALSE; - /* set coordinate for each case */ - result->x = (evas_info->eo_size.w-evas_info->w) / 2; - result->y = (evas_info->eo_size.h-evas_info->h) / 2; - result->w = evas_info->w; - result->h = evas_info->h; - } - else - { - LOGD("letter box mode"); - evas_info->use_ratio = TRUE; - result->w = evas_info->eo_size.w; - result->h = evas_info->eo_size.h; - } - break; - default: - LOGW("unsupported mode."); - break; - } - LOGD("geometry result [%d, %d, %d, %d]", result->x, result->y, result->w, result->h); -} - -int -_player_apply_geometry_evas_info (mm_evas_info *evas_info) -{ - if (!evas_info || !evas_info->eo) { - LOGW("there is no evas_info or evas object"); - return MM_ERROR_NONE; - } - - Evas_Native_Surface *surf = evas_object_image_native_surface_get(evas_info->eo); - rect_info result = {0}; - - if(surf) - { - LOGD("native surface exists"); -// surf->data.tbm.rot = evas_info->rotate_angle; -// surf->data.tbm.flip = evas_info->flip; - evas_object_image_native_surface_set(evas_info->eo, surf); - - _player_update_geometry_evas_info(evas_info, &result); - - if(evas_info->use_ratio) - { -// surf->data.tbm.ratio = (float) evas_info->w / evas_info->h; - LOGD("set ratio for letter mode"); - } - - if(result.x || result.y) - LOGD("coordinate x, y (%d, %d) for locating video to center", result.x, result.y); - - evas_object_image_fill_set(evas_info->eo, result.x, result.y, result.w, result.h); - return MM_ERROR_NONE; - } - else - LOGW("there is no surf"); - /* FIXME: before pipe_cb is invoked, apply_geometry can be called. */ - return MM_ERROR_NONE; -} - -int player_update_video_param(MMHandleType player) -{ - int ret = MM_ERROR_NONE; - mm_evas_info* handle = (mm_evas_info*) player; - - if (!handle) { - LOGW("skip it. it is not evas surface type."); - return ret; - } - - /* when player is realized, we need to update all properties */ - if(handle) - { - LOGD("set video param : evas-object %x, method %d", handle->eo, handle->display_geometry_method); - LOGD("set video param : visible %d", handle->visible); - LOGD("set video param : rotate %d", handle->rotate_angle); - - ret = _player_apply_geometry_evas_info(handle); - if (ret != MM_ERROR_NONE) - return ret; - - if (handle->epipe) { - ret = ecore_pipe_write (handle->epipe, &handle->visible, UPDATE_VISIBILITY); - if (!ret) { - LOGW ("fail to ecore_pipe_write() for updating visibility\n"); - ret = MM_ERROR_PLAYER_NO_OP; - } else { - ret = MM_ERROR_NONE; - } - } - } - - return ret; -} - -int player_set_evas_info (MMHandleType *player, Evas_Object *eo) -{ - int ret = MM_ERROR_NONE; - mm_evas_info* handle = NULL; - - ret = _player_create_evas_info(&handle); - if ( ret != MM_ERROR_NONE ) { - LOGE("fail to create evas_info"); - return ret; - } - ret = _player_set_evas_info(handle, eo); - if ( ret != MM_ERROR_NONE ) { - LOGE("fail to set evas_info"); - if (_player_destroy_evas_info(handle) != MM_ERROR_NONE) - LOGE("fail to destroy evas_info"); - return ret; - } - - *player = (MMHandleType) handle; - - return MM_ERROR_NONE; -} - -int player_unset_evas_info (MMHandleType player) -{ - int ret = MM_ERROR_NONE; - mm_evas_info* handle = (mm_evas_info*) player; - - if (!handle) { - LOGW("skip it. it is not evas surface type."); - return ret; - } - - ret = _player_destroy_evas_info(handle); - if ( ret != MM_ERROR_NONE ) { - LOGE("fail to destroy evas_info"); - return ret; - } - handle = NULL; - - return MM_ERROR_NONE; -} - -int player_get_evas_info (MMHandleType player, mm_evas_info **evas_info) -{ - mm_evas_info* handle = (mm_evas_info*) player; - if(evas_info) { - *evas_info= handle; - LOGD("get evas_info %p", handle); - } - return MM_ERROR_NONE; -} - -int player_set_visible_evas_info (MMHandleType player, bool visible) -{ - int ret = MM_ERROR_NONE; - mm_evas_info* handle = (mm_evas_info*) player; - - if (!handle) { - LOGW("skip it. it is not evas surface type or player is not prepared"); - return MM_ERROR_RESOURCE_NOT_INITIALIZED; - } - - if(visible) - handle->visible = VISIBLE_TRUE; - else - handle->visible = VISIBLE_FALSE; - - if (handle->epipe) { - ret = ecore_pipe_write (handle->epipe, &visible, UPDATE_VISIBILITY); - if (!ret) { - LOGW ("fail to ecore_pipe_write() for updating visibility\n"); - ret = MM_ERROR_PLAYER_NO_OP; - } else { - ret = MM_ERROR_NONE; - } - } else { - LOGW("there is no epipe. we cant update it"); - } - - return ret; -} - -int player_get_visible_evas_info (MMHandleType player, bool *visible) -{ - mm_evas_info* handle = (mm_evas_info*) player; - - if (!handle) { - LOGW("skip it. it is not evas surface type or player is not prepared"); - return MM_ERROR_RESOURCE_NOT_INITIALIZED; - } - - if (handle->visible==VISIBLE_FALSE) - *visible = FALSE; - else - *visible = TRUE; - - return MM_ERROR_NONE; -} - -int player_set_rotation_evas_info (MMHandleType player, int rotate) -{ - int ret = MM_ERROR_NONE; - mm_evas_info* handle = (mm_evas_info*) player; - - if (!handle) { - LOGW("skip it. it is not evas surface type or player is not prepared"); - return MM_ERROR_RESOURCE_NOT_INITIALIZED; - } - - handle->rotate_angle = rotate; - ret = _player_apply_geometry_evas_info(handle); - - return ret; -} - -int player_get_rotation_evas_info (MMHandleType player, int *rotate) -{ - mm_evas_info* handle = (mm_evas_info*) player; - - if (!handle) { - LOGW("skip it. it is not evas surface type or player is not prepared"); - return MM_ERROR_RESOURCE_NOT_INITIALIZED; - } - *rotate = handle->rotate_angle; - - return MM_ERROR_NONE; -} - -int player_set_geometry_evas_info (MMHandleType player, int mode) -{ - int ret = MM_ERROR_NONE; - mm_evas_info* handle = (mm_evas_info*) player; - - if (!handle) { - LOGW("skip it. it is not evas surface type or player is not prepared"); - return MM_ERROR_RESOURCE_NOT_INITIALIZED; - } - - handle->display_geometry_method = mode; - ret = _player_apply_geometry_evas_info(handle); - - return ret; -} - -int player_get_geometry_evas_info (MMHandleType player, int *mode) -{ - mm_evas_info* handle = (mm_evas_info*) player; - - if (!handle) { - LOGW("skip it. it is not evas surface type or player is not prepared"); - return MM_ERROR_RESOURCE_NOT_INITIALIZED; - } - *mode = handle->display_geometry_method; - - return MM_ERROR_NONE; -} -