1 /* GStreamer
2  * Copyright (C) 2006 Sjoerd Simons <sjoerd@luon.net>
3  * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
4  *
5  * gstmultipartdemux.h: multipart stream demuxer
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., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef __GST_MULTIPART_DEMUX__
24 #define __GST_MULTIPART_DEMUX__
25 
26 #include <gst/gst.h>
27 #include <gst/base/gstadapter.h>
28 
29 #include <string.h>
30 
31 G_BEGIN_DECLS
32 
33 #define GST_TYPE_MULTIPART_DEMUX (gst_multipart_demux_get_type())
34 #define GST_MULTIPART_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MULTIPART_DEMUX, GstMultipartDemux))
35 #define GST_MULTIPART_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MULTIPART_DEMUX, GstMultipartDemux))
36 #define GST_MULTIPART_DEMUX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_MULTIPART_DEMUX, GstMultipartDemuxClass))
37 #define GST_IS_MULTIPART_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MULTIPART_DEMUX))
38 #define GST_IS_MULTIPART_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULTIPART_DEMUX))
39 
40 typedef struct _GstMultipartDemux GstMultipartDemux;
41 typedef struct _GstMultipartDemuxClass GstMultipartDemuxClass;
42 
43 #define MULTIPART_NEED_MORE_DATA -1
44 #define MULTIPART_DATA_ERROR     -2
45 #define MULTIPART_DATA_EOS       -3
46 
47 /* all information needed for one multipart stream */
48 typedef struct
49 {
50   GstPad *pad;                  /* reference for this pad is held by element we belong to */
51 
52   gchar *mime;
53 
54   GstClockTime  last_ts;        /* last timestamp to make sure we don't send
55                                  * two buffers with the same timestamp */
56   GstFlowReturn last_ret;
57 
58   gboolean      discont;
59 }
60 GstMultipartPad;
61 
62 /**
63  * GstMultipartDemux:
64  *
65  * The opaque #GstMultipartDemux structure.
66  */
67 struct _GstMultipartDemux
68 {
69   GstElement element;
70 
71   /* pad */
72   GstPad *sinkpad;
73 
74   GSList *srcpads;
75   guint numpads;
76 
77   GstAdapter *adapter;
78 
79   /* Header information of the current frame */
80   gboolean header_completed;
81   gchar *boundary;
82   guint boundary_len;
83   gchar *mime_type;
84   gint content_length;
85 
86   /* Index inside the current data when manually looking for the boundary */
87   gint scanpos;
88 
89   gboolean singleStream;
90 
91   /* to handle stream-start */
92   gboolean have_group_id;
93   guint group_id;
94 };
95 
96 struct _GstMultipartDemuxClass
97 {
98   GstElementClass parent_class;
99 
100   GHashTable *gstnames;
101 };
102 
103 GType gst_multipart_demux_get_type (void);
104 
105 gboolean gst_multipart_demux_plugin_init (GstPlugin * plugin);
106 
107 G_END_DECLS
108 
109 #endif /* __GST_MULTIPART_DEMUX__ */
110 
111