Fix client-source negotiation and states

Avoid buffers without data.

Handle stream state changes in gstpvsrc and gstpvsink

Implement capabilities in v4l2 source
This commit is contained in:
Wim Taymans 2015-05-15 15:58:13 +02:00
parent cbe7b52a70
commit 31cc37b6a5
5 changed files with 99 additions and 32 deletions

View file

@ -257,6 +257,21 @@ gst_pulsevideo_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
g_mutex_unlock (&pvsink->lock);
pv_stream_start (pvsink->stream, format, PV_STREAM_MODE_BUFFER);
g_mutex_lock (&pvsink->lock);
while (TRUE) {
PvStreamState state = pv_stream_get_state (pvsink->stream);
if (state == PV_STREAM_STATE_STREAMING)
break;
if (state == PV_STREAM_STATE_ERROR)
goto connect_error;
g_cond_wait (&pvsink->cond, &pvsink->lock);
}
g_mutex_unlock (&pvsink->lock);
pvsink->negotiated = TRUE;
return TRUE;

View file

@ -368,8 +368,16 @@ gst_pulsevideo_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
goto not_negotiated;
g_mutex_lock (&pvsrc->lock);
g_cond_wait (&pvsrc->cond, &pvsrc->lock);
pv_stream_capture_buffer (pvsrc->stream, &info);
while (TRUE) {
g_cond_wait (&pvsrc->cond, &pvsrc->lock);
if (pv_stream_get_state (pvsrc->stream) != PV_STREAM_STATE_STREAMING)
goto streaming_stopped;
pv_stream_capture_buffer (pvsrc->stream, &info);
if (info.message != NULL)
break;
}
g_mutex_unlock (&pvsrc->lock);
*buffer = gst_buffer_new ();
@ -393,6 +401,11 @@ not_negotiated:
{
return GST_FLOW_NOT_NEGOTIATED;
}
streaming_stopped:
{
g_mutex_unlock (&pvsrc->lock);
return GST_FLOW_FLUSHING;
}
}
static gboolean