Move files from gst-plugins-bad into the "subprojects/gst-plugins-bad/" subdir
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / gst / gdp / 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., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #ifndef __GST_DATA_PROTOCOL_H__
24 #define __GST_DATA_PROTOCOL_H__
25
26 #include <gst/gstbuffer.h>
27 #include <gst/gstevent.h>
28 #include <gst/gstcaps.h>
29
30 G_BEGIN_DECLS
31
32 /**
33  * GST_DP_HEADER_LENGTH:
34  *
35  * The header size in bytes.
36  */
37 #define GST_DP_HEADER_LENGTH 62
38
39 /**
40  * GstDPHeaderFlag:
41  * @GST_DP_HEADER_FLAG_NONE: No flag present.
42  * @GST_DP_HEADER_FLAG_CRC_HEADER: a header CRC field is present.
43  * @GST_DP_HEADER_FLAG_CRC_PAYLOAD: a payload CRC field is present.
44  * @GST_DP_HEADER_FLAG_CRC: a CRC for header and payload is present.
45  *
46  * header flags for the dataprotocol.
47  */
48 typedef enum {
49   GST_DP_HEADER_FLAG_NONE        = 0,
50   GST_DP_HEADER_FLAG_CRC_HEADER  = (1 << 0),
51   GST_DP_HEADER_FLAG_CRC_PAYLOAD = (1 << 1),
52   GST_DP_HEADER_FLAG_CRC         = (1 << 1) | (1 << 0),
53 } GstDPHeaderFlag;
54
55 /**
56  * GstDPPayloadType:
57  * @GST_DP_PAYLOAD_NONE: Invalid payload type.
58  * @GST_DP_PAYLOAD_BUFFER: #GstBuffer payload packet.
59  * @GST_DP_PAYLOAD_CAPS: #GstCaps payload packet.
60  * @GST_DP_PAYLOAD_EVENT_NONE: First value of #GstEvent payload packets.
61  *
62  * The GDP payload types. a #GstEvent payload type is encoded with the
63  * event type number starting from @GST_DP_PAYLOAD_EVENT_NONE.
64  */
65 typedef enum {
66   GST_DP_PAYLOAD_NONE            = 0,
67   GST_DP_PAYLOAD_BUFFER,
68   GST_DP_PAYLOAD_CAPS,
69   GST_DP_PAYLOAD_EVENT_NONE      = 64,
70 } GstDPPayloadType;
71
72 void            gst_dp_init                     (void);
73
74 /* payload information from header */
75 guint32         gst_dp_header_payload_length    (const guint8 * header);
76 GstDPPayloadType
77                 gst_dp_header_payload_type      (const guint8 * header);
78
79 /* converting to GstBuffer/GstEvent/GstCaps */
80 GstBuffer *     gst_dp_buffer_from_header       (guint header_length,
81                                                 const guint8 * header,
82                                                 GstAllocator * allocator,
83                                                 GstAllocationParams * allocation_params);
84 GstCaps *       gst_dp_caps_from_packet         (guint header_length,
85                                                 const guint8 * header,
86                                                 const guint8 * payload);
87 GstEvent *      gst_dp_event_from_packet        (guint header_length,
88                                                 const guint8 * header,
89                                                 const guint8 * payload);
90
91 /* payloading GstBuffer/GstEvent/GstCaps */
92 GstBuffer *     gst_dp_payload_buffer           (GstBuffer      * buffer,
93                                                  GstDPHeaderFlag  flags);
94
95 GstBuffer *     gst_dp_payload_caps             (const GstCaps  * caps,
96                                                  GstDPHeaderFlag  flags);
97
98 GstBuffer *     gst_dp_payload_event            (const GstEvent * event,
99                                                  GstDPHeaderFlag  flags);
100
101 /* validation */
102 gboolean        gst_dp_validate_header          (guint header_length,
103                                                 const guint8 * header);
104 gboolean        gst_dp_validate_payload         (guint header_length,
105                                                 const guint8 * header,
106                                                 const guint8 * payload);
107 gboolean        gst_dp_validate_packet          (guint header_length,
108                                                 const guint8 * header,
109                                                 const guint8 * payload);
110
111 G_END_DECLS
112
113 #endif /* __GST_DATA_PROTOCOL_H__ */