From: Eunhae Choi Date: Wed, 7 Feb 2018 08:56:31 +0000 (+0900) Subject: [0.6.91] modify 360 related code X-Git-Tag: accepted/tizen/unified/20180209.064046^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=41a32d6398f1bfe8cd21fd537bf3fe24613cbc45;p=platform%2Fcore%2Fmultimedia%2Flibmm-player.git [0.6.91] modify 360 related code - fix the mused crash issue - add more log message Change-Id: I89fc7a6da18e7f1168427f2a52ddb135401fc30c --- diff --git a/src/include/mm_player_priv.h b/src/include/mm_player_priv.h index 73e0154..76c326d 100644 --- a/src/include/mm_player_priv.h +++ b/src/include/mm_player_priv.h @@ -847,12 +847,11 @@ typedef struct { /* Video360 related stuff * */ - bool is_content_spherical; + gboolean is_content_spherical; mm_player_spherical_metadata_t video360_metadata; - bool is_openal_plugin_used; - bool is_video360_plugin_used; + gboolean is_openal_plugin_used; /* User settable values */ - bool is_video360_enabled; + gboolean is_video360_enabled; float video360_yaw_radians; float video360_pitch_radians; float video360_zoom; diff --git a/src/mm_player_360.c b/src/mm_player_360.c index 738ed03..29fddb9 100644 --- a/src/mm_player_360.c +++ b/src/mm_player_360.c @@ -21,162 +21,298 @@ #include #include "mm_player_priv.h" #include "mm_player_360.h" +#include "mm_player_utils.h" #include #include #include -int _mmplayer_360_set_enable(MMHandleType player, bool enable) +static bool +__mmplayer_check_video_360_used(mm_player_t* player) { - ((mm_player_t*) player)->is_video360_enabled = enable; + /* check video 360 plugin is created */ + MMPLAYER_RETURN_VAL_IF_FAIL(player && + player->pipeline && + player->pipeline->videobin && + player->pipeline->videobin[MMPLAYER_V_BIN].gst && + player->pipeline->videobin[MMPLAYER_V_360].gst, + false); - if (((mm_player_t*) player)->is_content_spherical && - ((mm_player_t*) player)->is_video360_plugin_used) { + return true; +} + +static bool +__mmplayer_check_audio_sink(mm_player_t* player) +{ + /* check audio sink is created */ + MMPLAYER_RETURN_VAL_IF_FAIL(player && + player->pipeline && + player->pipeline->videobin && + player->pipeline->videobin[MMPLAYER_A_BIN].gst && + player->pipeline->videobin[MMPLAYER_A_SINK].gst, + false); + + return true; +} + +int _mmplayer_360_set_enable(MMHandleType hplayer, bool enable) +{ + mm_player_t* player = (mm_player_t*) hplayer; + int ret = MM_ERROR_NONE; + + MMPLAYER_FENTER(); + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + LOGD("state %s, spherical info %d", + MMPLAYER_STATE_GET_NAME(MMPLAYER_CURRENT_STATE(player)), player->is_content_spherical); + + player->is_video360_enabled = enable; + + if (player->is_content_spherical && __mmplayer_check_video_360_used(player)) { /* We will get here if player is pending ready or ready and above */ - g_object_set(G_OBJECT(((mm_player_t*) player)->pipeline->videobin[MMPLAYER_V_360].gst), + g_object_set(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_360].gst), "passthrough", !enable, NULL); + return MM_ERROR_NONE; } - return ((mm_player_t*) player)->state < MM_PLAYER_STATE_READY ? MM_ERROR_NONE : MM_ERROR_PLAYER_INTERNAL; + if (player->state >= MM_PLAYER_STATE_READY) { + LOGE("the content is not for 360 playback."); + ret = MM_ERROR_PLAYER_INTERNAL; + } + + MMPLAYER_FLEAVE(); + return ret; } -int _mmplayer_360_is_enabled(MMHandleType player, bool *enabled) +int _mmplayer_360_is_enabled(MMHandleType hplayer, bool *enabled) { - if (((mm_player_t*) player)->state < MM_PLAYER_STATE_READY) { - *enabled = ((mm_player_t*) player)->is_video360_enabled; + mm_player_t* player = (mm_player_t*) hplayer; + + MMPLAYER_FENTER(); + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT); + + LOGD("state %s, spherical info %d", + MMPLAYER_STATE_GET_NAME(MMPLAYER_CURRENT_STATE(player)), player->is_content_spherical); + + if (player->state < MM_PLAYER_STATE_READY) { + *enabled = player->is_video360_enabled; return MM_ERROR_NONE; } - if (((mm_player_t*) player)->is_content_spherical && - ((mm_player_t*) player)->is_video360_plugin_used) { - g_object_get(G_OBJECT(((mm_player_t*) player)->pipeline->videobin[MMPLAYER_V_360].gst), + if (player->is_content_spherical && __mmplayer_check_video_360_used(player)) { + g_object_get(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_360].gst), "passthrough", enabled, NULL); *enabled = !(*enabled); return MM_ERROR_NONE; } + LOGE("the content is not for 360 playback."); + + MMPLAYER_FLEAVE(); return MM_ERROR_PLAYER_INTERNAL; } -int _mmplayer_360_set_direction_of_view(MMHandleType player, float yaw, float pitch) +int _mmplayer_360_set_direction_of_view(MMHandleType hplayer, float yaw, float pitch) { - if (yaw > M_PI || yaw < -M_PI || pitch > M_PI_2 || pitch < -M_PI_2) + mm_player_t* player = (mm_player_t*) hplayer; + int ret = MM_ERROR_NONE; + + MMPLAYER_FENTER(); + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + if (yaw > M_PI || yaw < -M_PI || pitch > M_PI_2 || pitch < -M_PI_2) { + LOGE("invalid argument %f, %f", yaw, pitch); return MM_ERROR_INVALID_ARGUMENT; + } - ((mm_player_t*) player)->video360_yaw_radians = yaw; - ((mm_player_t*) player)->video360_pitch_radians = pitch; + LOGD("state %s, spherical info %d", + MMPLAYER_STATE_GET_NAME(MMPLAYER_CURRENT_STATE(player)), player->is_content_spherical); - if (((mm_player_t*) player)->is_content_spherical) { + player->video360_yaw_radians = yaw; + player->video360_pitch_radians = pitch; + + if (player->is_content_spherical) { /* We will get here if player is pending ready or ready and above */ - if (((mm_player_t*) player)->is_video360_plugin_used) { - g_object_set(G_OBJECT(((mm_player_t*) player)->pipeline->videobin[MMPLAYER_V_360].gst), + if (__mmplayer_check_video_360_used(player)) { + g_object_set(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_360].gst), "pose-yaw", (int) (yaw * 180.0f / M_PI), "pose-pitch", (int) (pitch * 180.0f / M_PI), NULL); } - if (((mm_player_t*) player)->is_openal_plugin_used) { - g_object_set(G_OBJECT(((mm_player_t*) player)->pipeline->audiobin[MMPLAYER_A_SINK].gst), + if (player->is_openal_plugin_used && __mmplayer_check_audio_sink(player)) { + g_object_set(G_OBJECT(player->pipeline->audiobin[MMPLAYER_A_SINK].gst), "source-orientation-y", (int) (yaw * 180.0f / M_PI), "source-orientation-x", (int) (pitch * 180.0f / M_PI), NULL); } return MM_ERROR_NONE; } - return ((mm_player_t*) player)->state < MM_PLAYER_STATE_READY ? MM_ERROR_NONE : MM_ERROR_PLAYER_INTERNAL; + if (player->state >= MM_PLAYER_STATE_READY) { + LOGE("the content is not for 360 playback."); + ret = MM_ERROR_PLAYER_INTERNAL; + } + + MMPLAYER_FLEAVE(); + return ret; } -int _mmplayer_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch) +int _mmplayer_360_get_direction_of_view(MMHandleType hplayer, float *yaw, float *pitch) { - int yaw_degrees, pitch_degrees; + mm_player_t* player = (mm_player_t*) hplayer; + int yaw_degrees = 0; + int pitch_degrees = 0; + + MMPLAYER_FENTER(); + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT); + + LOGD("state %s, spherical info %d", + MMPLAYER_STATE_GET_NAME(MMPLAYER_CURRENT_STATE(player)), player->is_content_spherical); - if (((mm_player_t*) player)->state < MM_PLAYER_STATE_READY) { - *yaw = ((mm_player_t*) player)->video360_yaw_radians; - *pitch = ((mm_player_t*) player)->video360_pitch_radians; + if (player->state < MM_PLAYER_STATE_READY) { + *yaw = player->video360_yaw_radians; + *pitch = player->video360_pitch_radians; return MM_ERROR_NONE; } - if (((mm_player_t*) player)->is_content_spherical && - ((mm_player_t*) player)->is_video360_plugin_used) { - g_object_get(G_OBJECT(((mm_player_t*) player)->pipeline->videobin[MMPLAYER_V_360].gst), + if (player->is_content_spherical && __mmplayer_check_video_360_used(player)) { + g_object_get(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_360].gst), "pose-yaw", &yaw_degrees, "pose-pitch", &pitch_degrees, NULL); *yaw = M_PI * yaw_degrees / 180.0f; *pitch = M_PI * pitch_degrees / 180.0f; return MM_ERROR_NONE; } + LOGE("the content is not for 360 playback."); + + MMPLAYER_FLEAVE(); return MM_ERROR_PLAYER_INTERNAL; } -int _mmplayer_360_set_zoom(MMHandleType player, float level) +int _mmplayer_360_set_zoom(MMHandleType hplayer, float level) { - if (level < 1.0f || level > VIDEO360_MAX_ZOOM) + mm_player_t* player = (mm_player_t*) hplayer; + int ret = MM_ERROR_NONE; + + MMPLAYER_FENTER(); + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + if (level < 1.0f || level > VIDEO360_MAX_ZOOM) { + LOGE("invalid argument %f", level); return MM_ERROR_INVALID_ARGUMENT; + } + + LOGD("state %s, spherical info %d", + MMPLAYER_STATE_GET_NAME(MMPLAYER_CURRENT_STATE(player)), player->is_content_spherical); - ((mm_player_t*) player)->video360_zoom = level; + player->video360_zoom = level; - if (((mm_player_t*) player)->is_content_spherical && - ((mm_player_t*) player)->is_video360_plugin_used) { + if (player->is_content_spherical && __mmplayer_check_video_360_used(player)) { /* We will get here if player is pending ready or ready and above */ - g_object_set(G_OBJECT(((mm_player_t*) player)->pipeline->videobin[MMPLAYER_V_360].gst), + g_object_set(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_360].gst), "zoom", 1.0f / level, NULL); return MM_ERROR_NONE; } - return ((mm_player_t*) player)->state < MM_PLAYER_STATE_READY ? MM_ERROR_NONE : MM_ERROR_PLAYER_INTERNAL; + if (player->state >= MM_PLAYER_STATE_READY) { + LOGE("the content is not for 360 playback."); + ret = MM_ERROR_PLAYER_INTERNAL; + } + + MMPLAYER_FLEAVE(); + return ret; } -int _mmplayer_360_get_zoom(MMHandleType player, float *level) +int _mmplayer_360_get_zoom(MMHandleType hplayer, float *level) { - float current_zoom; + mm_player_t* player = (mm_player_t*) hplayer; + float current_zoom = 0.0; + + MMPLAYER_FENTER(); + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT); + + LOGD("state %s, spherical info %d", + MMPLAYER_STATE_GET_NAME(MMPLAYER_CURRENT_STATE(player)), player->is_content_spherical); - if (((mm_player_t*) player)->state < MM_PLAYER_STATE_READY) { - *level = ((mm_player_t*) player)->video360_zoom; + if (player->state < MM_PLAYER_STATE_READY) { + *level = player->video360_zoom; return MM_ERROR_NONE; } - if (((mm_player_t*) player)->is_content_spherical && - ((mm_player_t*) player)->is_video360_plugin_used) { - g_object_get(G_OBJECT(((mm_player_t*) player)->pipeline->videobin[MMPLAYER_V_360].gst), + if (player->is_content_spherical && __mmplayer_check_video_360_used(player)) { + g_object_get(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_360].gst), "zoom", ¤t_zoom, NULL); *level = 1.0f / current_zoom; return MM_ERROR_NONE; } + LOGE("the content is not for 360 playback."); + + MMPLAYER_FLEAVE(); return MM_ERROR_PLAYER_INTERNAL; } -int _mmplayer_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees) +int _mmplayer_360_set_field_of_view(MMHandleType hplayer, int horizontal_degrees, int vertical_degrees) { - if (horizontal_degrees < 1 || horizontal_degrees > 360 || vertical_degrees < 1 || vertical_degrees > 180) + mm_player_t* player = (mm_player_t*) hplayer; + int ret = MM_ERROR_NONE; + + MMPLAYER_FENTER(); + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + if (horizontal_degrees < 1 || horizontal_degrees > 360 || vertical_degrees < 1 || vertical_degrees > 180) { + LOGE("invalid argument %d, %d", horizontal_degrees, vertical_degrees); return MM_ERROR_INVALID_ARGUMENT; + } + + LOGD("state %s, spherical info %d", + MMPLAYER_STATE_GET_NAME(MMPLAYER_CURRENT_STATE(player)), player->is_content_spherical); - ((mm_player_t*) player)->video360_horizontal_fov = horizontal_degrees; - ((mm_player_t*) player)->video360_vertical_fov = vertical_degrees; + player->video360_horizontal_fov = horizontal_degrees; + player->video360_vertical_fov = vertical_degrees; - if (((mm_player_t*) player)->is_content_spherical && - ((mm_player_t*) player)->is_video360_plugin_used) { + if (player->is_content_spherical && __mmplayer_check_video_360_used(player)) { /* We will get here if player is pending ready or ready and above */ - g_object_set(G_OBJECT(((mm_player_t*) player)->pipeline->videobin[MMPLAYER_V_360].gst), + g_object_set(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_360].gst), "horizontal-fov", horizontal_degrees, "vertical-fov", vertical_degrees, NULL); return MM_ERROR_NONE; } - return ((mm_player_t*) player)->state < MM_PLAYER_STATE_READY ? MM_ERROR_NONE : MM_ERROR_PLAYER_INTERNAL; + if (player->state >= MM_PLAYER_STATE_READY) { + LOGE("the content is not for 360 playback."); + ret = MM_ERROR_PLAYER_INTERNAL; + } + + MMPLAYER_FLEAVE(); + return ret; } -int _mmplayer_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees) +int _mmplayer_360_get_field_of_view(MMHandleType hplayer, int *horizontal_degrees, int *vertical_degrees) { - if (((mm_player_t*) player)->state < MM_PLAYER_STATE_READY) { - *horizontal_degrees = ((mm_player_t*) player)->video360_horizontal_fov; - *vertical_degrees = ((mm_player_t*) player)->video360_vertical_fov; + mm_player_t* player = (mm_player_t*) hplayer; + + MMPLAYER_FENTER(); + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT); + + LOGD("state %s, spherical info %d", + MMPLAYER_STATE_GET_NAME(MMPLAYER_CURRENT_STATE(player)), player->is_content_spherical); + + if (player->state < MM_PLAYER_STATE_READY) { + *horizontal_degrees = player->video360_horizontal_fov; + *vertical_degrees = player->video360_vertical_fov; return MM_ERROR_NONE; } - if (((mm_player_t*) player)->is_content_spherical && - ((mm_player_t*) player)->is_video360_plugin_used) { - g_object_get(G_OBJECT(((mm_player_t*) player)->pipeline->videobin[MMPLAYER_V_360].gst), + if (player->is_content_spherical && __mmplayer_check_video_360_used(player)) { + g_object_get(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_360].gst), "horizontal-fov", horizontal_degrees, "vertical-fov", vertical_degrees, NULL); return MM_ERROR_NONE; } + LOGE("the content is not for 360 playback."); + + MMPLAYER_FLEAVE(); return MM_ERROR_PLAYER_INTERNAL; } diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index 30bcdcc..f98ab43 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -2110,8 +2110,13 @@ if (gst_tag_list_get_double(tag_list, gsttag, &v_double)) {\ __mmplayer_get_metadata_360_from_tags(tag_list, &player->video360_metadata); mm_attrs_set_int_by_name(attrs, "content_video_is_spherical", player->video360_metadata.is_spherical); - player->is_content_spherical = - player->video360_metadata.is_spherical == 1 ? TRUE : FALSE; + if (player->video360_metadata.is_spherical == 1) { + LOGD("This is spherical content for 360 playback."); + player->is_content_spherical = TRUE; + } else { + player->is_content_spherical = FALSE; + } + if (player->video360_metadata.projection_type_string) { if (!strcmp(player->video360_metadata.projection_type_string, "equirectangular")) { player->video360_metadata.projection_type = VIDEO360_PROJECTION_TYPE_EQUIRECTANGULAR; @@ -4785,6 +4790,9 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) } /* create audio sink */ + LOGD("360 spherical %d, channels %d, ambisonic type %d, format %d, order %d", + player->is_content_spherical, channels, player->video360_metadata.ambisonic_type, + player->video360_metadata.ambisonic_format, player->video360_metadata.ambisonic_order); /* Note: qtdemux converts audio metadata defaults to openalsink defaults. */ if (player->is_content_spherical && @@ -5388,10 +5396,11 @@ __mmplayer_gst_create_video_pipeline(mm_player_t* player, GstCaps* caps, MMDispl mm_attrs_get_int_by_name(player->attrs, "enable_video_decoded_cb", &enable_video_decoded_cb); if (player->is_content_spherical) { + LOGD("video360 elem will be added."); + MMPLAYER_CREATE_ELEMENT(videobin, MMPLAYER_V_360, "video360", "video-360", TRUE, player); - player->is_video360_plugin_used = TRUE; /* Set spatial media metadata and/or user settings to the element. * */ g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst), @@ -6379,7 +6388,6 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) player->video360_metadata.is_spherical = -1; player->is_openal_plugin_used = FALSE; - player->is_video360_plugin_used = FALSE; player->pipeline = (MMPlayerGstPipelineInfo*) g_malloc0(sizeof(MMPlayerGstPipelineInfo)); if (player->pipeline == NULL) @@ -12075,6 +12083,9 @@ __mmplayer_release_misc(mm_player_t* player) /* Reset video360 settings to their defaults in case if the pipeline is to be * re-created. * */ + player->video360_metadata.is_spherical = -1; + player->is_openal_plugin_used = FALSE; + player->is_content_spherical = FALSE; player->is_video360_enabled = TRUE; player->video360_metadata.projection_type = VIDEO360_PROJECTION_TYPE_EQUIRECTANGULAR;