diff --git a/common b/common index 6b0a313b93..6757dae288 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 6b0a313b93535f0df7956a01405ddb63a3d76b5a +Subproject commit 6757dae2885c2c09ad6db243c73946ef387bb044 diff --git a/gst/tcp/gsttcpsrc.c b/gst/tcp/gsttcpsrc.c index eb93b25219..987cd650af 100644 --- a/gst/tcp/gsttcpsrc.c +++ b/gst/tcp/gsttcpsrc.c @@ -47,7 +47,8 @@ enum { enum { ARG_0, ARG_PORT, - ARG_CONTROL + ARG_CONTROL, + ARG_SOCKET_OPTIONS, /* FILL ME */ }; @@ -124,6 +125,10 @@ gst_tcpsrc_class_init (GstTCPSrc *klass) g_param_spec_enum ("control", "control", "The type of control", GST_TYPE_TCPSRC_CONTROL, CONTROL_TCP, G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SOCKET_OPTIONS, + g_param_spec_boolean ("socketop", "socketop", "Enable or disable socket options REUSEADDR and KEEPALIVE", + FALSE, G_PARAM_READWRITE)); + gobject_class->set_property = gst_tcpsrc_set_property; gobject_class->get_property = gst_tcpsrc_get_property; @@ -155,6 +160,7 @@ gst_tcpsrc_init (GstTCPSrc *tcpsrc) tcpsrc->sock = -1; tcpsrc->control_sock = -1; tcpsrc->client_sock = -1; + tcpsrc->socket_options = FALSE; GST_FLAG_UNSET (tcpsrc, GST_TCPSRC_OPEN); GST_FLAG_SET (tcpsrc, GST_TCPSRC_1ST_BUF); @@ -323,6 +329,9 @@ gst_tcpsrc_set_property (GObject *object, guint prop_id, const GValue *value, GP case ARG_CONTROL: tcpsrc->control = g_value_get_enum (value); break; + case ARG_SOCKET_OPTIONS: + tcpsrc->socket_options = g_value_get_boolean(value); + break; default: break; } @@ -344,6 +353,9 @@ gst_tcpsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSp case ARG_CONTROL: g_value_set_enum (value, tcpsrc->control); break; + case ARG_SOCKET_OPTIONS: + g_value_set_boolean(value,tcpsrc->socket_options); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -354,6 +366,7 @@ gst_tcpsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSp static gboolean gst_tcpsrc_init_receive (GstTCPSrc *src) { + guint val=0; bzero (&src->myaddr, sizeof (src->myaddr)); src->myaddr.sin_family = AF_INET; /* host byte order */ src->myaddr.sin_port = htons (src->port); /* short, network byte order */ @@ -363,7 +376,22 @@ gst_tcpsrc_init_receive (GstTCPSrc *src) perror("stream_socket"); return FALSE; } - + + if (src->socket_options) + { + g_print("Socket Options enabled\n"); + /* Sock Options */ + val = 1; + /* allow local address reuse */ + if( setsockopt( src->sock,SOL_SOCKET,SO_REUSEADDR, &val, sizeof( int )) <0) + perror( "setsockopt()" ); + val = 1; + /* periodically test if connection still alive */ + if( setsockopt( src->sock,SOL_SOCKET,SO_KEEPALIVE, &val, sizeof( int )) <0) + perror( "setsockopt()" ); + /* Sock Options */ + } + if (bind (src->sock, (struct sockaddr *) &src->myaddr, sizeof (src->myaddr)) == -1) { perror("stream_sock bind"); return FALSE; diff --git a/gst/tcp/gsttcpsrc.h b/gst/tcp/gsttcpsrc.h index c7166be182..9e2063f98a 100644 --- a/gst/tcp/gsttcpsrc.h +++ b/gst/tcp/gsttcpsrc.h @@ -71,6 +71,7 @@ struct _GstTCPSrc { int sock; int client_sock; int control_sock; + gboolean socket_options; Gst_TCP_Control control; struct sockaddr_in myaddr;