mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-25 15:36:42 +00:00
Do rate control, skip frames when too old.
Original commit message from CVS: Do rate control, skip frames when too old.
This commit is contained in:
parent
5e9794a11a
commit
244658dc96
2 changed files with 28 additions and 3 deletions
|
@ -90,6 +90,7 @@ GST_PAD_TEMPLATE_FACTORY (videotestsrc_src_template_factory,
|
||||||
static void gst_videotestsrc_class_init (GstVideotestsrcClass * klass);
|
static void gst_videotestsrc_class_init (GstVideotestsrcClass * klass);
|
||||||
static void gst_videotestsrc_init (GstVideotestsrc * videotestsrc);
|
static void gst_videotestsrc_init (GstVideotestsrc * videotestsrc);
|
||||||
static GstElementStateReturn gst_videotestsrc_change_state (GstElement * element);
|
static GstElementStateReturn gst_videotestsrc_change_state (GstElement * element);
|
||||||
|
static void gst_videotestsrc_set_clock (GstElement *element, GstClock *clock);
|
||||||
|
|
||||||
static void gst_videotestsrc_set_property (GObject * object, guint prop_id,
|
static void gst_videotestsrc_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
@ -160,6 +161,17 @@ gst_videotestsrc_class_init (GstVideotestsrcClass * klass)
|
||||||
gobject_class->get_property = gst_videotestsrc_get_property;
|
gobject_class->get_property = gst_videotestsrc_get_property;
|
||||||
|
|
||||||
gstelement_class->change_state = gst_videotestsrc_change_state;
|
gstelement_class->change_state = gst_videotestsrc_change_state;
|
||||||
|
gstelement_class->set_clock = gst_videotestsrc_set_clock;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_videotestsrc_set_clock (GstElement *element, GstClock *clock)
|
||||||
|
{
|
||||||
|
GstVideotestsrc *v;
|
||||||
|
|
||||||
|
v = GST_VIDEOTESTSRC (element);
|
||||||
|
|
||||||
|
gst_object_replace ((GstObject **)&v->clock, (GstObject *)clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstPadLinkReturn
|
static GstPadLinkReturn
|
||||||
|
@ -302,6 +314,7 @@ gst_videotestsrc_get (GstPad * pad)
|
||||||
GstVideotestsrc *videotestsrc;
|
GstVideotestsrc *videotestsrc;
|
||||||
gulong newsize;
|
gulong newsize;
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
GstClockTimeDiff jitter = 0;
|
||||||
|
|
||||||
GST_DEBUG (0, "gst_videotestsrc_get");
|
GST_DEBUG (0, "gst_videotestsrc_get");
|
||||||
|
|
||||||
|
@ -325,11 +338,22 @@ gst_videotestsrc_get (GstPad * pad)
|
||||||
}
|
}
|
||||||
g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
|
g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
|
||||||
|
|
||||||
|
videotestsrc->make_image (videotestsrc, (void *) GST_BUFFER_DATA (buf),
|
||||||
|
videotestsrc->width, videotestsrc->height);
|
||||||
|
|
||||||
|
do {
|
||||||
|
GstClockID id;
|
||||||
|
|
||||||
videotestsrc->timestamp += videotestsrc->interval;
|
videotestsrc->timestamp += videotestsrc->interval;
|
||||||
GST_BUFFER_TIMESTAMP (buf) = videotestsrc->timestamp;
|
GST_BUFFER_TIMESTAMP (buf) = videotestsrc->timestamp;
|
||||||
|
|
||||||
videotestsrc->make_image (videotestsrc, (void *) GST_BUFFER_DATA (buf),
|
if (videotestsrc->clock) {
|
||||||
videotestsrc->width, videotestsrc->height);
|
id = gst_clock_new_single_shot_id (videotestsrc->clock, GST_BUFFER_TIMESTAMP (buf));
|
||||||
|
gst_element_clock_wait (GST_ELEMENT (videotestsrc), id, &jitter);
|
||||||
|
gst_clock_id_free (id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (jitter > 100 * GST_MSECOND);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ struct _GstVideotestsrc {
|
||||||
gint64 interval;
|
gint64 interval;
|
||||||
gint bpp;
|
gint bpp;
|
||||||
int rate;
|
int rate;
|
||||||
|
GstClock *clock;
|
||||||
|
|
||||||
GstBufferPool *pool;
|
GstBufferPool *pool;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue