Commit 76c4048c authored by Edgard Gusmão Lima's avatar Edgard Gusmão Lima
Browse files

Trying to fix videos out of sync (not fixed yet)

Original commit message from CVS:
Trying to fix videos out of sync (not fixed yet)
parent 9faf9154
2005-10-27 Edgard Lima <edgard.lima@indt.org.br>
* ext/sdl/sdlvideosink.c:
* ext/sdl/sdlvideosink.h:
Trying to fix videos out of sync (not fixed yet)
2005-10-27 Tim-Philipp Müller <tim at centricular dot net> 2005-10-27 Tim-Philipp Müller <tim at centricular dot net>
* gst/qtdemux/qtdemux.h: * gst/qtdemux/qtdemux.h:
......
...@@ -161,6 +161,30 @@ gst_sdlvideosink_finalize (GObject * obj) ...@@ -161,6 +161,30 @@ gst_sdlvideosink_finalize (GObject * obj)
((GObjectClass *) parent_class)->finalize (obj); ((GObjectClass *) parent_class)->finalize (obj);
} }
static void
gst_sdlvideosink_get_times (GstBaseSink * basesink, GstBuffer * buffer,
GstClockTime * start, GstClockTime * end)
{
GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (basesink);
GstClockTime timestamp, duration;
timestamp = GST_BUFFER_TIMESTAMP (buffer);
if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
*start = timestamp;
duration = GST_BUFFER_DURATION (buffer);
if (GST_CLOCK_TIME_IS_VALID (duration)) {
*end = timestamp + duration;
} else {
if (sdlvideosink->framerate > 0) {
*end = timestamp + GST_SECOND / sdlvideosink->framerate;
}
}
}
}
static void static void
gst_sdlvideosink_class_init (GstSDLVideoSinkClass * klass) gst_sdlvideosink_class_init (GstSDLVideoSinkClass * klass)
{ {
...@@ -183,6 +207,7 @@ gst_sdlvideosink_class_init (GstSDLVideoSinkClass * klass) ...@@ -183,6 +207,7 @@ gst_sdlvideosink_class_init (GstSDLVideoSinkClass * klass)
GST_DEBUG_FUNCPTR (gst_sdlvideosink_change_state); GST_DEBUG_FUNCPTR (gst_sdlvideosink_change_state);
gstvs_class->set_caps = GST_DEBUG_FUNCPTR (gst_sdlvideosink_setcaps); gstvs_class->set_caps = GST_DEBUG_FUNCPTR (gst_sdlvideosink_setcaps);
gstvs_class->get_times = GST_DEBUG_FUNCPTR (gst_sdlvideosink_get_times);
gstvs_class->preroll = GST_DEBUG_FUNCPTR (gst_sdlvideosink_show_frame); gstvs_class->preroll = GST_DEBUG_FUNCPTR (gst_sdlvideosink_show_frame);
gstvs_class->render = GST_DEBUG_FUNCPTR (gst_sdlvideosink_show_frame); gstvs_class->render = GST_DEBUG_FUNCPTR (gst_sdlvideosink_show_frame);
...@@ -256,6 +281,7 @@ gst_sdlvideosink_init (GstSDLVideoSink * sdlvideosink) ...@@ -256,6 +281,7 @@ gst_sdlvideosink_init (GstSDLVideoSink * sdlvideosink)
sdlvideosink->width = -1; sdlvideosink->width = -1;
sdlvideosink->height = -1; sdlvideosink->height = -1;
sdlvideosink->framerate = 0;
sdlvideosink->overlay = NULL; sdlvideosink->overlay = NULL;
sdlvideosink->screen = NULL; sdlvideosink->screen = NULL;
...@@ -543,6 +569,7 @@ gst_sdlvideosink_setcaps (GstBaseSink * bsink, GstCaps * vscapslist) ...@@ -543,6 +569,7 @@ gst_sdlvideosink_setcaps (GstBaseSink * bsink, GstCaps * vscapslist)
gst_sdlvideosink_get_sdl_from_fourcc (sdlvideosink, format); gst_sdlvideosink_get_sdl_from_fourcc (sdlvideosink, format);
gst_structure_get_int (structure, "width", &sdlvideosink->width); gst_structure_get_int (structure, "width", &sdlvideosink->width);
gst_structure_get_int (structure, "height", &sdlvideosink->height); gst_structure_get_int (structure, "height", &sdlvideosink->height);
gst_structure_get_double (structure, "framerate", &sdlvideosink->framerate);
if (!sdlvideosink->format || !gst_sdlvideosink_create (sdlvideosink)) if (!sdlvideosink->format || !gst_sdlvideosink_create (sdlvideosink))
return FALSE; return FALSE;
...@@ -652,6 +679,7 @@ static GstStateChangeReturn ...@@ -652,6 +679,7 @@ static GstStateChangeReturn
gst_sdlvideosink_change_state (GstElement * element, GstStateChange transition) gst_sdlvideosink_change_state (GstElement * element, GstStateChange transition)
{ {
GstSDLVideoSink *sdlvideosink; GstSDLVideoSink *sdlvideosink;
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
g_return_val_if_fail (GST_IS_SDLVIDEOSINK (element), g_return_val_if_fail (GST_IS_SDLVIDEOSINK (element),
GST_STATE_CHANGE_FAILURE); GST_STATE_CHANGE_FAILURE);
...@@ -663,7 +691,16 @@ gst_sdlvideosink_change_state (GstElement * element, GstStateChange transition) ...@@ -663,7 +691,16 @@ gst_sdlvideosink_change_state (GstElement * element, GstStateChange transition)
return GST_STATE_CHANGE_FAILURE; return GST_STATE_CHANGE_FAILURE;
GST_OBJECT_FLAG_SET (sdlvideosink, GST_SDLVIDEOSINK_OPEN); GST_OBJECT_FLAG_SET (sdlvideosink, GST_SDLVIDEOSINK_OPEN);
break; break;
default: /* do nothing */
break;
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY: case GST_STATE_CHANGE_PAUSED_TO_READY:
sdlvideosink->framerate = 0;
gst_sdlvideosink_destroy (sdlvideosink); gst_sdlvideosink_destroy (sdlvideosink);
break; break;
case GST_STATE_CHANGE_READY_TO_NULL: case GST_STATE_CHANGE_READY_TO_NULL:
...@@ -674,8 +711,6 @@ gst_sdlvideosink_change_state (GstElement * element, GstStateChange transition) ...@@ -674,8 +711,6 @@ gst_sdlvideosink_change_state (GstElement * element, GstStateChange transition)
break; break;
} }
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
return GST_STATE_CHANGE_SUCCESS; return GST_STATE_CHANGE_SUCCESS;
} }
......
...@@ -52,6 +52,8 @@ struct _GstSDLVideoSink { ...@@ -52,6 +52,8 @@ struct _GstSDLVideoSink {
guint32 format; guint32 format;
gint width, height; /* the size of the incoming YUV stream */ gint width, height; /* the size of the incoming YUV stream */
unsigned long xwindow_id; unsigned long xwindow_id;
gdouble framerate;
gboolean init; gboolean init;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment