make this thing work with invalid buffer timestamps

Original commit message from CVS:
make this thing work with invalid buffer timestamps
This commit is contained in:
Benjamin Otte 2003-12-14 05:10:28 +00:00
parent bf9d39d5f3
commit a7d05f504a
2 changed files with 20 additions and 8 deletions

View file

@ -750,12 +750,14 @@ gst_xvimagesink_change_state (GstElement *element)
return GST_STATE_FAILURE; return GST_STATE_FAILURE;
break; break;
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
xvimagesink->time = 0;
break; break;
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
break; break;
case GST_STATE_PLAYING_TO_PAUSED: case GST_STATE_PLAYING_TO_PAUSED:
break; break;
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
xvimagesink->framerate = 0;
break; break;
case GST_STATE_READY_TO_NULL: case GST_STATE_READY_TO_NULL:
break; break;
@ -768,10 +770,9 @@ gst_xvimagesink_change_state (GstElement *element)
} }
static void static void
gst_xvimagesink_chain (GstPad *pad, GstData *_data) gst_xvimagesink_chain (GstPad *pad, GstData *data)
{ {
GstBuffer *buf = GST_BUFFER (_data); GstBuffer *buf;
GstClockTime time = GST_BUFFER_TIMESTAMP (buf);
GstXvImageSink *xvimagesink; GstXvImageSink *xvimagesink;
g_return_if_fail (pad != NULL); g_return_if_fail (pad != NULL);
@ -780,9 +781,9 @@ gst_xvimagesink_chain (GstPad *pad, GstData *_data)
xvimagesink = GST_XVIMAGESINK (gst_pad_get_parent (pad)); xvimagesink = GST_XVIMAGESINK (gst_pad_get_parent (pad));
if (GST_IS_EVENT (buf)) if (GST_IS_EVENT (data))
{ {
GstEvent *event = GST_EVENT (buf); GstEvent *event = GST_EVENT (data);
gint64 offset; gint64 offset;
switch (GST_EVENT_TYPE (event)) switch (GST_EVENT_TYPE (event))
@ -799,11 +800,16 @@ gst_xvimagesink_chain (GstPad *pad, GstData *_data)
return; return;
} }
GST_DEBUG ("videosink: clock wait: %" G_GUINT64_FORMAT, time); buf = GST_BUFFER (data);
/* update time */
if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
xvimagesink->time = GST_BUFFER_TIMESTAMP (buf);
}
GST_DEBUG ("videosink: clock wait: %" G_GUINT64_FORMAT, xvimagesink->time);
if (GST_VIDEOSINK_CLOCK (xvimagesink)) { if (GST_VIDEOSINK_CLOCK (xvimagesink)) {
GstClockID id; GstClockID id;
id = gst_clock_new_single_shot_id (GST_VIDEOSINK_CLOCK (xvimagesink), time); id = gst_clock_new_single_shot_id (GST_VIDEOSINK_CLOCK (xvimagesink), xvimagesink->time);
gst_element_clock_wait (GST_ELEMENT (xvimagesink), id, NULL); gst_element_clock_wait (GST_ELEMENT (xvimagesink), id, NULL);
gst_clock_id_free (id); gst_clock_id_free (id);
} }
@ -828,7 +834,11 @@ gst_xvimagesink_chain (GstPad *pad, GstData *_data)
return; return;
} }
} }
/* set correct time for next buffer */
if (!GST_BUFFER_TIMESTAMP_IS_VALID (buf) && xvimagesink->framerate > 0) {
xvimagesink->time += GST_SECOND / xvimagesink->framerate;
}
gst_buffer_unref (buf); gst_buffer_unref (buf);
gst_xvimagesink_handle_xevents (xvimagesink, pad); gst_xvimagesink_handle_xevents (xvimagesink, pad);

View file

@ -127,6 +127,8 @@ struct _GstXvImageSink {
/* Unused */ /* Unused */
gint pixel_width, pixel_height; gint pixel_width, pixel_height;
GstClockTime time;
GstBufferPool *bufferpool; GstBufferPool *bufferpool;
GMutex *pool_lock; GMutex *pool_lock;