mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-06 23:48:53 +00:00
shmsrc: Only connect to sink in PLAYING in live mode
This commit is contained in:
parent
a2b6dfa37e
commit
a646afcf88
1 changed files with 58 additions and 9 deletions
|
@ -71,6 +71,8 @@ static GstFlowReturn gst_shm_src_create (GstPushSrc * psrc,
|
||||||
GstBuffer ** outbuf);
|
GstBuffer ** outbuf);
|
||||||
static gboolean gst_shm_src_unlock (GstBaseSrc * bsrc);
|
static gboolean gst_shm_src_unlock (GstBaseSrc * bsrc);
|
||||||
static gboolean gst_shm_src_unlock_stop (GstBaseSrc * bsrc);
|
static gboolean gst_shm_src_unlock_stop (GstBaseSrc * bsrc);
|
||||||
|
static GstStateChangeReturn gst_shm_src_change_state (GstElement * element,
|
||||||
|
GstStateChange transition);
|
||||||
|
|
||||||
static void gst_shm_pipe_inc (GstShmPipe * pipe);
|
static void gst_shm_pipe_inc (GstShmPipe * pipe);
|
||||||
static void gst_shm_pipe_dec (GstShmPipe * pipe);
|
static void gst_shm_pipe_dec (GstShmPipe * pipe);
|
||||||
|
@ -97,10 +99,12 @@ static void
|
||||||
gst_shm_src_class_init (GstShmSrcClass * klass)
|
gst_shm_src_class_init (GstShmSrcClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
|
GstElementClass *gstelement_class;
|
||||||
GstBaseSrcClass *gstbasesrc_class;
|
GstBaseSrcClass *gstbasesrc_class;
|
||||||
GstPushSrcClass *gstpush_src_class;
|
GstPushSrcClass *gstpush_src_class;
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
|
gstelement_class = (GstElementClass *) klass;
|
||||||
gstbasesrc_class = (GstBaseSrcClass *) klass;
|
gstbasesrc_class = (GstBaseSrcClass *) klass;
|
||||||
gstpush_src_class = (GstPushSrcClass *) klass;
|
gstpush_src_class = (GstPushSrcClass *) klass;
|
||||||
|
|
||||||
|
@ -108,6 +112,8 @@ gst_shm_src_class_init (GstShmSrcClass * klass)
|
||||||
gobject_class->get_property = gst_shm_src_get_property;
|
gobject_class->get_property = gst_shm_src_get_property;
|
||||||
gobject_class->finalize = gst_shm_src_finalize;
|
gobject_class->finalize = gst_shm_src_finalize;
|
||||||
|
|
||||||
|
gstelement_class->change_state = gst_shm_src_change_state;
|
||||||
|
|
||||||
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_shm_src_start);
|
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_shm_src_start);
|
||||||
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_shm_src_stop);
|
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_shm_src_stop);
|
||||||
gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_shm_src_unlock);
|
gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_shm_src_unlock);
|
||||||
|
@ -197,28 +203,27 @@ gst_shm_src_get_property (GObject * object, guint prop_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_shm_src_start (GstBaseSrc * bsrc)
|
gst_shm_src_start_reading (GstShmSrc * self)
|
||||||
{
|
{
|
||||||
GstShmSrc *self = GST_SHM_SRC (bsrc);
|
|
||||||
GstShmPipe *gstpipe = g_slice_new0 (GstShmPipe);
|
GstShmPipe *gstpipe = g_slice_new0 (GstShmPipe);
|
||||||
|
|
||||||
gstpipe->use_count = 1;
|
gstpipe->use_count = 1;
|
||||||
gstpipe->src = gst_object_ref (self);
|
gstpipe->src = gst_object_ref (self);
|
||||||
|
|
||||||
if (!self->socket_path) {
|
if (!self->socket_path) {
|
||||||
GST_ELEMENT_ERROR (bsrc, RESOURCE, NOT_FOUND,
|
GST_ELEMENT_ERROR (self, RESOURCE, NOT_FOUND,
|
||||||
("No path specified for socket."), (NULL));
|
("No path specified for socket."), (NULL));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG ("Opening socket %s", self->socket_path);
|
GST_DEBUG_OBJECT (self, "Opening socket %s", self->socket_path);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (self);
|
GST_OBJECT_LOCK (self);
|
||||||
gstpipe->pipe = sp_client_open (self->socket_path);
|
gstpipe->pipe = sp_client_open (self->socket_path);
|
||||||
GST_OBJECT_UNLOCK (self);
|
GST_OBJECT_UNLOCK (self);
|
||||||
|
|
||||||
if (!gstpipe->pipe) {
|
if (!gstpipe->pipe) {
|
||||||
GST_ELEMENT_ERROR (bsrc, RESOURCE, OPEN_READ_WRITE,
|
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ_WRITE,
|
||||||
("Could not open socket %s: %d %s", self->socket_path, errno,
|
("Could not open socket %s: %d %s", self->socket_path, errno,
|
||||||
strerror (errno)), (NULL));
|
strerror (errno)), (NULL));
|
||||||
gst_shm_pipe_dec (gstpipe);
|
gst_shm_pipe_dec (gstpipe);
|
||||||
|
@ -237,11 +242,9 @@ gst_shm_src_start (GstBaseSrc * bsrc)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
gst_shm_src_stop (GstBaseSrc * bsrc)
|
gst_shm_src_stop_reading (GstShmSrc * self)
|
||||||
{
|
{
|
||||||
GstShmSrc *self = GST_SHM_SRC (bsrc);
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (self, "Stopping %p", self);
|
GST_DEBUG_OBJECT (self, "Stopping %p", self);
|
||||||
|
|
||||||
if (self->pipe) {
|
if (self->pipe) {
|
||||||
|
@ -253,6 +256,22 @@ gst_shm_src_stop (GstBaseSrc * bsrc)
|
||||||
gst_poll_fd_init (&self->pollfd);
|
gst_poll_fd_init (&self->pollfd);
|
||||||
|
|
||||||
gst_poll_set_flushing (self->poll, TRUE);
|
gst_poll_set_flushing (self->poll, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_shm_src_start (GstBaseSrc * bsrc)
|
||||||
|
{
|
||||||
|
if (gst_base_src_is_live (bsrc))
|
||||||
|
return TRUE;
|
||||||
|
else
|
||||||
|
return gst_shm_src_start_reading (GST_SHM_SRC (bsrc));
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_shm_src_stop (GstBaseSrc * bsrc)
|
||||||
|
{
|
||||||
|
if (!gst_base_src_is_live (bsrc))
|
||||||
|
gst_shm_src_stop_reading (GST_SHM_SRC (bsrc));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -339,6 +358,36 @@ gst_shm_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstStateChangeReturn
|
||||||
|
gst_shm_src_change_state (GstElement * element, GstStateChange transition)
|
||||||
|
{
|
||||||
|
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
||||||
|
GstShmSrc *self = GST_SHM_SRC (element);
|
||||||
|
|
||||||
|
switch (transition) {
|
||||||
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||||
|
if (gst_base_src_is_live (GST_BASE_SRC (element)))
|
||||||
|
if (!gst_shm_src_start_reading (self))
|
||||||
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||||
|
if (ret == GST_STATE_CHANGE_FAILURE)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
switch (transition) {
|
||||||
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||||
|
if (gst_base_src_is_live (GST_BASE_SRC (element)))
|
||||||
|
gst_shm_src_stop_reading (self);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_shm_src_unlock (GstBaseSrc * bsrc)
|
gst_shm_src_unlock (GstBaseSrc * bsrc)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue