gstreamer_core/gst/gstbufferlist.h
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
     1 /* GStreamer
       
     2  * Copyright (C) 2009 Axis Communications <dev-gstreamer at axis dot com>
       
     3  * @author Jonas Holmberg <jonas dot holmberg at axis dot com>
       
     4  *
       
     5  * gstbufferlist.h: Header for GstBufferList object
       
     6  *
       
     7  * This library is free software; you can redistribute it and/or
       
     8  * modify it under the terms of the GNU Library General Public
       
     9  * License as published by the Free Software Foundation; either
       
    10  * version 2 of the License, or (at your option) any later version.
       
    11  *
       
    12  * This library is distributed in the hope that it will be useful,
       
    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    15  * Library General Public License for more details.
       
    16  *
       
    17  * You should have received a copy of the GNU Library General Public
       
    18  * License along with this library; if not, write to the
       
    19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    20  * Boston, MA 02111-1307, USA.
       
    21  */
       
    22 
       
    23 #ifndef __GST_BUFFER_LIST_H__
       
    24 #define __GST_BUFFER_LIST_H__
       
    25 
       
    26 #include <gst/gstbuffer.h>
       
    27 
       
    28 G_BEGIN_DECLS
       
    29 
       
    30 #define GST_TYPE_BUFFER_LIST (gst_buffer_list_get_type ())
       
    31 #define GST_IS_BUFFER_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BUFFER_LIST))
       
    32 #define GST_IS_BUFFER_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BUFFER_LIST))
       
    33 #define GST_BUFFER_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BUFFER_LIST, GstBufferListClass))
       
    34 #define GST_BUFFER_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BUFFER_LIST, GstBufferList))
       
    35 #define GST_BUFFER_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BUFFER_LIST, GstBufferListClass))
       
    36 #define GST_BUFFER_LIST_CAST(obj) ((GstBufferList *)obj)
       
    37 
       
    38 typedef struct _GstBufferList GstBufferList;
       
    39 typedef struct _GstBufferListClass GstBufferListClass;
       
    40 typedef struct _GstBufferListIterator GstBufferListIterator;
       
    41 
       
    42 /**
       
    43  * GstBufferListDoFunction:
       
    44  * @buffer: the #GstBuffer
       
    45  * @user_data: user data
       
    46  *
       
    47  * A function for accessing the last buffer returned by
       
    48  * gst_buffer_list_iterator_next(). The function can leave @buffer in the list,
       
    49  * replace @buffer in the list or remove @buffer from the list, depending on
       
    50  * the return value. If the function returns NULL, @buffer will be removed from
       
    51  * the list, otherwise @buffer will be replaced with the returned buffer.
       
    52  *
       
    53  * The last buffer returned by gst_buffer_list_iterator_next() will be replaced
       
    54  * with the buffer returned from the function. The function takes ownership of
       
    55  * @buffer and if a different value than @buffer is returned, @buffer must be
       
    56  * unreffed. If NULL is returned, the buffer will be removed from the list. The
       
    57  * list must be writable.
       
    58  *
       
    59  * Returns: the buffer to replace @buffer in the list, or NULL to remove @buffer
       
    60  * from the list
       
    61  */
       
    62 typedef GstBuffer* (*GstBufferListDoFunction) (GstBuffer * buffer, gpointer user_data);
       
    63 
       
    64 /**
       
    65  * GstBufferListItem:
       
    66  * @GST_BUFFER_LIST_CONTINUE:   Retrieve next buffer
       
    67  * @GST_BUFFER_LIST_SKIP_GROUP: Skip to next group
       
    68  * @GST_BUFFER_LIST_END:        End iteration
       
    69  *
       
    70  * The result of the #GstBufferListFunc.
       
    71  */
       
    72 typedef enum {
       
    73   GST_BUFFER_LIST_CONTINUE,
       
    74   GST_BUFFER_LIST_SKIP_GROUP,
       
    75   GST_BUFFER_LIST_END
       
    76 } GstBufferListItem;
       
    77 
       
    78 /**
       
    79  * GstBufferListFunc:
       
    80  * @buffer: pointer the buffer
       
    81  * @group: the group index of @buffer
       
    82  * @idx: the index in @group of @buffer
       
    83  * @user_data: user data passed to gst_buffer_list_foreach()
       
    84  *
       
    85  * A function that will be called from gst_buffer_list_foreach(). The @buffer
       
    86  * field will point to a the reference of the buffer at @idx in @group.
       
    87  *
       
    88  * When this function returns #GST_BUFFER_LIST_CONTINUE, the next buffer will be
       
    89  * returned. When #GST_BUFFER_LIST_SKIP_GROUP is returned, all remaining buffers
       
    90  * in the current group will be skipped and the first buffer of the next group
       
    91  * is returned (if any). When GST_BUFFER_LIST_END is returned,
       
    92  * gst_buffer_list_foreach() will return.
       
    93  *
       
    94  * When @buffer is set to NULL, the item will be removed from the bufferlist.
       
    95  * When @buffer has been made writable, the new buffer reference can be assigned
       
    96  * to @buffer. This function is responsible for unreffing the old buffer when
       
    97  * removing or modifying.
       
    98  *
       
    99  * Returns: a #GstBufferListItem
       
   100  */
       
   101 typedef GstBufferListItem (*GstBufferListFunc)   (GstBuffer **buffer, guint group, guint idx,
       
   102                                                   gpointer user_data);
       
   103 #ifdef __SYMBIAN32__
       
   104 IMPORT_C
       
   105 #endif
       
   106 
       
   107 
       
   108 
       
   109 GType gst_buffer_list_get_type (void);
       
   110 
       
   111 /* allocation */
       
   112 #ifdef __SYMBIAN32__
       
   113 IMPORT_C
       
   114 #endif
       
   115 
       
   116 GstBufferList *gst_buffer_list_new (void);
       
   117 
       
   118 /* refcounting */
       
   119 /**
       
   120  * gst_buffer_list_ref:
       
   121  * @list: a #GstBufferList
       
   122  *
       
   123  * Increases the refcount of the given buffer list by one.
       
   124  *
       
   125  * Note that the refcount affects the writeability of @list and its data, see
       
   126  * gst_buffer_list_make_writable(). It is important to note that keeping
       
   127  * additional references to GstBufferList instances can potentially increase
       
   128  * the number of memcpy operations in a pipeline.
       
   129  *
       
   130  * Returns: @list
       
   131  */
       
   132 #ifdef _FOOL_GTK_DOC_
       
   133 G_INLINE_FUNC GstBufferList * gst_buffer_list_ref (GstBufferList * list);
       
   134 #endif
       
   135 
       
   136 static inline GstBufferList *
       
   137 gst_buffer_list_ref (GstBufferList * list)
       
   138 {
       
   139   return GST_BUFFER_LIST_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (
       
   140       list)));
       
   141 }
       
   142 
       
   143 /**
       
   144  * gst_buffer_list_unref:
       
   145  * @list: a #GstBufferList
       
   146  *
       
   147  * Decreases the refcount of the buffer list. If the refcount reaches 0, the
       
   148  * buffer list will be freed.
       
   149  */
       
   150 #ifdef _FOOL_GTK_DOC_
       
   151 G_INLINE_FUNC void gst_buffer_list_unref (GstBufferList * list);
       
   152 #endif
       
   153 
       
   154 static inline void
       
   155 gst_buffer_list_unref (GstBufferList * list)
       
   156 {
       
   157   gst_mini_object_unref (GST_MINI_OBJECT_CAST (list));
       
   158 }
       
   159 
       
   160 /* copy */
       
   161 /**
       
   162  * gst_buffer_list_copy:
       
   163  * @list: a #GstBufferList
       
   164  *
       
   165  * Create a shallow copy of the given buffer list. This will make a newly
       
   166  * allocated copy of the source list with copies of buffer pointers. The
       
   167  * refcount of buffers pointed to will be increased by one.
       
   168  *
       
   169  * Returns: a new copy of @list.
       
   170  */
       
   171 #ifdef _FOOL_GTK_DOC_
       
   172 G_INLINE_FUNC GstBufferList * gst_buffer_list_copy (const GstBufferList * list);
       
   173 #endif
       
   174 
       
   175 static inline GstBufferList *
       
   176 gst_buffer_list_copy (const GstBufferList * list)
       
   177 {
       
   178   return GST_BUFFER_LIST (gst_mini_object_copy (GST_MINI_OBJECT_CAST (list)));
       
   179 }
       
   180 
       
   181 /**
       
   182  * gst_buffer_list_is_writable:
       
   183  * @list: a #GstBufferList
       
   184  *
       
   185  * Tests if you can safely add buffers and groups into a buffer list.
       
   186  */
       
   187 #define gst_buffer_list_is_writable(list) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (list))
       
   188 
       
   189 /**
       
   190  * gst_buffer_list_make_writable:
       
   191  * @list: a #GstBufferList
       
   192  *
       
   193  * Makes a writable buffer list from the given buffer list. If the source buffer
       
   194  * list is already writable, this will simply return the same buffer list. A
       
   195  * copy will otherwise be made using gst_buffer_list_copy().
       
   196  */
       
   197 #define gst_buffer_list_make_writable(list) GST_BUFFER_LIST_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (list)))
       
   198 
       
   199 guint                    gst_buffer_list_n_groups              (GstBufferList *list);
       
   200 #ifdef __SYMBIAN32__
       
   201 IMPORT_C
       
   202 #endif
       
   203 
       
   204 
       
   205 void                     gst_buffer_list_foreach               (GstBufferList *list,
       
   206                                                                 GstBufferListFunc func,
       
   207 								gpointer user_data);
       
   208 #ifdef __SYMBIAN32__
       
   209 IMPORT_C
       
   210 #endif
       
   211 
       
   212 GstBuffer *              gst_buffer_list_get                   (GstBufferList *list, guint group, guint idx);
       
   213 
       
   214 /* iterator */
       
   215 #ifdef __SYMBIAN32__
       
   216 IMPORT_C
       
   217 #endif
       
   218 
       
   219 GstBufferListIterator *  gst_buffer_list_iterate               (GstBufferList *list);
       
   220 #ifdef __SYMBIAN32__
       
   221 IMPORT_C
       
   222 #endif
       
   223 
       
   224 void                     gst_buffer_list_iterator_free         (GstBufferListIterator *it);
       
   225 #ifdef __SYMBIAN32__
       
   226 IMPORT_C
       
   227 #endif
       
   228 
       
   229 
       
   230 guint                    gst_buffer_list_iterator_n_buffers    (const GstBufferListIterator *it);
       
   231 #ifdef __SYMBIAN32__
       
   232 IMPORT_C
       
   233 #endif
       
   234 
       
   235 GstBuffer *              gst_buffer_list_iterator_next         (GstBufferListIterator *it);
       
   236 #ifdef __SYMBIAN32__
       
   237 IMPORT_C
       
   238 #endif
       
   239 
       
   240 gboolean                 gst_buffer_list_iterator_next_group   (GstBufferListIterator *it);
       
   241 #ifdef __SYMBIAN32__
       
   242 IMPORT_C
       
   243 #endif
       
   244 
       
   245 
       
   246 void                     gst_buffer_list_iterator_add          (GstBufferListIterator *it, GstBuffer *buffer);
       
   247 #ifdef __SYMBIAN32__
       
   248 IMPORT_C
       
   249 #endif
       
   250 
       
   251 void                     gst_buffer_list_iterator_add_group    (GstBufferListIterator *it);
       
   252 #ifdef __SYMBIAN32__
       
   253 IMPORT_C
       
   254 #endif
       
   255 
       
   256 void                     gst_buffer_list_iterator_remove       (GstBufferListIterator *it);
       
   257 #ifdef __SYMBIAN32__
       
   258 IMPORT_C
       
   259 #endif
       
   260 
       
   261 GstBuffer *              gst_buffer_list_iterator_steal        (GstBufferListIterator *it);
       
   262 #ifdef __SYMBIAN32__
       
   263 IMPORT_C
       
   264 #endif
       
   265 
       
   266 void                     gst_buffer_list_iterator_take         (GstBufferListIterator *it, GstBuffer *buffer);
       
   267 #ifdef __SYMBIAN32__
       
   268 IMPORT_C
       
   269 #endif
       
   270 
       
   271 
       
   272 GstBuffer *              gst_buffer_list_iterator_do           (GstBufferListIterator *it, GstBufferListDoFunction do_func,
       
   273                                                                 gpointer user_data);
       
   274 
       
   275 /* conversion */
       
   276 #ifdef __SYMBIAN32__
       
   277 IMPORT_C
       
   278 #endif
       
   279 
       
   280 GstBuffer *              gst_buffer_list_iterator_merge_group  (const GstBufferListIterator *it);
       
   281 
       
   282 G_END_DECLS
       
   283 
       
   284 #endif /* __GST_BUFFER_LIST_H__ */