Add internal functions for mused 25/44825/1 submit/tizen/20150728.092220
authorHyongtaek Lim <hyongtaek.lim@samsung.com>
Tue, 28 Jul 2015 08:23:13 +0000 (17:23 +0900)
committerHyongtaek Lim <hyongtaek.lim@samsung.com>
Tue, 28 Jul 2015 08:23:59 +0000 (17:23 +0900)
Signed-off-by: Hyongtaek Lim <hyongtaek.lim@samsung.com>
Change-Id: I73d1a7157712bd5d74787e79c70091dccdf48b66

src/player_internal.c [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index bef6e82..9275b04
@@ -22,6 +22,7 @@
 #include <mm.h>
 #include <mm_player.h>
 #include <mm_player_internal.h>
+#include <mm_player_mused.h>
 #include <mm_types.h>
 #include <player.h>
 #include <player_internal.h>
@@ -97,3 +98,299 @@ int player_set_pcm_spec(player_h player, const char *format, int samplerate, int
 
        return PLAYER_ERROR_NONE;
 }
+
+/*
+* Internal Implementation for mused
+*/
+int player_set_shm_stream_path_for_mused (player_h player, const char *stream_path)
+{
+       PLAYER_INSTANCE_CHECK(player);
+       PLAYER_NULL_ARG_CHECK(stream_path);
+
+       player_s * handle = (player_s *) player;
+
+       if(mm_player_set_shm_stream_path(handle->mm_handle, stream_path)
+                       != MM_ERROR_NONE) {
+               LOGE("Fail to set attribute stream path");
+               return PLAYER_ERROR_INVALID_OPERATION;
+       }
+       return PLAYER_ERROR_NONE;
+}
+
+static MMDisplaySurfaceType __player_mused_convet_display_type(player_display_type_e type)
+{
+       switch(type) {
+       case PLAYER_DISPLAY_TYPE_OVERLAY:
+               return MM_DISPLAY_SURFACE_REMOTE;
+       case PLAYER_DISPLAY_TYPE_EVAS:
+               return MM_DISPLAY_SURFACE_EVAS;
+       case PLAYER_DISPLAY_TYPE_NONE:
+               return MM_DISPLAY_SURFACE_NULL;
+       default :
+               return MM_DISPLAY_SURFACE_NULL;
+       }
+}
+
+
+#ifdef HAVE_WAYLAND
+int player_set_display_wl_for_mused(player_h player, player_display_type_e type, unsigned int surface,
+               int x, int y, int w, int h)
+{
+       PLAYER_INSTANCE_CHECK(player);
+       player_s * handle = (player_s *) player;
+       void *set_handle = NULL;
+       MMDisplaySurfaceType mmType = __player_mused_convet_display_type(type);
+
+       int ret;
+       if (!__player_state_validate(handle, PLAYER_STATE_IDLE))
+       {
+               LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state);
+               return PLAYER_ERROR_INVALID_STATE;
+       }
+       if (handle->is_set_pixmap_cb)
+       {
+               if (handle->state < PLAYER_STATE_READY)
+               {
+                       /* just set below and go to "changing surface case" */
+                       handle->is_set_pixmap_cb = false;
+               }
+               else
+               {
+                       LOGE("[%s] pixmap callback was set, try it again after calling player_unprepare()" ,__FUNCTION__,PLAYER_ERROR_INVALID_OPERATION);
+                       LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)" ,__FUNCTION__,PLAYER_ERROR_INVALID_OPERATION);
+                       return PLAYER_ERROR_INVALID_OPERATION;
+               }
+       }
+
+       void* temp = NULL;
+       if (type == PLAYER_DISPLAY_TYPE_NONE)
+       {
+               /* NULL surface */
+               handle->display_handle = 0;
+               handle->display_type = type;
+               set_handle = NULL;
+       }
+       else
+       {
+               /* get handle from overlay or evas surface */
+               temp = handle->display_handle;
+               if (type == PLAYER_DISPLAY_TYPE_OVERLAY)
+               {
+                       LOGI("Wayland overlay surface type");
+                       handle->display_handle = (void *)surface;
+                       set_handle = &(handle->display_handle);
+               } else {
+                       LOGE("invalid surface type");
+                       return PLAYER_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       /* set display handle */
+       if (handle->display_type == PLAYER_DISPLAY_TYPE_NONE || type == handle->display_type) // first time or same type
+       {
+               LOGW("first time or same type");
+               ret = mm_player_set_attribute(handle->mm_handle, NULL,
+                       "display_surface_type", mmType,
+                       "display_overlay", set_handle,
+                       sizeof(void *), (char*)NULL);
+
+               if (ret != MM_ERROR_NONE)
+               {
+                       handle->display_handle = temp;
+                       LOGE("[%s] Failed to display surface change :%d",__FUNCTION__,ret);
+               }
+               else
+               {
+                       if (type != PLAYER_DISPLAY_TYPE_NONE)
+                       {
+                               handle->display_type = type;
+                               LOGI("[%s] video display has been changed- type :%d, addr : 0x%x",
+                                       __FUNCTION__,handle->display_type, handle->display_handle);
+                       }
+                       else
+                               LOGI("NULL surface");
+               }
+               LOGI("get window rectangle: x(%d) y(%d) width(%d) height(%d)", x, y, w, h);
+               ret = mm_player_set_attribute(handle->mm_handle, NULL,
+                       "wl_window_render_x", x,
+                       "wl_window_render_y", y,
+                       "wl_window_render_width", w,
+                       "wl_window_render_height", h,
+                       (char*)NULL);
+
+               if (ret != MM_ERROR_NONE)
+               {
+                       handle->display_handle = temp;
+                       LOGE("[%s] Failed to set wl_window render rectangle :%d",__FUNCTION__,ret);
+               }
+       }
+       else //changing surface case
+       {
+               ret = mm_player_change_videosink(handle->mm_handle, mmType, set_handle);
+               if (ret != MM_ERROR_NONE)
+               {
+                       handle->display_handle = temp;
+                       if(ret == MM_ERROR_NOT_SUPPORT_API)
+                       {
+                               LOGE("[%s] change video sink is not available.",__FUNCTION__);
+                               ret = PLAYER_ERROR_NONE;
+                       }
+                       else
+                       {
+                               LOGE("[%s] Failed to display surface change :%d",__FUNCTION__,ret);
+                       }
+               }
+               else
+               {
+                       handle->display_type = type;
+                       LOGI("[%s] video display has been changed- type :%d, addr : 0x%x",
+                               __FUNCTION__,handle->display_type, handle->display_handle);
+               }
+       }
+
+       if(ret != MM_ERROR_NONE)
+       {
+               handle->display_type = PLAYER_DISPLAY_TYPE_NONE;
+               return __player_convert_error_code(ret,(char*)__FUNCTION__);
+       }
+       else
+       {
+               return PLAYER_ERROR_NONE;
+       }
+}
+
+#else
+
+int player_set_display_for_mused(player_h player, player_display_type_e type, unsigned int xhandle)
+{
+       PLAYER_INSTANCE_CHECK(player);
+       player_s * handle = (player_s *) player;
+       void *set_handle = NULL;
+       MMDisplaySurfaceType mmType = __player_mused_convet_display_type(type);
+
+       int ret;
+       if (!__player_state_validate(handle, PLAYER_STATE_IDLE))
+       {
+               LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state);
+               return PLAYER_ERROR_INVALID_STATE;
+       }
+
+       if (handle->is_set_pixmap_cb)
+       {
+               if (handle->state < PLAYER_STATE_READY)
+               {
+                       /* just set below and go to "changing surface case" */
+                       handle->is_set_pixmap_cb = false;
+               }
+               else
+               {
+                       LOGE("[%s] pixmap callback was set, try it again after calling player_unprepare()" ,__FUNCTION__,PLAYER_ERROR_INVALID_OPERATION);
+                       LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)" ,__FUNCTION__,PLAYER_ERROR_INVALID_OPERATION);
+                       return PLAYER_ERROR_INVALID_OPERATION;
+               }
+       }
+
+       void* temp = NULL;
+       if (type == PLAYER_DISPLAY_TYPE_NONE)
+       {
+               /* NULL surface */
+               handle->display_handle = 0;
+               handle->display_type = PLAYER_DISPLAY_TYPE_NONE;
+               set_handle = NULL;
+       }
+       else
+       {
+               /* get handle from overlay or evas surface */
+               temp = handle->display_handle;
+               if (type == PLAYER_DISPLAY_TYPE_OVERLAY /*&& !strcmp(object_type, "elm_win")*/)
+               {
+                       /* x window overlay surface */
+                       LOGI("overlay surface type");
+                       handle->display_handle = (void *)xhandle;
+                       set_handle = &(handle->display_handle);
+               }
+               else
+               {
+                       LOGE("invalid surface type");
+                       return PLAYER_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       /* set display handle */
+       if (handle->display_type == PLAYER_DISPLAY_TYPE_NONE || type == handle->display_type) // first time or same type
+       {
+               ret = mm_player_set_attribute(handle->mm_handle, NULL,
+                       "display_surface_type", mmType,
+                       "display_overlay", set_handle,
+                       sizeof(xhandle), (char*)NULL);
+
+               if (ret != MM_ERROR_NONE)
+               {
+                       handle->display_handle = temp;
+                       LOGE("[%s] Failed to display surface change :%d",__FUNCTION__,ret);
+               }
+               else
+               {
+                       if (type != PLAYER_DISPLAY_TYPE_NONE)
+                       {
+                               handle->display_type = type;
+                               LOGI("[%s] video display has been changed- type :%d, addr : 0x%x",
+                                       __FUNCTION__,handle->display_type, handle->display_handle);
+                       }
+                       else
+                               LOGI("NULL surface");
+               }
+       }
+       else //changing surface case
+       {
+               ret = mm_player_change_videosink(handle->mm_handle, mmType, set_handle);
+               if (ret != MM_ERROR_NONE)
+               {
+                       handle->display_handle = temp;
+                       if(ret == MM_ERROR_NOT_SUPPORT_API)
+                       {
+                               LOGE("[%s] change video sink is not available.",__FUNCTION__);
+                               ret = PLAYER_ERROR_NONE;
+                       }
+                       else
+                       {
+                               LOGE("[%s] Failed to display surface change :%d",__FUNCTION__,ret);
+                       }
+               }
+               else
+               {
+                       handle->display_type = type;
+                       LOGI("[%s] video display has been changed- type :%d, addr : 0x%x",
+                               __FUNCTION__,handle->display_type, handle->display_handle);
+               }
+       }
+
+       if(ret != MM_ERROR_NONE)
+       {
+               handle->display_type = PLAYER_DISPLAY_TYPE_NONE;
+               return __player_convert_error_code(ret,(char*)__FUNCTION__);
+       }
+       else
+       {
+               return PLAYER_ERROR_NONE;
+       }
+}
+#endif
+
+int player_get_raw_video_caps(player_h player, char **caps)
+{
+       int ret;
+       PLAYER_INSTANCE_CHECK(player);
+       PLAYER_NULL_ARG_CHECK(caps);
+       player_s * handle = (player_s *) player;
+
+       if (handle->display_type == PLAYER_DISPLAY_TYPE_NONE)
+               return PLAYER_ERROR_INVALID_STATE;
+
+       ret = mm_player_get_raw_video_caps(handle->mm_handle, caps);
+       if(ret != MM_ERROR_NONE) {
+               return __player_convert_error_code(ret,(char*)__FUNCTION__);
+       }
+
+       return PLAYER_ERROR_NONE;
+}