Add coupling modes to server and TEARDOWN_COUPLING signal 62/205362/4 accepted/tizen_5.5_unified accepted/tizen_5.5_unified_mobile_hotfix accepted/tizen_5.5_unified_wearable_hotfix tizen_5.5 tizen_5.5_mobile_hotfix tizen_5.5_tv tizen_5.5_wearable_hotfix accepted/tizen/5.5/unified/20191031.004932 accepted/tizen/5.5/unified/mobile/hotfix/20201027.061804 accepted/tizen/5.5/unified/wearable/hotfix/20201027.101942 accepted/tizen/unified/20190508.111112 submit/tizen/20190507.101459 submit/tizen_5.5/20191031.000006 submit/tizen_5.5_mobile_hotfix/20201026.185106 submit/tizen_5.5_wearable_hotfix/20201026.184306 tizen_5.5.m2_release
authorHyunsoo Park <hance.park@samsung.com>
Thu, 2 May 2019 12:57:13 +0000 (21:57 +0900)
committerHyunsoo Park <hance.park@samsung.com>
Tue, 7 May 2019 07:00:05 +0000 (16:00 +0900)
-It is of no use setting coupled sink information when teardown.
-Add coupling mode process

Change-Id: Ie7fe95676530ef8eb207d98544dc035a0e95f7b1
Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
gst/rtsp-server/gstwfdmessage.c
gst/rtsp-server/gstwfdmessage.h
gst/rtsp-server/rtsp-client-wfd.c
gst/rtsp-server/rtsp-client-wfd.h
gst/rtsp-server/rtsp-server-wfd.c
gst/rtsp-server/rtsp-server-wfd.h
packaging/gst-rtsp-server.spec

index 8796ce3..be22134 100755 (executable)
@@ -702,7 +702,7 @@ gst_wfd_parse_attribute (gchar * buffer, GstWFDMessage * msg)
   } else if (!g_strcmp0 (attr, GST_STRING_WFD_COUPLED_SINK)) {
     msg->coupled_sink = g_new0 (GstWFDCoupledSink, 1);
     if (strlen (v)) {
-      msg->coupled_sink->coupled_sink_cap = g_new0 (GstWFDCoupled_sink_cap, 1);
+      msg->coupled_sink->coupled_sink_cap = g_new0 (GstWFDCoupledSinkCap, 1);
       WFD_SKIP_SPACE (v);
       WFD_READ_UINT32 (msg->coupled_sink->coupled_sink_cap->status);
       WFD_SKIP_SPACE (v);
@@ -1180,7 +1180,8 @@ gst_wfd_message_as_text (const GstWFDMessage * msg)
   if (msg->coupled_sink) {
     g_string_append_printf (lines, GST_STRING_WFD_COUPLED_SINK);
     g_string_append_printf (lines, ":");
-    if (msg->coupled_sink->coupled_sink_cap) {
+    if (msg->coupled_sink->coupled_sink_cap &&
+      (gboolean)msg->coupled_sink->coupled_sink_cap->sink_supported == TRUE) {
       g_string_append_printf (lines, " %02x",
           msg->coupled_sink->coupled_sink_cap->status);
       if (msg->coupled_sink->coupled_sink_cap->sink_address)
@@ -2594,6 +2595,34 @@ gst_wfd_message_get_display_edid (GstWFDMessage * msg,
   return GST_WFD_OK;
 }
 
+GstWFDResult gst_wfd_message_set_coupled_sink(GstWFDMessage *msg,
+    GstWFDCoupledSinkStatus status, gchar *sink_address, gboolean sink_supported)
+{
+  g_return_val_if_fail(msg != NULL, GST_WFD_EINVAL);
+  if (!msg->coupled_sink) msg->coupled_sink = g_new0(GstWFDCoupledSink, 1);
+  if (!sink_supported) return GST_WFD_OK;
+  msg->coupled_sink->coupled_sink_cap = g_new0(GstWFDCoupledSinkCap, 1);
+  msg->coupled_sink->coupled_sink_cap->status = status;
+  msg->coupled_sink->coupled_sink_cap->sink_address = g_strdup(sink_address);
+  msg->coupled_sink->coupled_sink_cap->sink_supported = sink_supported;
+  return GST_WFD_OK;
+}
+
+GstWFDResult gst_wfd_message_get_coupled_sink(GstWFDMessage *msg,
+    GstWFDCoupledSinkStatus *status, gchar **sink_address, gboolean *sink_supported)
+{
+  g_return_val_if_fail(msg != NULL, GST_WFD_EINVAL);
+  if (msg->coupled_sink
+      && msg->coupled_sink->coupled_sink_cap->sink_supported) {
+    *status = msg->coupled_sink->coupled_sink_cap->status;
+    *sink_address = g_strdup(msg->coupled_sink->coupled_sink_cap->sink_address);
+    *sink_supported = (gboolean)msg->coupled_sink->coupled_sink_cap->sink_supported;
+  }
+  else {
+    *status = GST_WFD_SINK_NOT_COUPLED;
+  }
+  return GST_WFD_OK;
+}
 
 GstWFDResult
 gst_wfd_message_set_contentprotection_type (GstWFDMessage * msg,
index b5dd372..0cebb9f 100755 (executable)
@@ -216,11 +216,9 @@ typedef enum {
 } GstWFDHDCPProtection;
 
 typedef enum {
-  GST_WFD_SINK_UNKNOWN = -1,
-  GST_WFD_SINK_NOT_COUPLED     = 0,
-  GST_WFD_SINK_COUPLED,
-  GST_WFD_SINK_TEARDOWN_COUPLING,
-  GST_WFD_SINK_RESERVED
+  GST_WFD_SINK_NOT_COUPLED          = 0,
+  GST_WFD_SINK_COUPLED           = (1 << 0),
+  GST_WFD_SINK_TEARDOWN_COUPLING = (1 << 1)
 } GstWFDCoupledSinkStatus;
 
 typedef enum {
@@ -371,10 +369,11 @@ typedef struct {
 typedef struct {
   guint status;
   gchar *sink_address;
-} GstWFDCoupled_sink_cap;
+  gboolean sink_supported;
+} GstWFDCoupledSinkCap;
 
 typedef struct {
-  GstWFDCoupled_sink_cap *coupled_sink_cap;
+  GstWFDCoupledSinkCap *coupled_sink_cap;
 } GstWFDCoupledSink;
 
 typedef struct {
@@ -718,6 +717,16 @@ GstWFDResult gst_wfd_message_get_display_edid (GstWFDMessage *msg,
                                         guint32 *edid_blockcount,
                                         gchar **edid_playload);
 
+GstWFDResult gst_wfd_message_set_coupled_sink(GstWFDMessage *msg,
+                                        GstWFDCoupledSinkStatus status,
+                                        gchar *sink_address,
+                                        gboolean sink_supported);
+
+GstWFDResult gst_wfd_message_get_coupled_sink(GstWFDMessage *msg,
+                                        GstWFDCoupledSinkStatus *status,
+                                        gchar **sink_address,
+                                        gboolean *sink_supported);
+
 GstWFDResult gst_wfd_message_set_contentprotection_type (GstWFDMessage *msg,
                                         GstWFDHDCPProtection hdcpversion,
                                         guint32 TCPPort);
index d1a05a7..57a6a86 100755 (executable)
@@ -179,6 +179,11 @@ struct _GstRTSPWFDClientPrivate
   /* enable or disable R2 features */
   gboolean wfd2_mode;
   gint wfd2_supported;
+  gboolean coupling_mode;
+
+  guint coupled_sink_status;
+  gchar *coupled_sink_address;
+  gboolean coupled_sink_supported;
 };
 
 #define DEFAULT_WFD_TIMEOUT 60
@@ -371,6 +376,7 @@ gst_rtsp_wfd_client_init (GstRTSPWFDClient * client)
   priv->report_type = WFD_TS_REP_AUDIO;
 
   priv->wfd2_supported = 0;
+  priv->coupled_sink_address = NULL;
 
   g_mutex_init (&priv->tcp_send_lock);
   GST_INFO_OBJECT (client, "Client is initialized");
@@ -1711,8 +1717,13 @@ handle_wfd_response (GstRTSPClient * client, GstRTSPContext * ctx)
     } else if (!priv->m4_done) {
       GST_INFO_OBJECT (_client, "M4 response is done");
       priv->m4_done = TRUE;
-
-      gst_rtsp_wfd_client_trigger_request (_client, WFD_TRIGGER_SETUP);
+      /* Checks whether server is 'coupling mode' or not */
+      GST_DEBUG_OBJECT (client, "server coupling mode [%d]",priv->coupling_mode );
+      if (priv->coupling_mode) {
+        gst_rtsp_wfd_client_trigger_request (_client, WFD_TRIGGER_TEARDOWN_COUPLING);
+      } else {
+        gst_rtsp_wfd_client_trigger_request (_client, WFD_TRIGGER_SETUP);
+      }
     } else {
       g_mutex_lock (&priv->keep_alive_lock);
       if (priv->keep_alive_flag == FALSE) {
@@ -1963,6 +1974,7 @@ typedef enum
   M4_RES_MSG,
   M5_REQ_MSG,
   TEARDOWN_TRIGGER,
+  TEARDOWN_COUPLING_TRIGGER,
   PLAY_TRIGGER,
   PAUSE_TRIGGER,
   TS_REQ_MSG,
@@ -2226,6 +2238,17 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type,
           "Failed to set tcp ports parameter on wfd message...");
       goto error;
     }
+
+    /* set the coupled sink for the WFD server */
+    wfd_res =
+        gst_wfd_message_set_coupled_sink (msg, GST_WFD_SINK_NOT_COUPLED, NULL, TRUE);
+
+    if (wfd_res != GST_WFD_OK) {
+      GST_ERROR_OBJECT (client,
+        "Failed to set coupled sink parameter on wfd message...");
+      goto error;
+    }
+
     *data = gst_wfd_message_param_names_as_text (msg);
     if (*data == NULL) {
       GST_ERROR_OBJECT (client, "Failed to get wfd message as text...");
@@ -2677,35 +2700,33 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type,
       *len = strlen (*data);
     }
   } else if (msg_type == M5_REQ_MSG) {
-    buf = g_string_new ("");
+    buf = g_string_new ("wfd_trigger_method: SETUP\r\n");
     if (buf == NULL)
       goto error;
-    g_string_append (buf, "wfd_trigger_method: SETUP");
-    g_string_append (buf, "\r\n");
     *len = buf->len;
     *data = g_string_free (buf, FALSE);
   } else if (msg_type == TEARDOWN_TRIGGER) {
-    buf = g_string_new ("");
+    buf = g_string_new ("wfd_trigger_method: TEARDOWN\r\n");
+    if (buf == NULL)
+      goto error;
+    *len = buf->len;
+    *data = g_string_free (buf, FALSE);
+  } else if (msg_type == TEARDOWN_COUPLING_TRIGGER) {
+    buf = g_string_new ("wfd_trigger_method: TEARDOWN_COUPLING\r\n");
     if (buf == NULL)
       goto error;
-    g_string_append (buf, "wfd_trigger_method: TEARDOWN");
-    g_string_append (buf, "\r\n");
     *len = buf->len;
     *data = g_string_free (buf, FALSE);
   } else if (msg_type == PLAY_TRIGGER) {
-    buf = g_string_new ("");
+    buf = g_string_new ("wfd_trigger_method: PLAY\r\n");
     if (buf == NULL)
       goto error;
-    g_string_append (buf, "wfd_trigger_method: PLAY");
-    g_string_append (buf, "\r\n");
     *len = buf->len;
     *data = g_string_free (buf, FALSE);
   } else if (msg_type == PAUSE_TRIGGER) {
-    buf = g_string_new ("");
+    buf = g_string_new ("wfd_trigger_method: PAUSE\r\n");
     if (buf == NULL)
       goto error;
-    g_string_append (buf, "wfd_trigger_method: PAUSE");
-    g_string_append (buf, "\r\n");
     *len = buf->len;
     *data = g_string_free (buf, FALSE);
   }
@@ -2930,6 +2951,43 @@ prepare_trigger_request (GstRTSPWFDClient * client, GstRTSPMessage * request,
       g_free (msg);
       break;
     }
+    case WFD_TRIGGER_TEARDOWN_COUPLING:{
+      gchar *msg;
+      guint msglen = 0;
+      GString *msglength;
+
+      /* add content type */
+      res =
+          gst_rtsp_message_add_header (request, GST_RTSP_HDR_CONTENT_TYPE,
+          "text/parameters");
+      if (res != GST_RTSP_OK) {
+        GST_ERROR_OBJECT (client, "Failed to add header to rtsp request...");
+        goto error;
+      }
+
+      _set_wfd_message_body (client, TEARDOWN_COUPLING_TRIGGER, &msg, &msglen);
+      msglength = g_string_new ("");
+      g_string_append_printf (msglength, "%d", msglen);
+      GST_DEBUG ("Trigger TEARDOWN server side message body: %s", msg);
+
+      /* add content-length type */
+      res =
+          gst_rtsp_message_add_header (request, GST_RTSP_HDR_CONTENT_LENGTH,
+          g_string_free (msglength, FALSE));
+      if (res != GST_RTSP_OK) {
+        GST_ERROR_OBJECT (client, "Failed to add header to rtsp message...");
+        goto error;
+      }
+
+      res = gst_rtsp_message_set_body (request, (guint8 *) msg, msglen);
+      if (res != GST_RTSP_OK) {
+        GST_ERROR_OBJECT (client, "Failed to add header to rtsp message...");
+        goto error;
+      }
+
+      g_free (msg);
+      break;
+    }
     case WFD_TRIGGER_PLAY:{
       gchar *msg;
       guint msglen = 0;
@@ -3297,6 +3355,20 @@ gst_rtsp_wfd_client_set_audio_codec (GstRTSPWFDClient * client,
   return res;
 }
 
+GstRTSPResult
+gst_rtsp_wfd_client_set_coupling_mode (GstRTSPWFDClient * client,
+    gboolean coupling_mode)
+{
+  GstRTSPResult res = GST_RTSP_OK;
+  GstRTSPWFDClientPrivate *priv = GST_RTSP_WFD_CLIENT_GET_PRIVATE (client);
+
+  g_return_val_if_fail (priv != NULL, GST_RTSP_EINVAL);
+  priv->coupling_mode = coupling_mode;
+
+  return res;
+}
+
+
 static gboolean
 wfd_ckeck_keep_alive_response (gpointer userdata)
 {
@@ -3636,6 +3708,15 @@ gst_rtsp_wfd_client_get_protection_enabled (GstRTSPWFDClient * client)
   return priv->protection_enabled;
 }
 
+gboolean
+gst_rtsp_wfd_client_get_coupling_mode (GstRTSPWFDClient * client)
+{
+  GstRTSPWFDClientPrivate *priv = GST_RTSP_WFD_CLIENT_GET_PRIVATE (client);
+  g_return_val_if_fail (priv != NULL, 0);
+
+  return priv->coupling_mode;
+}
+
 void
 gst_rtsp_wfd_client_set_audio_freq (GstRTSPWFDClient * client, guint freq)
 {
index 09c1631..2faa6b2 100644 (file)
@@ -53,6 +53,7 @@ typedef enum {
   WFD_TRIGGER_SETUP,
   WFD_TRIGGER_PAUSE,
   WFD_TRIGGER_TEARDOWN,
+  WFD_TRIGGER_TEARDOWN_COUPLING,
   WFD_TRIGGER_PLAY
 } GstWFDTriggerType;
 
@@ -149,6 +150,9 @@ GstRTSPResult         gst_rtsp_wfd_client_set_audio_codec (
                                      GstRTSPWFDClient * client, guint8 audio_codec);
 GstRTSPResult         gst_rtsp_wfd_client_set_direct_streaming(
                           GstRTSPWFDClient * client, gint direct_streaming, gchar *urisrc);
+GstRTSPResult         gst_rtsp_wfd_client_set_coupling_mode(
+                          GstRTSPWFDClient * client, gboolean coupling_mode);
+
 GstRTSPResult         gst_prepare_request (GstRTSPWFDClient * client,
                           GstRTSPMessage * request, GstRTSPMethod method, gchar * url);
 void                  gst_send_request (GstRTSPWFDClient * client,
@@ -182,6 +186,8 @@ gboolean  gst_rtsp_wfd_client_get_edid_supported(GstRTSPWFDClient *client);
 guint32   gst_rtsp_wfd_client_get_edid_hresolution(GstRTSPWFDClient *client);
 guint32   gst_rtsp_wfd_client_get_edid_vresolution(GstRTSPWFDClient *client);
 gboolean  gst_rtsp_wfd_client_get_protection_enabled(GstRTSPWFDClient *client);
+gboolean  gst_rtsp_wfd_client_get_coupling_mode(GstRTSPWFDClient *client);
+
 
 void gst_rtsp_wfd_client_set_audio_freq(GstRTSPWFDClient *client, guint freq);
 void gst_rtsp_wfd_client_set_edid_supported(GstRTSPWFDClient *client, gboolean supported);
index 5a0a981..359cb77 100644 (file)
@@ -76,6 +76,7 @@ struct _GstRTSPWFDServerPrivate
   guint8 audio_codec;
   guint8 video_codec;
   gint wfd2_supported;
+  gboolean coupling_mode;
 };
 
 G_DEFINE_TYPE (GstRTSPWFDServer, gst_rtsp_wfd_server, GST_TYPE_RTSP_SERVER);
@@ -127,6 +128,7 @@ gst_rtsp_wfd_server_init (GstRTSPWFDServer * server)
   server->priv->native_resolution = 0;
   server->priv->supported_resolution = 1;
   server->priv->audio_codec = 2;
+  server->priv->coupling_mode = FALSE;
   GST_INFO_OBJECT (server, "New server is initialized");
 }
 
@@ -249,6 +251,8 @@ create_client_wfd (GstRTSPServer * server)
 
   gst_rtsp_wfd_client_set_video_codec (client, priv->video_codec);
 
+  gst_rtsp_wfd_client_set_coupling_mode (client, priv->coupling_mode);
+
   /* enable or disable R2 features following ini */
   gst_rtsp_wfd_client_set_wfd2_supported (client, priv->wfd2_supported);
 
@@ -392,6 +396,23 @@ gst_rtsp_wfd_server_set_direct_streaming (GstRTSPWFDServer *server,
   return res;
 }
 
+
+GstRTSPResult
+gst_rtsp_wfd_server_set_coupling_mode (GstRTSPWFDServer * server,
+    gboolean coupling_mode)
+{
+  GstRTSPResult res = GST_RTSP_OK;
+  GstRTSPWFDServerPrivate *priv = GST_RTSP_WFD_SERVER_GET_PRIVATE (server);
+
+  g_return_val_if_fail (GST_IS_RTSP_WFD_SERVER (server), GST_RTSP_ERROR);
+  g_return_val_if_fail (priv != NULL, GST_RTSP_ERROR);
+
+  GST_RTSP_WFD_SERVER_LOCK (server);
+  priv->coupling_mode = coupling_mode;
+  GST_RTSP_WFD_SERVER_UNLOCK (server);
+  return res;
+}
+
 GstRTSPResult
 gst_rtsp_wfd_server_switch_to_udp (GstRTSPWFDServer *server)
 {
index 079d473..23db5b4 100644 (file)
@@ -83,6 +83,8 @@ GstRTSPResult         gst_rtsp_wfd_server_set_video_native_reso    (GstRTSPWFDSe
 GstRTSPResult         gst_rtsp_wfd_server_set_video_codec    (GstRTSPWFDServer *server, guint8 video_codec);
 GstRTSPResult         gst_rtsp_wfd_server_set_audio_codec    (GstRTSPWFDServer *server, guint8 audio_codec);
 GstRTSPResult         gst_rtsp_wfd_server_set_direct_streaming (GstRTSPWFDServer *server, gint direct_streaming, gchar *urisrc);
+GstRTSPResult         gst_rtsp_wfd_server_set_coupling_mode (GstRTSPWFDServer *server, gboolean coupling_mode);
+
 GstRTSPResult         gst_rtsp_wfd_server_switch_to_udp (GstRTSPWFDServer *server);
 GstRTSPResult         gst_rtsp_wfd_server_switch_to_tcp (GstRTSPWFDServer *server);
 GstRTSPResult         gst_rtsp_wfd_server_set_wfd2_supported (GstRTSPWFDServer *server, guint flag);
index f197fa8..b17335e 100644 (file)
@@ -1,7 +1,7 @@
 Name:       gst-rtsp-server
 Summary:    Multimedia Framework Library
 Version:    1.12.2
-Release:    10
+Release:    11
 Url:        http://gstreamer.freedesktop.org/
 Group:      System/Libraries
 License:    LGPL-2.0+