summaryrefslogtreecommitdiffstats
path: root/gst/videodrop
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2004-03-14 22:34:33 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2004-03-14 22:34:33 +0000
commit7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2 (patch)
treef863b467dea9559a6ec9c48affbfae11f8104164 /gst/videodrop
parenta19db4bbdc4a15ea0d8f4d28e9a1302c9c3d1657 (diff)
downloadgst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.gz
gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.bz2
gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.zip
gst-indent
Original commit message from CVS: gst-indent
Diffstat (limited to 'gst/videodrop')
-rw-r--r--gst/videodrop/gstvideodrop.c170
-rw-r--r--gst/videodrop/gstvideodrop.h14
2 files changed, 84 insertions, 100 deletions
diff --git a/gst/videodrop/gstvideodrop.c b/gst/videodrop/gstvideodrop.c
index 546873f0..6a83fd9d 100644
--- a/gst/videodrop/gstvideodrop.c
+++ b/gst/videodrop/gstvideodrop.c
@@ -25,63 +25,56 @@
#include <gst/video/video.h>
/* elementfactory information */
-static GstElementDetails videodrop_details = GST_ELEMENT_DETAILS (
- "Video frame dropper",
- "Filter/Effect/Video",
- "Re-FPS'es video",
- "Ronald Bultje <rbultje@ronald.bitfreak.net>"
-);
+static GstElementDetails videodrop_details =
+GST_ELEMENT_DETAILS ("Video frame dropper",
+ "Filter/Effect/Video",
+ "Re-FPS'es video",
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>");
/* GstVideodrop signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SPEED
- /* FILL ME */
+ /* FILL ME */
};
static GstStaticPadTemplate gst_videodrop_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS(
- GST_VIDEO_CAPS_YUV("{ YUY2, I420, YV12, YUYV, UYVY }")
- )
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ YUY2, I420, YV12, YUYV, UYVY }")
+ )
+ );
static GstStaticPadTemplate gst_videodrop_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS(
- GST_VIDEO_CAPS_YUV("{ YUY2, I420, YV12, YUYV, UYVY }")
- )
-);
-
-static void gst_videodrop_base_init (gpointer g_class);
-static void gst_videodrop_class_init (GstVideodropClass *klass);
-static void gst_videodrop_init (GstVideodrop *videodrop);
-static void gst_videodrop_chain (GstPad *pad, GstData *_data);
-
-static void gst_videodrop_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_videodrop_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ YUY2, I420, YV12, YUYV, UYVY }")
+ )
+ );
-static GstElementStateReturn
- gst_videodrop_change_state (GstElement *element);
+static void gst_videodrop_base_init (gpointer g_class);
+static void gst_videodrop_class_init (GstVideodropClass * klass);
+static void gst_videodrop_init (GstVideodrop * videodrop);
+static void gst_videodrop_chain (GstPad * pad, GstData * _data);
+
+static void gst_videodrop_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_videodrop_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+static GstElementStateReturn gst_videodrop_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_videodrop_signals[LAST_SIGNAL] = { 0 }; */
GType
@@ -103,8 +96,7 @@ gst_videodrop_get_type (void)
};
videodrop_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstVideodrop",
- &videodrop_info, 0);
+ "GstVideodrop", &videodrop_info, 0);
}
return videodrop_type;
@@ -123,7 +115,7 @@ gst_videodrop_base_init (gpointer g_class)
gst_static_pad_template_get (&gst_videodrop_src_template));
}
static void
-gst_videodrop_class_init (GstVideodropClass *klass)
+gst_videodrop_class_init (GstVideodropClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@@ -131,9 +123,8 @@ gst_videodrop_class_init (GstVideodropClass *klass)
parent_class = g_type_class_peek_parent (klass);
g_object_class_install_property (object_class, ARG_SPEED,
- g_param_spec_float ("speed", "Speed",
- "Output speed (relative to input)",
- 0.01, 100, 1, G_PARAM_READWRITE));
+ g_param_spec_float ("speed", "Speed",
+ "Output speed (relative to input)", 0.01, 100, 1, G_PARAM_READWRITE));
object_class->set_property = gst_videodrop_set_property;
object_class->get_property = gst_videodrop_get_property;
@@ -142,7 +133,7 @@ gst_videodrop_class_init (GstVideodropClass *klass)
}
static GstCaps *
-gst_videodrop_getcaps (GstPad *pad)
+gst_videodrop_getcaps (GstPad * pad)
{
GstVideodrop *videodrop;
GstPad *otherpad;
@@ -153,21 +144,21 @@ gst_videodrop_getcaps (GstPad *pad)
videodrop = GST_VIDEODROP (gst_pad_get_parent (pad));
otherpad = (pad == videodrop->srcpad) ? videodrop->sinkpad :
- videodrop->srcpad;
+ videodrop->srcpad;
caps = gst_pad_get_allowed_caps (otherpad);
- for (i=0;i<gst_caps_get_size(caps);i++) {
+ for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i);
gst_structure_set (structure,
- "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
+ "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
}
-
+
return caps;
}
static GstPadLinkReturn
-gst_videodrop_link (GstPad *pad, const GstCaps *caps)
+gst_videodrop_link (GstPad * pad, const GstCaps * caps)
{
GstVideodrop *videodrop;
GstStructure *structure;
@@ -181,11 +172,12 @@ gst_videodrop_link (GstPad *pad, const GstCaps *caps)
videodrop = GST_VIDEODROP (gst_pad_get_parent (pad));
otherpad = (pad == videodrop->srcpad) ? videodrop->sinkpad :
- videodrop->srcpad;
+ videodrop->srcpad;
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_double (structure, "framerate", &fps);
- if (!ret) return GST_PAD_LINK_REFUSED;
+ if (!ret)
+ return GST_PAD_LINK_REFUSED;
if (gst_pad_is_negotiated (otherpad)) {
othercaps = gst_caps_copy (caps);
@@ -194,8 +186,7 @@ gst_videodrop_link (GstPad *pad, const GstCaps *caps)
} else {
otherfps = videodrop->to_fps;
}
- gst_caps_set_simple (othercaps,
- "framerate", G_TYPE_DOUBLE, otherfps, NULL);
+ gst_caps_set_simple (othercaps, "framerate", G_TYPE_DOUBLE, otherfps, NULL);
link_ret = gst_pad_try_set_caps (otherpad, othercaps);
if (GST_PAD_LINK_FAILED (link_ret)) {
return link_ret;
@@ -212,21 +203,23 @@ gst_videodrop_link (GstPad *pad, const GstCaps *caps)
}
static void
-gst_videodrop_init (GstVideodrop *videodrop)
+gst_videodrop_init (GstVideodrop * videodrop)
{
GST_FLAG_SET (videodrop, GST_ELEMENT_EVENT_AWARE);
-
+
GST_DEBUG ("gst_videodrop_init");
- videodrop->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_videodrop_sink_template), "sink");
+ videodrop->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_videodrop_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (videodrop), videodrop->sinkpad);
gst_pad_set_chain_function (videodrop->sinkpad, gst_videodrop_chain);
gst_pad_set_getcaps_function (videodrop->sinkpad, gst_videodrop_getcaps);
gst_pad_set_link_function (videodrop->sinkpad, gst_videodrop_link);
- videodrop->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_videodrop_src_template), "src");
- gst_element_add_pad (GST_ELEMENT(videodrop), videodrop->srcpad);
+ videodrop->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_videodrop_src_template), "src");
+ gst_element_add_pad (GST_ELEMENT (videodrop), videodrop->srcpad);
gst_pad_set_getcaps_function (videodrop->srcpad, gst_videodrop_getcaps);
gst_pad_set_link_function (videodrop->srcpad, gst_videodrop_link);
@@ -237,7 +230,7 @@ gst_videodrop_init (GstVideodrop *videodrop)
}
static void
-gst_videodrop_chain (GstPad *pad, GstData *data)
+gst_videodrop_chain (GstPad * pad, GstData * data)
{
GstVideodrop *videodrop = GST_VIDEODROP (gst_pad_get_parent (pad));
GstBuffer *buf;
@@ -249,12 +242,13 @@ gst_videodrop_chain (GstPad *pad, GstData *data)
/* since we rely on timestamps of the source, we need to handle
* changes in time carefully. */
gint64 time;
+
if (gst_event_discont_get_value (event, GST_FORMAT_TIME, &time)) {
- videodrop->time_adjust = time;
+ videodrop->time_adjust = time;
videodrop->total = videodrop->pass = 0;
} else {
- GST_ELEMENT_ERROR (videodrop, STREAM, TOO_LAZY, (NULL),
- ("Received discont, but no time information"));
+ GST_ELEMENT_ERROR (videodrop, STREAM, TOO_LAZY, (NULL),
+ ("Received discont, but no time information"));
gst_event_unref (event);
return;
}
@@ -268,7 +262,8 @@ gst_videodrop_chain (GstPad *pad, GstData *data)
videodrop->total++;
while (((GST_BUFFER_TIMESTAMP (buf) - videodrop->time_adjust) *
- videodrop->to_fps * videodrop->speed / GST_SECOND) >= videodrop->pass) {
+ videodrop->to_fps * videodrop->speed / GST_SECOND) >=
+ videodrop->pass) {
/* since we write to the struct (time/duration), we need a new struct,
* but we don't want to copy around data - a subbuffer is the easiest
* way to accomplish that... */
@@ -276,7 +271,7 @@ gst_videodrop_chain (GstPad *pad, GstData *data)
/* adjust timestamp/duration and push forward */
GST_BUFFER_TIMESTAMP (copy) = videodrop->time_adjust / videodrop->speed +
- GST_SECOND * videodrop->pass / videodrop->to_fps;
+ GST_SECOND * videodrop->pass / videodrop->to_fps;
GST_BUFFER_DURATION (copy) = GST_SECOND / videodrop->to_fps;
gst_pad_push (videodrop->srcpad, GST_DATA (copy));
@@ -287,10 +282,8 @@ gst_videodrop_chain (GstPad *pad, GstData *data)
}
static void
-gst_videodrop_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_videodrop_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstVideodrop *videodrop = GST_VIDEODROP (object);
@@ -305,10 +298,8 @@ gst_videodrop_set_property (GObject *object,
}
static void
-gst_videodrop_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_videodrop_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstVideodrop *videodrop = GST_VIDEODROP (object);
@@ -323,7 +314,7 @@ gst_videodrop_get_property (GObject *object,
}
static GstElementStateReturn
-gst_videodrop_change_state (GstElement *element)
+gst_videodrop_change_state (GstElement * element)
{
GstVideodrop *videodrop = GST_VIDEODROP (element);
@@ -344,19 +335,14 @@ gst_videodrop_change_state (GstElement *element)
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "videodrop", GST_RANK_NONE, GST_TYPE_VIDEODROP);
+ return gst_element_register (plugin, "videodrop", GST_RANK_NONE,
+ GST_TYPE_VIDEODROP);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "videodrop",
- "Re-FPS'es video",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "videodrop",
+ "Re-FPS'es video",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
diff --git a/gst/videodrop/gstvideodrop.h b/gst/videodrop/gstvideodrop.h
index 20f954a4..913c91b5 100644
--- a/gst/videodrop/gstvideodrop.h
+++ b/gst/videodrop/gstvideodrop.h
@@ -23,7 +23,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_VIDEODROP \
(gst_videodrop_get_type())
#define GST_VIDEODROP(obj) \
@@ -34,29 +33,28 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEODROP))
#define GST_IS_VIDEODROP_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEODROP))
-
typedef struct _GstVideodrop GstVideodrop;
typedef struct _GstVideodropClass GstVideodropClass;
-struct _GstVideodrop {
+struct _GstVideodrop
+{
GstElement element;
GstPad *sinkpad, *srcpad;
/* video state */
gboolean inited;
- gfloat from_fps,
- to_fps;
+ gfloat from_fps, to_fps;
gfloat speed;
guint64 pass, total, time_adjust;
};
-struct _GstVideodropClass {
+struct _GstVideodropClass
+{
GstElementClass parent_class;
};
-GType gst_videodrop_get_type(void);
+GType gst_videodrop_get_type (void);
G_END_DECLS
-
#endif /* __GST_VIDEODROP_H__ */