make numbers garbage-collected objects
[swfdec.git] / swfdec / swfdec_buffer.h
blob99befd4202df3cecd626fbcb1ad63afe687e6b38
1 /* Swfdec
2 * Copyright (C) 2003-2006 David Schleef <ds@schleef.org>
3 * 2005-2006 Eric Anholt <eric@anholt.net>
4 * 2006-2007 Benjamin Otte <otte@gnome.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA
22 #ifndef __SWFDEC_BUFFER_H__
23 #define __SWFDEC_BUFFER_H__
25 #include <glib.h>
26 #include <glib-object.h>
28 G_BEGIN_DECLS
30 typedef struct _SwfdecBuffer SwfdecBuffer;
31 typedef struct _SwfdecBufferQueue SwfdecBufferQueue;
33 typedef void (* SwfdecBufferFreeFunc) (gpointer *priv, unsigned char *data);
35 struct _SwfdecBuffer
37 unsigned char * data; /* memory region (consider as read only) */
38 gsize length; /* length of the memory region pointer do by @data */
40 /*< private >*/
41 int ref_count; /* guess */
43 SwfdecBufferFreeFunc free; /* function to call to free @data */
44 gpointer priv; /* data to pass to @free */
47 #define SWFDEC_TYPE_BUFFER swfdec_buffer_get_type()
48 GType swfdec_buffer_get_type (void);
50 struct _SwfdecBufferQueue
52 /*< private >*/
53 GSList * first_buffer; /* pointer to first buffer */
54 GSList * last_buffer; /* pointer to last buffer (for fast appending) */
55 gsize depth; /* amount of bytes in the queue */
56 gsize offset; /* amount of data already flushed out of the queue */
58 int ref_count;
61 #define SWFDEC_TYPE_BUFFER_QUEUE swfdec_buffer_queue_get_type()
62 GType swfdec_buffer_queue_get_type (void);
64 SwfdecBuffer *swfdec_buffer_new (gsize size);
65 SwfdecBuffer *swfdec_buffer_new0 (gsize size);
66 SwfdecBuffer *swfdec_buffer_new_full (unsigned char *data, gsize size, SwfdecBufferFreeFunc free_func, gpointer priv);
67 SwfdecBuffer *swfdec_buffer_new_subbuffer (SwfdecBuffer * buffer, gsize offset,
68 gsize length);
69 SwfdecBuffer *swfdec_buffer_new_from_file (const char *filename, GError **error);
70 SwfdecBuffer *swfdec_buffer_new_for_data (unsigned char *data, gsize size);
71 #define swfdec_buffer_new_static(data, size) \
72 swfdec_buffer_new_full ((unsigned char *) data, size, NULL, NULL)
73 SwfdecBuffer *swfdec_buffer_ref (SwfdecBuffer * buffer);
74 SwfdecBuffer *swfdec_buffer_get_super (SwfdecBuffer *buffer);
75 void swfdec_buffer_unref (SwfdecBuffer * buffer);
77 SwfdecBufferQueue *swfdec_buffer_queue_new (void);
78 void swfdec_buffer_queue_flush (SwfdecBufferQueue *queue, gsize n_bytes);
79 void swfdec_buffer_queue_clear (SwfdecBufferQueue *queue);
80 gsize swfdec_buffer_queue_get_depth (SwfdecBufferQueue * queue);
81 gsize swfdec_buffer_queue_get_offset (SwfdecBufferQueue * queue);
82 void swfdec_buffer_queue_push (SwfdecBufferQueue * queue,
83 SwfdecBuffer * buffer);
84 SwfdecBuffer *swfdec_buffer_queue_pull (SwfdecBufferQueue * queue, gsize length);
85 SwfdecBuffer *swfdec_buffer_queue_pull_buffer (SwfdecBufferQueue * queue);
86 SwfdecBuffer *swfdec_buffer_queue_peek (SwfdecBufferQueue * queue, gsize length);
87 SwfdecBuffer *swfdec_buffer_queue_peek_buffer (SwfdecBufferQueue * queue);
88 SwfdecBufferQueue *swfdec_buffer_queue_ref (SwfdecBufferQueue * queue);
89 void swfdec_buffer_queue_unref (SwfdecBufferQueue * queue);
91 G_END_DECLS
92 #endif