gstgdkanimation.h 4.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*
 * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef __GST_LOADER_H__
#define __GST_LOADER_H__

#include <gst/gst.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk-pixbuf/gdk-pixbuf-animation.h>
#include <gdk-pixbuf/gdk-pixbuf-io.h>
#include <stdio.h>

G_BEGIN_DECLS
Johan Dahlin's avatar
Johan Dahlin committed
30

31
/* how many bytes we need to have available before we dare to start a new iteration */
Benjamin Otte's avatar
Benjamin Otte committed
32 33 34
#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)
Johan Dahlin's avatar
Johan Dahlin committed
35 36


Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
37 38 39 40 41
#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))
Johan Dahlin's avatar
Johan Dahlin committed
42 43

typedef struct _GstGdkAnimation      GstGdkAnimation;
44 45 46 47 48 49 50
typedef struct _GstGdkAnimationClass GstGdkAnimationClass;

typedef struct _GstGdkAnimationIter GstGdkAnimationIter;
typedef struct _GstGdkAnimationIterClass GstGdkAnimationIterClass;

struct _GstGdkAnimation
{
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
51
  GdkPixbufAnimation            parent;
52 53

  /* name of temporary buffer file */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
54
  gchar *                       temp_location;
55
  /* file descriptor to temporary file or 0 if we're done writing */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
56
  int                           temp_fd;
57 58

  /* size of image */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
59 60 61
  gint                          width;
  gint                          height;
  gint                          bpp;
62
  /* static image we use */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
63
  GdkPixbuf *                   pixbuf;
64 65
};

Johan Dahlin's avatar
Johan Dahlin committed
66
struct _GstGdkAnimationClass 
67
{
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
68
  GdkPixbufAnimationClass       parent_class;
69 70
};

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
71
GType                   gst_gdk_animation_get_type      (void);
72

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
73
GstGdkAnimation *       gst_gdk_animation_new           (GError **error);
74

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
75 76 77 78
gboolean                gst_gdk_animation_add_data      (GstGdkAnimation *      ani,
                                                         const guint8 *         data,
                                                         guint                  size);
void                    gst_gdk_animation_done_adding   (GstGdkAnimation *      ani);
79 80


Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
81 82 83
#define GST_TYPE_GDK_ANIMATION_ITER             (gst_gdk_animation_iter_get_type ())
#define GST_GDK_ANIMATION_ITER(object)          (G_TYPE_CHECK_INSTANCE_CAST ((object), GST_TYPE_GDK_ANIMATION_ITER, GstGdkAnimationIter))
#define GST_IS_GDK_ANIMATION_ITER(object)       (G_TYPE_CHECK_INSTANCE_TYPE ((object), GST_TYPE_GDK_ANIMATION_ITER))
84

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
85 86 87
#define GST_GDK_ANIMATION_ITER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GDK_ANIMATION_ITER, GstGdkAnimationIterClass))
#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))
88

Johan Dahlin's avatar
Johan Dahlin committed
89
struct _GstGdkAnimationIter {
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
90
  GdkPixbufAnimationIter        parent;
Johan Dahlin's avatar
Johan Dahlin committed
91
        
92
  /* our animation */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
93
  GstGdkAnimation *             ani;
94
  /* start timeval */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
95
  GTimeVal                      start;
96
  /* timestamp of last buffer */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
97
  GstClockTime                  last_timestamp;
Johan Dahlin's avatar
Johan Dahlin committed
98
  
99
  /* pipeline we're using */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
100 101 102
  GstElement *                  pipeline;
  gboolean                      eos;
  gboolean                      just_seeked;
Johan Dahlin's avatar
Johan Dahlin committed
103
  
104
  /* current image and the buffers containing the data */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
105 106
  GdkPixbuf *                   pixbuf;
  GQueue *                      buffers;
107 108
};

Johan Dahlin's avatar
Johan Dahlin committed
109
struct _GstGdkAnimationIterClass {
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
110
  GdkPixbufAnimationIterClass   parent_class;
111 112
};

Johan Dahlin's avatar
Johan Dahlin committed
113
GType gst_gdk_animation_iter_get_type (void) G_GNUC_CONST;
114 115

G_END_DECLS
Johan Dahlin's avatar
Johan Dahlin committed
116

117
#endif /* __GST_GDK_ANIMATION_H__ */