#include <dri2.h>
#include <utilX.h>
+#define DEFAULT_RTSP_TIMEOUT 60
#define DRM_EXYNOS_VIDI_ON 1
#define DRM_EXYNOS_VIDI_OFF 0
/* temporary multicast address until it's configurable somewhere */
#define MCAST_ADDRESS "224.2.0.1"
+#define DEFAULT_WFD_MTU_SIZE 1400
+
static GMutex *tunnels_lock;
static GHashTable *tunnels;
enum
{
SIGNAL_CLOSED,
+ SIGNAL_ERROR,
SIGNAL_LAST
};
static gboolean
gst_rtsp_client_parse_methods (GstRTSPClient * client, GstRTSPMessage * response);
-
+gboolean
+keep_alive_condition(gpointer *userdata);
+gboolean
+gst_rtsp_client_sending_m16_message (GstRTSPClient * client);
#ifdef WFD_PAD_PROBE
static gboolean
G_STRUCT_OFFSET (GstRTSPClientClass, closed), NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, G_TYPE_NONE);
+ gst_rtsp_client_signals[SIGNAL_ERROR] =
+ g_signal_new ("error_noti", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstRTSPClientClass, on_error), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, G_TYPE_NONE);
+
tunnels =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
tunnels_lock = g_mutex_new ();
gst_rtsp_client_init (GstRTSPClient * client)
{
client->state_lock = g_mutex_new ();
+ client->keep_alive_lock = g_mutex_new();
+ client->keep_alive_flag = TRUE;
+ client->cseq = 0;
client->state_wait = g_cond_new ();
client->client_state = CLIENT_STATE_UNKNOWN;
client->videosrc_type = WFD_INI_VSRC_XVIMAGESRC;
client->session_mode = 0;
client->infile = NULL;
+ client->MTUsize = DEFAULT_WFD_MTU_SIZE;
}
static void
client_cleanup_sessions (client);
- gst_rtsp_connection_free (client->connection);
+ if(client->connection)
+ {
+ gst_rtsp_connection_close (client->connection);
+ gst_rtsp_connection_free(client->connection);
+ if (client->watch)
+ g_source_destroy ((GSource *) client->watch);
+ client->watchid = 0;
+ client->watch = NULL;
+ }
if (client->session_pool)
g_object_unref (client->session_pool);
if (client->media_mapping)
g_object_unref (client->media);
g_free (client->server_ip);
set_edid_info(NULL, FALSE);
-
+ if(client->keep_alive_lock)
+ g_mutex_free (client->keep_alive_lock);
+ client->keep_alive_lock = NULL;
g_cond_signal (client->state_wait);
-
+ if (client->server)
+ g_object_unref (client->server);
if(client->tcpsock)
close(client->tcpsock);
G_OBJECT_CLASS (gst_rtsp_client_parent_class)->finalize (obj);
GST_DEBUG ("session is not NULL - %p", session);
- if (session->timeout != 60)
- str =
- g_strdup_printf ("%s; timeout=%d", session->sessionid,
- session->timeout);
+ if (session->timeout > 30)
+ str = g_strdup_printf ("%s; timeout=%d", session->sessionid, session->timeout);
else
-#if 0 //Changes for testing with dongle
- str = g_strdup (session->sessionid);
-#else
{
- //str = g_strdup (session->sessionid);
- str = g_strdup_printf ("%s;timeout=%d", session->sessionid, 30); //Changes for testing with dongle
+ str = g_strdup_printf ("%s;timeout=%d", session->sessionid, 30);
}
-#endif
gst_rtsp_message_take_header (response, GST_RTSP_HDR_SESSION, str);
}
GST_DEBUG ("session is not NULL - %p", session);
- if (session->timeout != 60)
+ if (session->timeout != DEFAULT_RTSP_TIMEOUT)
str =
g_strdup_printf ("%s; timeout=%d", session->sessionid,
session->timeout);
* something. */
if (!(session = gst_rtsp_session_pool_create (client->session_pool)))
goto service_unavailable;
-
+ session->timeout = DEFAULT_RTSP_TIMEOUT;
state->session = session;
client->sessionid = g_strdup(session->sessionid);
/* we need a new media configuration in this session */
/* check what kind of format is accepted, we don't really do anything with it
* and always return SDP for now. */
- for (i = 0; i++;) {
+ for (i = 0; ;i++) {
gchar *accept;
-
res =
gst_rtsp_message_get_header (state->request, GST_RTSP_HDR_ACCEPT,
&accept, i);
break;
case GST_RTSP_PLAY:
handle_play_request (client, &state);
+ g_timeout_add((DEFAULT_RTSP_TIMEOUT - 5)*1000, keep_alive_condition, client);
break;
case GST_RTSP_PAUSE:
handle_pause_request (client, &state);
gst_rtsp_message_parse_response (message, &code, &uristr, &version);
GST_INFO_OBJECT (client, "revd message method = %d", code);
+ g_mutex_lock(client->keep_alive_lock);
+ client->keep_alive_flag = TRUE;
+ g_mutex_unlock(client->keep_alive_lock);
}
break;
case GST_RTSP_MESSAGE_DATA:
client->connection = conn;
/* create watch for the connection and attach */
- client->watch = gst_rtsp_watch_new (client->connection, &watch_funcs,
- g_object_ref (client), (GDestroyNotify) client_watch_notify);
+ client->watch = gst_rtsp_watch_new (client->connection, &watch_funcs, client, (GDestroyNotify) client_watch_notify);
#if 0
/* find the context to add the watch */
GstRTSPResult res = GST_RTSP_OK;
gchar *str = NULL;
WFDResult wfd_res = WFD_OK;
-
+ GString *cseqstr;
/* initialize the request */
res = gst_rtsp_message_init_request (request, method, url);
if (res < 0) {
return res;
}
+ client->cseq++;
+ cseqstr = g_string_new ("");
+ g_string_append_printf (cseqstr,"%d",client->cseq);
+ GST_DEBUG ("CSeq value has been incremented to %d", client->cseq);
+ res = gst_rtsp_message_add_header (request, GST_RTSP_HDR_CSEQ, g_string_free (cseqstr, FALSE));
+ if (res < 0) {
+ GST_ERROR ("Failed to add header");
+ return res;
+ }
+
switch (method) {
/* Prepare OPTIONS request to send */
GST_ERROR_OBJECT (client, "Failed to set coupled sink type on wfd message...");
res = GST_RTSP_ERROR;
goto error;
- }
+ } */
+#ifdef STANDBY_RESUME_CAPABILITY
GST_DEBUG ("wfdconfig_set_standby_resume_capability...");
wfd_res = wfdconfig_set_standby_resume_capability(msg3, FALSE);
if (wfd_res != WFD_OK) {
GST_ERROR_OBJECT (client, "Failed to set coupled sink type on wfd message...");
res = GST_RTSP_ERROR;
goto error;
- }*/
-
+ }
+#endif
/* set the preffered RTP ports for the WFD server*/
wfd_res = wfdconfig_set_prefered_RTP_ports(msg3, WFD_RTSP_TRANS_UNKNOWN, WFD_RTSP_PROFILE_UNKNOWN,
WFD_RTSP_LOWER_TRANS_UNKNOWN, 0, 0);
goto error;
}
}
+#ifdef STANDBY_RESUME_CAPABILITY
+ if(client->standby_resume_capability_support){
+ wfd_res = wfdconfig_set_standby_resume_capability(msg4, TRUE);
+ if (wfd_res != WFD_OK) {
+ GST_ERROR_OBJECT (client, "Failed to set supported standby resume capability type on wfd message...");
+ res = GST_RTSP_ERROR;
+ goto error;
+ }
+ }
+#endif
wfd_res = wfdconfig_message_dump(msg4);
if (wfd_res != WFD_OK) {
GST_ERROR_OBJECT (client, "Failed to dump wfd message...");
client->hdcp_version = WFD_HDCP_NONE;
client->hdcp_tcpport = 0;
client->hdcp_support = FALSE;
-
+#ifdef STANDBY_RESUME_CAPABILITY
+ client->standby_resume_capability_support = FALSE;
+#endif
url = gst_rtsp_connection_get_url (client->connection);
if (url == NULL) {
goto error;
}
}
-
+#ifdef STANDBY_RESUME_CAPABILITY
+ if (msg3res->standby_resume_capability) {
+ /*Get the standby_resume_capability value by WFDSink*/
+ wfd_res = wfdconfig_get_standby_resume_capability(msg3res, &client->standby_resume_capability_support );
+ if (wfd_res != WFD_OK) {
+ GST_WARNING_OBJECT (client, "Failed to get wfd standby resume capability...");
+ goto error;
+ }
+ }
+#endif
wfdconfig_message_dump(msg3res);
}
}
+
/**
* handle_M12_message:
* @client: client object
}
void
-gst_rtsp_client_set_params (GstRTSPClient *client, int videosrc_type, gint session_mode, int videobitrate, gchar *infile)
+gst_rtsp_client_set_params (GstRTSPClient *client, int videosrc_type, gint session_mode, int videobitrate, gint mtu_size, gchar *infile)
{
client->videosrc_type = videosrc_type;
client->session_mode = session_mode;
client->bitrate = videobitrate;
+ client->MTUsize = mtu_size;
client->infile = g_strdup (infile);
g_print ("\n\n\nvideo src type = %d & session_mode = %d & filename = %s\n",
//g_object_set (audiosrc, "latency-time", 1000, NULL);
//g_object_set (audiosrc, "actual-latency-time", 1000, NULL);
- //g_object_set (audiosrc, "is-live", 1, NULL);
+ g_object_set (audiosrc, "is-live", 1, NULL);
g_object_set (audiosrc, "do-timestamp", 1, NULL);
/* create audio caps element */
acaps = gst_element_factory_make ("capsfilter", "audiocaps");
}
g_object_set (payload, "pt", 33, NULL);
- g_object_set (payload, "max-ptime", 2000000, NULL); // Why max-ptime is 2microsec ???
+ g_object_set (payload, "mtu", client->MTUsize, NULL);
gst_bin_add_many (srcbin->srcbin, mux, payload, NULL);
}
#endif
+static void
+keep_alive_response_check (gpointer *userdata)
+{
+ GstRTSPClient *client = (GstRTSPClient *)userdata;
+ if (!client) {
+ return;
+ }
+ if (client->keep_alive_flag) {
+ return;
+ }
+ else {
+ GST_INFO ("%p: source error notification", client);
+ g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_ERROR], 0, NULL);
+ }
+}
+
+/*CHecking whether source has got response of any request.
+ * If yes, keep alive message is sent otherwise error message
+ * will be displayed.*/
+gboolean
+keep_alive_condition(gpointer *userdata)
+{
+ GstRTSPClient *client;
+ gboolean res;
+ client = (GstRTSPClient *)userdata;
+ if (!client) {
+ return FALSE;
+ }
+ if(client->keep_alive_lock)
+ g_mutex_lock(client->keep_alive_lock);
+ else
+ return FALSE;
+ if(!client->keep_alive_flag) {
+ g_timeout_add(5000, keep_alive_response_check, client);
+ }
+ else {
+ GST_DEBUG_OBJECT (client, "have received last keep alive message response");
+ }
+ GST_DEBUG("sending keep alive message");
+ res = gst_rtsp_client_sending_m16_message(client);
+ if(res) {
+ client->keep_alive_flag = FALSE;
+ }
+ else {
+ GST_ERROR_OBJECT (client, "Failed to send Keep Alive Message");
+ g_mutex_unlock(client->keep_alive_lock);
+ return FALSE;
+ }
+ g_mutex_unlock(client->keep_alive_lock);
+ return TRUE;
+}
+/*Sending keep_alive (M16) message.
+ Without calling prepare_request function.*/
+
+gboolean
+gst_rtsp_client_sending_m16_message (GstRTSPClient * client)
+{
+ GstRTSPResult res = GST_RTSP_OK;
+ GstRTSPUrl *url = NULL;
+ GstRTSPMessage request = { 0 };
+ gchar *url_str = NULL;
+ GstRTSPSession *session = NULL;
+
+ url = gst_rtsp_connection_get_url (client->connection);
+ if (url == NULL) {
+ GST_ERROR_OBJECT (client, "Failed to get connection URL");
+ return FALSE;
+ }
+
+ url_str = gst_rtsp_url_get_request_uri (url);
+ if (url_str == NULL) {
+ GST_ERROR_OBJECT (client, "Failed to get connection URL");
+ return FALSE;
+ }
+
+ res = gst_rtsp_message_init_request (&request, GST_RTSP_GET_PARAMETER, url_str);
+ if (res < 0) {
+ GST_ERROR ("init request failed");
+ return FALSE;
+ }
+
+ if (client->sessionid) {
+ session = gst_rtsp_session_pool_find (client->session_pool, client->sessionid);
+ GST_INFO_OBJECT (client, "session = %p & sessionid = %s", session, session->sessionid);
+ }
+ send_request (client, session, &request);
+ return TRUE;
+}
+