1 /* 2 * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public 15 * License along with this library; if not, write to the 16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef __GST_LOADER_H__ 21 #define __GST_LOADER_H__ 22 23 #include <gst/gst.h> 24 #include <gdk-pixbuf/gdk-pixbuf.h> 25 #include <gdk-pixbuf/gdk-pixbuf-animation.h> 26 #include <gdk-pixbuf/gdk-pixbuf-io.h> 27 #include <stdio.h> 28 29 G_BEGIN_DECLS 30 31 /* how many bytes we need to have available before we dare to start a new iteration */ 32 #define GST_GDK_BUFFER_SIZE (102400) 33 /* how far behind we need to be before we attempt to seek */ 34 #define GST_GDK_MAX_DELAY_TO_SEEK (GST_SECOND / 4) 35 36 37 #define GST_TYPE_GDK_ANIMATION (gst_gdk_animation_get_type()) 38 #define GST_GDK_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GDK_ANIMATION,GstGdkAnimation)) 39 #define GST_GDK_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GDK_ANIMATION,GstGdkAnimationClass)) 40 #define GST_IS_GDK_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GDK_ANIMATION)) 41 #define GST_IS_GDK_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GDK_ANIMATION)) 42 43 typedef struct _GstGdkAnimation GstGdkAnimation; 44 typedef struct _GstGdkAnimationClass GstGdkAnimationClass; 45 46 typedef struct _GstGdkAnimationIter GstGdkAnimationIter; 47 typedef struct _GstGdkAnimationIterClass GstGdkAnimationIterClass; 48 49 struct _GstGdkAnimation 50 { 51 GdkPixbufAnimation parent; 52 53 /* name of temporary buffer file */ 54 gchar * temp_location; 55 /* file descriptor to temporary file or 0 if we're done writing */ 56 int temp_fd; 57 58 /* size of image */ 59 gint width; 60 gint height; 61 gint bpp; 62 /* static image we use */ 63 GdkPixbuf * pixbuf; 64 }; 65 66 struct _GstGdkAnimationClass 67 { 68 GdkPixbufAnimationClass parent_class; 69 }; 70 71 GType gst_gdk_animation_get_type (void); 72 73 GstGdkAnimation * gst_gdk_animation_new (GError **error); 74 75 gboolean gst_gdk_animation_add_data (GstGdkAnimation * ani, 76 const guint8 * data, 77 guint size); 78 void gst_gdk_animation_done_adding (GstGdkAnimation * ani); 79 80 81 #define GST_TYPE_GDK_ANIMATION_ITER (gst_gdk_animation_iter_get_type ()) 82 #define GST_GDK_ANIMATION_ITER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GST_TYPE_GDK_ANIMATION_ITER, GstGdkAnimationIter)) 83 #define GST_IS_GDK_ANIMATION_ITER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GST_TYPE_GDK_ANIMATION_ITER)) 84 85 #define GST_GDK_ANIMATION_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GDK_ANIMATION_ITER, GstGdkAnimationIterClass)) 86 #define GST_IS_GDK_ANIMATION_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GDK_ANIMATION_ITER)) 87 #define GST_GDK_ANIMATION_ITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GDK_ANIMATION_ITER, GstGdkAnimationIterClass)) 88 89 struct _GstGdkAnimationIter { 90 GdkPixbufAnimationIter parent; 91 92 /* our animation */ 93 GstGdkAnimation * ani; 94 /* start timeval */ 95 GTimeVal start; 96 /* timestamp of last buffer */ 97 GstClockTime last_timestamp; 98 99 /* pipeline we're using */ 100 GstElement * pipeline; 101 gboolean eos; 102 gboolean just_seeked; 103 104 /* current image and the buffers containing the data */ 105 GdkPixbuf * pixbuf; 106 GQueue * buffers; 107 }; 108 109 struct _GstGdkAnimationIterClass { 110 GdkPixbufAnimationIterClass parent_class; 111 }; 112 113 GType gst_gdk_animation_iter_get_type (void) G_GNUC_CONST; 114 115 G_END_DECLS 116 117 #endif /* __GST_GDK_ANIMATION_H__ */ 118