From b25e522e47134c3709e4ffa5678bee27a80016b9 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Mon, 21 Nov 2016 16:07:13 +0900 Subject: [PATCH 01/16] Fix return type Delete unreached code [Version] 1.6.1 - 2 [Profile] Common [Issue Type] Bug fix [Dependency module] N/A [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-mobile_20161111.1] Signed-off-by: SeokHoon Lee Change-Id: Iea325ad74b7b31216c502068b18df2f5163b4b1c --- gst/rtsp-server/rtsp-client-ext.c | 21 ++++++--------------- gst/rtsp-server/rtsp-media-ext.c | 20 ++++++++++---------- gst/rtsp-server/rtsp-media.c | 4 ++-- packaging/gst-rtsp-server.spec | 2 +- 4 files changed, 19 insertions(+), 28 deletions(-) mode change 100755 => 100644 gst/rtsp-server/rtsp-client-ext.c mode change 100755 => 100644 gst/rtsp-server/rtsp-media-ext.c diff --git a/gst/rtsp-server/rtsp-client-ext.c b/gst/rtsp-server/rtsp-client-ext.c old mode 100755 new mode 100644 index 5f73c99..6c41344 --- a/gst/rtsp-server/rtsp-client-ext.c +++ b/gst/rtsp-server/rtsp-client-ext.c @@ -372,7 +372,7 @@ handle_ext_stats (GstRTSPWFDClient * client, GstStructure * stats) GstRTSPExtClientPrivate *priv = GST_RTSP_EXT_CLIENT_GET_PRIVATE (_client); guint latest_resend_packets = 0; - g_return_val_if_fail (priv != NULL, FALSE); + g_return_if_fail (priv != NULL); latest_resend_packets = gst_rtsp_media_ext_get_resent_packets (priv->media); @@ -552,7 +552,7 @@ handle_ext_m3_req_msg (GstRTSPWFDClient * client, gchar * data) GstWFDResult wfd_res = GST_WFD_EINVAL; gboolean is_appended = FALSE; - g_return_if_fail (client != NULL); + g_return_val_if_fail (client != NULL, NULL); g_return_val_if_fail (data != NULL, NULL); sink_user_agent = gst_rtsp_wfd_client_get_sink_user_agent (client); @@ -637,7 +637,7 @@ handle_ext_m3_res_msg (GstRTSPWFDClient * client, gchar * data) GstWFDResult wfd_res = GST_WFD_EINVAL; g_return_if_fail (ext_priv != NULL); - g_return_val_if_fail (data != NULL, NULL); + g_return_if_fail (data != NULL); wfd_res = gst_wfd_ext_message_new (&msg); if (wfd_res != GST_WFD_OK) { @@ -811,7 +811,7 @@ handle_ext_set_param_msg (GstRTSPWFDClient * client, gchar * data) GstRTSPExtClientPrivate *priv = GST_RTSP_EXT_CLIENT_GET_PRIVATE (client); g_return_if_fail (priv != NULL); - g_return_val_if_fail (data != NULL, NULL); + g_return_if_fail (data != NULL); return; } @@ -823,9 +823,8 @@ handle_ext_m4_req_msg (GstRTSPWFDClient * client, gchar * data) gchar *tmp = NULL; GstRTSPExtClientPrivate *ext_priv = GST_RTSP_EXT_CLIENT_GET_PRIVATE (client); GstWFDResult wfd_res = GST_WFD_EINVAL; - gboolean is_appended = FALSE; - g_return_if_fail (ext_priv != NULL); + g_return_val_if_fail (ext_priv != NULL, NULL); g_return_val_if_fail (data != NULL, NULL); wfd_res = gst_wfd_ext_message_new (&msg); @@ -893,7 +892,6 @@ handle_ext_m4_req_msg (GstRTSPWFDClient * client, gchar * data) if (tmp) { data = g_strconcat (data, tmp, NULL); g_free (tmp); - is_appended = TRUE; } else { GST_ERROR_OBJECT (client, "Failed to gst_wfd_ext_message_as_text"); goto error; @@ -904,16 +902,9 @@ handle_ext_m4_req_msg (GstRTSPWFDClient * client, gchar * data) gst_wfd_ext_listen_media_constructed (client); - if (is_appended == FALSE) { - return NULL; - } else { - return data; - }; - return data; + error: - if (tmp != NULL) - g_free (tmp); if (msg != NULL) gst_wfd_ext_message_free (msg); diff --git a/gst/rtsp-server/rtsp-media-ext.c b/gst/rtsp-server/rtsp-media-ext.c old mode 100755 new mode 100644 index abecb86..d1d2ebe --- a/gst/rtsp-server/rtsp-media-ext.c +++ b/gst/rtsp-server/rtsp-media-ext.c @@ -571,7 +571,7 @@ ext_preparing (GstRTSPMedia * media, GstRTSPStream * stream, guint idx) GstRTSPMediaExtPrivate *priv; priv = _media->priv; - g_return_val_if_fail (priv != NULL, 0); + g_return_if_fail (priv != NULL); pipeline = gst_rtsp_media_get_pipeline (media); rtpbin = gst_rtsp_media_get_rtpbin (media); @@ -666,7 +666,7 @@ ext_unpreparing (GstRTSPMedia * media, GstRTSPStream * stream, guint idx) GstRTSPMediaExtPrivate *priv; priv = _media->priv; - g_return_val_if_fail (priv != NULL, 0); + g_return_if_fail (priv != NULL); pipeline = gst_rtsp_media_get_pipeline (media); rtpbin = gst_rtsp_media_get_rtpbin (media); @@ -720,10 +720,10 @@ gst_rtsp_media_ext_set_retrans_port (GstRTSPMediaExt * media, guint port) { GstRTSPMediaExtPrivate *priv; - g_return_val_if_fail (GST_IS_RTSP_MEDIA_EXT (media), 0); + g_return_if_fail (GST_IS_RTSP_MEDIA_EXT (media)); priv = media->priv; - g_return_val_if_fail (priv != NULL, 0); + g_return_if_fail (priv != NULL); priv->retransmit_port = port; } @@ -734,10 +734,10 @@ gst_rtsp_media_ext_set_fec_value (GstRTSPMediaExt * media, guint max_k, { GstRTSPMediaExtPrivate *priv; - g_return_val_if_fail (GST_IS_RTSP_MEDIA_EXT (media), 0); + g_return_if_fail (GST_IS_RTSP_MEDIA_EXT (media)); priv = media->priv; - g_return_val_if_fail (priv != NULL, 0); + g_return_if_fail (priv != NULL); priv->max_size_k = max_k; priv->max_size_p = max_p; @@ -749,10 +749,10 @@ gst_rtsp_media_ext_set_latency_mode (GstRTSPMediaExt * media, { GstRTSPMediaExtPrivate *priv; - g_return_val_if_fail (GST_IS_RTSP_MEDIA_EXT (media), 0); + g_return_if_fail (GST_IS_RTSP_MEDIA_EXT (media)); priv = media->priv; - g_return_val_if_fail (priv != NULL, 0); + g_return_if_fail (priv != NULL); priv->latency_mode = latency; } @@ -763,10 +763,10 @@ gst_rtsp_media_ext_set_next_param (GstRTSPMediaExt * media, gint32 next_k, { GstRTSPMediaExtPrivate *priv; - g_return_val_if_fail (GST_IS_RTSP_MEDIA_EXT (media), 0); + g_return_if_fail (GST_IS_RTSP_MEDIA_EXT (media)); priv = media->priv; - g_return_val_if_fail (priv != NULL, 0); + g_return_if_fail (priv != NULL); g_object_set (G_OBJECT (priv->fecenc), "next-k", next_k, NULL); g_object_set (G_OBJECT (priv->fecenc), "next-p", next_p, NULL); diff --git a/gst/rtsp-server/rtsp-media.c b/gst/rtsp-server/rtsp-media.c index 8f29da0..f79a457 100644 --- a/gst/rtsp-server/rtsp-media.c +++ b/gst/rtsp-server/rtsp-media.c @@ -4185,7 +4185,7 @@ gst_rtsp_media_get_pipeline (GstRTSPMedia * media) { GstRTSPMediaPrivate *priv; - g_return_if_fail (GST_IS_RTSP_MEDIA (media));; + g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), NULL); priv = media->priv; @@ -4202,7 +4202,7 @@ gst_rtsp_media_get_rtpbin (GstRTSPMedia * media) { GstRTSPMediaPrivate *priv; - g_return_if_fail (GST_IS_RTSP_MEDIA (media));; + g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), NULL); priv = media->priv; diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index 41b739c..f73387c 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 2 +Release: 3 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4 From e6b9d94ba0002775c7e1c6e7956e80ffd307f07b Mon Sep 17 00:00:00 2001 From: "Hyunsoo, Park" Date: Wed, 23 Nov 2016 13:48:18 +0900 Subject: [PATCH 02/16] Add 'TCP/UDP Switching' feature Using this feature, User can choose transport layer protocol between TCP and UDP. [Version] 1.6.1-4 [Profile] Common [Issue Type] Add feature [Dependency module] N/A [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-mobile_20161111.1] Change-Id: Ief6aec65e3058c32760fc5490631c3bff635c254 Signed-off-by: Hyunsoo, Park --- gst/rtsp-server/gstwfdmessage.c | 240 +++++++++++++ gst/rtsp-server/gstwfdmessage.h | 55 +++ gst/rtsp-server/rtsp-client-wfd.c | 701 +++++++++++++++++++++++++++++++++++++- gst/rtsp-server/rtsp-client-wfd.h | 2 + gst/rtsp-server/rtsp-server-wfd.c | 58 ++++ gst/rtsp-server/rtsp-server-wfd.h | 2 + packaging/gst-rtsp-server.spec | 2 +- 7 files changed, 1057 insertions(+), 3 deletions(-) mode change 100644 => 100755 gst/rtsp-server/gstwfdmessage.c mode change 100644 => 100755 gst/rtsp-server/gstwfdmessage.h mode change 100755 => 100644 gst/rtsp-server/rtsp-client-wfd.c mode change 100644 => 100755 gst/rtsp-server/rtsp-client-wfd.h mode change 100644 => 100755 gst/rtsp-server/rtsp-server-wfd.h diff --git a/gst/rtsp-server/gstwfdmessage.c b/gst/rtsp-server/gstwfdmessage.c old mode 100644 new mode 100755 index 0e1f7dd..8d75982 --- a/gst/rtsp-server/gstwfdmessage.c +++ b/gst/rtsp-server/gstwfdmessage.c @@ -334,6 +334,21 @@ gst_wfd_message_uninit (GstWFDMessage * msg) if (msg->idr_request) { FREE_STRING (msg->idr_request); } + if (msg->tcp_ports) { + FREE_STRING(msg->tcp_ports); + } + + if (msg->buf_len) { + FREE_STRING(msg->buf_len); + } + + if (msg->audio_status) { + FREE_STRING(msg->audio_status); + } + + if (msg->video_status) { + FREE_STRING(msg->video_status); + } return GST_WFD_OK; } @@ -444,6 +459,7 @@ gst_wfd_parse_attribute (gchar * buffer, GstWFDMessage * msg) #define WFD_READ_STRING(field) _read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); REPLACE_STRING (field, temp) #define WFD_READ_UINT32(field) _read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); field = strtoul (temp, NULL, 16) #define WFD_READ_UINT32_DIGIT(field) _read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); field = strtoul (temp, NULL, 10) +#define WFD_READ_UINT64_DIGIT(field) _read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); field = strtoull (temp, NULL, 10) _read_string_attr_and_value (attr, value, sizeof (attr), sizeof (value), ':', p); @@ -743,6 +759,40 @@ gst_wfd_parse_attribute (gchar * buffer, GstWFDMessage * msg) } else if (!g_strcmp0 (attr, GST_STRING_WFD_IDR_REQUEST)) { msg->idr_request = g_new0 (GstWFDIdrRequest, 1); msg->idr_request->idr_request = TRUE; + } else if (!g_strcmp0 (attr, GST_STRING_WFD2_TCP_PORTS)) { + msg->tcp_ports = g_new0 (GstWFDTCPPorts, 1); + if (strlen (v)) { + WFD_SKIP_SPACE (v); + WFD_READ_STRING (msg->tcp_ports->profile); + WFD_SKIP_SPACE (v); + WFD_READ_UINT32_DIGIT (msg->tcp_ports->rtp_port0); + WFD_SKIP_SPACE (v); + WFD_READ_UINT32_DIGIT (msg->tcp_ports->rtp_port1); + WFD_SKIP_SPACE (v); + WFD_READ_STRING (msg->tcp_ports->mode); + } + } else if (!g_strcmp0 (attr, GST_STRING_WFD2_BUFFER_LEN)) { + msg->buf_len = g_new0 (GstWFDBufferLen, 1); + if (strlen (v)) { + WFD_SKIP_SPACE (v); + WFD_READ_UINT32_DIGIT (msg->buf_len->buf_len); + } + } else if (!g_strcmp0 (attr, GST_STRING_WFD2_AUDIO_STATUS)) { + msg->audio_status = g_new0 (GstWFDAudioReport, 1); + if (strlen (v)) { + WFD_SKIP_SPACE (v); + WFD_READ_UINT32_DIGIT (msg->audio_status->aud_bufsize); + WFD_SKIP_SPACE (v); + WFD_READ_UINT64_DIGIT (msg->audio_status->aud_pts); + } + } else if (!g_strcmp0 (attr, GST_STRING_WFD2_VIDEO_STATUS)) { + msg->video_status = g_new0 (GstWFDVideoReport, 1); + if (strlen (v)) { + WFD_SKIP_SPACE (v); + WFD_READ_UINT32_DIGIT (msg->video_status->vid_bufsize); + WFD_SKIP_SPACE (v); + WFD_READ_UINT64_DIGIT (msg->video_status->vid_pts); + } } return; } @@ -1106,6 +1156,24 @@ gst_wfd_message_as_text (const GstWFDMessage * msg) g_string_append_printf (lines, "\r\n"); } + if (msg->tcp_ports) { + g_string_append_printf (lines, GST_STRING_WFD2_TCP_PORTS); + if (msg->tcp_ports->profile) { + g_string_append_printf (lines, ":"); + g_string_append_printf (lines, " %s", msg->tcp_ports->profile); + g_string_append_printf (lines, " %d", msg->tcp_ports->rtp_port0); + g_string_append_printf (lines, " %d", msg->tcp_ports->rtp_port1); + g_string_append_printf (lines, " %s", msg->tcp_ports->mode); + } + g_string_append_printf (lines, "\r\n"); + } + + if (msg->buf_len) { + g_string_append_printf (lines, GST_STRING_WFD2_BUFFER_LEN); + g_string_append_printf (lines, ":"); + g_string_append_printf (lines, " %d", msg->buf_len->buf_len); + g_string_append_printf (lines, "\r\n"); + } return g_string_free (lines, FALSE); } @@ -1189,6 +1257,22 @@ gst_wfd_message_param_names_as_text (const GstWFDMessage * msg) g_string_append_printf (lines, GST_STRING_WFD_IDR_REQUEST); g_string_append_printf (lines, "\r\n"); } + if (msg->tcp_ports) { + g_string_append_printf (lines, GST_STRING_WFD2_TCP_PORTS); + g_string_append_printf (lines, "\r\n"); + } + if (msg->buf_len) { + g_string_append_printf (lines, GST_STRING_WFD2_BUFFER_LEN); + g_string_append_printf (lines, "\r\n"); + } + if (msg->audio_status) { + g_string_append_printf (lines, GST_STRING_WFD2_AUDIO_STATUS); + g_string_append_printf (lines, "\r\n"); + } + if (msg->video_status) { + g_string_append_printf (lines, GST_STRING_WFD2_VIDEO_STATUS); + g_string_append_printf (lines, "\r\n"); + } return g_string_free (lines, FALSE); } @@ -1383,6 +1467,35 @@ gst_wfd_message_dump (const GstWFDMessage * msg) g_print (GST_STRING_WFD_IDR_REQUEST); g_print ("\r\n"); } + if (msg->tcp_ports) { + g_print (" TCP Ports : \n"); + if (msg->tcp_ports->profile) { + g_print ("%s\n", msg->tcp_ports->profile); + g_print (" %d\n", msg->tcp_ports->rtp_port0); + g_print (" %d\n", msg->tcp_ports->rtp_port1); + g_print (" %s\n", msg->tcp_ports->mode); + } + g_print ("\r\n"); + } + + if (msg->buf_len) { + g_print (" Buffer Length : %d\n", msg->buf_len->buf_len); + g_print ("\r\n"); + } + + if (msg->audio_status) { + g_print ("Audio Playback Status : \n"); + g_print (" Current audio buffer size : %d\n", msg->audio_status->aud_bufsize); + g_print (" Current audio decoded PTS : %lld\n", msg->audio_status->aud_pts); + g_print ("\r\n"); + } + + if (msg->video_status) { + g_print ("Video Playback Status : \n"); + g_print (" Current video buffer size : %d\n", msg->video_status->vid_bufsize); + g_print (" Current video decoded PTS : %lld\n", msg->video_status->vid_pts); + g_print ("\r\n"); + } return GST_WFD_OK; } @@ -1982,3 +2095,130 @@ gst_wfd_message_get_av_format_change_timing (GstWFDMessage * msg, guint64 * PTS, return GST_WFD_OK; } +GstWFDResult +gst_wfd_messge_set_prefered_tcp_ports (GstWFDMessage *msg, + GstWFDRTSPTransMode trans, + GstWFDRTSPProfile profile, + GstWFDRTSPLowerTrans lowertrans, + guint32 rtp_port0, + guint32 rtp_port1) +{ + GString *lines; + g_return_val_if_fail (msg != NULL, GST_WFD_EINVAL); + + if (!msg->tcp_ports) + msg->tcp_ports = g_new0 (GstWFDTCPPorts, 1); + + if (trans != GST_WFD_RTSP_TRANS_UNKNOWN) { + lines = g_string_new (""); + if (trans == GST_WFD_RTSP_TRANS_RTP) + g_string_append_printf (lines, "RTP"); + else if (trans == GST_WFD_RTSP_TRANS_RDT) + g_string_append_printf (lines, "RDT"); + + if (profile == GST_WFD_RTSP_PROFILE_AVP) + g_string_append_printf (lines, "/AVP"); + else if (profile == GST_WFD_RTSP_PROFILE_SAVP) + g_string_append_printf (lines, "/SAVP"); + + if (lowertrans == GST_WFD_RTSP_LOWER_TRANS_UDP) + g_string_append_printf (lines, "/UDP;unicast"); + else if (lowertrans == GST_WFD_RTSP_LOWER_TRANS_UDP_MCAST) + g_string_append_printf (lines, "/UDP;multicast"); + else if (lowertrans == GST_WFD_RTSP_LOWER_TRANS_TCP) + g_string_append_printf (lines, "/TCP;unicast"); + else if (lowertrans == GST_WFD_RTSP_LOWER_TRANS_HTTP) + g_string_append_printf (lines, "/HTTP"); + + msg->tcp_ports->profile = g_string_free (lines, FALSE); + msg->tcp_ports->rtp_port0 = rtp_port0; + msg->tcp_ports->rtp_port1 = rtp_port1; + msg->tcp_ports->mode = g_strdup ("mode=play"); + } + return GST_WFD_OK; +} + +GstWFDResult +gst_wfd_message_get_prefered_tcp_ports (GstWFDMessage *msg, + GstWFDRTSPTransMode *trans, + GstWFDRTSPProfile *profile, + GstWFDRTSPLowerTrans *lowertrans, + guint32 *rtp_port0, + guint32 *rtp_port1) +{ + g_return_val_if_fail (msg != NULL, GST_WFD_EINVAL); + g_return_val_if_fail (msg->tcp_ports != NULL, GST_WFD_EINVAL); + + if (g_strrstr (msg->tcp_ports->profile, "RTP")) + *trans = GST_WFD_RTSP_TRANS_RTP; + if (g_strrstr (msg->tcp_ports->profile, "RDT")) + *trans = GST_WFD_RTSP_TRANS_RDT; + if (g_strrstr (msg->tcp_ports->profile, "AVP")) + *profile = GST_WFD_RTSP_PROFILE_AVP; + if (g_strrstr (msg->tcp_ports->profile, "SAVP")) + *profile = GST_WFD_RTSP_PROFILE_SAVP; + if (g_strrstr (msg->tcp_ports->profile, "UDP;unicast")) + *lowertrans = GST_WFD_RTSP_LOWER_TRANS_UDP; + if (g_strrstr (msg->tcp_ports->profile, "UDP;multicast")) + *lowertrans = GST_WFD_RTSP_LOWER_TRANS_UDP_MCAST; + if (g_strrstr (msg->tcp_ports->profile, "TCP;unicast")) + *lowertrans = GST_WFD_RTSP_LOWER_TRANS_TCP; + if (g_strrstr (msg->tcp_ports->profile, "HTTP")) + *lowertrans = GST_WFD_RTSP_LOWER_TRANS_HTTP; + + *rtp_port0 = msg->tcp_ports->rtp_port0; + *rtp_port1 = msg->tcp_ports->rtp_port1; + + return GST_WFD_OK; +} + +GstWFDResult +gst_wfd_message_set_buffer_length (GstWFDMessage *msg, guint buf_len) +{ + g_return_val_if_fail (msg != NULL, GST_WFD_EINVAL); + + if (!msg->buf_len) + msg->buf_len = g_new0 (GstWFDBufferLen, 1); + msg->buf_len->buf_len = buf_len; + + return GST_WFD_OK; +} + +GstWFDResult +gst_wfd_message_get_buffer_length (GstWFDMessage *msg, guint *buf_len) +{ + g_return_val_if_fail (msg != NULL, GST_WFD_EINVAL); + g_return_val_if_fail (msg->buf_len != NULL, GST_WFD_EINVAL); + + *buf_len = msg->buf_len->buf_len; + + return GST_WFD_OK; +} + +GstWFDResult +gst_wfd_message_get_audio_playback_status (GstWFDMessage *msg, + guint *bufsize, + guint64 *pts) +{ + g_return_val_if_fail (msg != NULL, GST_WFD_EINVAL); + g_return_val_if_fail (msg->audio_status != NULL, GST_WFD_EINVAL); + + *bufsize = msg->audio_status->aud_bufsize; + *pts = msg->audio_status->aud_pts; + + return GST_WFD_OK; +} + +GstWFDResult +gst_wfd_message_get_video_playback_status (GstWFDMessage *msg, + guint *bufsize, + guint64 *pts) +{ + g_return_val_if_fail (msg != NULL, GST_WFD_EINVAL); + g_return_val_if_fail (msg->video_status != NULL, GST_WFD_EINVAL); + + *bufsize = msg->video_status->vid_bufsize; + *pts = msg->video_status->vid_pts; + + return GST_WFD_OK; +} diff --git a/gst/rtsp-server/gstwfdmessage.h b/gst/rtsp-server/gstwfdmessage.h old mode 100644 new mode 100755 index b390ef3..5a64696 --- a/gst/rtsp-server/gstwfdmessage.h +++ b/gst/rtsp-server/gstwfdmessage.h @@ -66,6 +66,10 @@ G_BEGIN_DECLS #define GST_STRING_WFD_CONNECTOR_TYPE "wfd_connector_type" #define GST_STRING_WFD_IDR_REQUEST "wfd_idr_request" +#define GST_STRING_WFD2_TCP_PORTS "wfd2_tcp_ports" +#define GST_STRING_WFD2_BUFFER_LEN "wfd2_buffer_len" +#define GST_STRING_WFD2_AUDIO_STATUS "wfd2_audio_playback_status" +#define GST_STRING_WFD2_VIDEO_STATUS "wfd2_video_playback_status" /** * GstWFDResult: * @GST_WFD_OK: A successful return value @@ -422,6 +426,26 @@ typedef struct { gboolean idr_request; } GstWFDIdrRequest; +typedef struct { + gchar *profile; + guint32 rtp_port0; + guint32 rtp_port1; + gchar *mode; +} GstWFDTCPPorts; + +typedef struct { + guint buf_len; +} GstWFDBufferLen; + +typedef struct { + guint aud_bufsize; + guint64 aud_pts; +} GstWFDAudioReport; + +typedef struct { + guint vid_bufsize; + guint64 vid_pts; +} GstWFDVideoReport; /** * GstWFDMessage: * @version: the protocol version @@ -459,6 +483,10 @@ typedef struct { GstWFDStandby *standby; GstWFDConnectorType *connector_type; GstWFDIdrRequest *idr_request; + GstWFDTCPPorts *tcp_ports; + GstWFDBufferLen *buf_len; + GstWFDAudioReport *audio_status; + GstWFDVideoReport *video_status; } GstWFDMessage; GType gst_wfd_message_get_type (void); @@ -613,6 +641,33 @@ GstWFDResult gst_wfd_message_set_av_format_change_timing(GstWFDMessage *msg, GstWFDResult gst_wfd_message_get_av_format_change_timing(GstWFDMessage *msg, guint64 *PTS, guint64 *DTS); +GstWFDResult gst_wfd_messge_set_prefered_tcp_ports (GstWFDMessage *msg, + GstWFDRTSPTransMode trans, + GstWFDRTSPProfile profile, + GstWFDRTSPLowerTrans lowertrans, + guint32 rtp_port0, + guint32 rtp_port1); + +GstWFDResult gst_wfd_message_get_prefered_tcp_ports (GstWFDMessage *msg, + GstWFDRTSPTransMode *trans, + GstWFDRTSPProfile *profile, + GstWFDRTSPLowerTrans *lowertrans, + guint32 *rtp_port0, + guint32 *rtp_port1); + +GstWFDResult gst_wfd_message_set_buffer_length (GstWFDMessage *msg, + guint buf_len); + +GstWFDResult gst_wfd_message_get_buffer_length (GstWFDMessage *msg, + guint *buf_len); + +GstWFDResult gst_wfd_message_get_audio_playback_status (GstWFDMessage *msg, + guint *bufsize, + guint64 *pts); + +GstWFDResult gst_wfd_message_get_video_playback_status (GstWFDMessage *msg, + guint *bufsize, + guint64 *pts); G_END_DECLS #endif /* __GST_WFD_MESSAGE_H__ */ diff --git a/gst/rtsp-server/rtsp-client-wfd.c b/gst/rtsp-server/rtsp-client-wfd.c old mode 100755 new mode 100644 index 6e5729a..55c32d7 --- a/gst/rtsp-server/rtsp-client-wfd.c +++ b/gst/rtsp-server/rtsp-client-wfd.c @@ -41,6 +41,11 @@ #include #include +#include +#include +#include +#include +#include #include "rtsp-client-wfd.h" #include "rtsp-media-factory-wfd.h" @@ -71,6 +76,16 @@ struct _GstRTSPClientRTPStats guint resent_packets; }; +typedef enum { + WFD_TS_UDP, + WFD_TS_TCP +} WFDTSMode; + +typedef enum { + WFD_TS_REP_AUDIO, + WFD_TS_REP_VIDEO +} WFDTSReportType; + struct _GstRTSPWFDClientPrivate { GstRTSPWFDClientSendFunc send_func; /* protected by send_lock */ @@ -141,6 +156,19 @@ struct _GstRTSPWFDClientPrivate gboolean rtcp_stats_enabled; gchar *sink_user_agent; + guint ctrans_tcp; + guint cprofile_tcp; + guint clowertrans_tcp; + guint32 crtp_port0_tcp; + guint32 crtp_port1_tcp; + guint buf_len; + WFDTSMode ts_mode; + WFDTSReportType report_type; + GstRTSPWatch *datawatch; + guint datawatchid; + GstRTSPConnection *data_conn; + gchar *uristr; + GMutex tcp_send_lock; }; #define DEFAULT_WFD_TIMEOUT 60 @@ -323,6 +351,9 @@ gst_rtsp_wfd_client_init (GstRTSPWFDClient * client) memset (&priv->stats, 0x00, sizeof (GstRTSPClientRTPStats)); priv->sink_user_agent = NULL; + priv->ts_mode = WFD_TS_UDP; + priv->report_type = WFD_TS_REP_AUDIO; + g_mutex_init (&priv->tcp_send_lock); GST_INFO_OBJECT (client, "Client is initialized"); } @@ -351,6 +382,7 @@ gst_rtsp_wfd_client_finalize (GObject * obj) g_mutex_clear (&priv->keep_alive_lock); g_mutex_clear (&priv->stats_lock); + g_mutex_clear (&priv->tcp_send_lock); G_OBJECT_CLASS (gst_rtsp_wfd_client_parent_class)->finalize (obj); } @@ -499,6 +531,10 @@ static gboolean wfd_configure_client_media (GstRTSPClient * client, GstRTSPMedia * media, GstRTSPStream * stream, GstRTSPContext * ctx) { + if (media) { + GstRTSPWFDClientPrivate *priv = GST_RTSP_WFD_CLIENT_GET_PRIVATE (client); + priv->media = media; + } if (stream) { GstRTSPWFDClientPrivate *priv = GST_RTSP_WFD_CLIENT_GET_PRIVATE (client); if (priv) @@ -1008,6 +1044,378 @@ handle_wfd_play (GstRTSPClient * client, GstRTSPContext * ctx) gst_rtsp_client_wfd_signals[SIGNAL_WFD_PLAYING_DONE], 0, NULL); } +static gboolean +do_send_data (GstBuffer * buffer, guint8 channel, GstRTSPClient * client) +{ + GstRTSPMessage message = { 0 }; + GstRTSPResult res = GST_RTSP_OK; + GstMapInfo map_info; + guint8 *data; + guint usize; + + gst_rtsp_message_init_data (&message, channel); + + /* FIXME, need some sort of iovec RTSPMessage here */ + if (!gst_buffer_map (buffer, &map_info, GST_MAP_READ)) + return FALSE; + + gst_rtsp_message_take_body (&message, map_info.data, map_info.size); + + g_mutex_lock (&(GST_RTSP_WFD_CLIENT (client)->priv->tcp_send_lock)); + + gst_rtsp_watch_send_message (GST_RTSP_WFD_CLIENT (client)->priv->datawatch, &message, NULL); + + g_mutex_unlock (&(GST_RTSP_WFD_CLIENT (client)->priv->tcp_send_lock)); + + gst_rtsp_message_steal_body (&message, &data, &usize); + gst_buffer_unmap (buffer, &map_info); + + gst_rtsp_message_unset (&message); + + return res == GST_RTSP_OK; +} +static GstRTSPResult +message_received (GstRTSPWatch * watch, GstRTSPMessage * message, + gpointer user_data) +{ + return gst_rtsp_client_handle_message (GST_RTSP_CLIENT (user_data), message); +} + +static GstRTSPResult +message_sent (GstRTSPWatch * watch, guint cseq, gpointer user_data) +{ + GstRTSPClient *client; + + client = GST_RTSP_CLIENT (user_data); + if(client == NULL) + return GST_RTSP_ERROR; + return GST_RTSP_OK; +} + +static GstRTSPResult +error (GstRTSPWatch * watch, GstRTSPResult result, gpointer user_data) +{ + GstRTSPClient *client = GST_RTSP_CLIENT (user_data); + gchar *str; + + str = gst_rtsp_strresult (result); + GST_INFO ("client %p: received an error %s", client, str); + g_free (str); + + return GST_RTSP_OK; +} +static GstRTSPResult +closed_tcp (GstRTSPWatch * watch, gpointer user_data) +{ + GstRTSPClient *client = GST_RTSP_CLIENT (user_data); + + GST_INFO ("client %p: connection closed", client); + + return GST_RTSP_OK; +} + +static GstRTSPResult +error_full_tcp (GstRTSPWatch * watch, GstRTSPResult result, + GstRTSPMessage * message, guint id, gpointer user_data) +{ + GstRTSPClient *client = GST_RTSP_CLIENT (user_data); + gchar *str; + + str = gst_rtsp_strresult (result); + GST_INFO + ("client %p: received an error %s when handling message %p with id %d", + client, str, message, id); + g_free (str); + + return GST_RTSP_OK; +} + +static GstRTSPWatchFuncs watch_funcs_tcp = { + message_received, + message_sent, + closed_tcp, + error, + NULL, + NULL, + error_full_tcp, + NULL +}; +static void +client_watch_notify_tcp (GstRTSPClient * client) +{ + GST_INFO ("client %p: watch destroyed", client); + GST_RTSP_WFD_CLIENT (client)->priv->datawatch = NULL; + GST_RTSP_WFD_CLIENT (client)->priv->data_conn = NULL; +} + +static GstRTSPResult +new_tcp (GstRTSPWFDClient * client) +{ + int fd; + GstRTSPResult res = GST_RTSP_OK; + GstRTSPConnection *conn = NULL; + GstRTSPConnection *parent_conn = NULL; + GstRTSPUrl *url; + guint64 timeout = 20000000; + struct sockaddr_in server_addr; + socklen_t sin_len; + GSource *source; + GMainContext *context; + int retry = 0; + int bsize = 1024000; + int rn = sizeof(int); + int state = 1; + GSocket *tcp = NULL; + + struct sockaddr_in my_addr; + /* client's address */ + gint sockoptval = 1; + int ret; + GSocketAddress *local; + + /* Get the client connection details */ + parent_conn = gst_rtsp_client_get_connection (GST_RTSP_CLIENT (client)); + url = gst_rtsp_connection_get_url (parent_conn); + if(!url) + return GST_RTSP_ERROR; + + gst_rtsp_url_set_port (url, client->priv->crtp_port0_tcp); + + GST_INFO ("create new connection %p ip %s:%d", client, url->host, url->port); + + /* create a TCP/IP socket */ + if ((tcp = g_socket_new (AF_INET, SOCK_STREAM, 0, NULL)) == NULL) { + GST_ERROR ("cannot create socket"); + return GST_RTSP_ERROR; + } + /* allow immediate reuse of the port */ + ret = g_socket_set_option (tcp, SOL_SOCKET, SO_REUSEADDR, sockoptval, NULL); + if(ret == 0) + { + GST_ERROR ("cannot change socket options"); + return GST_RTSP_ERROR; + } + /* bind the socket to our source address */ + memset ((char*)&my_addr, 0, sizeof(my_addr)); + /* 0 out the structure */ + my_addr.sin_family = AF_INET; + /* address family */ + my_addr.sin_port = htons (url->port); + my_addr.sin_addr.s_addr = inet_addr(url->host); + + local = g_socket_address_new_from_native (&my_addr, sizeof(my_addr)); + + g_socket_set_blocking (tcp, FALSE); + +tcp_retry: + if ((g_socket_connect (tcp, local, NULL, NULL))) { + g_print( "Error connecting socket : %s\n", strerror( errno ) ); + if (retry < 50) { + GST_ERROR("Connection failed... Try again..."); + usleep(100000); + retry++; + goto tcp_retry; + } + + return GST_RTSP_ERROR; + } + + if ((res = gst_rtsp_connection_create_from_socket (tcp, url->host, url->port, NULL, &conn)) < 0) + return GST_RTSP_ERROR; + + GST_DEBUG_OBJECT (client, "Able to connect to new port"); + + sin_len = sizeof(struct sockaddr); + fd = g_socket_get_fd (gst_rtsp_connection_get_read_socket (conn)); + if (fd == -1) { + return GST_RTSP_EINVAL; + } + + if (getsockname (fd, (struct sockaddr *)&server_addr, &sin_len) < 0) { + GST_ERROR_OBJECT (client, "Getsockname fail"); + close(fd); + return GST_RTSP_ERROR; + } + + GST_DEBUG_OBJECT (client, "New port created : %d", ntohs(server_addr.sin_port)); + + /* Set send buffer size to 5242880 */ + if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bsize, (socklen_t)rn) < 0) { + GST_ERROR_OBJECT(client, "setsockopt failed"); + } else { + getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bsize, (socklen_t *)&rn); + GST_WARNING_OBJECT(client, "New Send buf size : %d\n", bsize); + } + + if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &state, sizeof(state)) < 0) { + GST_ERROR_OBJECT(client, "setsockopt failed"); + } else { + GST_WARNING_OBJECT(client, "TCP NO DELAY"); + } + + client->priv->data_conn = conn; + + /* create watch for the connection and attach */ + client->priv->datawatch = gst_rtsp_watch_new (client->priv->data_conn, &watch_funcs_tcp, client, (GDestroyNotify) client_watch_notify_tcp); + GST_DEBUG_OBJECT (client, "data watch : %p", client->priv->datawatch); + /* find the context to add the watch */ + if ((source = g_main_current_source ())) + context = g_source_get_context (source); + else + context = NULL; + + GST_DEBUG (" source = %p", source); + GST_INFO ("attaching to context %p", context); + client->priv->datawatchid = gst_rtsp_watch_attach (client->priv->datawatch, context); + gst_rtsp_watch_unref (client->priv->datawatch); + return res; +} + +static void +do_keepalive (GstRTSPSession * session) +{ + GST_INFO ("keep session %p alive", session); + gst_rtsp_session_touch (session); +} +static void +map_transport (GstRTSPWFDClient * client, GstRTSPTransport * ct) +{ + switch(client->priv->ctrans) { + case GST_WFD_RTSP_TRANS_RTP: + ct->trans = GST_RTSP_TRANS_RTP; + break; + case GST_WFD_RTSP_TRANS_RDT: + ct->trans = GST_RTSP_TRANS_RDT; + break; + default: + ct->trans = GST_RTSP_TRANS_UNKNOWN; + break; + } + switch(client->priv->cprofile) { + case GST_WFD_RTSP_PROFILE_AVP: + ct->profile = GST_RTSP_PROFILE_AVP; + break; + case GST_WFD_RTSP_PROFILE_SAVP: + ct->profile = GST_RTSP_PROFILE_SAVP; + break; + default: + ct->profile = GST_RTSP_PROFILE_UNKNOWN; + break; + } + switch(client->priv->clowertrans) { + case GST_WFD_RTSP_LOWER_TRANS_UDP: + ct->lower_transport = GST_RTSP_LOWER_TRANS_UDP; + break; + case GST_WFD_RTSP_LOWER_TRANS_UDP_MCAST: + ct->lower_transport = GST_RTSP_LOWER_TRANS_UDP_MCAST; + break; + case GST_WFD_RTSP_LOWER_TRANS_TCP: + ct->lower_transport = GST_RTSP_LOWER_TRANS_TCP; + break; + case GST_WFD_RTSP_LOWER_TRANS_HTTP: + ct->lower_transport = GST_RTSP_LOWER_TRANS_HTTP; + break; + default: + ct->lower_transport = GST_RTSP_LOWER_TRANS_UNKNOWN; + break; + } + + if (client->priv->ts_mode == WFD_TS_TCP) + ct->lower_transport = GST_RTSP_LOWER_TRANS_TCP; +} + +static GstRTSPResult +handle_ts_response (GstRTSPWFDClient * client, GstRTSPContext * ctx) +{ + GstRTSPResult res = GST_RTSP_OK; + GstRTSPTransport *ct; + GstRTSPConnection *conn; + GstRTSPUrl *url = NULL; + GList *t = NULL; + GstRTSPStreamTransport *tr = NULL; + GPtrArray *ta = NULL; + + ta = g_ptr_array_new(); + + t = client->priv->transports; + tr = GST_RTSP_STREAM_TRANSPORT (t->data); + g_ptr_array_add (ta, t->data); + + gst_rtsp_stream_transport_set_callbacks (tr, NULL, NULL, NULL, NULL); + gst_rtsp_stream_transport_set_keepalive (tr, NULL, ctx->session, NULL); + + gst_rtsp_transport_new (&ct); + gst_rtsp_transport_init (ct); + + map_transport (client, ct); + + if (ct->trans != GST_RTSP_TRANS_RTP || ct->profile != GST_RTSP_PROFILE_AVP) { + GST_WARNING_OBJECT (client, "Trans or profile is wrong"); + goto error; + } + if (ct->lower_transport == GST_RTSP_LOWER_TRANS_HTTP || + ct->lower_transport == GST_RTSP_LOWER_TRANS_UNKNOWN) { + GST_WARNING_OBJECT (client, "Lowertrans is wrong"); + goto error; + } + g_free (ct->destination); + if (client->priv->ts_mode == WFD_TS_UDP) { + g_print ("\nSwitched to UDP !!!\n"); + /* Free any previous TCP connection */ + if(client->priv->data_conn) + { + gst_rtsp_connection_close (client->priv->data_conn); + gst_rtsp_connection_free(client->priv->data_conn); + if (client->priv->datawatch) { + g_source_destroy ((GSource *)client->priv->datawatch); + } + } + conn = gst_rtsp_client_get_connection (GST_RTSP_CLIENT (client)); + url = gst_rtsp_connection_get_url (conn); + gst_rtsp_url_set_port (url, client->priv->crtp_port0); + ct->destination = g_strdup (url->host); + ct->client_port.min = client->priv->crtp_port0; + if(client->priv->crtp_port1 == 0) + ct->client_port.max = client->priv->crtp_port0 + 1; + else ct->client_port.max = client->priv->crtp_port1; + } else if (client->priv->ts_mode == WFD_TS_TCP) { + res = new_tcp(client); + if(res != GST_RTSP_OK) + goto error; + + conn = gst_rtsp_client_get_connection (GST_RTSP_CLIENT (client)); + url = gst_rtsp_connection_get_url (conn); + ct->destination = g_strdup (url->host); + ct->client_port.min = client->priv->crtp_port0_tcp; + if(client->priv->crtp_port1_tcp == 0) + ct->client_port.max = client->priv->crtp_port0_tcp + 1; + else ct->client_port.max = client->priv->crtp_port1_tcp; + } + + gst_rtsp_stream_transport_set_transport (tr, ct); + + GST_DEBUG ("client %p: linking transport", client); + if (client->priv->ts_mode == WFD_TS_TCP) { + g_print ("\nSwitched to TCP !!!\n"); + gst_rtsp_stream_transport_set_callbacks (tr, (GstRTSPSendFunc) do_send_data, + (GstRTSPSendFunc) do_send_data, client, NULL); + } + else if(client->priv->ts_mode == WFD_TS_UDP ) { + g_print ("\nSwitched to UDP !!!\n"); + /* configure keepalive for this transport */ + gst_rtsp_stream_transport_set_keepalive (tr, (GstRTSPKeepAliveFunc) do_keepalive, ctx->session, NULL); + gst_rtsp_stream_transport_set_callbacks (tr, NULL, NULL, client, NULL); + } + + gst_rtsp_media_set_state (client->priv->media, GST_STATE_PLAYING, ta); + + g_ptr_array_free (ta, FALSE); + + return res; + +error: + return GST_RTSP_ERROR; +} static void handle_wfd_response (GstRTSPClient * client, GstRTSPContext * ctx) { @@ -1111,6 +1519,28 @@ handle_wfd_response (GstRTSPClient * client, GstRTSPContext * ctx) goto error; } } + if (msg->tcp_ports) { + /* Get the TCP ports preferred by WFDSink */ + wfd_res = + gst_wfd_message_get_prefered_tcp_ports (msg, &priv->ctrans_tcp, + &priv->cprofile_tcp, &priv->clowertrans_tcp, &priv->crtp_port0_tcp, + &priv->crtp_port1_tcp); + if (wfd_res != GST_WFD_OK) { + GST_WARNING_OBJECT (client, + "Failed to get wfd prefered RTP ports..."); + goto error; + } + } + + if (msg->buf_len) { + wfd_res = + gst_wfd_message_get_buffer_length (msg, &priv->buf_len); + if (wfd_res != GST_WFD_OK) { + GST_WARNING_OBJECT (client, + "Failed to get wfd prefered RTP ports..."); + goto error; + } + } if (msg->display_edid) { guint32 edid_block_count = 0; @@ -1176,6 +1606,41 @@ handle_wfd_response (GstRTSPClient * client, GstRTSPContext * ctx) gst_rtsp_client_wfd_signals[SIGNAL_WFD_GET_PARAMETER_REQUEST], 0, ctx); } else { + if (g_strrstr((char *)data, "wfd2_buffer_len")) { + GstWFDResult wfd_res; + GstWFDMessage *msg = NULL; + GST_DEBUG_OBJECT (_client, "Get TS message responce"); + + /* Parse TS response from sink */ + wfd_res = gst_wfd_message_new (&msg); + if (wfd_res != GST_WFD_OK) { + GST_ERROR_OBJECT (client, "Failed to create wfd message..."); + goto error; + } + + wfd_res = gst_wfd_message_init (msg); + if (wfd_res != GST_WFD_OK) { + GST_ERROR_OBJECT (client, "Failed to init wfd message..."); + goto error; + } + + wfd_res = gst_wfd_message_parse_buffer (data, size, msg); + if (wfd_res != GST_WFD_OK) { + GST_ERROR_OBJECT (client, "Failed to parse wfd message..."); + goto error; + } + + wfd_res = gst_wfd_message_get_buffer_length (msg, &_client->priv->buf_len); + if (wfd_res != GST_WFD_OK) { + GST_ERROR_OBJECT (client, "Failed to parse wfd message..."); + goto error; + } + + if (GST_RTSP_OK != handle_ts_response (_client, ctx)) { + GST_ERROR_OBJECT (client, "Failed to handle transport switch response"); + goto error; + } + } /* TODO-WFD: Handle another GET_PARAMETER response with body */ } } else if (size == 0) { @@ -1431,6 +1896,8 @@ typedef enum TEARDOWN_TRIGGER, PLAY_TRIGGER, PAUSE_TRIGGER, + TS_REQ_MSG, + TS_REP_REQ_MSG, } GstWFDMessageType; static gboolean @@ -1605,6 +2072,24 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, goto error; } + /* set the preffered TCP ports for the WFD server */ + wfd_res = + gst_wfd_messge_set_prefered_tcp_ports (msg, GST_WFD_RTSP_TRANS_RTP, + GST_WFD_RTSP_PROFILE_AVP, GST_WFD_RTSP_LOWER_TRANS_UDP, priv->crtp_port0, priv->crtp_port1); + if (wfd_res != GST_WFD_OK) { + GST_ERROR_OBJECT (client, + "Failed to set tcp ports parameter on wfd message..."); + goto error; + } + + /* set the buffer length for the WFD server */ + wfd_res = + gst_wfd_message_set_buffer_length (msg, 0); + if (wfd_res != GST_WFD_OK) { + GST_ERROR_OBJECT (client, + "Failed to set tcp ports 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..."); @@ -1794,6 +2279,69 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, GST_ERROR_OBJECT (client, "Failed to get wfd message as text..."); goto error; } else { + *len = strlen (*data); + } + + } else if (msg_type == TS_REQ_MSG) { + /* create transport switch request to be sent */ + wfd_res = gst_wfd_message_new (&msg); + if (wfd_res != GST_WFD_OK) { + GST_ERROR_OBJECT (client, "Failed to create wfd message..."); + goto error; + } + + wfd_res = gst_wfd_message_init (msg); + if (wfd_res != GST_WFD_OK) { + GST_ERROR_OBJECT (client, "Failed to init wfd message..."); + goto error; + } + + g_string_append_printf (buf, "rtsp://"); + + if (priv->host_address) { + g_string_append (buf, priv->host_address); + } else { + GST_ERROR_OBJECT (client, "Failed to get host address"); + if (buf) g_string_free (buf, TRUE); + goto error; + } + + g_string_append_printf (buf, "/wfd1.0/streamid=0"); + + /* set the preffered TCP ports for the WFD server */ + if (priv->ts_mode == WFD_TS_UDP) { + wfd_res = + gst_wfd_messge_set_prefered_rtp_ports (msg, GST_WFD_RTSP_TRANS_RTP, + GST_WFD_RTSP_PROFILE_AVP, GST_WFD_RTSP_LOWER_TRANS_UDP, priv->crtp_port0, priv->crtp_port1); + if (wfd_res != GST_WFD_OK) { + GST_ERROR_OBJECT (client, + "Failed to set prefered RTP ports on wfd message..."); + goto error; + } + } else { + wfd_res = + gst_wfd_messge_set_prefered_tcp_ports (msg, GST_WFD_RTSP_TRANS_RTP, + GST_WFD_RTSP_PROFILE_AVP, GST_WFD_RTSP_LOWER_TRANS_TCP, priv->crtp_port0_tcp, priv->crtp_port1_tcp); + if (wfd_res != GST_WFD_OK) { + GST_ERROR_OBJECT (client, + "Failed to set prefered TCP ports on wfd message..."); + goto error; + } + } + + wfd_res = + gst_wfd_message_set_buffer_length (msg, 200); + if (wfd_res != GST_WFD_OK) { + GST_ERROR_OBJECT (client, + "Failed to set prefered buffer length on wfd message..."); + goto error; + } + + *data = gst_wfd_message_as_text (msg); + if (*data == NULL) { + GST_ERROR_OBJECT (client, "Failed to get wfd message as text..."); + goto error; + } else { gchar *append_data = NULL; g_signal_emit (client, @@ -3102,8 +3650,157 @@ gst_rtsp_wfd_client_set_rtp_port1 (GstRTSPWFDClient * client, guint32 port) priv->crtp_port1 = port; } -gchar * -gst_rtsp_wfd_client_get_sink_user_agent (GstRTSPWFDClient * client) + +/** +* prepare_transport_switch_request: +* @client: client object +* @request : requst message to be prepared +* @url : url need to be in the request +* +* Prepares request based on @method & @message_type +* +* Returns: a #GstRTSPResult. +*/ +static GstRTSPResult +prepare_transport_switch_request (GstRTSPWFDClient * client, GstRTSPMessage * request) +{ + GstRTSPResult res = GST_RTSP_OK; + gchar *url = NULL; + gchar *msg = NULL; + guint msglen = 0; + GString *msglength; + + GstRTSPMethod method = GST_RTSP_SET_PARAMETER; + + url = g_strdup ("rtsp://localhost/wfd1.0"); + + GST_DEBUG_OBJECT (client, "Preparing request for transport switch"); + + /* initialize the request */ + res = gst_rtsp_message_init_request (request, method, url); + if (res < 0) { + GST_ERROR ("init request failed"); + return res; + } + + /* 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, TS_REQ_MSG, &msg, &msglen); + msglength = g_string_new (""); + g_string_append_printf (msglength, "%d", msglen); + GST_DEBUG ("Transport switch 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); + + return res; + +error: + return GST_RTSP_ERROR; +} + +GstRTSPResult +gst_rtsp_wfd_client_switch_to_udp (GstRTSPWFDClient * client) +{ + GstRTSPResult res = GST_RTSP_OK; + GstRTSPMessage request = { 0 }; + GList *tl = NULL; + GPtrArray *ta = NULL; + + ta = g_ptr_array_new(); + + tl = gst_rtsp_stream_transport_filter (client->priv->stats.stream, NULL, NULL); + client->priv->transports = tl; + g_ptr_array_add (ta, tl->data); + + if (client->priv->ts_mode == WFD_TS_UDP) { + GST_ERROR_OBJECT (client, "Transport already UDP"); + return res; + } + + client->priv->ts_mode = WFD_TS_UDP; + res = prepare_transport_switch_request (client, &request); + if (GST_RTSP_OK != res) { + GST_ERROR_OBJECT (client, "Failed to prepare transport switch request....\n"); + goto error; + } + + GST_DEBUG_OBJECT (client, "Sending SET_PARAMETER request message for transport switch..."); + + gst_send_request (client, NULL, &request); + + gst_rtsp_media_set_state (client->priv->media, GST_STATE_PAUSED, ta); + + g_ptr_array_free (ta, FALSE); + + return res; + +error: + return res; + +} + +GstRTSPResult +gst_rtsp_wfd_client_switch_to_tcp (GstRTSPWFDClient * client) +{ + GstRTSPResult res = GST_RTSP_OK; + GstRTSPMessage request = { 0 }; + GList *tl = NULL; + GPtrArray *ta = NULL; + + ta = g_ptr_array_new(); + + tl = gst_rtsp_stream_transport_filter (client->priv->stats.stream, NULL, NULL); + client->priv->transports = tl; + g_ptr_array_add (ta, tl->data); + + if (client->priv->ts_mode == WFD_TS_TCP) { + GST_ERROR_OBJECT (client, "Transport already TCP"); + return res; + } + + client->priv->ts_mode = WFD_TS_TCP; + res = prepare_transport_switch_request (client, &request); + if (GST_RTSP_OK != res) { + GST_ERROR_OBJECT (client, "Failed to prepare transport switch request....\n"); + goto error; + } + + GST_DEBUG_OBJECT (client, "Sending SET_PARAMETER request message for transport switch..."); + + gst_send_request (client, NULL, &request); + + gst_rtsp_media_set_state (client->priv->media, GST_STATE_PAUSED, ta); + + g_ptr_array_free (ta, FALSE); + + return res; + +error: + return res; +} +gchar * gst_rtsp_wfd_client_get_sink_user_agent (GstRTSPWFDClient * client) { char *str = NULL; GstRTSPWFDClientPrivate *priv = GST_RTSP_WFD_CLIENT_GET_PRIVATE (client); diff --git a/gst/rtsp-server/rtsp-client-wfd.h b/gst/rtsp-server/rtsp-client-wfd.h old mode 100644 new mode 100755 index f59835b..4d78382 --- a/gst/rtsp-server/rtsp-client-wfd.h +++ b/gst/rtsp-server/rtsp-client-wfd.h @@ -149,6 +149,8 @@ GstRTSPResult gst_prepare_request (GstRTSPWFDClient * client, GstRTSPMessage * request, GstRTSPMethod method, gchar * url); void gst_send_request (GstRTSPWFDClient * client, GstRTSPSession * session, GstRTSPMessage * request); +GstRTSPResult gst_rtsp_wfd_client_switch_to_udp (GstRTSPWFDClient * client); +GstRTSPResult gst_rtsp_wfd_client_switch_to_tcp (GstRTSPWFDClient * client); guint gst_rtsp_wfd_client_get_audio_codec(GstRTSPWFDClient *client); guint gst_rtsp_wfd_client_get_audio_freq(GstRTSPWFDClient *client); diff --git a/gst/rtsp-server/rtsp-server-wfd.c b/gst/rtsp-server/rtsp-server-wfd.c index 0fa2cd5..042ec3b 100644 --- a/gst/rtsp-server/rtsp-server-wfd.c +++ b/gst/rtsp-server/rtsp-server-wfd.c @@ -334,3 +334,61 @@ gst_rtsp_wfd_server_set_audio_codec (GstRTSPWFDServer * server, GST_RTSP_WFD_SERVER_UNLOCK (server); return res; } + +GstRTSPResult +gst_rtsp_wfd_server_switch_to_udp (GstRTSPWFDServer *server) +{ + GstRTSPResult res = GST_RTSP_OK; + GList *clients, *walk, *next; + + g_return_val_if_fail (GST_IS_RTSP_SERVER (server), GST_RTSP_ERROR); + + clients = gst_rtsp_server_client_filter (GST_RTSP_SERVER(server), NULL, NULL); + if (clients == NULL) { + GST_ERROR_OBJECT (server, "There is no client in this server"); + } + + for (walk = clients; walk; walk = next) { + GstRTSPClient *client = walk->data; + + next = g_list_next (walk); + + res = + gst_rtsp_wfd_client_switch_to_udp (GST_RTSP_WFD_CLIENT (client)); + if (res != GST_RTSP_OK) { + GST_ERROR_OBJECT (server, "Failed to switch transport to UDP"); + } + g_object_unref (client); + } + + return res; +} + +GstRTSPResult +gst_rtsp_wfd_server_switch_to_tcp (GstRTSPWFDServer *server) +{ + GstRTSPResult res = GST_RTSP_OK; + GList *clients, *walk, *next; + + g_return_val_if_fail (GST_IS_RTSP_SERVER (server), GST_RTSP_ERROR); + + clients = gst_rtsp_server_client_filter (GST_RTSP_SERVER(server), NULL, NULL); + if (clients == NULL) { + GST_ERROR_OBJECT (server, "There is no client in this server"); + } + + for (walk = clients; walk; walk = next) { + GstRTSPClient *client = walk->data; + + next = g_list_next (walk); + + res = + gst_rtsp_wfd_client_switch_to_tcp (GST_RTSP_WFD_CLIENT (client)); + if (res != GST_RTSP_OK) { + GST_ERROR_OBJECT (server, "Failed to switch transport to TCP"); + } + g_object_unref (client); + } + + return res; +} diff --git a/gst/rtsp-server/rtsp-server-wfd.h b/gst/rtsp-server/rtsp-server-wfd.h old mode 100644 new mode 100755 index e718e62..1666f18 --- a/gst/rtsp-server/rtsp-server-wfd.h +++ b/gst/rtsp-server/rtsp-server-wfd.h @@ -81,6 +81,8 @@ GstRTSPResult gst_rtsp_wfd_server_trigger_request (GstRTSPServer *s GstRTSPResult gst_rtsp_wfd_server_set_supported_reso (GstRTSPWFDServer *server, guint64 supported_reso); GstRTSPResult gst_rtsp_wfd_server_set_video_native_reso (GstRTSPWFDServer *server, guint64 native_reso); GstRTSPResult gst_rtsp_wfd_server_set_audio_codec (GstRTSPWFDServer *server, guint8 audio_codec); +GstRTSPResult gst_rtsp_wfd_server_switch_to_udp (GstRTSPWFDServer *server); +GstRTSPResult gst_rtsp_wfd_server_switch_to_tcp (GstRTSPWFDServer *server); #if 0 void gst_rtsp_server_set_address (GstRTSPServer *server, const gchar *address); diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index f73387c..d6ae977 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 3 +Release: 4 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4 From 363980e83ec3b1933a3d532bc907d68014d81872 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Wed, 30 Nov 2016 13:29:01 +0900 Subject: [PATCH 03/16] fix return value delete unused variable Signed-off-by: SeokHoon Lee Change-Id: I16b786adf29a582bd60ace505c033b309736950e --- gst/rtsp-server/rtsp-client-wfd.c | 1 - gst/rtsp-server/rtsp-media-ext.c | 4 ++-- packaging/gst-rtsp-server.spec | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/gst/rtsp-server/rtsp-client-wfd.c b/gst/rtsp-server/rtsp-client-wfd.c index 55c32d7..69741cf 100644 --- a/gst/rtsp-server/rtsp-client-wfd.c +++ b/gst/rtsp-server/rtsp-client-wfd.c @@ -1156,7 +1156,6 @@ new_tcp (GstRTSPWFDClient * client) GstRTSPConnection *conn = NULL; GstRTSPConnection *parent_conn = NULL; GstRTSPUrl *url; - guint64 timeout = 20000000; struct sockaddr_in server_addr; socklen_t sin_len; GSource *source; diff --git a/gst/rtsp-server/rtsp-media-ext.c b/gst/rtsp-server/rtsp-media-ext.c index d1d2ebe..10fb69d 100644 --- a/gst/rtsp-server/rtsp-media-ext.c +++ b/gst/rtsp-server/rtsp-media-ext.c @@ -707,10 +707,10 @@ gst_rtsp_media_ext_set_extended_mode (GstRTSPMediaExt * media, { GstRTSPMediaExtPrivate *priv; - g_return_val_if_fail (GST_IS_RTSP_MEDIA_EXT (media), 0); + g_return_if_fail (GST_IS_RTSP_MEDIA_EXT (media)); priv = media->priv; - g_return_val_if_fail (priv != NULL, 0); + g_return_if_fail (priv != NULL); priv->mode = mode; } diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index d6ae977..6d51203 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 4 +Release: 5 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4 From d6208d3b646f783620488f74359171ef04a92c09 Mon Sep 17 00:00:00 2001 From: "Hyunsoo, Park" Date: Wed, 30 Nov 2016 17:01:53 +0900 Subject: [PATCH 04/16] Modify spell 'prefered' to 'preferred' [Version] 1.6.1-6 [Profile] Common [Issue Type] Modify mispelling api name [Dependency module] N/A [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-mobile_20161111.1] Change-Id: Idd3494c5e93eb38cf9c614976f100f282374ed4c Signed-off-by: Hyunsoo, Park --- gst/rtsp-server/gstwfdmessage.c | 16 +++++++-------- gst/rtsp-server/gstwfdmessage.h | 16 +++++++-------- gst/rtsp-server/rtsp-client-wfd.c | 42 +++++++++++++++++++-------------------- packaging/gst-rtsp-server.spec | 2 +- 4 files changed, 38 insertions(+), 38 deletions(-) mode change 100644 => 100755 gst/rtsp-server/rtsp-client-wfd.c diff --git a/gst/rtsp-server/gstwfdmessage.c b/gst/rtsp-server/gstwfdmessage.c index 8d75982..1e7e042 100755 --- a/gst/rtsp-server/gstwfdmessage.c +++ b/gst/rtsp-server/gstwfdmessage.c @@ -1547,7 +1547,7 @@ gst_wfd_message_set_supported_audio_format (GstWFDMessage * msg, } GstWFDResult -gst_wfd_message_set_prefered_audio_format (GstWFDMessage * msg, +gst_wfd_message_set_preferred_audio_format (GstWFDMessage * msg, GstWFDAudioFormats a_codec, GstWFDAudioFreq a_freq, GstWFDAudioChannels a_channels, guint a_bitwidth, guint32 a_latency) @@ -1609,7 +1609,7 @@ gst_wfd_message_get_supported_audio_format (GstWFDMessage * msg, } GstWFDResult -gst_wfd_message_get_prefered_audio_format (GstWFDMessage * msg, +gst_wfd_message_get_preferred_audio_format (GstWFDMessage * msg, GstWFDAudioFormats * a_codec, GstWFDAudioFreq * a_freq, GstWFDAudioChannels * a_channels, guint * a_bitwidth, guint32 * a_latency) @@ -1699,7 +1699,7 @@ gst_wfd_message_set_supported_video_format (GstWFDMessage * msg, } GstWFDResult -gst_wfd_message_set_prefered_video_format (GstWFDMessage * msg, +gst_wfd_message_set_preferred_video_format (GstWFDMessage * msg, GstWFDVideoCodecs v_codec, GstWFDVideoNativeResolution v_native, guint64 v_native_resolution, @@ -1801,7 +1801,7 @@ gst_wfd_message_get_supported_video_format (GstWFDMessage * msg, } GstWFDResult -gst_wfd_message_get_prefered_video_format (GstWFDMessage * msg, +gst_wfd_message_get_preferred_video_format (GstWFDMessage * msg, GstWFDVideoCodecs * v_codec, GstWFDVideoNativeResolution * v_native, guint64 * v_native_resolution, @@ -1966,7 +1966,7 @@ gst_wfd_message_get_contentprotection_type (GstWFDMessage * msg, GstWFDResult -gst_wfd_messge_set_prefered_rtp_ports (GstWFDMessage * msg, +gst_wfd_messge_set_preferred_rtp_ports (GstWFDMessage * msg, GstWFDRTSPTransMode trans, GstWFDRTSPProfile profile, GstWFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1) @@ -2007,7 +2007,7 @@ gst_wfd_messge_set_prefered_rtp_ports (GstWFDMessage * msg, } GstWFDResult -gst_wfd_message_get_prefered_rtp_ports (GstWFDMessage * msg, +gst_wfd_message_get_preferred_rtp_ports (GstWFDMessage * msg, GstWFDRTSPTransMode * trans, GstWFDRTSPProfile * profile, GstWFDRTSPLowerTrans * lowertrans, guint32 * rtp_port0, guint32 * rtp_port1) @@ -2096,7 +2096,7 @@ gst_wfd_message_get_av_format_change_timing (GstWFDMessage * msg, guint64 * PTS, return GST_WFD_OK; } GstWFDResult -gst_wfd_messge_set_prefered_tcp_ports (GstWFDMessage *msg, +gst_wfd_messge_set_preferred_tcp_ports (GstWFDMessage *msg, GstWFDRTSPTransMode trans, GstWFDRTSPProfile profile, GstWFDRTSPLowerTrans lowertrans, @@ -2139,7 +2139,7 @@ gst_wfd_messge_set_prefered_tcp_ports (GstWFDMessage *msg, } GstWFDResult -gst_wfd_message_get_prefered_tcp_ports (GstWFDMessage *msg, +gst_wfd_message_get_preferred_tcp_ports (GstWFDMessage *msg, GstWFDRTSPTransMode *trans, GstWFDRTSPProfile *profile, GstWFDRTSPLowerTrans *lowertrans, diff --git a/gst/rtsp-server/gstwfdmessage.h b/gst/rtsp-server/gstwfdmessage.h index 5a64696..6a506a6 100755 --- a/gst/rtsp-server/gstwfdmessage.h +++ b/gst/rtsp-server/gstwfdmessage.h @@ -513,7 +513,7 @@ GstWFDResult gst_wfd_message_set_supported_audio_format(GstWFDMessage *msg, guint a_freq, guint a_channels, guint a_bitwidth, guint32 a_latency); -GstWFDResult gst_wfd_message_set_prefered_audio_format(GstWFDMessage *msg, +GstWFDResult gst_wfd_message_set_preferred_audio_format(GstWFDMessage *msg, GstWFDAudioFormats a_codec, GstWFDAudioFreq a_freq, GstWFDAudioChannels a_channels, @@ -526,7 +526,7 @@ GstWFDResult gst_wfd_message_get_supported_audio_format (GstWFDMessage *msg, guint *a_bitwidth, guint32 *a_latency); -GstWFDResult gst_wfd_message_get_prefered_audio_format (GstWFDMessage *msg, +GstWFDResult gst_wfd_message_get_preferred_audio_format (GstWFDMessage *msg, GstWFDAudioFormats *a_codec, GstWFDAudioFreq *a_freq, GstWFDAudioChannels *a_channels, @@ -548,7 +548,7 @@ GstWFDResult gst_wfd_message_set_supported_video_format (GstWFDMessage *msg, guint32 slice_enc_params, guint frame_rate_control); -GstWFDResult gst_wfd_message_set_prefered_video_format(GstWFDMessage *msg, +GstWFDResult gst_wfd_message_set_preferred_video_format(GstWFDMessage *msg, GstWFDVideoCodecs v_codec, GstWFDVideoNativeResolution v_native, guint64 v_native_resolution, @@ -580,7 +580,7 @@ GstWFDResult gst_wfd_message_get_supported_video_format(GstWFDMessage *msg, guint32 *slice_enc_params, guint *frame_rate_control); -GstWFDResult gst_wfd_message_get_prefered_video_format(GstWFDMessage *msg, +GstWFDResult gst_wfd_message_get_preferred_video_format(GstWFDMessage *msg, GstWFDVideoCodecs *v_codec, GstWFDVideoNativeResolution *v_native, guint64 *v_native_resolution, @@ -614,14 +614,14 @@ GstWFDResult gst_wfd_message_get_contentprotection_type (GstWFDMessage *msg, GstWFDHDCPProtection *hdcpversion, guint32 *TCPPort); -GstWFDResult gst_wfd_messge_set_prefered_rtp_ports (GstWFDMessage *msg, +GstWFDResult gst_wfd_messge_set_preferred_rtp_ports (GstWFDMessage *msg, GstWFDRTSPTransMode trans, GstWFDRTSPProfile profile, GstWFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1); -GstWFDResult gst_wfd_message_get_prefered_rtp_ports (GstWFDMessage *msg, +GstWFDResult gst_wfd_message_get_preferred_rtp_ports (GstWFDMessage *msg, GstWFDRTSPTransMode *trans, GstWFDRTSPProfile *profile, GstWFDRTSPLowerTrans *lowertrans, @@ -641,14 +641,14 @@ GstWFDResult gst_wfd_message_set_av_format_change_timing(GstWFDMessage *msg, GstWFDResult gst_wfd_message_get_av_format_change_timing(GstWFDMessage *msg, guint64 *PTS, guint64 *DTS); -GstWFDResult gst_wfd_messge_set_prefered_tcp_ports (GstWFDMessage *msg, +GstWFDResult gst_wfd_messge_set_preferred_tcp_ports (GstWFDMessage *msg, GstWFDRTSPTransMode trans, GstWFDRTSPProfile profile, GstWFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1); -GstWFDResult gst_wfd_message_get_prefered_tcp_ports (GstWFDMessage *msg, +GstWFDResult gst_wfd_message_get_preferred_tcp_ports (GstWFDMessage *msg, GstWFDRTSPTransMode *trans, GstWFDRTSPProfile *profile, GstWFDRTSPLowerTrans *lowertrans, diff --git a/gst/rtsp-server/rtsp-client-wfd.c b/gst/rtsp-server/rtsp-client-wfd.c old mode 100644 new mode 100755 index 69741cf..55ad960 --- a/gst/rtsp-server/rtsp-client-wfd.c +++ b/gst/rtsp-server/rtsp-client-wfd.c @@ -594,7 +594,7 @@ wfd_get_param_request_done (GstRTSPWFDClient * client, GstRTSPContext * ctx) } static guint -wfd_get_prefered_audio_codec (guint8 srcAudioCodec, guint sinkAudioCodec) +wfd_get_preferred_audio_codec (guint8 srcAudioCodec, guint sinkAudioCodec) { int i = 0; guint codec = 0; @@ -609,7 +609,7 @@ wfd_get_prefered_audio_codec (guint8 srcAudioCodec, guint sinkAudioCodec) } static guint64 -wfd_get_prefered_resolution (guint64 srcResolution, +wfd_get_preferred_resolution (guint64 srcResolution, guint64 sinkResolution, GstWFDVideoNativeResolution native, guint32 * cMaxWidth, @@ -1509,24 +1509,24 @@ handle_wfd_response (GstRTSPClient * client, GstRTSPContext * ctx) if (msg->client_rtp_ports) { /* Get the RTP ports preferred by WFDSink */ wfd_res = - gst_wfd_message_get_prefered_rtp_ports (msg, &priv->ctrans, + gst_wfd_message_get_preferred_rtp_ports (msg, &priv->ctrans, &priv->cprofile, &priv->clowertrans, &priv->crtp_port0, &priv->crtp_port1); if (wfd_res != GST_WFD_OK) { GST_WARNING_OBJECT (client, - "Failed to get wfd prefered RTP ports..."); + "Failed to get wfd preferred RTP ports..."); goto error; } } if (msg->tcp_ports) { /* Get the TCP ports preferred by WFDSink */ wfd_res = - gst_wfd_message_get_prefered_tcp_ports (msg, &priv->ctrans_tcp, + gst_wfd_message_get_preferred_tcp_ports (msg, &priv->ctrans_tcp, &priv->cprofile_tcp, &priv->clowertrans_tcp, &priv->crtp_port0_tcp, &priv->crtp_port1_tcp); if (wfd_res != GST_WFD_OK) { GST_WARNING_OBJECT (client, - "Failed to get wfd prefered RTP ports..."); + "Failed to get wfd preferred RTP ports..."); goto error; } } @@ -1536,7 +1536,7 @@ handle_wfd_response (GstRTSPClient * client, GstRTSPContext * ctx) gst_wfd_message_get_buffer_length (msg, &priv->buf_len); if (wfd_res != GST_WFD_OK) { GST_WARNING_OBJECT (client, - "Failed to get wfd prefered RTP ports..."); + "Failed to get wfd preferred RTP ports..."); goto error; } } @@ -2063,7 +2063,7 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, /* set the preffered RTP ports for the WFD server */ wfd_res = - gst_wfd_messge_set_prefered_rtp_ports (msg, GST_WFD_RTSP_TRANS_UNKNOWN, + gst_wfd_messge_set_preferred_rtp_ports (msg, GST_WFD_RTSP_TRANS_UNKNOWN, GST_WFD_RTSP_PROFILE_UNKNOWN, GST_WFD_RTSP_LOWER_TRANS_UNKNOWN, 0, 0); if (wfd_res != GST_WFD_OK) { GST_ERROR_OBJECT (client, @@ -2073,7 +2073,7 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, /* set the preffered TCP ports for the WFD server */ wfd_res = - gst_wfd_messge_set_prefered_tcp_ports (msg, GST_WFD_RTSP_TRANS_RTP, + gst_wfd_messge_set_preferred_tcp_ports (msg, GST_WFD_RTSP_TRANS_RTP, GST_WFD_RTSP_PROFILE_AVP, GST_WFD_RTSP_LOWER_TRANS_UDP, priv->crtp_port0, priv->crtp_port1); if (wfd_res != GST_WFD_OK) { GST_ERROR_OBJECT (client, @@ -2168,7 +2168,7 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, } taudiocodec = - wfd_get_prefered_audio_codec (priv->audio_codec, priv->caCodec); + wfd_get_preferred_audio_codec (priv->audio_codec, priv->caCodec); priv->caCodec = taudiocodec; if (!_set_negotiated_audio_codec (client, priv->caCodec)) { GST_ERROR_OBJECT (client, "Failed to set negotiated " @@ -2193,7 +2193,7 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, priv->cChanels = taudiochannels; wfd_res = - gst_wfd_message_set_prefered_audio_format (msg, taudiocodec, taudiofreq, + gst_wfd_message_set_preferred_audio_format (msg, taudiocodec, taudiofreq, taudiochannels, priv->cBitwidth, priv->caLatency); if (wfd_res != GST_WFD_OK) { GST_ERROR_OBJECT (priv, "Failed to set preffered audio formats..."); @@ -2217,7 +2217,7 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, if (priv->video_native_resolution == GST_WFD_VIDEO_CEA_RESOLUTION) { tcCEAResolution = - wfd_get_prefered_resolution (resolution_supported, + wfd_get_preferred_resolution (resolution_supported, priv->cCEAResolution, priv->video_native_resolution, &priv->cMaxWidth, &priv->cMaxHeight, &priv->cFramerate, &priv->cInterleaved); GST_DEBUG @@ -2226,7 +2226,7 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, priv->cInterleaved); } else if (priv->video_native_resolution == GST_WFD_VIDEO_VESA_RESOLUTION) { tcVESAResolution = - wfd_get_prefered_resolution (resolution_supported, + wfd_get_preferred_resolution (resolution_supported, priv->cVESAResolution, priv->video_native_resolution, &priv->cMaxWidth, &priv->cMaxHeight, &priv->cFramerate, &priv->cInterleaved); @@ -2236,7 +2236,7 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, priv->cInterleaved); } else if (priv->video_native_resolution == GST_WFD_VIDEO_HH_RESOLUTION) { tcHHResolution = - wfd_get_prefered_resolution (resolution_supported, + wfd_get_preferred_resolution (resolution_supported, priv->cHHResolution, priv->video_native_resolution, &priv->cMaxWidth, &priv->cMaxHeight, &priv->cFramerate, &priv->cInterleaved); GST_DEBUG @@ -2251,7 +2251,7 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, } wfd_res = - gst_wfd_message_set_prefered_video_format (msg, priv->cvCodec, + gst_wfd_message_set_preferred_video_format (msg, priv->cvCodec, priv->video_native_resolution, GST_WFD_CEA_UNKNOWN, tcCEAResolution, tcVESAResolution, tcHHResolution, tcProfile, tcLevel, priv->cvLatency, priv->cMaxWidth, priv->cMaxHeight, priv->cmin_slice_size, @@ -2264,7 +2264,7 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, /* set the preffered RTP ports for the WFD server */ wfd_res = - gst_wfd_messge_set_prefered_rtp_ports (msg, GST_WFD_RTSP_TRANS_RTP, + gst_wfd_messge_set_preferred_rtp_ports (msg, GST_WFD_RTSP_TRANS_RTP, GST_WFD_RTSP_PROFILE_AVP, GST_WFD_RTSP_LOWER_TRANS_UDP, priv->crtp_port0, priv->crtp_port1); if (wfd_res != GST_WFD_OK) { @@ -2310,20 +2310,20 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, /* set the preffered TCP ports for the WFD server */ if (priv->ts_mode == WFD_TS_UDP) { wfd_res = - gst_wfd_messge_set_prefered_rtp_ports (msg, GST_WFD_RTSP_TRANS_RTP, + gst_wfd_messge_set_preferred_rtp_ports (msg, GST_WFD_RTSP_TRANS_RTP, GST_WFD_RTSP_PROFILE_AVP, GST_WFD_RTSP_LOWER_TRANS_UDP, priv->crtp_port0, priv->crtp_port1); if (wfd_res != GST_WFD_OK) { GST_ERROR_OBJECT (client, - "Failed to set prefered RTP ports on wfd message..."); + "Failed to set preferred RTP ports on wfd message..."); goto error; } } else { wfd_res = - gst_wfd_messge_set_prefered_tcp_ports (msg, GST_WFD_RTSP_TRANS_RTP, + gst_wfd_messge_set_preferred_tcp_ports (msg, GST_WFD_RTSP_TRANS_RTP, GST_WFD_RTSP_PROFILE_AVP, GST_WFD_RTSP_LOWER_TRANS_TCP, priv->crtp_port0_tcp, priv->crtp_port1_tcp); if (wfd_res != GST_WFD_OK) { GST_ERROR_OBJECT (client, - "Failed to set prefered TCP ports on wfd message..."); + "Failed to set preferred TCP ports on wfd message..."); goto error; } } @@ -2332,7 +2332,7 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, gst_wfd_message_set_buffer_length (msg, 200); if (wfd_res != GST_WFD_OK) { GST_ERROR_OBJECT (client, - "Failed to set prefered buffer length on wfd message..."); + "Failed to set preferred buffer length on wfd message..."); goto error; } diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index 6d51203..3f6fb7a 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 5 +Release: 6 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4 From e96377472cfd40548816c99cbba53298acc01d5a Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Tue, 6 Dec 2016 16:12:06 +0900 Subject: [PATCH 05/16] Change strerror to strerror_r because of thread safety Signed-off-by: SeokHoon Lee Change-Id: I81b5f14ba6dd5b984ea7d607cd82f6b43391ffe8 --- gst/rtsp-server/rtsp-client-wfd.c | 4 +++- packaging/gst-rtsp-server.spec | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gst/rtsp-server/rtsp-client-wfd.c b/gst/rtsp-server/rtsp-client-wfd.c index 69741cf..49783ea 100644 --- a/gst/rtsp-server/rtsp-client-wfd.c +++ b/gst/rtsp-server/rtsp-client-wfd.c @@ -1208,7 +1208,9 @@ new_tcp (GstRTSPWFDClient * client) tcp_retry: if ((g_socket_connect (tcp, local, NULL, NULL))) { - g_print( "Error connecting socket : %s\n", strerror( errno ) ); + char buf[255] = {0, }; + strerror_r (errno, buf, sizeof(buf)); + g_print( "Error connecting socket : %s\n", buf ); if (retry < 50) { GST_ERROR("Connection failed... Try again..."); usleep(100000); diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index 6d51203..3f6fb7a 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 5 +Release: 6 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4 From 4ed4fb655ed9c3ac03c5cf53136cf5e2e3f65e61 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Tue, 13 Dec 2016 17:04:08 +0900 Subject: [PATCH 06/16] Add gst_object_unref about pad [Version] 1.6.1-7 [Profile] Common [Issue Type] refactoring code [Dependency module] N/A [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-mobile_20161130-2] Signed-off-by: SeokHoon Lee Change-Id: Icffe192c59b40aa683673961beea0df2e517b0a1 --- gst/rtsp-server/rtsp-media-factory-wfd.c | 8 ++++++++ packaging/gst-rtsp-server.spec | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) mode change 100755 => 100644 gst/rtsp-server/rtsp-media-factory-wfd.c diff --git a/gst/rtsp-server/rtsp-media-factory-wfd.c b/gst/rtsp-server/rtsp-media-factory-wfd.c old mode 100755 new mode 100644 index c8ff33f..de3569a --- a/gst/rtsp-server/rtsp-media-factory-wfd.c +++ b/gst/rtsp-server/rtsp-media-factory-wfd.c @@ -1259,6 +1259,8 @@ _rtsp_media_factory_wfd_create_srcbin (GstRTSPMediaFactoryWFD * factory) } gst_pad_add_probe (pad_probe, GST_PAD_PROBE_TYPE_BUFFER, rtsp_media_wfd_dump_data, factory, NULL); + if (pad_probe) + gst_object_unref (pad_probe); } GST_DEBUG_OBJECT (factory, "successfully created source bin..."); @@ -1267,6 +1269,12 @@ _rtsp_media_factory_wfd_create_srcbin (GstRTSPMediaFactoryWFD * factory) create_error: GST_ERROR_OBJECT (factory, "Failed to create pipeline"); + if (mux_vsinkpad) + gst_object_unref (mux_vsinkpad); + if (mux_asinkpad) + gst_object_unref (mux_asinkpad); + if (srcpad) + gst_object_unref (srcpad); return NULL; } diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index 3f6fb7a..d777ac1 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 6 +Release: 7 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4 From 5fc34fcac72592592e3d06d41f182ba76f97dbca Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Tue, 7 Feb 2017 16:13:04 +0900 Subject: [PATCH 07/16] Change wfd message wfd-video-formats have none parameter for audio only sink Signed-off-by: SeokHoon Lee Change-Id: Ie2703c2015aa110b8d45e937e327d953b58d2193 --- gst/rtsp-server/gstwfdmessage.c | 86 +++++++++------- gst/rtsp-server/rtsp-client-wfd.c | 168 ++++++++++++++++++++----------- gst/rtsp-server/rtsp-media-factory-wfd.c | 58 +++++++---- packaging/gst-rtsp-server.spec | 2 +- 4 files changed, 201 insertions(+), 113 deletions(-) mode change 100755 => 100644 gst/rtsp-server/gstwfdmessage.c mode change 100755 => 100644 gst/rtsp-server/rtsp-client-wfd.c diff --git a/gst/rtsp-server/gstwfdmessage.c b/gst/rtsp-server/gstwfdmessage.c old mode 100755 new mode 100644 index 1e7e042..4ad9d1b --- a/gst/rtsp-server/gstwfdmessage.c +++ b/gst/rtsp-server/gstwfdmessage.c @@ -484,44 +484,49 @@ gst_wfd_parse_attribute (gchar * buffer, GstWFDMessage * msg) } else if (!g_strcmp0 (attr, GST_STRING_WFD_VIDEO_FORMATS)) { msg->video_formats = g_new0 (GstWFDVideoCodeclist, 1); if (strlen (v)) { - msg->video_formats->count = 1; - msg->video_formats->list = g_new0 (GstWFDVideoCodec, 1); WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->video_formats->list->native); - WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->video_formats->list-> - preferred_display_mode_supported); - WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->video_formats->list->H264_codec.profile); - WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->video_formats->list->H264_codec.level); - WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. - CEA_Support); - WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. - VESA_Support); - WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. - HH_Support); - WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. - latency); - WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. - min_slice_size); - WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. - slice_enc_params); - WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. - frame_rate_control_support); - WFD_SKIP_SPACE (v); - if (msg->video_formats->list->preferred_display_mode_supported == 1) { - WFD_READ_UINT32 (msg->video_formats->list->H264_codec.max_hres); + if (strncmp (v, "none", 4)) { + msg->video_formats->count = 1; + msg->video_formats->list = g_new0 (GstWFDVideoCodec, 1); + WFD_READ_UINT32 (msg->video_formats->list->native); WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->video_formats->list->H264_codec.max_vres); + WFD_READ_UINT32 (msg->video_formats->list-> + preferred_display_mode_supported); + WFD_SKIP_SPACE (v); + WFD_READ_UINT32 (msg->video_formats->list->H264_codec.profile); + WFD_SKIP_SPACE (v); + WFD_READ_UINT32 (msg->video_formats->list->H264_codec.level); + WFD_SKIP_SPACE (v); + WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. + CEA_Support); WFD_SKIP_SPACE (v); + WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. + VESA_Support); + WFD_SKIP_SPACE (v); + WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. + HH_Support); + WFD_SKIP_SPACE (v); + WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. + latency); + WFD_SKIP_SPACE (v); + WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. + min_slice_size); + WFD_SKIP_SPACE (v); + WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. + slice_enc_params); + WFD_SKIP_SPACE (v); + WFD_READ_UINT32 (msg->video_formats->list->H264_codec.misc_params. + frame_rate_control_support); + WFD_SKIP_SPACE (v); + if (msg->video_formats->list->preferred_display_mode_supported == 1) { + WFD_READ_UINT32 (msg->video_formats->list->H264_codec.max_hres); + WFD_SKIP_SPACE (v); + WFD_READ_UINT32 (msg->video_formats->list->H264_codec.max_vres); + WFD_SKIP_SPACE (v); + } + } else { + msg->video_formats->count = 0; + msg->video_formats->list = NULL; } } } else if (!g_strcmp0 (attr, GST_STRING_WFD_3D_VIDEO_FORMATS)) { @@ -904,8 +909,8 @@ gst_wfd_message_as_text (const GstWFDMessage * msg) /* list of video codecs */ if (msg->video_formats) { g_string_append_printf (lines, GST_STRING_WFD_VIDEO_FORMATS); + g_string_append_printf (lines, ":"); if (msg->video_formats->list) { - g_string_append_printf (lines, ":"); g_string_append_printf (lines, " %02x", msg->video_formats->list->native); g_string_append_printf (lines, " %02x", msg->video_formats->list->preferred_display_mode_supported); @@ -940,6 +945,8 @@ gst_wfd_message_as_text (const GstWFDMessage * msg) msg->video_formats->list->H264_codec.max_vres); else g_string_append_printf (lines, " none"); + } else { + g_string_append_printf (lines, " none"); } g_string_append_printf (lines, "\r\n"); } @@ -1720,6 +1727,13 @@ gst_wfd_message_set_preferred_video_format (GstWFDMessage * msg, if (!msg->video_formats) msg->video_formats = g_new0 (GstWFDVideoCodeclist, 1); + + if (v_codec == GST_WFD_VIDEO_UNKNOWN) { + msg->video_formats->list = NULL; + msg->video_formats->count = 0; + return GST_WFD_OK; + } + msg->video_formats->list = g_new0 (GstWFDVideoCodec, 1); while (temp) { diff --git a/gst/rtsp-server/rtsp-client-wfd.c b/gst/rtsp-server/rtsp-client-wfd.c old mode 100755 new mode 100644 index 973305f..d75b7c8 --- a/gst/rtsp-server/rtsp-client-wfd.c +++ b/gst/rtsp-server/rtsp-client-wfd.c @@ -1493,19 +1493,21 @@ handle_wfd_response (GstRTSPClient * client, GstRTSPContext * ctx) } /* Get the Video formats supported by WFDSink */ - wfd_res = - gst_wfd_message_get_supported_video_format (msg, &priv->cvCodec, - &priv->cNative, &priv->cNativeResolution, - (guint64 *) & priv->cCEAResolution, - (guint64 *) & priv->cVESAResolution, - (guint64 *) & priv->cHHResolution, &priv->cProfile, &priv->cLevel, - &priv->cvLatency, &priv->cMaxHeight, &priv->cMaxWidth, - &priv->cmin_slice_size, &priv->cslice_enc_params, - &priv->cframe_rate_control); - if (wfd_res != GST_WFD_OK) { - GST_WARNING_OBJECT (client, - "Failed to get wfd supported video formats..."); - goto error; + if (msg->video_formats && msg->video_formats->count > 0) { + wfd_res = + gst_wfd_message_get_supported_video_format (msg, &priv->cvCodec, + &priv->cNative, &priv->cNativeResolution, + (guint64 *) & priv->cCEAResolution, + (guint64 *) & priv->cVESAResolution, + (guint64 *) & priv->cHHResolution, &priv->cProfile, &priv->cLevel, + &priv->cvLatency, &priv->cMaxHeight, &priv->cMaxWidth, + &priv->cmin_slice_size, &priv->cslice_enc_params, + &priv->cframe_rate_control); + if (wfd_res != GST_WFD_OK) { + GST_WARNING_OBJECT (client, + "Failed to get wfd supported video formats..."); + goto error; + } } if (msg->client_rtp_ports) { @@ -1948,6 +1950,52 @@ no_mount_points: } static gboolean +_set_negotiated_video_codec (GstRTSPWFDClient * client, guint video_codec) +{ + GstRTSPClient *parent_client = GST_RTSP_CLIENT_CAST (client); + + GstRTSPMediaFactory *factory = NULL; + GstRTSPMountPoints *mount_points = NULL; + gchar *path = NULL; + gint matched = 0; + gboolean ret = TRUE; + + if (!(mount_points = gst_rtsp_client_get_mount_points (parent_client))) { + ret = FALSE; + GST_ERROR_OBJECT (client, + "Failed to set negotiated video codec: no mount points..."); + goto no_mount_points; + } + + path = g_strdup (WFD_MOUNT_POINT); + if (!path) { + ret = FALSE; + GST_ERROR_OBJECT (client, + "Failed to set negotiated vidoe codec: no path..."); + goto no_path; + } + + if (!(factory = gst_rtsp_mount_points_match (mount_points, path, &matched))) { + GST_ERROR_OBJECT (client, + "Failed to set negotiated vidoe codec: no factory..."); + ret = FALSE; + goto no_factory; + } + + gst_rtsp_media_factory_wfd_set_video_codec (factory, video_codec); + ret = TRUE; + + g_object_unref (factory); + +no_factory: + g_free (path); +no_path: + g_object_unref (mount_points); +no_mount_points: + return ret; +} + +static gboolean _set_negotiated_resolution (GstRTSPWFDClient * client, guint32 width, guint32 height) { @@ -2203,53 +2251,61 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, } /* Set the preffered video formats */ - priv->cvCodec = GST_WFD_VIDEO_H264; - priv->cProfile = tcProfile = GST_WFD_H264_BASE_PROFILE; - priv->cLevel = tcLevel = GST_WFD_H264_LEVEL_3_1; - - resolution_supported = priv->video_resolution_supported; - - /* TODO-WFD: Need to verify this logic - if(priv->edid_supported) { - if (priv->edid_hres < 1920) resolution_supported = resolution_supported & 0x8C7F; - if (priv->edid_hres < 1280) resolution_supported = resolution_supported & 0x1F; - if (priv->edid_hres < 720) resolution_supported = resolution_supported & 0x01; - } - */ + GST_INFO_OBJECT (priv, "Set the video formats... %d", priv->cvCodec); + if (priv->cvCodec != GST_WFD_VIDEO_UNKNOWN) { + priv->cvCodec = GST_WFD_VIDEO_H264; + priv->cProfile = tcProfile = GST_WFD_H264_BASE_PROFILE; + priv->cLevel = tcLevel = GST_WFD_H264_LEVEL_3_1; + + resolution_supported = priv->video_resolution_supported; + + /* TODO-WFD: Need to verify this logic + if(priv->edid_supported) { + if (priv->edid_hres < 1920) resolution_supported = resolution_supported & 0x8C7F; + if (priv->edid_hres < 1280) resolution_supported = resolution_supported & 0x1F; + if (priv->edid_hres < 720) resolution_supported = resolution_supported & 0x01; + } + */ + + if (priv->video_native_resolution == GST_WFD_VIDEO_CEA_RESOLUTION) { + tcCEAResolution = + wfd_get_preferred_resolution (resolution_supported, + priv->cCEAResolution, priv->video_native_resolution, &priv->cMaxWidth, + &priv->cMaxHeight, &priv->cFramerate, &priv->cInterleaved); + GST_DEBUG + ("wfd negotiated resolution: %08x, width: %d, height: %d, framerate: %d, interleaved: %d", + tcCEAResolution, priv->cMaxWidth, priv->cMaxHeight, priv->cFramerate, + priv->cInterleaved); + } else if (priv->video_native_resolution == GST_WFD_VIDEO_VESA_RESOLUTION) { + tcVESAResolution = + wfd_get_preferred_resolution (resolution_supported, + priv->cVESAResolution, priv->video_native_resolution, + &priv->cMaxWidth, &priv->cMaxHeight, &priv->cFramerate, + &priv->cInterleaved); + GST_DEBUG + ("wfd negotiated resolution: %08x, width: %d, height: %d, framerate: %d, interleaved: %d", + tcVESAResolution, priv->cMaxWidth, priv->cMaxHeight, priv->cFramerate, + priv->cInterleaved); + } else if (priv->video_native_resolution == GST_WFD_VIDEO_HH_RESOLUTION) { + tcHHResolution = + wfd_get_preferred_resolution (resolution_supported, + priv->cHHResolution, priv->video_native_resolution, &priv->cMaxWidth, + &priv->cMaxHeight, &priv->cFramerate, &priv->cInterleaved); + GST_DEBUG + ("wfd negotiated resolution: %08x, width: %d, height: %d, framerate: %d, interleaved: %d", + tcHHResolution, priv->cMaxWidth, priv->cMaxHeight, priv->cFramerate, + priv->cInterleaved); + } - if (priv->video_native_resolution == GST_WFD_VIDEO_CEA_RESOLUTION) { - tcCEAResolution = - wfd_get_preferred_resolution (resolution_supported, - priv->cCEAResolution, priv->video_native_resolution, &priv->cMaxWidth, - &priv->cMaxHeight, &priv->cFramerate, &priv->cInterleaved); - GST_DEBUG - ("wfd negotiated resolution: %08x, width: %d, height: %d, framerate: %d, interleaved: %d", - tcCEAResolution, priv->cMaxWidth, priv->cMaxHeight, priv->cFramerate, - priv->cInterleaved); - } else if (priv->video_native_resolution == GST_WFD_VIDEO_VESA_RESOLUTION) { - tcVESAResolution = - wfd_get_preferred_resolution (resolution_supported, - priv->cVESAResolution, priv->video_native_resolution, - &priv->cMaxWidth, &priv->cMaxHeight, &priv->cFramerate, - &priv->cInterleaved); - GST_DEBUG - ("wfd negotiated resolution: %08x, width: %d, height: %d, framerate: %d, interleaved: %d", - tcVESAResolution, priv->cMaxWidth, priv->cMaxHeight, priv->cFramerate, - priv->cInterleaved); - } else if (priv->video_native_resolution == GST_WFD_VIDEO_HH_RESOLUTION) { - tcHHResolution = - wfd_get_preferred_resolution (resolution_supported, - priv->cHHResolution, priv->video_native_resolution, &priv->cMaxWidth, - &priv->cMaxHeight, &priv->cFramerate, &priv->cInterleaved); - GST_DEBUG - ("wfd negotiated resolution: %08x, width: %d, height: %d, framerate: %d, interleaved: %d", - tcHHResolution, priv->cMaxWidth, priv->cMaxHeight, priv->cFramerate, - priv->cInterleaved); + if (!_set_negotiated_resolution (client, priv->cMaxWidth, priv->cMaxHeight)) { + GST_ERROR_OBJECT (client, "Failed to set negotiated " + "resolution to media factory..."); + } } - if (!_set_negotiated_resolution (client, priv->cMaxWidth, priv->cMaxHeight)) { + if (!_set_negotiated_video_codec (client, priv->cvCodec)) { GST_ERROR_OBJECT (client, "Failed to set negotiated " - "resolution to media factory..."); + "video format to media factory..."); } wfd_res = diff --git a/gst/rtsp-server/rtsp-media-factory-wfd.c b/gst/rtsp-server/rtsp-media-factory-wfd.c index de3569a..6d19dfa 100644 --- a/gst/rtsp-server/rtsp-media-factory-wfd.c +++ b/gst/rtsp-server/rtsp-media-factory-wfd.c @@ -222,6 +222,16 @@ gst_rtsp_media_factory_wfd_set_audio_codec (GstRTSPMediaFactory * factory, priv->audio_codec = audio_codec; } +void +gst_rtsp_media_factory_wfd_set_video_codec (GstRTSPMediaFactory * factory, + guint video_codec) +{ + GstRTSPMediaFactoryWFD *factory_wfd = GST_RTSP_MEDIA_FACTORY_WFD (factory); + GstRTSPMediaFactoryWFDPrivate *priv = factory_wfd->priv; + + priv->video_codec = video_codec; +} + static void _config_bitrate (GstRTSPMediaFactoryWFD * factory) { @@ -752,6 +762,11 @@ _rtsp_media_factory_wfd_create_waylandsrc_bin (GstRTSPMediaFactoryWFD * factory, GST_INFO_OBJECT (factory, "picked waylandsrc as video source"); + if (priv->video_codec == GST_WFD_VIDEO_UNKNOWN) { + GST_INFO_OBJECT (factory, "Skip create video source."); + return TRUE; + } + videosrc = gst_element_factory_make ("waylandsrc", "videosrc"); if (NULL == videosrc) { GST_ERROR_OBJECT (factory, "failed to create ximagesrc element"); @@ -1126,6 +1141,7 @@ _rtsp_media_factory_wfd_create_srcbin (GstRTSPMediaFactoryWFD * factory) goto create_error; } + GST_INFO_OBJECT (factory, "Check video codec... %d", priv->video_codec); /* create video src element */ switch (priv->videosrc_type) { case GST_WFD_VSRC_XIMAGESRC: @@ -1196,29 +1212,31 @@ _rtsp_media_factory_wfd_create_srcbin (GstRTSPMediaFactoryWFD * factory) goto create_error; } - /* request video sink pad from muxer, which has elementary pid 0x1011 */ - mux_vsinkpad = gst_element_get_request_pad (mux, "sink_4113"); - if (!mux_vsinkpad) { - GST_ERROR_OBJECT (factory, "Failed to get sink pad from muxer..."); - goto create_error; - } + if (priv->video_codec > GST_WFD_VIDEO_UNKNOWN) { + /* request video sink pad from muxer, which has elementary pid 0x1011 */ + mux_vsinkpad = gst_element_get_request_pad (mux, "sink_4113"); + if (!mux_vsinkpad) { + GST_ERROR_OBJECT (factory, "Failed to get sink pad from muxer..."); + goto create_error; + } - /* request srcpad from video queue */ - srcpad = gst_element_get_static_pad (priv->video_queue, "src"); - if (!srcpad) { - GST_ERROR_OBJECT (factory, "Failed to get srcpad from video queue..."); - goto create_error; - } + /* request srcpad from video queue */ + srcpad = gst_element_get_static_pad (priv->video_queue, "src"); + if (!srcpad) { + GST_ERROR_OBJECT (factory, "Failed to get srcpad from video queue..."); + goto create_error; + } - if (gst_pad_link (srcpad, mux_vsinkpad) != GST_PAD_LINK_OK) { - GST_ERROR_OBJECT (factory, - "Failed to link video queue src pad & muxer video sink pad..."); - goto create_error; - } + if (gst_pad_link (srcpad, mux_vsinkpad) != GST_PAD_LINK_OK) { + GST_ERROR_OBJECT (factory, + "Failed to link video queue src pad & muxer video sink pad..."); + goto create_error; + } - gst_object_unref (mux_vsinkpad); - gst_object_unref (srcpad); - srcpad = NULL; + gst_object_unref (mux_vsinkpad); + gst_object_unref (srcpad); + srcpad = NULL; + } /* create audio source elements & add to pipeline */ if (!_rtsp_media_factory_wfd_create_audio_capture_bin (factory, srcbin)) diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index d777ac1..ac6ccb6 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 7 +Release: 8 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4 From 9ae1d7ee50992f41007371c3ef010afbb86d1702 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Tue, 14 Feb 2017 13:42:51 +0900 Subject: [PATCH 08/16] fix memory leak and delete unused buffer - fix nativeidex underflow. - delete unused block about buf - free msg after use. - remove ta memoryleak in error case Signed-off-by: SeokHoon Lee Change-Id: Ib55adb29dc49e2e21852bd509c828040879253b6 --- gst/rtsp-server/gstwfdmessage.c | 5 +++- gst/rtsp-server/rtsp-client-wfd.c | 53 +++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/gst/rtsp-server/gstwfdmessage.c b/gst/rtsp-server/gstwfdmessage.c index 4ad9d1b..6540b9d 100644 --- a/gst/rtsp-server/gstwfdmessage.c +++ b/gst/rtsp-server/gstwfdmessage.c @@ -864,6 +864,7 @@ gst_wfd_message_free (GstWFDMessage * msg) gst_wfd_message_uninit (msg); g_free (msg); + msg = NULL; return GST_WFD_OK; } @@ -1670,12 +1671,14 @@ gst_wfd_message_set_supported_video_format (GstWFDMessage * msg, if (v_codec != GST_WFD_VIDEO_UNKNOWN) { msg->video_formats->list = g_new0 (GstWFDVideoCodec, 1); + + temp >>= 1; while (temp) { nativeindex++; temp >>= 1; } - msg->video_formats->list->native = nativeindex - 1; + msg->video_formats->list->native = nativeindex; msg->video_formats->list->native <<= 3; if (v_native == GST_WFD_VIDEO_VESA_RESOLUTION) diff --git a/gst/rtsp-server/rtsp-client-wfd.c b/gst/rtsp-server/rtsp-client-wfd.c index d75b7c8..969e26a 100644 --- a/gst/rtsp-server/rtsp-client-wfd.c +++ b/gst/rtsp-server/rtsp-client-wfd.c @@ -2054,9 +2054,6 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, g_return_if_fail (priv != NULL); - buf = g_string_new (""); - g_return_if_fail (buf != NULL); - if (msg_type == M3_REQ_MSG) { /* create M3 request to be sent */ wfd_res = gst_wfd_message_new (&msg); @@ -2196,14 +2193,17 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, goto error; } + buf = g_string_new (""); + if (buf == NULL) + goto error; + g_string_append_printf (buf, "rtsp://"); if (priv->host_address) { g_string_append (buf, priv->host_address); } else { GST_ERROR_OBJECT (client, "Failed to get host address"); - if (buf) - g_string_free (buf, TRUE); + g_string_free (buf, TRUE); goto error; } @@ -2353,18 +2353,6 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, goto error; } - g_string_append_printf (buf, "rtsp://"); - - if (priv->host_address) { - g_string_append (buf, priv->host_address); - } else { - GST_ERROR_OBJECT (client, "Failed to get host address"); - if (buf) g_string_free (buf, TRUE); - goto error; - } - - g_string_append_printf (buf, "/wfd1.0/streamid=0"); - /* set the preffered TCP ports for the WFD server */ if (priv->ts_mode == WFD_TS_UDP) { wfd_res = @@ -2412,32 +2400,49 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, *len = strlen (*data); } } else if (msg_type == M5_REQ_MSG) { + buf = g_string_new (""); + 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 (""); + 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 (""); + 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 (""); + 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); - } else { - return; } + if (msg != NULL) + gst_wfd_message_free(msg); + return; error: + + if (msg != NULL) + gst_wfd_message_free(msg); + *data = NULL; *len = 0; @@ -3785,17 +3790,17 @@ gst_rtsp_wfd_client_switch_to_udp (GstRTSPWFDClient * client) GList *tl = NULL; GPtrArray *ta = NULL; + if (client->priv->ts_mode == WFD_TS_UDP) { + GST_ERROR_OBJECT (client, "Transport already UDP"); + return res; + } + ta = g_ptr_array_new(); tl = gst_rtsp_stream_transport_filter (client->priv->stats.stream, NULL, NULL); client->priv->transports = tl; g_ptr_array_add (ta, tl->data); - if (client->priv->ts_mode == WFD_TS_UDP) { - GST_ERROR_OBJECT (client, "Transport already UDP"); - return res; - } - client->priv->ts_mode = WFD_TS_UDP; res = prepare_transport_switch_request (client, &request); if (GST_RTSP_OK != res) { -- 2.7.4 From fbcc329984ede6192f95a0024368c8e84658faa1 Mon Sep 17 00:00:00 2001 From: "Hyunsoo, Park" Date: Tue, 21 Feb 2017 20:22:01 +0900 Subject: [PATCH 09/16] Change wfd message for video only mirroring Using this patch, 'wfd-audio-formats' parameter have none parameter for video only sink. Basically, screen mirroring provides video & audio simultaneously. This patch will make screen mirroring to provide Video only. -When Video only mirroring mode goes, it makes 'wfd_audio_codecs' messages to 'none'. If 'sink session mode' in 'mmfw_wfd_sink.ini' is set '2', screen mirroring runs without audio(that is, video only mirroring) Change-Id: Ia88fb8a23c2f28cda222075835aa16c4a6bb3987 Signed-off-by: Hyunsoo, Park --- gst/rtsp-server/gstwfdmessage.c | 37 +++++++++++++++++-------- gst/rtsp-server/rtsp-client-wfd.c | 44 ++++++++++++++++-------------- gst/rtsp-server/rtsp-media-factory-wfd.c | 47 +++++++++++++++++++------------- gst/rtsp-server/rtsp-media-factory-wfd.h | 2 ++ packaging/gst-rtsp-server.spec | 2 +- 5 files changed, 79 insertions(+), 53 deletions(-) diff --git a/gst/rtsp-server/gstwfdmessage.c b/gst/rtsp-server/gstwfdmessage.c index 6540b9d..3e6d099 100644 --- a/gst/rtsp-server/gstwfdmessage.c +++ b/gst/rtsp-server/gstwfdmessage.c @@ -467,18 +467,24 @@ gst_wfd_parse_attribute (gchar * buffer, GstWFDMessage * msg) if (!g_strcmp0 (attr, GST_STRING_WFD_AUDIO_CODECS)) { msg->audio_codecs = g_new0 (GstWFDAudioCodeclist, 1); if (strlen (v)) { - guint i = 0; - msg->audio_codecs->count = strlen (v) / 16; - msg->audio_codecs->list = + WFD_SKIP_SPACE (v); + if (strncmp (v, "none", 4)) { + guint i = 0; + msg->audio_codecs->count = strlen (v) / 16; + msg->audio_codecs->list = g_new0 (GstWFDAudioCodec, msg->audio_codecs->count); - for (; i < msg->audio_codecs->count; i++) { - WFD_SKIP_SPACE (v); - WFD_READ_STRING (msg->audio_codecs->list[i].audio_format); - WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->audio_codecs->list[i].modes); - WFD_SKIP_SPACE (v); - WFD_READ_UINT32 (msg->audio_codecs->list[i].latency); - WFD_SKIP_COMMA (v); + for (; i < msg->audio_codecs->count; i++) { + WFD_SKIP_SPACE (v); + WFD_READ_STRING (msg->audio_codecs->list[i].audio_format); + WFD_SKIP_SPACE (v); + WFD_READ_UINT32 (msg->audio_codecs->list[i].modes); + WFD_SKIP_SPACE (v); + WFD_READ_UINT32 (msg->audio_codecs->list[i].latency); + WFD_SKIP_COMMA (v); + } + } else { + msg->audio_codecs->count = 0; + msg->audio_codecs->list = NULL; } } } else if (!g_strcmp0 (attr, GST_STRING_WFD_VIDEO_FORMATS)) { @@ -891,8 +897,8 @@ gst_wfd_message_as_text (const GstWFDMessage * msg) /* list of audio codecs */ if (msg->audio_codecs) { g_string_append_printf (lines, GST_STRING_WFD_AUDIO_CODECS); + g_string_append_printf (lines, ":"); if (msg->audio_codecs->list) { - g_string_append_printf (lines, ":"); for (i = 0; i < msg->audio_codecs->count; i++) { g_string_append_printf (lines, " %s", msg->audio_codecs->list[i].audio_format); @@ -903,6 +909,8 @@ gst_wfd_message_as_text (const GstWFDMessage * msg) if ((i + 1) < msg->audio_codecs->count) g_string_append_printf (lines, ","); } + } else { + g_string_append_printf (lines, " none"); } g_string_append_printf (lines, "\r\n"); } @@ -1565,6 +1573,11 @@ gst_wfd_message_set_preferred_audio_format (GstWFDMessage * msg, if (!msg->audio_codecs) msg->audio_codecs = g_new0 (GstWFDAudioCodeclist, 1); + if (a_codec == GST_WFD_AUDIO_UNKNOWN) { + msg->audio_codecs->list = NULL; + msg->audio_codecs->count = 0; + return GST_WFD_OK; + } msg->audio_codecs->list = g_new0 (GstWFDAudioCodec, 1); msg->audio_codecs->count = 1; if (a_codec == GST_WFD_AUDIO_LPCM) { diff --git a/gst/rtsp-server/rtsp-client-wfd.c b/gst/rtsp-server/rtsp-client-wfd.c index 969e26a..42a2417 100644 --- a/gst/rtsp-server/rtsp-client-wfd.c +++ b/gst/rtsp-server/rtsp-client-wfd.c @@ -1481,7 +1481,7 @@ handle_wfd_response (GstRTSPClient * client, GstRTSPContext * ctx) gst_wfd_message_as_text (msg)); /* Get the audio formats supported by WFDSink */ - if (msg->audio_codecs) { + if (msg->audio_codecs && msg->audio_codecs->count > 0) { wfd_res = gst_wfd_message_get_supported_audio_format (msg, &priv->caCodec, &priv->cFreq, &priv->cChanels, &priv->cBitwidth, &priv->caLatency); @@ -2217,31 +2217,33 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, goto error; } - taudiocodec = - wfd_get_preferred_audio_codec (priv->audio_codec, priv->caCodec); - priv->caCodec = taudiocodec; + if (priv->caCodec != GST_WFD_AUDIO_UNKNOWN) { + taudiocodec = wfd_get_preferred_audio_codec (priv->audio_codec, priv->caCodec); + priv->caCodec = taudiocodec; + } if (!_set_negotiated_audio_codec (client, priv->caCodec)) { GST_ERROR_OBJECT (client, "Failed to set negotiated " "audio codec to media factory..."); } - if (priv->cFreq & GST_WFD_FREQ_48000) - taudiofreq = GST_WFD_FREQ_48000; - else if (priv->cFreq & GST_WFD_FREQ_44100) - taudiofreq = GST_WFD_FREQ_44100; - priv->cFreq = taudiofreq; - - /* TODO-WFD: Currently only 2 channels is present */ - if (priv->cChanels & GST_WFD_CHANNEL_8) - taudiochannels = GST_WFD_CHANNEL_2; - else if (priv->cChanels & GST_WFD_CHANNEL_6) - taudiochannels = GST_WFD_CHANNEL_2; - else if (priv->cChanels & GST_WFD_CHANNEL_4) - taudiochannels = GST_WFD_CHANNEL_2; - else if (priv->cChanels & GST_WFD_CHANNEL_2) - taudiochannels = GST_WFD_CHANNEL_2; - priv->cChanels = taudiochannels; - + if (priv->caCodec != GST_WFD_AUDIO_UNKNOWN) { + if (priv->cFreq & GST_WFD_FREQ_48000) + taudiofreq = GST_WFD_FREQ_48000; + else if (priv->cFreq & GST_WFD_FREQ_44100) + taudiofreq = GST_WFD_FREQ_44100; + priv->cFreq = taudiofreq; + + /* TODO-WFD: Currently only 2 channels is present */ + if (priv->cChanels & GST_WFD_CHANNEL_8) + taudiochannels = GST_WFD_CHANNEL_2; + else if (priv->cChanels & GST_WFD_CHANNEL_6) + taudiochannels = GST_WFD_CHANNEL_2; + else if (priv->cChanels & GST_WFD_CHANNEL_4) + taudiochannels = GST_WFD_CHANNEL_2; + else if (priv->cChanels & GST_WFD_CHANNEL_2) + taudiochannels = GST_WFD_CHANNEL_2; + priv->cChanels = taudiochannels; + } wfd_res = gst_wfd_message_set_preferred_audio_format (msg, taudiocodec, taudiofreq, taudiochannels, priv->cBitwidth, priv->caLatency); diff --git a/gst/rtsp-server/rtsp-media-factory-wfd.c b/gst/rtsp-server/rtsp-media-factory-wfd.c index 6d19dfa..127af3c 100644 --- a/gst/rtsp-server/rtsp-media-factory-wfd.c +++ b/gst/rtsp-server/rtsp-media-factory-wfd.c @@ -465,6 +465,11 @@ _rtsp_media_factory_wfd_create_audio_capture_bin (GstRTSPMediaFactoryWFD * priv = factory->priv; + if (priv->audio_codec == GST_WFD_AUDIO_UNKNOWN) { + GST_INFO_OBJECT (factory, "Skip create audio source"); + return TRUE; + } + /* create audio src element */ audiosrc = gst_element_factory_make ("pulsesrc", "audiosrc"); if (!audiosrc) { @@ -1238,32 +1243,36 @@ _rtsp_media_factory_wfd_create_srcbin (GstRTSPMediaFactoryWFD * factory) srcpad = NULL; } + GST_INFO_OBJECT (factory, "Check audio codec... %d", priv->audio_codec); + /* create audio source elements & add to pipeline */ if (!_rtsp_media_factory_wfd_create_audio_capture_bin (factory, srcbin)) goto create_error; - /* request audio sink pad from muxer, which has elementary pid 0x1100 */ - mux_asinkpad = gst_element_get_request_pad (mux, "sink_4352"); - if (!mux_asinkpad) { - GST_ERROR_OBJECT (factory, "Failed to get sinkpad from muxer..."); - goto create_error; - } + if (priv->audio_codec > GST_WFD_AUDIO_UNKNOWN) { + /* request audio sink pad from muxer, which has elementary pid 0x1100 */ + mux_asinkpad = gst_element_get_request_pad (mux, "sink_4352"); + if (!mux_asinkpad) { + GST_ERROR_OBJECT (factory, "Failed to get sinkpad from muxer..."); + goto create_error; + } - /* request srcpad from audio queue */ - srcpad = gst_element_get_static_pad (priv->audio_queue, "src"); - if (!srcpad) { - GST_ERROR_OBJECT (factory, "Failed to get srcpad from audio queue..."); - goto create_error; - } + /* request srcpad from audio queue */ + srcpad = gst_element_get_static_pad (priv->audio_queue, "src"); + if (!srcpad) { + GST_ERROR_OBJECT (factory, "Failed to get srcpad from audio queue..."); + goto create_error; + } - /* link audio queue's srcpad & muxer sink pad */ - if (gst_pad_link (srcpad, mux_asinkpad) != GST_PAD_LINK_OK) { - GST_ERROR_OBJECT (factory, - "Failed to link audio queue src pad & muxer audio sink pad..."); - goto create_error; + /* link audio queue's srcpad & muxer sink pad */ + if (gst_pad_link (srcpad, mux_asinkpad) != GST_PAD_LINK_OK) { + GST_ERROR_OBJECT (factory, + "Failed to link audio queue src pad & muxer audio sink pad..."); + goto create_error; + } + gst_object_unref (mux_asinkpad); + gst_object_unref (srcpad); } - gst_object_unref (mux_asinkpad); - gst_object_unref (srcpad); if (priv->dump_ts) { diff --git a/gst/rtsp-server/rtsp-media-factory-wfd.h b/gst/rtsp-server/rtsp-media-factory-wfd.h index 582ded4..ba58776 100644 --- a/gst/rtsp-server/rtsp-media-factory-wfd.h +++ b/gst/rtsp-server/rtsp-media-factory-wfd.h @@ -126,6 +126,8 @@ void gst_rtsp_media_factory_wfd_set_negotiated_resolution (GstRTSPMediaFactory * guint32 width, guint32 height); void gst_rtsp_media_factory_wfd_set_audio_codec (GstRTSPMediaFactory *factory, guint audio_codec); +void gst_rtsp_media_factory_wfd_set_video_codec (GstRTSPMediaFactory * factory, + guint video_codec); void gst_rtsp_media_factory_wfd_set_venc_bitrate (GstRTSPMediaFactory *factory, gint bitrate); diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index ac6ccb6..bf13245 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 8 +Release: 9 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4 From 13eabe9ec46221f1ed8dd7e588c86c34f8d7aef7 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Fri, 17 Mar 2017 15:45:28 +0900 Subject: [PATCH 10/16] Add video codec parameter for source - For video codec negotiation between source and sink, add video codec parameter in client Signed-off-by: SeokHoon Lee Change-Id: I89b22ee50fc8806bbaf932e0b50eff110b030eca --- gst/rtsp-server/rtsp-client-wfd.c | 21 +++++++++++++++++++-- gst/rtsp-server/rtsp-client-wfd.h | 4 +++- gst/rtsp-server/rtsp-server-wfd.c | 21 +++++++++++++++++++++ gst/rtsp-server/rtsp-server-wfd.h | 1 + packaging/gst-rtsp-server.spec | 2 +- 5 files changed, 45 insertions(+), 4 deletions(-) mode change 100755 => 100644 gst/rtsp-server/rtsp-client-wfd.h mode change 100755 => 100644 gst/rtsp-server/rtsp-server-wfd.h diff --git a/gst/rtsp-server/rtsp-client-wfd.c b/gst/rtsp-server/rtsp-client-wfd.c index 42a2417..c07f802 100644 --- a/gst/rtsp-server/rtsp-client-wfd.c +++ b/gst/rtsp-server/rtsp-client-wfd.c @@ -115,6 +115,7 @@ struct _GstRTSPWFDClientPrivate guint cBitwidth; guint caLatency; guint cvCodec; + guint8 video_codec; guint cNative; guint64 cNativeResolution; guint64 video_resolution_supported; @@ -2253,7 +2254,8 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, } /* Set the preffered video formats */ - GST_INFO_OBJECT (priv, "Set the video formats... %d", priv->cvCodec); + GST_INFO_OBJECT (priv, "Set the video formats. source codec %d, sink codec %d", priv->video_codec, priv->cvCodec); + /* TODO : need to negotiate video codec between source and sink */ if (priv->cvCodec != GST_WFD_VIDEO_UNKNOWN) { priv->cvCodec = GST_WFD_VIDEO_H264; priv->cProfile = tcProfile = GST_WFD_H264_BASE_PROFILE; @@ -3075,6 +3077,21 @@ gst_rtsp_wfd_client_set_video_native_resolution (GstRTSPWFDClient * client, } GstRTSPResult +gst_rtsp_wfd_client_set_video_codec (GstRTSPWFDClient * client, + guint8 video_codec) +{ + 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->video_codec = video_codec; + GST_DEBUG ("Video codec : %d", video_codec); + + return res; +} + +GstRTSPResult gst_rtsp_wfd_client_set_audio_codec (GstRTSPWFDClient * client, guint8 audio_codec) { @@ -3552,7 +3569,7 @@ gst_rtsp_wfd_client_set_audio_latency (GstRTSPWFDClient * client, guint latency) } void -gst_rtsp_wfd_client_set_video_codec (GstRTSPWFDClient * client, guint vcodec) +gst_rtsp_wfd_client_set_vid_codec (GstRTSPWFDClient * client, guint vcodec) { GstRTSPWFDClientPrivate *priv = GST_RTSP_WFD_CLIENT_GET_PRIVATE (client); g_return_if_fail (priv != NULL); diff --git a/gst/rtsp-server/rtsp-client-wfd.h b/gst/rtsp-server/rtsp-client-wfd.h old mode 100755 new mode 100644 index 4d78382..382ce16 --- a/gst/rtsp-server/rtsp-client-wfd.h +++ b/gst/rtsp-server/rtsp-client-wfd.h @@ -143,6 +143,8 @@ GstRTSPResult gst_rtsp_wfd_client_set_video_supported_resolution ( GstRTSPWFDClient * client, guint64 supported_reso); GstRTSPResult gst_rtsp_wfd_client_set_video_native_resolution ( GstRTSPWFDClient * client, guint64 native_reso); +GstRTSPResult gst_rtsp_wfd_client_set_video_codec ( + GstRTSPWFDClient * client, guint8 video_codec); GstRTSPResult gst_rtsp_wfd_client_set_audio_codec ( GstRTSPWFDClient * client, guint8 audio_codec); GstRTSPResult gst_prepare_request (GstRTSPWFDClient * client, @@ -191,7 +193,7 @@ void gst_rtsp_wfd_client_set_aud_codec(GstRTSPWFDClient *client, guint acodec); void gst_rtsp_wfd_client_set_audio_channels(GstRTSPWFDClient *client, guint channels); void gst_rtsp_wfd_client_set_audio_bit_width(GstRTSPWFDClient *client, guint bwidth); void gst_rtsp_wfd_client_set_audio_latency(GstRTSPWFDClient *client, guint latency); -void gst_rtsp_wfd_client_set_video_codec(GstRTSPWFDClient *client, guint vcodec); +void gst_rtsp_wfd_client_set_vid_codec(GstRTSPWFDClient *client, guint vcodec); void gst_rtsp_wfd_client_set_video_native(GstRTSPWFDClient *client, guint native); void gst_rtsp_wfd_client_set_vid_native_resolution(GstRTSPWFDClient *client, guint64 res); void gst_rtsp_wfd_client_set_video_cea_resolution(GstRTSPWFDClient *client, guint64 res); diff --git a/gst/rtsp-server/rtsp-server-wfd.c b/gst/rtsp-server/rtsp-server-wfd.c index 042ec3b..47cc17a 100644 --- a/gst/rtsp-server/rtsp-server-wfd.c +++ b/gst/rtsp-server/rtsp-server-wfd.c @@ -75,6 +75,7 @@ struct _GstRTSPWFDServerPrivate guint64 native_resolution; guint64 supported_resolution; guint8 audio_codec; + guint8 video_codec; }; G_DEFINE_TYPE (GstRTSPWFDServer, gst_rtsp_wfd_server, GST_TYPE_RTSP_SERVER); @@ -244,6 +245,8 @@ create_client_wfd (GstRTSPServer * server) gst_rtsp_wfd_client_set_audio_codec (client, priv->audio_codec); + gst_rtsp_wfd_client_set_video_codec (client, priv->video_codec); + GST_RTSP_WFD_SERVER_UNLOCK (server); return GST_RTSP_CLIENT (client); @@ -318,6 +321,24 @@ gst_rtsp_wfd_server_set_video_native_reso (GstRTSPWFDServer * server, } GstRTSPResult +gst_rtsp_wfd_server_set_video_codec (GstRTSPWFDServer * server, + guint8 video_codec) +{ + 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->video_codec = video_codec; + + GST_RTSP_WFD_SERVER_UNLOCK (server); + return res; +} + +GstRTSPResult gst_rtsp_wfd_server_set_audio_codec (GstRTSPWFDServer * server, guint8 audio_codec) { diff --git a/gst/rtsp-server/rtsp-server-wfd.h b/gst/rtsp-server/rtsp-server-wfd.h old mode 100755 new mode 100644 index 1666f18..663a9a4 --- a/gst/rtsp-server/rtsp-server-wfd.h +++ b/gst/rtsp-server/rtsp-server-wfd.h @@ -80,6 +80,7 @@ GstRTSPResult gst_rtsp_wfd_server_trigger_request (GstRTSPServer *s GstRTSPResult gst_rtsp_wfd_server_set_supported_reso (GstRTSPWFDServer *server, guint64 supported_reso); GstRTSPResult gst_rtsp_wfd_server_set_video_native_reso (GstRTSPWFDServer *server, guint64 native_reso); +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_switch_to_udp (GstRTSPWFDServer *server); GstRTSPResult gst_rtsp_wfd_server_switch_to_tcp (GstRTSPWFDServer *server); diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index bf13245..ba801c2 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 9 +Release: 10 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4 From 2ebc75ab20d2e3ffc8d5600398aa3c509fe65d3b Mon Sep 17 00:00:00 2001 From: "Hyunsoo, Park" Date: Wed, 22 Mar 2017 17:47:26 +0900 Subject: [PATCH 11/16] Modify license macro [Version] 1.6.1-10 [Profile] Common [Issue Type] Update [Dependency module] N/A Change-Id: I7869857b4d4b3bac4cda4776a9e740215209f968 Signed-off-by: Hyunsoo, Park --- packaging/gst-rtsp-server.spec | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index ba801c2..d1636f2 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 10 +Release: 11 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ @@ -50,8 +50,6 @@ make %{?jobs:-j%jobs} %install rm -rf %{buildroot} %make_install -mkdir -p %{buildroot}/%{_datadir}/license -cp -rf %{_builddir}/%{name}-%{version}/COPYING %{buildroot}%{_datadir}/license/%{name} %clean rm -rf %{buildroot} @@ -65,7 +63,7 @@ rm -rf %{buildroot} %files %manifest gst-rtsp-server.manifest %defattr(-,root,root,-) -%{_datadir}/license/%{name} +%license COPYING %{_libdir}/*.so.* %files devel -- 2.7.4 From 969b39b61bb4c9b5bba2ea5af11af1138392f4a7 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Wed, 29 Mar 2017 14:57:16 +0900 Subject: [PATCH 12/16] Fix memory leak - url free after use - server_addr free after use Signed-off-by: SeokHoon Lee Change-Id: I41bf5ca91ba19f43ea17de4d2cfa53a75afc4417 --- gst/rtsp-server/rtsp-client-wfd.c | 3 +++ gst/rtsp-server/rtsp-server-wfd.c | 5 ++++- packaging/gst-rtsp-server.spec | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gst/rtsp-server/rtsp-client-wfd.c b/gst/rtsp-server/rtsp-client-wfd.c index c07f802..7d3a475 100644 --- a/gst/rtsp-server/rtsp-client-wfd.c +++ b/gst/rtsp-server/rtsp-client-wfd.c @@ -3754,11 +3754,14 @@ prepare_transport_switch_request (GstRTSPWFDClient * client, GstRTSPMessage * re GstRTSPMethod method = GST_RTSP_SET_PARAMETER; url = g_strdup ("rtsp://localhost/wfd1.0"); + if (!url) + return GST_RTSP_ERROR; GST_DEBUG_OBJECT (client, "Preparing request for transport switch"); /* initialize the request */ res = gst_rtsp_message_init_request (request, method, url); + g_free (url); if (res < 0) { GST_ERROR ("init request failed"); return res; diff --git a/gst/rtsp-server/rtsp-server-wfd.c b/gst/rtsp-server/rtsp-server-wfd.c index 47cc17a..e3b3d05 100644 --- a/gst/rtsp-server/rtsp-server-wfd.c +++ b/gst/rtsp-server/rtsp-server-wfd.c @@ -194,10 +194,13 @@ _start_wfd (gpointer data) static void client_connected_wfd (GstRTSPServer * server, GstRTSPClient * client) { + gchar *server_addr = NULL; GST_INFO_OBJECT (server, "Client is connected"); + server_addr = gst_rtsp_server_get_address (server); gst_rtsp_wfd_client_set_host_address (GST_RTSP_WFD_CLIENT_CAST (client), - gst_rtsp_server_get_address (server)); + server_addr); + g_free (server_addr); g_idle_add (_start_wfd, client); return; } diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index d1636f2..f21da9b 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 11 +Release: 12 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4 From dbad4e28365b8066662077791a38a53aa36ac868 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Thu, 6 Apr 2017 11:20:25 +0900 Subject: [PATCH 13/16] Add video codec negotiation - Add video codec negotiation for audio only session Signed-off-by: SeokHoon Lee Change-Id: I31f106ff96c20234374bb1763c76f518a7abc4e0 --- gst/rtsp-server/rtsp-client-wfd.c | 23 +++++++++++++++++++++-- packaging/gst-rtsp-server.spec | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/gst/rtsp-server/rtsp-client-wfd.c b/gst/rtsp-server/rtsp-client-wfd.c index 7d3a475..776bef8 100644 --- a/gst/rtsp-server/rtsp-client-wfd.c +++ b/gst/rtsp-server/rtsp-client-wfd.c @@ -609,6 +609,21 @@ wfd_get_preferred_audio_codec (guint8 srcAudioCodec, guint sinkAudioCodec) return codec; } +static guint +wfd_get_preferred_video_codec (guint8 srcVideoCodec, guint sinkVideoCodec) +{ + int i = 0; + guint codec = 0; + for (i = 0; i < 8; i++) { + if (((sinkVideoCodec << i) & 0x80) + && ((srcVideoCodec << i) & 0x80)) { + codec = (0x01 << (7 - i)); + break; + } + } + return codec; +} + static guint64 wfd_get_preferred_resolution (guint64 srcResolution, guint64 sinkResolution, @@ -2167,6 +2182,7 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, GstWFDAudioChannels taudiochannels = GST_WFD_CHANNEL_UNKNOWN; /* Parameters for the preffered video formats */ + GstWFDVideoCodecs tvideocodec = GST_WFD_VIDEO_UNKNOWN; GstWFDVideoCEAResolution tcCEAResolution = GST_WFD_CEA_UNKNOWN; GstWFDVideoVESAResolution tcVESAResolution = GST_WFD_VESA_UNKNOWN; GstWFDVideoHHResolution tcHHResolution = GST_WFD_HH_UNKNOWN; @@ -2254,8 +2270,11 @@ _set_wfd_message_body (GstRTSPWFDClient * client, GstWFDMessageType msg_type, } /* Set the preffered video formats */ - GST_INFO_OBJECT (priv, "Set the video formats. source codec %d, sink codec %d", priv->video_codec, priv->cvCodec); - /* TODO : need to negotiate video codec between source and sink */ + tvideocodec = wfd_get_preferred_video_codec (priv->video_codec, priv->cvCodec); + GST_INFO_OBJECT (priv, "Set the video formats. source codec %d, sink codec %d, Negotiated code %d", + priv->video_codec, priv->cvCodec, tvideocodec); + priv->cvCodec = tvideocodec; + if (priv->cvCodec != GST_WFD_VIDEO_UNKNOWN) { priv->cvCodec = GST_WFD_VIDEO_H264; priv->cProfile = tcProfile = GST_WFD_H264_BASE_PROFILE; diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index f21da9b..858f5bf 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 12 +Release: 13 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4 From a837041d4dae71a4df08a7af2220e8a78442b27d Mon Sep 17 00:00:00 2001 From: "Hyunsoo, Park" Date: Thu, 20 Apr 2017 11:20:05 +0900 Subject: [PATCH 14/16] Fix memory leak after using 'url_str' variable. After using this variable, it seems not to be released. So i added free code. [Version] 1.6.1-14 [Profile] Common [Issue Type] Fix [Dependency module] N/A [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-mobile_201670328.1] Change-Id: I3204355675e04ee14dd8487b071530666ee46524 Signed-off-by: Hyunsoo, Park --- gst/rtsp-server/rtsp-client-wfd.c | 3 ++- packaging/gst-rtsp-server.spec | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gst/rtsp-server/rtsp-client-wfd.c b/gst/rtsp-server/rtsp-client-wfd.c index 776bef8..f6cb221 100644 --- a/gst/rtsp-server/rtsp-client-wfd.c +++ b/gst/rtsp-server/rtsp-client-wfd.c @@ -2973,10 +2973,11 @@ handle_M3_message (GstRTSPWFDClient * client) GST_DEBUG_OBJECT (client, "Sending GET_PARAMETER request message (M3)..."); gst_send_request (client, NULL, &request); - + g_free(url_str); return res; error: + g_free(url_str); return res; } diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index 858f5bf..4810e65 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 13 +Release: 14 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4 From 093f537389c1a34cac82390a85fc1b32ce6714f3 Mon Sep 17 00:00:00 2001 From: "Hyunsoo, Park" Date: Wed, 26 Apr 2017 19:53:03 +0900 Subject: [PATCH 15/16] Change rtsp media object from gst_rtsp_media_ext to gst_rtsp_media. After applying this patch, rtsp_media_factory_wfd makes GstRTSPMedia using gst_rtsp_media_new() api not gst_rtsp_media_ext_new() api. The reason why changing constructor is removing rtpresender. And gst_rtsp_media_ext use rtpresender. So because of patent issue, we will change constructor and remove rtpresender. [Version] 1.6.1-15 [Profile] Common [Issue Type] removing module [Dependency module] gst-plugins-tizen (https://review.tizen.org/gerrit/127198) [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-mobile_20170328.4] Change-Id: I55568bbdaf18ed6f2d9709bcd2283372c54c05ed Signed-off-by: Hyunsoo, Park --- gst/rtsp-server/rtsp-media-factory-wfd.c | 4 ++-- packaging/gst-rtsp-server.spec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gst/rtsp-server/rtsp-media-factory-wfd.c b/gst/rtsp-server/rtsp-media-factory-wfd.c index 127af3c..cf7674a 100644 --- a/gst/rtsp-server/rtsp-media-factory-wfd.c +++ b/gst/rtsp-server/rtsp-media-factory-wfd.c @@ -1339,8 +1339,8 @@ rtsp_media_factory_wfd_construct (GstRTSPMediaFactory * factory, goto no_element; /* create a new empty media */ - //media = gst_rtsp_media_new (element); - media = g_object_new (GST_TYPE_RTSP_MEDIA_EXT, "element", element, NULL); + media = gst_rtsp_media_new (element); + //media = g_object_new (GST_TYPE_RTSP_MEDIA_EXT, "element", element, NULL); gst_rtsp_media_collect_streams (media); diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index 4810e65..a783f26 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 14 +Release: 15 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4 From 02c733a5e357e713dc3db71d754b509ca641b641 Mon Sep 17 00:00:00 2001 From: SeokHoon Lee Date: Mon, 8 May 2017 09:59:33 +0900 Subject: [PATCH 16/16] fix memory leak issue - add g_free after using url_str in function gst_rtsp_wfd_client_trigger_request - remove additioanl g_strdup for SET_PARAMETER and GET_PARAMETER in function M3, M4, M16_message Signed-off-by: SeokHoon Lee Change-Id: Iac82ce7d8b987e82842eb55275a27ce8a550e04f --- gst/rtsp-server/rtsp-client-wfd.c | 66 ++++++--------------------------------- packaging/gst-rtsp-server.spec | 2 +- 2 files changed, 10 insertions(+), 58 deletions(-) diff --git a/gst/rtsp-server/rtsp-client-wfd.c b/gst/rtsp-server/rtsp-client-wfd.c index f6cb221..93b1fea 100644 --- a/gst/rtsp-server/rtsp-client-wfd.c +++ b/gst/rtsp-server/rtsp-client-wfd.c @@ -2492,20 +2492,11 @@ gst_prepare_request (GstRTSPWFDClient * client, GstRTSPMessage * request, GstRTSPResult res = GST_RTSP_OK; gchar *str = NULL; - if (method == GST_RTSP_GET_PARAMETER || method == GST_RTSP_SET_PARAMETER) { - g_free (url); - url = g_strdup ("rtsp://localhost/wfd1.0"); - } - GST_DEBUG_OBJECT (client, "Preparing request: %d", method); /* initialize the request */ res = gst_rtsp_message_init_request (request, method, url); - if (method == GST_RTSP_GET_PARAMETER || method == GST_RTSP_SET_PARAMETER) { - g_free (url); - } - if (res < 0) { GST_ERROR ("init request failed"); return res; @@ -2943,28 +2934,10 @@ handle_M3_message (GstRTSPWFDClient * client) { GstRTSPResult res = GST_RTSP_OK; GstRTSPMessage request = { 0 }; - GstRTSPUrl *url = NULL; - gchar *url_str = NULL; - - GstRTSPClient *parent_client = GST_RTSP_CLIENT_CAST (client); - GstRTSPConnection *connection = - gst_rtsp_client_get_connection (parent_client); - - url = gst_rtsp_connection_get_url (connection); - if (url == NULL) { - GST_ERROR_OBJECT (client, "Failed to get connection URL"); - res = GST_RTSP_ERROR; - goto error; - } - url_str = gst_rtsp_url_get_request_uri (url); - if (url_str == NULL) { - GST_ERROR_OBJECT (client, "Failed to get connection URL"); - res = GST_RTSP_ERROR; - goto error; - } + res = gst_prepare_request (client, &request, GST_RTSP_GET_PARAMETER, + (gchar *) "rtsp://localhost/wfd1.0"); - res = gst_prepare_request (client, &request, GST_RTSP_GET_PARAMETER, url_str); if (GST_RTSP_OK != res) { GST_ERROR_OBJECT (client, "Failed to prepare M3 request....\n"); goto error; @@ -2973,11 +2946,10 @@ handle_M3_message (GstRTSPWFDClient * client) GST_DEBUG_OBJECT (client, "Sending GET_PARAMETER request message (M3)..."); gst_send_request (client, NULL, &request); - g_free(url_str); + return res; error: - g_free(url_str); return res; } @@ -2986,28 +2958,10 @@ handle_M4_message (GstRTSPWFDClient * client) { GstRTSPResult res = GST_RTSP_OK; GstRTSPMessage request = { 0 }; - GstRTSPUrl *url = NULL; - gchar *url_str = NULL; - - GstRTSPClient *parent_client = GST_RTSP_CLIENT_CAST (client); - GstRTSPConnection *connection = - gst_rtsp_client_get_connection (parent_client); - - url = gst_rtsp_connection_get_url (connection); - if (url == NULL) { - GST_ERROR_OBJECT (client, "Failed to get connection URL"); - res = GST_RTSP_ERROR; - goto error; - } - url_str = gst_rtsp_url_get_request_uri (url); - if (url_str == NULL) { - GST_ERROR_OBJECT (client, "Failed to get connection URL"); - res = GST_RTSP_ERROR; - goto error; - } + res = gst_prepare_request (client, &request, GST_RTSP_SET_PARAMETER, + (gchar *) "rtsp://localhost/wfd1.0"); - res = gst_prepare_request (client, &request, GST_RTSP_SET_PARAMETER, url_str); if (GST_RTSP_OK != res) { GST_ERROR_OBJECT (client, "Failed to prepare M4 request....\n"); goto error; @@ -3051,6 +3005,8 @@ gst_rtsp_wfd_client_trigger_request (GstRTSPWFDClient * client, } res = prepare_trigger_request (client, &request, type, url_str); + g_free (url_str); + if (GST_RTSP_OK != res) { GST_ERROR_OBJECT (client, "Failed to prepare M5 request....\n"); goto error; @@ -3157,20 +3113,16 @@ handle_M16_message (GstRTSPWFDClient * client) { GstRTSPResult res = GST_RTSP_OK; GstRTSPMessage request = { 0 }; - gchar *url_str = NULL; - url_str = g_strdup ("rtsp://localhost/wfd1.0"); + res = gst_rtsp_message_init_request (&request, GST_RTSP_GET_PARAMETER, + (gchar *) "rtsp://localhost/wfd1.0"); - res = - gst_rtsp_message_init_request (&request, GST_RTSP_GET_PARAMETER, url_str); if (res < 0) { GST_ERROR ("init request failed"); - g_free (url_str); return FALSE; } gst_send_request (client, NULL, &request); - g_free (url_str); return GST_RTSP_OK; } diff --git a/packaging/gst-rtsp-server.spec b/packaging/gst-rtsp-server.spec index a783f26..d8ebea3 100644 --- a/packaging/gst-rtsp-server.spec +++ b/packaging/gst-rtsp-server.spec @@ -1,7 +1,7 @@ Name: gst-rtsp-server Summary: Multimedia Framework Library Version: 1.6.1 -Release: 15 +Release: 16 Url: http://gstreamer.freedesktop.org/ Group: System/Libraries License: LGPL-2.0+ -- 2.7.4