summaryrefslogtreecommitdiffstats
path: root/ext/gdk_pixbuf
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
commit5d25c00e4b613b9cdf2c04fa3a68dffa03834a68 (patch)
tree74a5b1eaf3a324b520e64e87404fd0b3018a7829 /ext/gdk_pixbuf
parent1e83b097f7b732ae49e294a5a398bdc3e88854a8 (diff)
gst-indent
Original commit message from CVS: gst-indent
Diffstat (limited to 'ext/gdk_pixbuf')
-rw-r--r--ext/gdk_pixbuf/gst_loader.c144
-rw-r--r--ext/gdk_pixbuf/gstgdkanimation.c340
-rw-r--r--ext/gdk_pixbuf/gstgdkanimation.h72
-rw-r--r--ext/gdk_pixbuf/gstgdkpixbuf.c304
-rw-r--r--ext/gdk_pixbuf/gstgdkpixbuf.h9
5 files changed, 462 insertions, 407 deletions
diff --git a/ext/gdk_pixbuf/gst_loader.c b/ext/gdk_pixbuf/gst_loader.c
index b0538cac..95fd5af7 100644
--- a/ext/gdk_pixbuf/gst_loader.c
+++ b/ext/gdk_pixbuf/gst_loader.c
@@ -31,53 +31,58 @@
#include <fcntl.h>
-typedef struct {
+typedef struct
+{
/* stuff gdk throws at us and we're supposed to keep */
- GdkPixbufModuleSizeFunc size_func;
- GdkPixbufModulePreparedFunc prepared_func;
- GdkPixbufModuleUpdatedFunc updated_func;
- gpointer user_data;
+ GdkPixbufModuleSizeFunc size_func;
+ GdkPixbufModulePreparedFunc prepared_func;
+ GdkPixbufModuleUpdatedFunc updated_func;
+ gpointer user_data;
/* our own stuff - we're much better at keeping fields small :p */
- GstGdkAnimation * ani;
- gboolean initialized;
+ GstGdkAnimation *ani;
+ gboolean initialized;
} GstLoaderContext;
GST_DEBUG_CATEGORY_STATIC (gst_loader_debug);
#define GST_CAT_DEFAULT gst_loader_debug
static gboolean
-gst_loader_init (GError **error)
+gst_loader_init (GError ** error)
{
static gboolean inited = FALSE;
-
+
if (inited)
return TRUE;
-
+
if (!g_thread_supported ()) {
g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_FAILED,
- "The GStreamer loader requires threading support.");
+ "The GStreamer loader requires threading support.");
return FALSE;
}
if (!gst_init_check (0, NULL)) {
g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_FAILED,
- "GStreamer could not be initialized.");
+ "GStreamer could not be initialized.");
return FALSE;
}
inited = TRUE;
- GST_DEBUG_CATEGORY_INIT (gst_loader_debug, "gstloader", 0, "entry point debugging for the GStreamer gdk pixbuf loader");
+ GST_DEBUG_CATEGORY_INIT (gst_loader_debug, "gstloader", 0,
+ "entry point debugging for the GStreamer gdk pixbuf loader");
return TRUE;
}
+
static gpointer
-gst_loader_begin_load (GdkPixbufModuleSizeFunc size_func, GdkPixbufModulePreparedFunc prepared_func,
- GdkPixbufModuleUpdatedFunc updated_func, gpointer user_data, GError **error)
+gst_loader_begin_load (GdkPixbufModuleSizeFunc size_func,
+ GdkPixbufModulePreparedFunc prepared_func,
+ GdkPixbufModuleUpdatedFunc updated_func, gpointer user_data,
+ GError ** error)
{
GstLoaderContext *context;
-
+
if (!gst_loader_init (error))
return NULL;
-
+
context = g_new (GstLoaderContext, 1);
context->size_func = size_func;
context->prepared_func = prepared_func;
@@ -91,7 +96,8 @@ gst_loader_begin_load (GdkPixbufModuleSizeFunc size_func, GdkPixbufModulePrepare
g_free (context);
return NULL;
}
- context->ani->temp_fd = g_file_open_tmp (NULL, &context->ani->temp_location, error);
+ context->ani->temp_fd =
+ g_file_open_tmp (NULL, &context->ani->temp_location, error);
if (context->ani->temp_fd == 0) {
g_object_unref (context->ani);
g_free (context);
@@ -101,19 +107,27 @@ gst_loader_begin_load (GdkPixbufModuleSizeFunc size_func, GdkPixbufModulePrepare
GST_LOG_OBJECT (context->ani, "begin loading");
return context;
}
+
static gboolean
-gst_loader_load_increment (gpointer context_pointer, const guchar *buf, guint size, GError **error)
+gst_loader_load_increment (gpointer context_pointer, const guchar * buf,
+ guint size, GError ** error)
{
GdkPixbufAnimationIter *iter;
GstLoaderContext *context = (GstLoaderContext *) context_pointer;
GST_LOG_OBJECT (context->ani, "load increment: %u bytes", size);
gst_gdk_animation_add_data (context->ani, buf, size);
- if (!context->initialized && (iter = gdk_pixbuf_animation_get_iter (
- GDK_PIXBUF_ANIMATION (context->ani), NULL)) != NULL) {
- int width = gdk_pixbuf_animation_get_width (GDK_PIXBUF_ANIMATION (context->ani));
- int height = gdk_pixbuf_animation_get_height (GDK_PIXBUF_ANIMATION (context->ani));
- GdkPixbuf *pixbuf = gdk_pixbuf_animation_get_static_image (GDK_PIXBUF_ANIMATION (context->ani));
+ if (!context->initialized
+ && (iter =
+ gdk_pixbuf_animation_get_iter (GDK_PIXBUF_ANIMATION (context->ani),
+ NULL)) != NULL) {
+ int width =
+ gdk_pixbuf_animation_get_width (GDK_PIXBUF_ANIMATION (context->ani));
+ int height =
+ gdk_pixbuf_animation_get_height (GDK_PIXBUF_ANIMATION (context->ani));
+ GdkPixbuf *pixbuf =
+ gdk_pixbuf_animation_get_static_image (GDK_PIXBUF_ANIMATION (context->
+ ani));
g_object_unref (iter);
GST_LOG_OBJECT (context->ani, "initializing loader");
@@ -123,17 +137,20 @@ gst_loader_load_increment (gpointer context_pointer, const guchar *buf, guint si
}
if (context->prepared_func) {
- GST_LOG_OBJECT (context->ani, "calling prepared_func %p", context->prepared_func);
- context->prepared_func (pixbuf, GDK_PIXBUF_ANIMATION (context->ani), context->user_data);
+ GST_LOG_OBJECT (context->ani, "calling prepared_func %p",
+ context->prepared_func);
+ context->prepared_func (pixbuf, GDK_PIXBUF_ANIMATION (context->ani),
+ context->user_data);
}
-
+
context->initialized = TRUE;
}
-
+
return TRUE;
}
+
static gboolean
-gst_loader_stop_load (gpointer context_pointer, GError **error)
+gst_loader_stop_load (gpointer context_pointer, GError ** error)
{
GstLoaderContext *context = (GstLoaderContext *) context_pointer;
@@ -146,20 +163,20 @@ gst_loader_stop_load (gpointer context_pointer, GError **error)
}
static GdkPixbufAnimation *
-gst_loader_load_animation (FILE *f, GError **error)
+gst_loader_load_animation (FILE * f, GError ** error)
{
gchar *filename;
GstGdkAnimation *ani;
GdkPixbufAnimationIter *iter = NULL;
-
+
if (!gst_loader_init (error))
return NULL;
-
+
GST_LOG ("load_animation");
ani = gst_gdk_animation_new (error);
if (!ani)
return NULL;
-
+
filename = g_strdup_printf ("/proc/self/fd/%d", fileno (f));
ani->temp_fd = open (filename, 0);
if (ani->temp_fd >= 0) {
@@ -170,21 +187,21 @@ gst_loader_load_animation (FILE *f, GError **error)
g_free (filename);
if (iter == NULL) {
g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
- "could not create an image");
+ "could not create an image");
g_object_unref (ani);
GST_INFO ("could not create an image");
- return NULL;
+ return NULL;
}
g_object_unref (iter);
GST_LOG_OBJECT (ani, "load_animation succeeded");
return GDK_PIXBUF_ANIMATION (ani);
}
static GdkPixbuf *
-gst_loader_load (FILE *f, GError **error)
+gst_loader_load (FILE * f, GError ** error)
{
GdkPixbufAnimation *ani;
GdkPixbuf *pixbuf;
-
+
ani = gst_loader_load_animation (f, error);
if (ani == NULL)
return NULL;
@@ -193,8 +210,8 @@ gst_loader_load (FILE *f, GError **error)
if (!pixbuf) {
GST_ERROR_OBJECT (ani, "Could not get an image in _pixbuf_load");
g_object_unref (ani);
- g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
- "Could not get an image from file.");
+ g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ "Could not get an image from file.");
return NULL;
}
@@ -203,8 +220,9 @@ gst_loader_load (FILE *f, GError **error)
return pixbuf;
}
+
void
-fill_vtable (GdkPixbufModule *module)
+fill_vtable (GdkPixbufModule * module)
{
module->load = gst_loader_load;
module->begin_load = gst_loader_begin_load;
@@ -212,33 +230,35 @@ fill_vtable (GdkPixbufModule *module)
module->stop_load = gst_loader_stop_load;
module->load_animation = gst_loader_load_animation;
}
+
void
-fill_info (GdkPixbufFormat *info)
+fill_info (GdkPixbufFormat * info)
{
static GdkPixbufModulePattern signature[] = {
/* AVI */
- { "RIFF AVI ", " xxxx ", 100 },
+ {"RIFF AVI ", " xxxx ", 100},
/* MPEG 1 */
- { "xx\001\272", "zz ", 100 },
+ {"xx\001\272", "zz ", 100},
/* MPEG 2 */
- { "xx\001\263", "zz ", 100 },
+ {"xx\001\263", "zz ", 100},
/* Quicktime */
- { " wide", "xxxx ", 80 },
- { " moov", "xxxx ", 80 },
- { " mdat", "xxxx ", 80 },
- { " pnot", "xxxx ", 80 },
- { " PICT", "xxxx ", 80 },
- { " free", "xxxx ", 80 },
+ {" wide", "xxxx ", 80},
+ {" moov", "xxxx ", 80},
+ {" mdat", "xxxx ", 80},
+ {" pnot", "xxxx ", 80},
+ {" PICT", "xxxx ", 80},
+ {" free", "xxxx ", 80},
/* ASF */
- { "\060\046\262\165\216\146\317\021\246\331 \252 \142\316\154", " z z ", 100 },
- { NULL, NULL, 0 }
+ {"\060\046\262\165\216\146\317\021\246\331 \252 \142\316\154",
+ " z z ", 100},
+ {NULL, NULL, 0}
};
-
+
static gchar *mime_types[] = {
"video/avi", "video/x-avi", "video/x-msvideo",
"video/mpeg",
- "video/quicktime",
- "video/x-ms-asf",
+ "video/quicktime",
+ "video/x-ms-asf",
NULL
};
@@ -246,14 +266,14 @@ fill_info (GdkPixbufFormat *info)
"avi",
"mpeg", "mpe", "mpg",
"mov",
- "asf", "wmv",
+ "asf", "wmv",
NULL
};
-
- info->name = "GStreamer";
- info->signature = signature;
+
+ info->name = "GStreamer";
+ info->signature = signature;
info->description = "GStreamer supported video";
- info->mime_types = mime_types;
- info->extensions = extensions;
- info->flags = 0;
+ info->mime_types = mime_types;
+ info->extensions = extensions;
+ info->flags = 0;
}
diff --git a/ext/gdk_pixbuf/gstgdkanimation.c b/ext/gdk_pixbuf/gstgdkanimation.c
index a0b6cb93..df58c5be 100644
--- a/ext/gdk_pixbuf/gstgdkanimation.c
+++ b/ext/gdk_pixbuf/gstgdkanimation.c
@@ -27,17 +27,18 @@
GST_DEBUG_CATEGORY_STATIC (gst_gdk_animation_debug);
#define GST_CAT_DEFAULT gst_gdk_animation_debug
-static void gst_gdk_animation_class_init (gpointer g_class,
- gpointer class_data);
-static void gst_gdk_animation_finalize (GObject * object);
+static void gst_gdk_animation_class_init (gpointer g_class,
+ gpointer class_data);
+static void gst_gdk_animation_finalize (GObject * object);
-static gboolean gst_gdk_animation_is_static_image (GdkPixbufAnimation * animation);
-static GdkPixbuf* gst_gdk_animation_get_static_image (GdkPixbufAnimation * animation);
-static void gst_gdk_animation_get_size (GdkPixbufAnimation * anim,
- gint * width,
- gint * height);
-static GdkPixbufAnimationIter* gst_gdk_animation_get_iter (GdkPixbufAnimation * anim,
- const GTimeVal * start_time);
+static gboolean gst_gdk_animation_is_static_image (GdkPixbufAnimation *
+ animation);
+static GdkPixbuf *gst_gdk_animation_get_static_image (GdkPixbufAnimation *
+ animation);
+static void gst_gdk_animation_get_size (GdkPixbufAnimation * anim, gint * width,
+ gint * height);
+static GdkPixbufAnimationIter *gst_gdk_animation_get_iter (GdkPixbufAnimation *
+ anim, const GTimeVal * start_time);
static gpointer parent_class;
@@ -53,19 +54,20 @@ gst_gdk_animation_get_type (void)
NULL,
NULL,
gst_gdk_animation_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
sizeof (GstGdkAnimation),
- 0, /* n_preallocs */
+ 0, /* n_preallocs */
NULL,
};
-
+
object_type = g_type_register_static (GDK_TYPE_PIXBUF_ANIMATION,
- "GstGdkAnimation", &object_info, 0);
+ "GstGdkAnimation", &object_info, 0);
- GST_DEBUG_CATEGORY_INIT (gst_gdk_animation_debug, "gstloader_animation", 0, "GStreamer GdkPixbuf loader - GdkAnimation class");
+ GST_DEBUG_CATEGORY_INIT (gst_gdk_animation_debug, "gstloader_animation", 0,
+ "GStreamer GdkPixbuf loader - GdkAnimation class");
}
-
+
return object_type;
}
static void
@@ -73,9 +75,9 @@ gst_gdk_animation_class_init (gpointer g_class, gpointer class_data)
{
GObjectClass *object_class = G_OBJECT_CLASS (g_class);
GdkPixbufAnimationClass *anim_class = GDK_PIXBUF_ANIMATION_CLASS (g_class);
-
+
parent_class = g_type_class_peek_parent (g_class);
-
+
object_class->finalize = gst_gdk_animation_finalize;
anim_class->is_static_image = gst_gdk_animation_is_static_image;
@@ -84,7 +86,7 @@ gst_gdk_animation_class_init (gpointer g_class, gpointer class_data)
anim_class->get_iter = gst_gdk_animation_get_iter;
}
static void
-gst_gdk_animation_finalize (GObject *object)
+gst_gdk_animation_finalize (GObject * object)
{
GstGdkAnimation *ani = GST_GDK_ANIMATION (object);
@@ -99,39 +101,47 @@ gst_gdk_animation_finalize (GObject *object)
g_object_unref (ani->pixbuf);
ani->pixbuf = NULL;
}
-
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
+
GstGdkAnimation *
-gst_gdk_animation_new (GError **error)
+gst_gdk_animation_new (GError ** error)
{
- GstGdkAnimation *ani = GST_GDK_ANIMATION (g_object_new (GST_TYPE_GDK_ANIMATION, NULL));
+ GstGdkAnimation *ani =
+ GST_GDK_ANIMATION (g_object_new (GST_TYPE_GDK_ANIMATION, NULL));
return ani;
}
+
gboolean
-gst_gdk_animation_add_data (GstGdkAnimation *ani, const guint8 *data, guint size)
+gst_gdk_animation_add_data (GstGdkAnimation * ani, const guint8 * data,
+ guint size)
{
return (write (ani->temp_fd, data, size) == size);
}
+
void
-gst_gdk_animation_done_adding (GstGdkAnimation *ani)
+gst_gdk_animation_done_adding (GstGdkAnimation * ani)
{
close (ani->temp_fd);
ani->temp_fd = 0;
}
+
static gboolean
-gst_gdk_animation_is_static_image (GdkPixbufAnimation *animation)
+gst_gdk_animation_is_static_image (GdkPixbufAnimation * animation)
{
return FALSE;
}
static void
-gst_gdk_animation_get_size (GdkPixbufAnimation *anim, gint *width, int *height)
+gst_gdk_animation_get_size (GdkPixbufAnimation * anim, gint * width,
+ int *height)
{
GstGdkAnimation *ani = GST_GDK_ANIMATION (anim);
- GST_LOG_OBJECT (ani, "get_size called (%p, %p) %d x %d", width, height, ani->width, ani->height);
+ GST_LOG_OBJECT (ani, "get_size called (%p, %p) %d x %d", width, height,
+ ani->width, ani->height);
if (width)
*width = ani->width;
@@ -140,17 +150,21 @@ gst_gdk_animation_get_size (GdkPixbufAnimation *anim, gint *width, int *height)
}
-static void gst_gdk_animation_iter_class_init (gpointer g_class,
- gpointer class_data);
-static void gst_gdk_animation_iter_init (GTypeInstance * instance,
- gpointer g_class);
-static void gst_gdk_animation_iter_finalize (GObject * object);
+static void gst_gdk_animation_iter_class_init (gpointer g_class,
+ gpointer class_data);
+static void gst_gdk_animation_iter_init (GTypeInstance * instance,
+ gpointer g_class);
+static void gst_gdk_animation_iter_finalize (GObject * object);
-static gint gst_gdk_animation_iter_get_delay_time (GdkPixbufAnimationIter * iter);
-static GdkPixbuf * gst_gdk_animation_iter_get_pixbuf (GdkPixbufAnimationIter * iter);
-static gboolean gst_gdk_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter * iter);
-static gboolean gst_gdk_animation_iter_advance (GdkPixbufAnimationIter * iter,
- const GTimeVal * current_time);
+static gint gst_gdk_animation_iter_get_delay_time (GdkPixbufAnimationIter *
+ iter);
+static GdkPixbuf *gst_gdk_animation_iter_get_pixbuf (GdkPixbufAnimationIter *
+ iter);
+static gboolean
+gst_gdk_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *
+ iter);
+static gboolean gst_gdk_animation_iter_advance (GdkPixbufAnimationIter * iter,
+ const GTimeVal * current_time);
static gpointer iter_parent_class;
@@ -165,17 +179,17 @@ gst_gdk_animation_iter_get_type (void)
NULL,
NULL,
gst_gdk_animation_iter_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
sizeof (GstGdkAnimationIter),
- 0, /* n_preallocs */
+ 0, /* n_preallocs */
gst_gdk_animation_iter_init,
};
-
+
object_type = g_type_register_static (GDK_TYPE_PIXBUF_ANIMATION_ITER,
- "GdkPixbufAniAnimIter", &object_info, 0);
+ "GdkPixbufAniAnimIter", &object_info, 0);
}
-
+
return object_type;
}
@@ -183,19 +197,21 @@ static void
gst_gdk_animation_iter_class_init (gpointer g_class, gpointer class_data)
{
GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- GdkPixbufAnimationIterClass *anim_iter_class = GDK_PIXBUF_ANIMATION_ITER_CLASS (g_class);
-
+ GdkPixbufAnimationIterClass *anim_iter_class =
+ GDK_PIXBUF_ANIMATION_ITER_CLASS (g_class);
+
iter_parent_class = g_type_class_peek_parent (g_class);
-
+
object_class->finalize = gst_gdk_animation_iter_finalize;
-
+
anim_iter_class->get_delay_time = gst_gdk_animation_iter_get_delay_time;
anim_iter_class->get_pixbuf = gst_gdk_animation_iter_get_pixbuf;
- anim_iter_class->on_currently_loading_frame = gst_gdk_animation_iter_on_currently_loading_frame;
+ anim_iter_class->on_currently_loading_frame =
+ gst_gdk_animation_iter_on_currently_loading_frame;
anim_iter_class->advance = gst_gdk_animation_iter_advance;
}
static void
-gst_gdk_animation_iter_init (GTypeInstance *instance, gpointer g_class)
+gst_gdk_animation_iter_init (GTypeInstance * instance, gpointer g_class)
{
GstGdkAnimationIter *iter = GST_GDK_ANIMATION_ITER (instance);
@@ -203,18 +219,19 @@ gst_gdk_animation_iter_init (GTypeInstance *instance, gpointer g_class)
iter->eos = FALSE;
}
static void
-gst_gdk_animation_iter_finalize (GObject *object)
+gst_gdk_animation_iter_finalize (GObject * object)
{
GstGdkAnimationIter *iter = GST_GDK_ANIMATION_ITER (object);
-
+
g_object_unref (iter->ani);
-
+
if (iter->pipeline)
g_object_unref (iter->pipeline);
if (iter->pixbuf)
g_object_unref (iter->pixbuf);
while (iter->buffers) {
GstBuffer *buffer = GST_BUFFER (g_queue_pop_head (iter->buffers));
+
if (buffer) {
GST_LOG_OBJECT (iter, "unreffing buffer %p on finalize", buffer);
gst_data_unref (GST_DATA (buffer));
@@ -226,36 +243,40 @@ gst_gdk_animation_iter_finalize (GObject *object)
G_OBJECT_CLASS (iter_parent_class)->finalize (object);
}
static void
-got_handoff (GstElement *fakesink, GstBuffer *buffer, GstPad *pad, GstGdkAnimationIter *iter)
+got_handoff (GstElement * fakesink, GstBuffer * buffer, GstPad * pad,
+ GstGdkAnimationIter * iter)
{
- GST_LOG_OBJECT (iter, "enqueing buffer %p (timestamp %"G_GUINT64_FORMAT")",
- buffer, GST_BUFFER_TIMESTAMP (buffer));
+ GST_LOG_OBJECT (iter, "enqueing buffer %p (timestamp %" G_GUINT64_FORMAT ")",
+ buffer, GST_BUFFER_TIMESTAMP (buffer));
gst_data_ref (GST_DATA (buffer));
g_queue_push_tail (iter->buffers, buffer);
}
+
static gboolean
-gst_gdk_animation_iter_create_pipeline (GstGdkAnimationIter *iter)
+gst_gdk_animation_iter_create_pipeline (GstGdkAnimationIter * iter)
{
GstElement *src, *typefind, *autoplugger, *sink, *colorspace;
GstCaps *caps = GST_CAPS_NEW ("pixbuf_filter32",
- "video/x-raw-rgb",
- "endianness", GST_PROPS_INT (G_BIG_ENDIAN),
- "bpp", GST_PROPS_INT (32),
- "red_mask", GST_PROPS_INT (0xFF000000),
- "green_mask", GST_PROPS_INT (0x00FF0000),
- "blue_mask", GST_PROPS_INT (0x0000FF00)
- );
+ "video/x-raw-rgb",
+ "endianness", GST_PROPS_INT (G_BIG_ENDIAN),
+ "bpp", GST_PROPS_INT (32),
+ "red_mask", GST_PROPS_INT (0xFF000000),
+ "green_mask", GST_PROPS_INT (0x00FF0000),
+ "blue_mask", GST_PROPS_INT (0x0000FF00)
+ );
+
gst_caps_append (caps, GST_CAPS_NEW ("pixbuf_filter24",
- "video/x-raw-rgb",
- "endianness", GST_PROPS_INT (G_BIG_ENDIAN),
- "bpp", GST_PROPS_INT (24),
- "red_mask", GST_PROPS_INT (0xFF0000),
- "green_mask", GST_PROPS_INT (0x00FF00),
- "blue_mask", GST_PROPS_INT (0x0000FF)
- ));
+ "video/x-raw-rgb",
+ "endianness", GST_PROPS_INT (G_BIG_ENDIAN),
+ "bpp", GST_PROPS_INT (24),
+ "red_mask", GST_PROPS_INT (0xFF0000),
+ "green_mask", GST_PROPS_INT (0x00FF00),
+ "blue_mask", GST_PROPS_INT (0x0000FF)
+ ));
iter->pipeline = gst_element_factory_make ("pipeline", "main_pipeline");
- if (iter->pipeline == NULL) return FALSE;
+ if (iter->pipeline == NULL)
+ return FALSE;
if (!(src = gst_element_factory_make ("filesrc", "source")))
goto error;
@@ -265,6 +286,7 @@ gst_gdk_animation_iter_create_pipeline (GstGdkAnimationIter *iter)
GST_INFO_OBJECT (iter, "using file '%s'", iter->ani->temp_location);
} else {
gchar *filename = g_strdup_printf ("/proc/self/fd/%d", iter->ani->temp_fd);
+
g_object_set (src, "location", filename, NULL);
GST_INFO_OBJECT (iter, "using file '%s'", filename);
g_free (filename);
@@ -292,7 +314,7 @@ gst_gdk_animation_iter_create_pipeline (GstGdkAnimationIter *iter)
gst_bin_add (GST_BIN (iter->pipeline), colorspace);
if (!gst_element_link (autoplugger, colorspace))
goto error;
-
+
if (!(sink = gst_element_factory_make ("fakesink", "sink")))
goto error;
g_object_set (sink, "signal-handoffs", TRUE, NULL);
@@ -300,39 +322,42 @@ gst_gdk_animation_iter_create_pipeline (GstGdkAnimationIter *iter)
gst_bin_add (GST_BIN (iter->pipeline), sink);
if (!gst_element_link_filtered (colorspace, sink, caps))
goto error;
- if (gst_element_set_state (iter->pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+ if (gst_element_set_state (iter->pipeline,
+ GST_STATE_PLAYING) != GST_STATE_SUCCESS)
goto error;
-
+
return TRUE;
error:
g_object_unref (iter->pipeline);
iter->pipeline = NULL;
return FALSE;
}
+
static gboolean
-gst_gdk_animation_iter_may_advance (GstGdkAnimationIter *iter)
+gst_gdk_animation_iter_may_advance (GstGdkAnimationIter * iter)
{
GstFormat bytes = GST_FORMAT_BYTES;
gint64 offset;
gint64 data_amount;
-
+
if (iter->ani->temp_fd == 0 || iter->ani->temp_location == NULL)
return TRUE;
data_amount = lseek (iter->ani->temp_fd, 0, SEEK_CUR);
g_assert (data_amount >= 0);
- g_assert (gst_element_query (gst_bin_get_by_name (GST_BIN (iter->pipeline), "source"),
- GST_QUERY_POSITION, &bytes, &offset));
+ g_assert (gst_element_query (gst_bin_get_by_name (GST_BIN (iter->pipeline),
+ "source"), GST_QUERY_POSITION, &bytes, &offset));
if (data_amount - offset > GST_GDK_BUFFER_SIZE)
return TRUE;
return FALSE;
}
+
static gboolean
-gst_gdk_animation_get_more_buffers (GstGdkAnimationIter *iter)
+gst_gdk_animation_get_more_buffers (GstGdkAnimationIter * iter)
{
GstBuffer *last = g_queue_peek_tail (iter->buffers);
-
+
do {
GST_LOG_OBJECT (iter, "iterating...");
if (!gst_gdk_animation_iter_may_advance (iter)) {
@@ -348,17 +373,17 @@ gst_gdk_animation_get_more_buffers (GstGdkAnimationIter *iter)
return last != g_queue_peek_tail (iter->buffers);
}
static void
-pixbuf_destroy_notify (guchar *pixels, gpointer data)
+pixbuf_destroy_notify (guchar * pixels, gpointer data)
{
GST_LOG ("unreffing buffer %p because pixbuf was destroyed", data);
gst_data_unref (GST_DATA (data));
}
static void
-gst_gdk_animation_iter_create_pixbuf (GstGdkAnimationIter *iter)
+gst_gdk_animation_iter_create_pixbuf (GstGdkAnimationIter * iter)
{
GstBuffer *buf;
GstGdkAnimation *ani = iter->ani;
-
+
buf = g_queue_pop_head (iter->buffers);
g_assert (buf);
if (iter->pixbuf) {
@@ -368,7 +393,8 @@ gst_gdk_animation_iter_create_pixbuf (GstGdkAnimationIter *iter)
if (ani->width == 0) {
GstPad *pad;
GstCaps *caps;
- GstElement *fakesink = gst_bin_get_by_name (GST_BIN (iter->pipeline), "sink");
+ GstElement *fakesink =
+ gst_bin_get_by_name (GST_BIN (iter->pipeline), "sink");
g_assert (fakesink);
pad = gst_element_get_pad (fakesink, "sink");
g_assert (pad);
@@ -376,92 +402,108 @@ gst_gdk_animation_iter_create_pixbuf (GstGdkAnimationIter *iter)
g_assert (caps);
g_assert (GST_CAPS_IS_FIXED (caps));
g_assert (gst_caps_has_fixed_property (caps, "bpp") &&
- gst_caps_has_fixed_property (caps, "width") &&
- gst_caps_has_fixed_property (caps, "height"));
+ gst_caps_has_fixed_property (caps, "width") &&
+ gst_caps_has_fixed_property (caps, "height"));
gst_caps_get_int (caps, "width", &ani->width);
gst_caps_get_int (caps, "height", &ani->height);
gst_caps_get_int (caps, "bpp", &ani->bpp);
- GST_DEBUG_OBJECT (ani, "found format (width %d, height %d, bpp %d)", ani->width, ani->height, ani->bpp);
+ GST_DEBUG_OBJECT (ani, "found format (width %d, height %d, bpp %d)",
+ ani->width, ani->height, ani->bpp);
}
g_assert (GST_BUFFER_SIZE (buf) == ani->width * ani->height * ani->bpp / 8);
if (ani->bpp == 32) {
gint i;
guint32 *data = (guint32 *) GST_BUFFER_DATA (buf);
+
/* ensure opacity */
for (i = 0; i < ani->width * ani->height; i++) {
data[i] |= 0xFF000000;
}
}
iter->pixbuf = gdk_pixbuf_new_from_data (GST_BUFFER_DATA (buf),
- GDK_COLORSPACE_RGB, ani->bpp == 32, 8, ani->width, ani->height, ani->width * ani->bpp / 8, pixbuf_destroy_notify, buf);
- GST_LOG_OBJECT (iter, "created pixbuf %p from buffer %p (refcount %d)", iter->pixbuf, buf, GST_DATA_REFCOUNT_VALUE (buf));
+ GDK_COLORSPACE_RGB, ani->bpp == 32, 8, ani->width, ani->height,
+ ani->width * ani->bpp / 8, pixbuf_destroy_notify, buf);
+ GST_LOG_OBJECT (iter, "created pixbuf %p from buffer %p (refcount %d)",
+ iter->pixbuf, buf, GST_DATA_REFCOUNT_VALUE (buf));
}
-static GdkPixbufAnimationIter*
-gst_gdk_animation_get_iter (GdkPixbufAnimation *anim, const GTimeVal *start_time)
+static GdkPixbufAnimationIter *
+gst_gdk_animation_get_iter (GdkPixbufAnimation * anim,
+ const GTimeVal * start_time)
{
GstGdkAnimation *ani = GST_GDK_ANIMATION (anim);
GstGdkAnimationIter *iter;
- if (ani->temp_fd != 0 && ani->temp_location != NULL &&
+ if (ani->temp_fd != 0 && ani->temp_location != NULL &&
lseek (ani->temp_fd, 0, SEEK_CUR) < GST_GDK_BUFFER_SIZE) {
GST_DEBUG_OBJECT (ani, "Not enough data to create iterator.");
return NULL;
}
-
+
iter = g_object_new (GST_TYPE_GDK_ANIMATION_ITER, NULL);
iter->start = *start_time;
-
+
iter->ani = ani;
g_object_ref (ani);
if (!gst_gdk_animation_iter_create_pipeline (iter))
goto error;
-
+
if (!gst_gdk_animation_get_more_buffers (iter))
goto error;
-
+
gst_gdk_animation_iter_create_pixbuf (iter);
-
+
return GDK_PIXBUF_ANIMATION_ITER (iter);
error:
g_object_unref (iter);
return NULL;
}
+
static gboolean
-gst_gdk_animation_iter_advance (GdkPixbufAnimationIter *anim_iter, const GTimeVal *current_time)
+gst_gdk_animation_iter_advance (GdkPixbufAnimationIter * anim_iter,
+ const GTimeVal * current_time)
{
GstClockTime offset;
GstBuffer *buffer = NULL;
GstGdkAnimationIter *iter = GST_GDK_ANIMATION_ITER (anim_iter);
/* compute timestamp that next buffer must match */
- offset = ((GstClockTime) current_time->tv_sec - iter->start.tv_sec) * GST_SECOND;
+ offset =
+ ((GstClockTime) current_time->tv_sec - iter->start.tv_sec) * GST_SECOND;
if (iter->start.tv_usec > current_time->tv_usec) {
- offset -= ((GstClockTime) iter->start.tv_usec - current_time->tv_usec) * GST_SECOND / G_USEC_PER_SEC;
+ offset -=
+ ((GstClockTime) iter->start.tv_usec -
+ current_time->tv_usec) * GST_SECOND / G_USEC_PER_SEC;
} else {
- offset += ((GstClockTime) current_time->tv_usec - iter->start.tv_usec) * GST_SECOND / G_USEC_PER_SEC;
+ offset +=
+ ((GstClockTime) current_time->tv_usec -
+ iter->start.tv_usec) * GST_SECOND / G_USEC_PER_SEC;
}
- GST_DEBUG_OBJECT (iter, "advancing to %ld:%ld (started at %ld:%ld) need offset %"G_GUINT64_FORMAT,
- current_time->tv_sec, current_time->tv_usec, iter->start.tv_sec, iter->start.tv_usec, offset);
- if (!iter->just_seeked &&
- offset - iter->last_timestamp > GST_GDK_MAX_DELAY_TO_SEEK) {
- GST_INFO_OBJECT (iter, "current pipeline timestamp is too old (%"G_GUINT64_FORMAT
- " vs %"G_GUINT64_FORMAT"), seeking there", iter->last_timestamp, offset);
- if (gst_element_send_event (gst_bin_get_by_name (GST_BIN (iter->pipeline), "sink"),
- gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
- offset))) {
- iter->last_timestamp = offset;
- iter->just_seeked = TRUE;
- } else {
- GST_WARNING_OBJECT (iter, "seek to %"G_GUINT64_FORMAT" didn't work. Iterating there...",
- offset);
- }
+ GST_DEBUG_OBJECT (iter,
+ "advancing to %ld:%ld (started at %ld:%ld) need offset %"
+ G_GUINT64_FORMAT, current_time->tv_sec, current_time->tv_usec,
+ iter->start.tv_sec, iter->start.tv_usec, offset);
+ if (!iter->just_seeked
+ && offset - iter->last_timestamp > GST_GDK_MAX_DELAY_TO_SEEK) {
+ GST_INFO_OBJECT (iter,
+ "current pipeline timestamp is too old (%" G_GUINT64_FORMAT " vs %"
+ G_GUINT64_FORMAT "), seeking there", iter->last_timestamp, offset);
+ if (gst_element_send_event (gst_bin_get_by_name (GST_BIN (iter->pipeline),
+ "sink"),
+ gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, offset))) {
+ iter->last_timestamp = offset;
+ iter->just_seeked = TRUE;
+ } else {
+ GST_WARNING_OBJECT (iter,
+ "seek to %" G_GUINT64_FORMAT " didn't work. Iterating there...",
+ offset);
+ }
} else if (iter->just_seeked) {
iter->just_seeked = FALSE;
}
-
+
while (TRUE) {
if (g_queue_is_empty (iter->buffers)) {
if (iter->eos)
@@ -474,8 +516,8 @@ gst_gdk_animation_iter_advance (GdkPixbufAnimationIter *anim_iter, const GTimeVa
break;
if (buffer) {
GST_LOG_OBJECT (iter, "unreffing buffer %p, because timestamp too low (%"
- G_GUINT64_FORMAT" vs %"G_GUINT64_FORMAT")",
- buffer, GST_BUFFER_TIMESTAMP (buffer), offset);
+ G_GUINT64_FORMAT " vs %" G_GUINT64_FORMAT ")",
+ buffer, GST_BUFFER_TIMESTAMP (buffer), offset);
gst_data_unref (GST_DATA (buffer));
}
buffer = GST_BUFFER (g_queue_pop_head (iter->buffers));
@@ -492,39 +534,44 @@ gst_gdk_animation_iter_advance (GdkPixbufAnimationIter *anim_iter, const GTimeVa
gst_gdk_animation_iter_create_pixbuf (iter);
return TRUE;
}
+
static gint
-gst_gdk_animation_iter_get_delay_time (GdkPixbufAnimationIter *anim_iter)
+gst_gdk_animation_iter_get_delay_time (GdkPixbufAnimationIter * anim_iter)
{
gint delay;
GstGdkAnimationIter *iter = GST_GDK_ANIMATION_ITER (anim_iter);
-
+
while (g_queue_is_empty (iter->buffers)) {
if (iter->eos) {
GST_LOG_OBJECT (iter, "returning delay of infinite, we're EOS");
return -1;
}
if (!gst_gdk_animation_get_more_buffers (iter))
- return -1; /* FIXME? */
+ return -1; /* FIXME? */
}
- delay = (GST_BUFFER_TIMESTAMP (g_queue_peek_head (iter->buffers)) - iter->last_timestamp) *
- 1000 / GST_SECOND;
+ delay =
+ (GST_BUFFER_TIMESTAMP (g_queue_peek_head (iter->buffers)) -
+ iter->last_timestamp) * 1000 / GST_SECOND;
GST_LOG_OBJECT (iter, "returning delay of %d ms", delay);
return delay;
}
-GdkPixbuf*
-gst_gdk_animation_iter_get_pixbuf (GdkPixbufAnimationIter *anim_iter)
+
+GdkPixbuf *
+gst_gdk_animation_iter_get_pixbuf (GdkPixbufAnimationIter * anim_iter)
{
GstGdkAnimationIter *iter = GST_GDK_ANIMATION_ITER (anim_iter);
-
+
GST_LOG_OBJECT (iter, "returning pixbuf %p", iter->pixbuf);
return iter->pixbuf;
}
+
static gboolean
-gst_gdk_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *anim_iter)
+gst_gdk_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *
+ anim_iter)
{
GstGdkAnimationIter *iter = GST_GDK_ANIMATION_ITER (anim_iter);
-
+
/* EOS - last frame */
if (iter->eos && g_queue_is_empty (iter->buffers))
return TRUE;
@@ -532,11 +579,11 @@ gst_gdk_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *anim_
/* can't load more frames */
if (!gst_gdk_animation_iter_may_advance (iter))
return FALSE;
-
+
return TRUE;
}
-static GdkPixbuf*
-gst_gdk_animation_get_static_image (GdkPixbufAnimation *animation)
+static GdkPixbuf *
+gst_gdk_animation_get_static_image (GdkPixbufAnimation * animation)
{
GstGdkAnimation *ani = GST_GDK_ANIMATION (animation);
GTimeVal tv;
@@ -545,16 +592,15 @@ gst_gdk_animation_get_static_image (GdkPixbufAnimation *animation)
if (!ani->pixbuf) {
GST_LOG_OBJECT (ani, "trying to create pixbuf");
g_get_current_time (&tv);
- iter = GST_GDK_ANIMATION_ITER (
- gdk_pixbuf_animation_get_iter (animation, &tv));
+ iter =
+ GST_GDK_ANIMATION_ITER (gdk_pixbuf_animation_get_iter (animation, &tv));
if (iter) {
guint64 offset;
GstBuffer *buf;
GstFormat time = GST_FORMAT_TIME;
- if (!gst_element_query (gst_bin_get_by_name (GST_BIN (
- iter->pipeline), "sink"),
- GST_QUERY_TOTAL, &time, &offset)) {
+ if (!gst_element_query (gst_bin_get_by_name (GST_BIN (iter->pipeline),
+ "sink"), GST_QUERY_TOTAL, &time, &offset)) {
offset = 0;
}
if (offset > 120 * GST_SECOND) {
@@ -563,15 +609,17 @@ gst_gdk_animation_get_static_image (GdkPixbufAnimation *animation)
offset = offset / 2;
}
g_assert (time == GST_FORMAT_TIME);
- GST_LOG_OBJECT (ani, "using time offset %"G_GUINT64_FORMAT" for creating static image",
- offset);
+ GST_LOG_OBJECT (ani,
+ "using time offset %" G_GUINT64_FORMAT " for creating static image",
+ offset);
while ((buf = g_queue_pop_head (iter->buffers)) != NULL) {
gst_data_unref (GST_DATA (buf));
}
/* now we do evil stuff, be sure to get rid of the iterator afterwards */
- if (!gst_element_send_event (gst_bin_get_by_name (GST_BIN (iter->pipeline), "sink"),
- gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, offset))) {
+ if (!gst_element_send_event (gst_bin_get_by_name (GST_BIN (iter->
+ pipeline), "sink"),
+ gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, offset))) {
GST_INFO_OBJECT (ani, "seeking didn't work. Using next image");
}
@@ -585,7 +633,9 @@ gst_gdk_animation_get_static_image (GdkPixbufAnimation *animation)
} while (FALSE);
if (!g_queue_is_empty (iter->buffers)) {
gst_gdk_animation_iter_create_pixbuf (iter);
- ani->pixbuf = gst_gdk_animation_iter_get_pixbuf (GDK_PIXBUF_ANIMATION_ITER (iter));
+ ani->pixbuf =
+ gst_gdk_animation_iter_get_pixbuf (GDK_PIXBUF_ANIMATION_ITER
+ (iter));
g_object_ref (ani->pixbuf);
} else {
g_assert (ani->pixbuf == NULL);
diff --git a/ext/gdk_pixbuf/gstgdkanimation.h b/ext/gdk_pixbuf/gstgdkanimation.h
index 183d335e..8dc0d4ef 100644
--- a/ext/gdk_pixbuf/gstgdkanimation.h
+++ b/ext/gdk_pixbuf/gstgdkanimation.h
@@ -27,20 +27,16 @@
#include <stdio.h>
G_BEGIN_DECLS
-
/* how many bytes we need to have available before we dare to start a new iteration */
#define GST_GDK_BUFFER_SIZE (102400)
/* how far behind we need to be before we attempt to seek */
#define GST_GDK_MAX_DELAY_TO_SEEK (GST_SECOND / 4)
-
-
#define GST_TYPE_GDK_ANIMATION (gst_gdk_animation_get_type())
#define GST_GDK_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GDK_ANIMATION,GstGdkAnimation))
#define GST_GDK_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GDK_ANIMATION,GstGdkAnimation))
#define GST_IS_GDK_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GDK_ANIMATION))
#define GST_IS_GDK_ANIMATION_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GDK_ANIMATION))
-
-typedef struct _GstGdkAnimation GstGdkAnimation;
+typedef struct _GstGdkAnimation GstGdkAnimation;
typedef struct _GstGdkAnimationClass GstGdkAnimationClass;
typedef struct _GstGdkAnimationIter GstGdkAnimationIter;
@@ -48,34 +44,33 @@ typedef struct _GstGdkAnimationIterClass GstGdkAnimationIterClass;
struct _GstGdkAnimation
{
- GdkPixbufAnimation parent;
+ GdkPixbufAnimation parent;
/* name of temporary buffer file */
- gchar * temp_location;
+ gchar *temp_location;
/* file descriptor to temporary file or 0 if we're done writing */
- int temp_fd;
+ int temp_fd;
/* size of image */
- gint width;
- gint height;
- gint bpp;
+ gint width;
+ gint height;
+ gint bpp;
/* static image we use */
- GdkPixbuf * pixbuf;
+ GdkPixbuf *pixbuf;
};
-struct _GstGdkAnimationClass
+struct _GstGdkAnimationClass
{
- GdkPixbufAnimationClass parent_class;
+ GdkPixbufAnimationClass parent_class;
};
-GType gst_gdk_animation_get_type (void);
+GType gst_gdk_animation_get_type (void);
-GstGdkAnimation * gst_gdk_animation_new (GError **error);
+GstGdkAnimation *gst_gdk_animation_new (GError ** error);
-gboolean gst_gdk_animation_add_data (GstGdkAnimation * ani,
- const guint8 * data,
- guint size);
-void gst_gdk_animation_done_adding (GstGdkAnimation * ani);
+gboolean gst_gdk_animation_add_data (GstGdkAnimation * ani,
+ const guint8 * data, guint size);
+void gst_gdk_animation_done_adding (GstGdkAnimation * ani);
#define GST_TYPE_GDK_ANIMATION_ITER (gst_gdk_animation_iter_get_type ())
@@ -86,32 +81,35 @@ void gst_gdk_animation_done_adding (GstGdkAnimation * ani);
#define GST_IS_GDK_ANIMATION_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GDK_ANIMATION_ITER))
#define GST_GDK_ANIMATION_ITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GDK_ANIMATION_ITER, GstGdkAnimationIterClass))
-struct _GstGdkAnimationIter {
- GdkPixbufAnimationIter parent;
-
+struct _GstGdkAnimationIter
+{
+ GdkPixbufAnimationIter parent;
+
/* our animation */
- GstGdkAnimation * ani;
+ GstGdkAnimation *ani;
/* start timeval */
- GTimeVal start;
+ GTimeVal start;
/* timestamp of last buffer */
- GstClockTime last_timestamp;
-
+ GstClockTime last_timestamp;
+
/* pipeline we're using */
- GstElement * pipeline;
- gboolean eos;
- gboolean just_seeked;
-
+ GstElement *pipeline;
+ gboolean eos;
+ gboolean just_seeked;
+
/* current image and the buffers containing the data */
- GdkPixbuf * pixbuf;
- GQueue * buffers;
+ GdkPixbuf *pixbuf;
+ GQueue *buffers;
};
-struct _GstGdkAnimationIterClass {
- GdkPixbufAnimationIterClass parent_class;
+struct _GstGdkAnimationIterClass
+{
+ GdkPixbufAnimationIterClass parent_class;
};
-GType gst_gdk_animation_iter_get_type (void) G_GNUC_CONST;
+GType
+gst_gdk_animation_iter_get_type (void)
+ G_GNUC_CONST;
G_END_DECLS
-
#endif /* __GST_GDK_ANIMATION_H__ */
diff --git a/ext/gdk_pixbuf/gstgdkpixbuf.c b/ext/gdk_pixbuf/gstgdkpixbuf.c
index 99d937bd..9691782d 100644
--- a/ext/gdk_pixbuf/gstgdkpixbuf.c
+++ b/ext/gdk_pixbuf/gstgdkpixbuf.c
@@ -41,78 +41,73 @@ static GstElementDetails plugin_details = {
};
/* Filter signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SILENT
};
static GstStaticPadTemplate gst_gdk_pixbuf_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "image/png; "
- "image/jpeg; "
- "image/gif; "
- "image/x-icon; "
- "application/x-navi-animation; "
- "image/x-cmu-raster; "
- "image/x-sun-raster; "
- "image/x-pixmap; "
- "image/tiff; "
- "image/x-portable-anymap; "
- "image/x-portable-bitmap; "
- "image/x-portable-graymap; "
- "image/x-portable-pixmap; "
- "image/bmp; "
- "image/x-bmp; "
- "image/x-MS-bmp; "
- "image/vnd.wap.wbmp; "
- "image/x-bitmap; "
- "image/x-tga")
-);
+ GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("image/png; "
+ "image/jpeg; "
+ "image/gif; "
+ "image/x-icon; "
+ "application/x-navi-animation; "
+ "image/x-cmu-raster; "
+ "image/x-sun-raster; "
+ "image/x-pixmap; "
+ "image/tiff; "
+ "image/x-portable-anymap; "
+ "image/x-portable-bitmap; "
+ "image/x-portable-graymap; "
+ "image/x-portable-pixmap; "
+ "image/bmp; "
+ "image/x-bmp; "
+ "image/x-MS-bmp; "
+ "image/vnd.wap.wbmp; " "image/x-bitmap; " "image/x-tga")
+ );
static GstStaticPadTemplate gst_gdk_pixbuf_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
-);
-
-static void gst_gdk_pixbuf_base_init (gpointer g_class);
-static void gst_gdk_pixbuf_class_init (GstGdkPixbufClass *klass);
-static void gst_gdk_pixbuf_init (GstGdkPixbuf *filter);
-
-static void gst_gdk_pixbuf_set_property(GObject *object, guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_gdk_pixbuf_get_property(GObject *object, guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gst_gdk_pixbuf_chain (GstPad *pad, GstData *_data);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
+ );
+
+static void gst_gdk_pixbuf_base_init (gpointer g_class);
+static void gst_gdk_pixbuf_class_init (GstGdkPixbufClass * klass);
+static void gst_gdk_pixbuf_init (GstGdkPixbuf * filter);
+
+static void gst_gdk_pixbuf_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_gdk_pixbuf_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static void gst_gdk_pixbuf_chain (GstPad * pad, GstData * _data);
+
#ifdef enable_typefind
-static void gst_gdk_pixbuf_type_find (GstTypeFind *tf, gpointer ignore);
+static void gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore);
#endif
static GstElementClass *parent_class = NULL;
static GstPadLinkReturn
-gst_gdk_pixbuf_sink_link (GstPad *pad, const GstCaps *caps)
+gst_gdk_pixbuf_sink_link (GstPad * pad, const GstCaps * caps)
{
GstGdkPixbuf *filter;
filter = GST_GDK_PIXBUF (gst_pad_get_parent (pad));
g_return_val_if_fail (filter != NULL, GST_PAD_LINK_REFUSED);
- g_return_val_if_fail (GST_IS_GDK_PIXBUF (filter),
- GST_PAD_LINK_REFUSED);
+ g_return_val_if_fail (GST_IS_GDK_PIXBUF (filter), GST_PAD_LINK_REFUSED);
filter->framerate = 1.0;
gst_structure_get_double (gst_caps_get_structure (caps, 0), "framerate",
@@ -126,13 +121,15 @@ gst_gdk_pixbuf_sink_link (GstPad *pad, const GstCaps *caps)
* These are just the formats that gdk-pixbuf is known to support.
* But maybe not -- it may have been compiled without an external
* library. */
-static GstCaps *gst_gdk_pixbuf_get_capslist(void)
+static GstCaps *
+gst_gdk_pixbuf_get_capslist (void)
{
- return gst_caps_copy (gst_static_caps_get (
- &gst_gdk_pixbuf_sink_template.static_caps));
+ return gst_caps_copy (gst_static_caps_get (&gst_gdk_pixbuf_sink_template.
+ static_caps));
}
#else
-static GstCaps *gst_gdk_pixbuf_get_capslist(void)
+static GstCaps *
+gst_gdk_pixbuf_get_capslist (void)
{
GSList *slist;
GSList *slist0;
@@ -142,24 +139,24 @@ static GstCaps *gst_gdk_pixbuf_get_capslist(void)
GstCaps *capslist = NULL;
capslist = gst_caps_new_empty ();
- slist0 = gdk_pixbuf_get_formats();
+ slist0 = gdk_pixbuf_get_formats ();
- for(slist = slist0;slist;slist=g_slist_next(slist)){
+ for (slist = slist0; slist; slist = g_slist_next (slist)) {
pixbuf_format = slist->data;
- mimetypes = gdk_pixbuf_format_get_mime_types(pixbuf_format);
- for(mimetype = mimetypes; *mimetype; mimetype++){
- gst_caps_append_structure (capslist,
- gst_structure_new (*mimetype,NULL));
+ mimetypes = gdk_pixbuf_format_get_mime_types (pixbuf_format);
+ for (mimetype = mimetypes; *mimetype; mimetype++) {
+ gst_caps_append_structure (capslist, gst_structure_new (*mimetype, NULL));
}
- g_free(mimetypes);
+ g_free (mimetypes);
}
- g_slist_free(slist0);
+ g_slist_free (slist0);
return capslist;
}
#endif
-static GstCaps *gst_gdk_pixbuf_sink_getcaps(GstPad *pad)
+static GstCaps *
+gst_gdk_pixbuf_sink_getcaps (GstPad * pad)
{
GstGdkPixbuf *filter;
@@ -167,7 +164,7 @@ static GstCaps *gst_gdk_pixbuf_sink_getcaps(GstPad *pad)
g_return_val_if_fail (filter != NULL, NULL);
g_return_val_if_fail (GST_IS_GDK_PIXBUF (filter), NULL);
- return gst_gdk_pixbuf_get_capslist();
+ return gst_gdk_pixbuf_get_capslist ();
}
GType
@@ -175,10 +172,8 @@ gst_gdk_pixbuf_get_type (void)
{
static GType plugin_type = 0;
- if (!plugin_type)
- {
- static const GTypeInfo plugin_info =
- {
+ if (!plugin_type) {
+ static const GTypeInfo plugin_info = {
sizeof (GstGdkPixbufClass),
gst_gdk_pixbuf_base_init,
NULL,
@@ -190,8 +185,7 @@ gst_gdk_pixbuf_get_type (void)
(GInstanceInitFunc) gst_gdk_pixbuf_init,
};
plugin_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstGdkPixbuf",
- &plugin_info, 0);
+ "GstGdkPixbuf", &plugin_info, 0);
}
return plugin_type;
}
@@ -202,42 +196,44 @@ gst_gdk_pixbuf_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get( &gst_gdk_pixbuf_src_template));
+ gst_static_pad_template_get (&gst_gdk_pixbuf_src_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get( &gst_gdk_pixbuf_sink_template));
+ gst_static_pad_template_get (&gst_gdk_pixbuf_sink_template));
gst_element_class_set_details (element_class, &plugin_details);
}
/* initialize the plugin's class */
static void
-gst_gdk_pixbuf_class_init (GstGdkPixbufClass *klass)
+gst_gdk_pixbuf_class_init (GstGdkPixbufClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*) klass;
- gstelement_class = (GstElementClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (gobject_class, ARG_SILENT,
- g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
+ FALSE, G_PARAM_READWRITE));
gobject_class->set_property = gst_gdk_pixbuf_set_property;
gobject_class->get_property = gst_gdk_pixbuf_get_property;
}
static void
-gst_gdk_pixbuf_init (GstGdkPixbuf *filter)
+gst_gdk_pixbuf_init (GstGdkPixbuf * filter)
{
- filter->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get( &gst_gdk_pixbuf_sink_template), "sink");
+ filter->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_gdk_pixbuf_sink_template), "sink");
gst_pad_set_link_function (filter->sinkpad, gst_gdk_pixbuf_sink_link);
gst_pad_set_getcaps_function (filter->sinkpad, gst_gdk_pixbuf_sink_getcaps);
- filter->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get( &gst_gdk_pixbuf_src_template), "src");
+ filter->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_gdk_pixbuf_src_template), "src");
gst_pad_use_explicit_caps (filter->srcpad);
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
@@ -248,7 +244,7 @@ gst_gdk_pixbuf_init (GstGdkPixbuf *filter)
}
static void
-gst_gdk_pixbuf_chain (GstPad *pad, GstData *_data)
+gst_gdk_pixbuf_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstGdkPixbuf *filter;
@@ -270,15 +266,15 @@ gst_gdk_pixbuf_chain (GstPad *pad, GstData *_data)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
- push_buffer = TRUE;
- got_eos = TRUE;
- break;
+ push_buffer = TRUE;
+ got_eos = TRUE;
+ break;
case GST_EVENT_DISCONTINUOUS:
- dump_buffer = TRUE;
- break;
+ dump_buffer = TRUE;
+ break;
default:
- gst_pad_event_default (pad, event);
- return;
+ gst_pad_event_default (pad, event);
+ return;
}
}
@@ -293,41 +289,41 @@ gst_gdk_pixbuf_chain (GstPad *pad, GstData *_data)
GError *error = NULL;
if (!gdk_pixbuf_loader_close (filter->pixbuf_loader, &error)) {
- GST_ELEMENT_ERROR (filter, LIBRARY, SHUTDOWN, (NULL), (error->message));
- g_error_free (error);
- return;
+ GST_ELEMENT_ERROR (filter, LIBRARY, SHUTDOWN, (NULL), (error->message));
+ g_error_free (error);
+ return;
}
pixbuf = gdk_pixbuf_loader_get_pixbuf (filter->pixbuf_loader);
- if(filter->image_size == 0){
- GstCaps *caps;
+ if (filter->image_size == 0) {
+ GstCaps *caps;
- filter->width = gdk_pixbuf_get_width(pixbuf);
- filter->height = gdk_pixbuf_get_height(pixbuf);
- filter->rowstride = gdk_pixbuf_get_rowstride(pixbuf);
- filter->image_size = filter->rowstride * filter->height;
+ filter->width = gdk_pixbuf_get_width (pixbuf);
+ filter->height = gdk_pixbuf_get_height (pixbuf);
+ filter->rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ filter->image_size = filter->rowstride * filter->height;
- caps = gst_caps_copy (gst_pad_get_pad_template_caps (filter->srcpad));
- gst_caps_set_simple (caps,
- "width", G_TYPE_INT, filter->width,
- "height", G_TYPE_INT, filter->height,
- "framerate", G_TYPE_DOUBLE, filter->framerate, NULL);
+ caps = gst_caps_copy (gst_pad_get_pad_template_caps (filter->srcpad));
+ gst_caps_set_simple (caps,
+ "width", G_TYPE_INT, filter->width,
+ "height", G_TYPE_INT, filter->height,
+ "framerate", G_TYPE_DOUBLE, filter->framerate, NULL);
- gst_pad_set_explicit_caps (filter->srcpad, caps);
+ gst_pad_set_explicit_caps (filter->srcpad, caps);
}
outbuf = gst_pad_alloc_buffer (filter->srcpad, GST_BUFFER_OFFSET_NONE,
- filter->image_size);
- GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf);
- GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(buf);
-
- memcpy(GST_BUFFER_DATA(outbuf), gdk_pixbuf_get_pixels(pixbuf),
- filter->image_size);
+ filter->image_size);
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
+ GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
+
+ memcpy (GST_BUFFER_DATA (outbuf), gdk_pixbuf_get_pixels (pixbuf),
+ filter->image_size);
gst_pad_push (filter->srcpad, GST_DATA (outbuf));
- g_object_unref(G_OBJECT(filter->pixbuf_loader));
+ g_object_unref (G_OBJECT (filter->pixbuf_loader));
filter->pixbuf_loader = NULL;
dump_buffer = FALSE;
}
@@ -336,19 +332,19 @@ gst_gdk_pixbuf_chain (GstPad *pad, GstData *_data)
if (dump_buffer) {
if (filter->pixbuf_loader != NULL) {
gdk_pixbuf_loader_close (filter->pixbuf_loader, NULL);
- g_object_unref(G_OBJECT(filter->pixbuf_loader));
+ g_object_unref (G_OBJECT (filter->pixbuf_loader));
filter->pixbuf_loader = NULL;
}
}
if (GST_IS_BUFFER (_data)) {
if (filter->pixbuf_loader == NULL) {
- filter->pixbuf_loader = gdk_pixbuf_loader_new();
+ filter->pixbuf_loader = gdk_pixbuf_loader_new ();
filter->last_timestamp = GST_BUFFER_TIMESTAMP (buf);
}
-
- gdk_pixbuf_loader_write(filter->pixbuf_loader, GST_BUFFER_DATA(buf),
- GST_BUFFER_SIZE(buf), &error);
+
+ gdk_pixbuf_loader_write (filter->pixbuf_loader, GST_BUFFER_DATA (buf),
+ GST_BUFFER_SIZE (buf), &error);
gst_buffer_unref (buf);
}
@@ -358,28 +354,27 @@ gst_gdk_pixbuf_chain (GstPad *pad, GstData *_data)
}
static void
-gst_gdk_pixbuf_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_gdk_pixbuf_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstGdkPixbuf *filter;
g_return_if_fail (GST_IS_GDK_PIXBUF (object));
filter = GST_GDK_PIXBUF (object);
- switch (prop_id)
- {
- case ARG_SILENT:
- //filter->silent = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ switch (prop_id) {
+ case ARG_SILENT:
+ //filter->silent = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
-gst_gdk_pixbuf_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_gdk_pixbuf_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstGdkPixbuf *filter;
@@ -387,12 +382,12 @@ gst_gdk_pixbuf_get_property (GObject *object, guint prop_id,
filter = GST_GDK_PIXBUF (object);
switch (prop_id) {
- case ARG_SILENT:
- //g_value_set_boolean (value, filter->silent);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case ARG_SILENT:
+ //g_value_set_boolean (value, filter->silent);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
@@ -400,22 +395,23 @@ gst_gdk_pixbuf_get_property (GObject *object, guint prop_id,
#ifdef enable_typefind
static void
-gst_gdk_pixbuf_type_find (GstTypeFind *tf, gpointer ignore)
+gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore)
{
guint8 *data;
GdkPixbufLoader *pixbuf_loader;
GdkPixbufFormat *format;
data = gst_type_find_peek (tf, 0, GST_GDK_PIXBUF_TYPE_FIND_SIZE);
- if (data == NULL) return;
+ if (data == NULL)
+ return;
GST_DEBUG ("creating new loader");
- pixbuf_loader = gdk_pixbuf_loader_new();
-
+ pixbuf_loader = gdk_pixbuf_loader_new ();
+
gdk_pixbuf_loader_write (pixbuf_loader, data, GST_GDK_PIXBUF_TYPE_FIND_SIZE,
NULL);
-
+
format = gdk_pixbuf_loader_get_format (pixbuf_loader);
if (format != NULL) {
@@ -423,8 +419,7 @@ gst_gdk_pixbuf_type_find (GstTypeFind *tf, gpointer ignore)
gchar **p;
gchar **mlist = gdk_pixbuf_format_get_mime_types (format);
- for (p = mlist; *p; ++p)
- {
+ for (p = mlist; *p; ++p) {
GST_DEBUG ("suggesting mime type %s", *p);
caps = gst_caps_new_simple (*p, NULL);
gst_type_find_suggest (tf, GST_TYPE_FIND_MINIMUM, caps);
@@ -449,17 +444,18 @@ gst_gdk_pixbuf_type_find (GstTypeFind *tf, gpointer ignore)
* register the features
*/
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- GST_DEBUG_CATEGORY_INIT (gst_gdk_pixbuf_debug, "gdkpixbuf", 0, "gdk pixbuf loader");
+ GST_DEBUG_CATEGORY_INIT (gst_gdk_pixbuf_debug, "gdkpixbuf", 0,
+ "gdk pixbuf loader");
- if (!gst_element_register (plugin, "gdkpixbufdec", GST_RANK_NONE, GST_TYPE_GDK_PIXBUF))
+ if (!gst_element_register (plugin, "gdkpixbufdec", GST_RANK_NONE,
+ GST_TYPE_GDK_PIXBUF))
return FALSE;
#ifdef enable_typefind
gst_type_find_register (plugin, "image/*", GST_RANK_MARGINAL,
- gst_gdk_pixbuf_type_find, NULL,
- GST_CAPS_ANY, NULL);
+ gst_gdk_pixbuf_type_find, NULL, GST_CAPS_ANY, NULL);
#endif
/* plugin initialisation succeeded */
@@ -468,13 +464,7 @@ plugin_init (GstPlugin *plugin)
/* this is the structure that gst-register looks for
* so keep the name plugin_desc, or you cannot get your plug-in registered */
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gdkpixbuf",
- "GDK Pixbuf decoder",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gdkpixbuf",
+ "GDK Pixbuf decoder", plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/gdk_pixbuf/gstgdkpixbuf.h b/ext/gdk_pixbuf/gstgdkpixbuf.h
index 62e11aac..f239bf72 100644
--- a/ext/gdk_pixbuf/gstgdkpixbuf.h
+++ b/ext/gdk_pixbuf/gstgdkpixbuf.h
@@ -26,7 +26,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
/* #define's don't like whitespacey bits */
#define GST_TYPE_GDK_PIXBUF \
(gst_gdk_pixbuf_get_type())
@@ -38,8 +37,7 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GDK_PIXBUF))
#define GST_IS_GDK_PIXBUF_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GDK_PIXBUF))
-
-typedef struct _GstGdkPixbuf GstGdkPixbuf;
+typedef struct _GstGdkPixbuf GstGdkPixbuf;
typedef struct _GstGdkPixbufClass GstGdkPixbufClass;
struct _GstGdkPixbuf
@@ -48,7 +46,7 @@ struct _GstGdkPixbuf
GstPad *sinkpad, *srcpad;
- GstClockTime last_timestamp;
+ GstClockTime last_timestamp;
GdkPixbufLoader *pixbuf_loader;
int width;
@@ -59,7 +57,7 @@ struct _GstGdkPixbuf
double framerate;
};
-struct _GstGdkPixbufClass
+struct _GstGdkPixbufClass
{
GstElementClass parent_class;
};
@@ -67,5 +65,4 @@ struct _GstGdkPixbufClass
GType gst_gdk_pixbuf_get_type (void);
G_END_DECLS
-
#endif /* __GST_GDK_PIXBUF_H__ */