gst_plugins_base/gst-libs/gst/app/gstappsrc.h
changeset 0 0e761a78d257
equal deleted inserted replaced
-1:000000000000 0:0e761a78d257
       
     1 /* GStreamer
       
     2  * Copyright (C) 2007 David Schleef <ds@schleef.org>
       
     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., 59 Temple Place - Suite 330,
       
    17  * Boston, MA 02111-1307, USA.
       
    18  */
       
    19 
       
    20 #ifndef _GST_APP_SRC_H_
       
    21 #define _GST_APP_SRC_H_
       
    22 
       
    23 #include <gst/gst.h>
       
    24 #include <gst/base/gstpushsrc.h>
       
    25 
       
    26 G_BEGIN_DECLS
       
    27 
       
    28 #define GST_TYPE_APP_SRC \
       
    29   (gst_app_src_get_type())
       
    30 #define GST_APP_SRC(obj) \
       
    31   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_APP_SRC,GstAppSrc))
       
    32 #define GST_APP_SRC_CLASS(klass) \
       
    33   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_APP_SRC,GstAppSrcClass))
       
    34 #define GST_IS_APP_SRC(obj) \
       
    35   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_APP_SRC))
       
    36 #define GST_IS_APP_SRC_CLASS(klass) \
       
    37   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_APP_SRC))
       
    38 /* Since 0.10.23 */
       
    39 #define GST_APP_SRC_CAST(obj) \
       
    40   ((GstAppSrc*)(obj))
       
    41 
       
    42 typedef struct _GstAppSrc GstAppSrc;
       
    43 typedef struct _GstAppSrcClass GstAppSrcClass;
       
    44 typedef struct _GstAppSrcPrivate GstAppSrcPrivate;
       
    45 
       
    46 /**
       
    47  * GstAppSrcCallbacks:
       
    48  * @need_data: Called when the appsrc needs more data. A buffer or EOS should be
       
    49  *    pushed to appsrc from this thread or another thread. @length is just a hint
       
    50  *    and when it is set to -1, any number of bytes can be pushed into @appsrc.
       
    51  * @enough_data: Called when appsrc has enough data. It is recommended that the
       
    52  *    application stops calling push-buffer until the need_data callback is
       
    53  *    emited again to avoid excessive buffer queueing.
       
    54  * @seek_data: Called when a seek should be performed to the offset.
       
    55  *    The next push-buffer should produce buffers from the new @offset.
       
    56  *    This callback is only called for seekable stream types.
       
    57  *
       
    58  * A set of callbacks that can be installed on the appsrc with
       
    59  * gst_app_src_set_callbacks().
       
    60  *
       
    61  * Since: 0.10.23
       
    62  */
       
    63 typedef struct {
       
    64   void      (*need_data)    (GstAppSrc *src, guint length, gpointer user_data);
       
    65   void      (*enough_data)  (GstAppSrc *src, gpointer user_data);
       
    66   gboolean  (*seek_data)    (GstAppSrc *src, guint64 offset, gpointer user_data);
       
    67 
       
    68   /*< private >*/
       
    69   gpointer     _gst_reserved[GST_PADDING];
       
    70 } GstAppSrcCallbacks;
       
    71 
       
    72 /**
       
    73  * GstAppStreamType:
       
    74  * @GST_APP_STREAM_TYPE_STREAM: No seeking is supported in the stream, such as a
       
    75  * live stream.
       
    76  * @GST_APP_STREAM_TYPE_SEEKABLE: The stream is seekable but seeking might not
       
    77  * be very fast, such as data from a webserver. 
       
    78  * @GST_APP_STREAM_TYPE_RANDOM_ACCESS: The stream is seekable and seeking is fast,
       
    79  * such as in a local file.
       
    80  *
       
    81  * The stream type.
       
    82  */
       
    83 typedef enum
       
    84 {
       
    85   GST_APP_STREAM_TYPE_STREAM,
       
    86   GST_APP_STREAM_TYPE_SEEKABLE,
       
    87   GST_APP_STREAM_TYPE_RANDOM_ACCESS
       
    88 } GstAppStreamType;
       
    89 
       
    90 struct _GstAppSrc
       
    91 {
       
    92   GstBaseSrc basesrc;
       
    93 
       
    94   /*< private >*/
       
    95   GstAppSrcPrivate *priv;
       
    96 
       
    97   /*< private >*/
       
    98   gpointer     _gst_reserved[GST_PADDING];
       
    99 };
       
   100 
       
   101 struct _GstAppSrcClass
       
   102 {
       
   103   GstBaseSrcClass basesrc_class;
       
   104 
       
   105   /* signals */
       
   106   void          (*need_data)       (GstAppSrc *src, guint length);
       
   107   void          (*enough_data)     (GstAppSrc *src);
       
   108   gboolean      (*seek_data)       (GstAppSrc *src, guint64 offset);
       
   109 
       
   110   /* actions */
       
   111   GstFlowReturn (*push_buffer)     (GstAppSrc *src, GstBuffer *buffer);
       
   112   GstFlowReturn (*end_of_stream)   (GstAppSrc *src);
       
   113 
       
   114   /*< private >*/
       
   115   gpointer     _gst_reserved[GST_PADDING];
       
   116 };
       
   117 
       
   118 IMPORT_C GType gst_app_src_get_type(void);
       
   119 
       
   120 IMPORT_C void             gst_app_src_set_caps         (GstAppSrc *appsrc, const GstCaps *caps);
       
   121 IMPORT_C GstCaps*         gst_app_src_get_caps         (GstAppSrc *appsrc);
       
   122 
       
   123 IMPORT_C void             gst_app_src_set_size         (GstAppSrc *appsrc, gint64 size);
       
   124 IMPORT_C gint64           gst_app_src_get_size         (GstAppSrc *appsrc);
       
   125 
       
   126 IMPORT_C void             gst_app_src_set_stream_type  (GstAppSrc *appsrc, GstAppStreamType type);
       
   127 IMPORT_C GstAppStreamType gst_app_src_get_stream_type  (GstAppSrc *appsrc);
       
   128 
       
   129 IMPORT_C void             gst_app_src_set_max_bytes    (GstAppSrc *appsrc, guint64 max);
       
   130 IMPORT_C guint64          gst_app_src_get_max_bytes    (GstAppSrc *appsrc);
       
   131 
       
   132 IMPORT_C void             gst_app_src_set_latency      (GstAppSrc *appsrc, guint64 min, guint64 max);
       
   133 IMPORT_C void             gst_app_src_get_latency      (GstAppSrc *appsrc, guint64 *min, guint64 *max);
       
   134 
       
   135 IMPORT_C void             gst_app_src_set_emit_signals (GstAppSrc *appsrc, gboolean emit);
       
   136 IMPORT_C gboolean         gst_app_src_get_emit_signals (GstAppSrc *appsrc);
       
   137 
       
   138 IMPORT_C GstFlowReturn    gst_app_src_push_buffer      (GstAppSrc *appsrc, GstBuffer *buffer);
       
   139 IMPORT_C GstFlowReturn    gst_app_src_end_of_stream    (GstAppSrc *appsrc);
       
   140 
       
   141 IMPORT_C void             gst_app_src_set_callbacks    (GstAppSrc * appsrc,
       
   142                                                GstAppSrcCallbacks *callbacks,
       
   143                                                gpointer user_data,
       
   144                                                GDestroyNotify notify);
       
   145 
       
   146 G_END_DECLS
       
   147 
       
   148 #endif
       
   149