g_thread_create() is deprecated in GLib master, use g_thread_try_new() instead
[glsdk/gstreamer0-10.git] / libs / gst / dataprotocol / dataprotocol.h
1 /* GStreamer
2  * Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
3  * Copyright (C) 2004,2006 Thomas Vander Stichele <thomas at apestaart dot org>
4  *
5  * dataprotocol.h: Functions implementing the GStreamer Data Protocol
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  */
23 #ifndef __GST_DATA_PROTOCOL_H__
24 #define __GST_DATA_PROTOCOL_H__
26 #include <gst/gstbuffer.h>
27 #include <gst/gstevent.h>
28 #include <gst/gstcaps.h>
30 G_BEGIN_DECLS
32 /**
33  * GstDPVersion:
34  * @GST_DP_VERSION_0_2: protocol version 0.2
35  * @GST_DP_VERSION_1_0: protocol version 1.0
36  *
37  * The version of the GDP protocol being used.
38  */
39 typedef enum {
40   GST_DP_VERSION_0_2 = 1,
41   GST_DP_VERSION_1_0,
42 } GstDPVersion;
44 GType gst_dp_version_get_type (void);
45 #define GST_TYPE_DP_VERSION (gst_dp_version_get_type ())
47 /**
48  * GST_DP_VERSION_MAJOR:
49  *
50  * The major version number of the GStreamer Data Protocol.
51  */
52 #define GST_DP_VERSION_MAJOR 0
53 /**
54  * GST_DP_VERSION_MINOR:
55  *
56  * The minor version number of the GStreamer Data Protocol.
57  */
58 #define GST_DP_VERSION_MINOR 2
60 /**
61  * GST_DP_HEADER_LENGTH:
62  *
63  * The header size in bytes.
64  */
65 #define GST_DP_HEADER_LENGTH 62
67 /**
68  * GstDPHeaderFlag:
69  * @GST_DP_HEADER_FLAG_NONE: No flag present.
70  * @GST_DP_HEADER_FLAG_CRC_HEADER: a header CRC field is present.
71  * @GST_DP_HEADER_FLAG_CRC_PAYLOAD: a payload CRC field is present.
72  * @GST_DP_HEADER_FLAG_CRC: a CRC for header and payload is present.
73  *
74  * header flags for the dataprotocol.
75  */
76 typedef enum {
77   GST_DP_HEADER_FLAG_NONE        = 0,
78   GST_DP_HEADER_FLAG_CRC_HEADER  = (1 << 0),
79   GST_DP_HEADER_FLAG_CRC_PAYLOAD = (1 << 1),
80   GST_DP_HEADER_FLAG_CRC         = (1 << 1) | (1 << 0),
81 } GstDPHeaderFlag;
83 /**
84  * GstDPPayloadType:
85  * @GST_DP_PAYLOAD_NONE: Invalid payload type.
86  * @GST_DP_PAYLOAD_BUFFER: #GstBuffer payload packet.
87  * @GST_DP_PAYLOAD_CAPS: #GstCaps payload packet.
88  * @GST_DP_PAYLOAD_EVENT_NONE: First value of #GstEvent payload packets.
89  *
90  * The GDP payload types. a #GstEvent payload type is encoded with the
91  * event type number starting from @GST_DP_PAYLOAD_EVENT_NONE.
92  */
93 typedef enum {
94   GST_DP_PAYLOAD_NONE            = 0,
95   GST_DP_PAYLOAD_BUFFER,
96   GST_DP_PAYLOAD_CAPS,
97   GST_DP_PAYLOAD_EVENT_NONE      = 64,
98 } GstDPPayloadType;
100 typedef gboolean (*GstDPHeaderFromBufferFunction) (const GstBuffer * buffer,
101                                                 GstDPHeaderFlag flags,
102                                                 guint * length,
103                                                 guint8 ** header);
104 typedef gboolean (*GstDPPacketFromCapsFunction) (const GstCaps * caps,
105                                                 GstDPHeaderFlag flags,
106                                                 guint * length,
107                                                 guint8 ** header,
108                                                 guint8 ** payload);
109 typedef gboolean (*GstDPPacketFromEventFunction) (const GstEvent * event,
110                                                 GstDPHeaderFlag flags,
111                                                 guint * length,
112                                                 guint8 ** header,
113                                                 guint8 ** payload);
115 /**
116  * GstDPPacketizer:
117  * @version: the #GstDPVersion of the protocol to be used
118  * @header_from_buffer: buffer serializer function
119  * @packet_from_caps: caps serializer function
120  * @packet_from_event: event serializer function
121  *
122  * Data protocol packetizer handle.
123  */
124 typedef struct {
125   GstDPVersion version;
127   GstDPHeaderFromBufferFunction header_from_buffer;
128   GstDPPacketFromCapsFunction packet_from_caps;
129   GstDPPacketFromEventFunction packet_from_event;
131   /*< private >*/
132   gpointer _gst_reserved[GST_PADDING];
133 } GstDPPacketizer;
136 void            gst_dp_init                     (void);
138 /* packetizer */
139 GstDPPacketizer *
140                 gst_dp_packetizer_new           (GstDPVersion version);
141 void            gst_dp_packetizer_free          (GstDPPacketizer *packetizer);
143 /* crc checksum */
144 guint16         gst_dp_crc                      (const guint8 * buffer,
145                                                  guint length);
147 /* payload information from header */
148 guint32         gst_dp_header_payload_length    (const guint8 * header);
149 GstDPPayloadType
150                 gst_dp_header_payload_type      (const guint8 * header);
152 /* converting from GstBuffer/GstEvent/GstCaps */
153 #ifndef GST_DISABLE_DEPRECATED
154 gboolean        gst_dp_header_from_buffer       (const GstBuffer * buffer,
155                                                 GstDPHeaderFlag flags,
156                                                 guint * length,
157                                                 guint8 ** header);
158 #endif
159 #ifndef GST_DISABLE_DEPRECATED
160 gboolean        gst_dp_packet_from_caps         (const GstCaps * caps,
161                                                 GstDPHeaderFlag flags,
162                                                 guint * length,
163                                                 guint8 ** header,
164                                                 guint8 ** payload);
165 #endif
166 #ifndef GST_DISABLE_DEPRECATED
167 gboolean        gst_dp_packet_from_event        (const GstEvent * event,
168                                                 GstDPHeaderFlag flags,
169                                                 guint * length,
170                                                 guint8 ** header,
171                                                 guint8 ** payload);
172 #endif
173 /* converting to GstBuffer/GstEvent/GstCaps */
174 GstBuffer *     gst_dp_buffer_from_header       (guint header_length,
175                                                 const guint8 * header);
176 GstCaps *       gst_dp_caps_from_packet         (guint header_length,
177                                                 const guint8 * header,
178                                                 const guint8 * payload);
179 GstEvent *      gst_dp_event_from_packet        (guint header_length,
180                                                 const guint8 * header,
181                                                 const guint8 * payload);
183 /* validation */
184 gboolean        gst_dp_validate_header          (guint header_length,
185                                                 const guint8 * header);
186 gboolean        gst_dp_validate_payload         (guint header_length,
187                                                 const guint8 * header,
188                                                 const guint8 * payload);
189 gboolean        gst_dp_validate_packet          (guint header_length,
190                                                 const guint8 * header,
191                                                 const guint8 * payload);
193 G_END_DECLS
195 #endif /* __GST_DATA_PROTOCOL_H__ */