mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 18:35:35 +00:00
multifdsink: add property to handle client write
Add a property to disable listening to client writes. This property is usefull when other code will deal with reading from the client socket. API: GstMultiFdSink::handle-read property
This commit is contained in:
parent
86edcadc43
commit
19d30b90d4
2 changed files with 30 additions and 4 deletions
|
@ -179,6 +179,7 @@ enum
|
||||||
#define DEFAULT_BURST_VALUE 0
|
#define DEFAULT_BURST_VALUE 0
|
||||||
|
|
||||||
#define DEFAULT_QOS_DSCP -1
|
#define DEFAULT_QOS_DSCP -1
|
||||||
|
#define DEFAULT_HANDLE_READ TRUE
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -211,6 +212,8 @@ enum
|
||||||
|
|
||||||
PROP_QOS_DSCP,
|
PROP_QOS_DSCP,
|
||||||
|
|
||||||
|
PROP_HANDLE_READ,
|
||||||
|
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -485,10 +488,22 @@ gst_multi_fd_sink_class_init (GstMultiFdSinkClass * klass)
|
||||||
DEFAULT_BURST_VALUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
DEFAULT_BURST_VALUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_QOS_DSCP,
|
g_object_class_install_property (gobject_class, PROP_QOS_DSCP,
|
||||||
g_param_spec_int ("qos_dscp", "QoS diff srv code point",
|
g_param_spec_int ("qos-dscp", "QoS diff srv code point",
|
||||||
"Quality of Service, differentiated services code point (-1 default)",
|
"Quality of Service, differentiated services code point (-1 default)",
|
||||||
-1, 63, DEFAULT_QOS_DSCP, G_PARAM_READWRITE));
|
-1, 63, DEFAULT_QOS_DSCP, G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstMultiFdSink::handle-read
|
||||||
|
*
|
||||||
|
* Handle read requests from clients and discard the data.
|
||||||
|
*
|
||||||
|
* Since: 0.10.23
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (gobject_class, PROP_HANDLE_READ,
|
||||||
|
g_param_spec_boolean ("handle-read", "Handle Read",
|
||||||
|
"Handle client reads and discard the data",
|
||||||
|
DEFAULT_HANDLE_READ, G_PARAM_READWRITE));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstMultiFdSink::add:
|
* GstMultiFdSink::add:
|
||||||
* @gstmultifdsink: the multifdsink element to emit this signal on
|
* @gstmultifdsink: the multifdsink element to emit this signal on
|
||||||
|
@ -678,6 +693,7 @@ gst_multi_fd_sink_init (GstMultiFdSink * this, GstMultiFdSinkClass * klass)
|
||||||
this->def_burst_value = DEFAULT_BURST_VALUE;
|
this->def_burst_value = DEFAULT_BURST_VALUE;
|
||||||
|
|
||||||
this->qos_dscp = DEFAULT_QOS_DSCP;
|
this->qos_dscp = DEFAULT_QOS_DSCP;
|
||||||
|
this->handle_read = DEFAULT_HANDLE_READ;
|
||||||
|
|
||||||
this->header_flags = 0;
|
this->header_flags = 0;
|
||||||
}
|
}
|
||||||
|
@ -841,9 +857,11 @@ gst_multi_fd_sink_add_full (GstMultiFdSink * sink, int fd,
|
||||||
gst_poll_add_fd (sink->fdset, &client->fd);
|
gst_poll_add_fd (sink->fdset, &client->fd);
|
||||||
|
|
||||||
/* we don't try to read from write only fds */
|
/* we don't try to read from write only fds */
|
||||||
flags = fcntl (fd, F_GETFL, 0);
|
if (sink->handle_read) {
|
||||||
if ((flags & O_ACCMODE) != O_WRONLY) {
|
flags = fcntl (fd, F_GETFL, 0);
|
||||||
gst_poll_fd_ctl_read (sink->fdset, &client->fd, TRUE);
|
if ((flags & O_ACCMODE) != O_WRONLY) {
|
||||||
|
gst_poll_fd_ctl_read (sink->fdset, &client->fd, TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* figure out the mode, can't use send() for non sockets */
|
/* figure out the mode, can't use send() for non sockets */
|
||||||
res = fstat (fd, &statbuf);
|
res = fstat (fd, &statbuf);
|
||||||
|
@ -2414,6 +2432,7 @@ gst_multi_fd_sink_handle_clients (GstMultiFdSink * sink)
|
||||||
fd, g_strerror (errno), errno);
|
fd, g_strerror (errno), errno);
|
||||||
if (errno == EBADF) {
|
if (errno == EBADF) {
|
||||||
client->status = GST_CLIENT_STATUS_ERROR;
|
client->status = GST_CLIENT_STATUS_ERROR;
|
||||||
|
/* releases the CLIENTS lock */
|
||||||
gst_multi_fd_sink_remove_client_link (sink, clients);
|
gst_multi_fd_sink_remove_client_link (sink, clients);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2663,6 +2682,9 @@ gst_multi_fd_sink_set_property (GObject * object, guint prop_id,
|
||||||
multifdsink->qos_dscp = g_value_get_int (value);
|
multifdsink->qos_dscp = g_value_get_int (value);
|
||||||
setup_dscp (multifdsink);
|
setup_dscp (multifdsink);
|
||||||
break;
|
break;
|
||||||
|
case PROP_HANDLE_READ:
|
||||||
|
multifdsink->handle_read = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -2742,6 +2764,9 @@ gst_multi_fd_sink_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
case PROP_QOS_DSCP:
|
case PROP_QOS_DSCP:
|
||||||
g_value_set_int (value, multifdsink->qos_dscp);
|
g_value_set_int (value, multifdsink->qos_dscp);
|
||||||
break;
|
break;
|
||||||
|
case PROP_HANDLE_READ:
|
||||||
|
g_value_set_boolean (value, multifdsink->handle_read);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
|
|
@ -209,6 +209,7 @@ struct _GstMultiFdSink {
|
||||||
GstTCPProtocol protocol;
|
GstTCPProtocol protocol;
|
||||||
guint mtu;
|
guint mtu;
|
||||||
gint qos_dscp;
|
gint qos_dscp;
|
||||||
|
gboolean handle_read;
|
||||||
|
|
||||||
GArray *bufqueue; /* global queue of buffers */
|
GArray *bufqueue; /* global queue of buffers */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue