From: Hyunsoo Park Date: Wed, 31 Oct 2018 02:30:59 +0000 (+0900) Subject: Add 'coupled-sink-ip' attribute on sink and source structure and change 'TEARDOWN... X-Git-Tag: submit/tizen/20190507.101459^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d672f0e12adea23061cebeb28d3196503dfa68e;p=platform%2Fcore%2Fapi%2Fscreen-mirroring.git Add 'coupled-sink-ip' attribute on sink and source structure and change 'TEARDOWN' process for secondary sink It is step on developing Secondary Sink. 1.Set 'coupled-sink-ip' attribute on related structure. - That attribute is set on scmirroring_src_s, scmirrroring_sink_s, scmirroring_sink_t, _GstWFDBaseSrcPrivate. 2.Add TEARDOWN STEP when negotiaing with Secondary Sink. - MiracastServer send TEARDOWN signal after M4 negotiation when do negotiating with Secondary Sink. Change-Id: I0c259a909535ce57f1c73befc51bd4df04f25330 Signed-off-by: Hyunsoo Park --- diff --git a/include/scmirroring_internal.h b/include/scmirroring_internal.h index ece8e68..ec6ca0a 100644 --- a/include/scmirroring_internal.h +++ b/include/scmirroring_internal.h @@ -54,6 +54,7 @@ typedef enum { SCMIRRORING_STATE_PLAYING, /**< Screen mirroring is now playing media */ SCMIRRORING_STATE_PAUSED, /**< Screen mirroring is paused while playing media */ SCMIRRORING_STATE_TEARDOWN, /**< Teardown Screen mirroring */ + SCMIRRORING_STATE_TEARDOWN_FOR_SINK,/**< Teardown Screen mirroring */ SCMIRRORING_STATE_MAX /* Number of screen mirroring states */ } scmirroring_state_e; @@ -72,6 +73,20 @@ typedef enum { */ typedef void(*scmirroring_state_cb)(scmirroring_error_e error, scmirroring_state_e state, void *user_data); +/** + * @brief Called when user wants to set 'coupled_sink_ip'. + * + * @details This callback is called for state and error of screen mirroring. + * + * @param[in] scmirroring_sink screen mirroring sink handle + * @param[in] coupled_ip ip address which is coupled with primary sink. e.g secondary sink + * + * @pre scmirroring_src_create() + * + * @see scmirroring_src_create() + */ +int scmirroring_sink_set_coupled_ip(scmirroring_sink_h scmirroring_sink, char* coupled_ip); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/include/scmirroring_private.h b/include/scmirroring_private.h index f3dee22..fedfc61 100644 --- a/include/scmirroring_private.h +++ b/include/scmirroring_private.h @@ -133,6 +133,7 @@ typedef struct { scmirroring_direct_streaming_e direct_streaming; char *filesrc; scmirroring_av_transport_e av_transport; + char *coupled_sink_ip; } scmirroring_src_s; typedef struct { @@ -142,6 +143,7 @@ typedef struct { bool use_hdcp; scmirroring_sink_state_cb_s *scmirroring_sink_state_cb; unsigned int magic_num; + char *coupled_sink_ip; } scmirroring_sink_s; #define WIFIDIRECT_DISPLAY_FEATURE "http://tizen.org/feature/network.wifi.direct.display" diff --git a/include/scmirroring_type.h b/include/scmirroring_type.h index 8294cad..73d3e6f 100644 --- a/include/scmirroring_type.h +++ b/include/scmirroring_type.h @@ -39,6 +39,18 @@ extern "C" { */ typedef void *scmirroring_sink_h; +/** + * @brief The handle to the screen mirroring primary sink. + * @since_tizen 5.5 + */ +typedef void *scmirroring_primary_sink_h; + +/** + * @brief The handle to the screen mirroring secondary sink. + * @since_tizen 5.5 + */ +typedef void *scmirroring_secondary_sink_h; + /** * @brief Enumeration for screen mirroring error. * @since_tizen 2.4 diff --git a/miracast_server/miracast_server_impl.c b/miracast_server/miracast_server_impl.c index 9c9db71..eccd172 100644 --- a/miracast_server/miracast_server_impl.c +++ b/miracast_server/miracast_server_impl.c @@ -50,6 +50,7 @@ #define SWITCH_TO_UDP 0 #define SWITCH_TO_TCP 1 +#define SECONDARY_SINK_IP "192.168.0.10" static gint g_server_status = MIRACAST_WFD_SOURCE_OFF; @@ -144,7 +145,7 @@ static void miracast_server_init(MiracastServer *obj) obj->client = NULL; obj->factory = NULL; obj->resolution = 0; - obj->multisink = SCMIRRORING_MULTISINK_DISABLE; + obj->multisink = SCMIRRORING_MULTISINK_ENABLE; } static void miracast_server_class_init(MiracastServerClass *klass) @@ -492,6 +493,14 @@ __client_closed(GstRTSPClient *client, gpointer user_data) scmirroring_debug("client %p: connection closed", client); + /* Sends Secondary sink ip to scmirroring_src */ + if(g_strcmp0(gst_rtsp_connection_get_ip(connection),SECONDARY_SINK_IP) == 0){ + gchar * msg = g_malloc(sizeof(char *) * 30); + g_sprintf(msg, "SECONDARY_IP:%s",gst_rtsp_connection_get_ip(connection)); + klass->send_response(server_obj,msg); + g_free(msg); + usleep(250000); + } klass->send_response(server_obj, "OK:STOP"); return; diff --git a/packaging/capi-media-screen-mirroring.spec b/packaging/capi-media-screen-mirroring.spec index cfce69c..f5d8361 100644 --- a/packaging/capi-media-screen-mirroring.spec +++ b/packaging/capi-media-screen-mirroring.spec @@ -1,6 +1,6 @@ Name: capi-media-screen-mirroring Summary: A screen mirroring library in Tizen C API -Version: 0.1.93 +Version: 0.1.94 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/scmirroring_sink.c b/src/scmirroring_sink.c index 0faac23..93c2842 100644 --- a/src/scmirroring_sink.c +++ b/src/scmirroring_sink.c @@ -716,3 +716,30 @@ int scmirroring_sink_get_current_state(scmirroring_sink_h scmirroring_sink, scmi scmirroring_debug_fleave(); return __scmirroring_sink_error_convert(__func__, result); } + +int scmirroring_sink_set_coupled_ip(scmirroring_sink_h scmirroring_sink, char* coupled_ip) +{ + int ret = SCMIRRORING_ERROR_NONE; + scmirroring_debug_fenter(); + scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink; + + scmirroring_retvm_if(handle == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "scmirroring_sink is NULL"); + scmirroring_retvm_if(handle->magic_num != SCMIRRORING_MAGIC_NUMBER, SCMIRRORING_ERROR_INVALID_PARAMETER, "scmirroring_sink is invalid handle"); + + if (coupled_ip == NULL) { + scmirroring_error("Invalid coupled ip parameter [%s]", coupled_ip); + return SCMIRRORING_ERROR_INVALID_PARAMETER; + } + scmirroring_debug("coupled_ip (%s)", coupled_ip); + + ret = mm_wfd_sink_set_coupled_ip(handle->mm_handle, coupled_ip); + if (ret != MM_ERROR_NONE) { + scmirroring_error("Fail to Set Coupled IP"); + return __scmirroring_sink_error_convert(__func__, ret); + } + ret = __scmirroring_sink_error_convert(__func__, ret); + + scmirroring_debug_fleave(); + + return ret; +} diff --git a/src/scmirroring_src.c b/src/scmirroring_src.c index 474f1ff..b6eecd8 100644 --- a/src/scmirroring_src.c +++ b/src/scmirroring_src.c @@ -240,15 +240,25 @@ static void __scmirroring_src_interpret(scmirroring_src_s *scmirroring, char *bu scmirroring_debug("error: %s, status: %s", response[0], response[1]); - error_code = __scmirroring_src_get_error(response[0]); - src_state = __scmirroring_src_get_status(response[1]);; - g_strfreev(response); + /* if front-half message is "OK" or "FAIL", it is ERROR:STATE pair*/ + if(g_strcmp0("OK",response[0]) == 0 || g_strcmp0("FAIL",response[0]) == 0){ + error_code = __scmirroring_src_get_error(response[0]); + src_state = __scmirroring_src_get_status(response[1]);; + g_strfreev(response); + if (scmirroring->current_state != src_state) { + scmirroring->current_state = src_state; + __scmirroring_src_set_callback_info(scmirroring, error_code, src_state); + } else { + scmirroring_debug("Current state is already %d", src_state); + } - if (scmirroring->current_state != src_state) { - scmirroring->current_state = src_state; + }else{ + scmirroring->coupled_sink_ip = response[1]; + error_code = SCMIRRORING_ERROR_NONE; + src_state = SCMIRRORING_STATE_TEARDOWN_FOR_SINK; + scmirroring_debug("__scmirroring_src_interpret sec_ip : %s", scmirroring->coupled_sink_ip); + scmirroring_debug("__scmirroring_src_interpret is here %d : %d",error_code, src_state); __scmirroring_src_set_callback_info(scmirroring, error_code, src_state); - } else { - scmirroring_debug("Current state is already %d", src_state); } return; @@ -450,6 +460,7 @@ int scmirroring_src_create(scmirroring_src_h *scmirroring) _scmirroring->server_name = g_strdup("scmirroring"); _scmirroring->multisink = SCMIRRORING_MULTISINK_DISABLE; _scmirroring->av_transport = SCMIRRORING_AV_TRANSPORT_UDP; + _scmirroring->coupled_sink_ip = NULL; *scmirroring = (scmirroring_src_h)_scmirroring; diff --git a/test_sink/scmirroring_sink_test.c b/test_sink/scmirroring_sink_test.c index 3403a71..878a5b2 100644 --- a/test_sink/scmirroring_sink_test.c +++ b/test_sink/scmirroring_sink_test.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -1066,6 +1067,10 @@ static int __scmirroring_sink_create(gpointer data) return SCMIRRORING_ERROR_INVALID_OPERATION; } + char ip[50]={0}; + strncpy(ip,"192.168.0.23",50); + g_print("IP is %s\n", ip); + ret=scmirroring_sink_set_coupled_ip(g_scmirroring,ip); if (g_sinktype != -1) { if (g_sinktype == SCMIRRORING_DISPLAY_TYPE_OVERLAY) { evas_object_show(g_evas);