Merging gst-plugins-ugly
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-ugly / gst / realmedia / gstrdtbuffer.h
1 /* GStreamer
2  * Copyright (C) <2008> Wim Taymans <wim.taymans@gmail.com>
3  *
4  * gstrdtbuffer.h: various helper functions to manipulate buffers
5  *     with RDT payload.
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_RDTBUFFER_H__
24 #define __GST_RDTBUFFER_H__
25
26 #include <gst/gst.h>
27
28 G_BEGIN_DECLS
29 /**
30  * GstRDTType:
31  * @GST_RDT_TYPE_INVALID:
32  * @GST_RDT_TYPE_ASMACTION:
33  * @GST_RDT_TYPE_ACK:
34  * @GST_RDT_TYPE_RTTREQ:
35  * @GST_RDT_TYPE_RTTRESP:
36  * @GST_RDT_TYPE_CONGESTION:
37  * @GST_RDT_TYPE_STREAMEND:
38  * @GST_RDT_TYPE_LATENCY:
39  * @GST_RDT_TYPE_INFOREQ:
40  * @GST_RDT_TYPE_INFORESP:
41  * @GST_RDT_TYPE_AUTOBW:
42  *
43  * Different RDT packet types.
44  */
45 typedef enum
46 {
47   GST_RDT_TYPE_INVALID     = 0xffff,
48   GST_RDT_TYPE_ASMACTION   = 0xff00,
49   GST_RDT_TYPE_BWREPORT    = 0xff01,
50   GST_RDT_TYPE_ACK         = 0xff02,
51   GST_RDT_TYPE_RTTREQ      = 0xff03,
52   GST_RDT_TYPE_RTTRESP     = 0xff04,
53   GST_RDT_TYPE_CONGESTION  = 0xff05,
54   GST_RDT_TYPE_STREAMEND   = 0xff06,
55   GST_RDT_TYPE_REPORT      = 0xff07,
56   GST_RDT_TYPE_LATENCY     = 0xff08,
57   GST_RDT_TYPE_INFOREQ     = 0xff09,
58   GST_RDT_TYPE_INFORESP    = 0xff0a,
59   GST_RDT_TYPE_AUTOBW      = 0xff0b
60 } GstRDTType;
61
62 /**
63  * GST_RDT_IS_DATA_TYPE:
64  * @t: the #GstRDTType to check
65  *
66  * Check if @t is a data packet type.
67  */
68 #define GST_RDT_IS_DATA_TYPE(t) ((t) < 0xff00)
69
70 typedef struct _GstRDTPacket GstRDTPacket;
71
72 /**
73  * GstRDTPacket:
74  * @buffer: pointer to RDT buffer
75  * @offset: offset of packet in buffer data
76  *
77  * Data structure that points to a packet at @offset in @buffer.
78  * The size of the structure is made public to allow stack allocations.
79  */
80 struct _GstRDTPacket
81 {
82   GstBuffer   *buffer;
83   guint        offset;
84
85   /*< private >*/
86   GstRDTType   type;         /* type of current packet */
87   guint16      length;       /* length of current packet in bytes */
88   GstMapInfo   map;          /* last mapped data */
89 };
90
91 /* validate buffers */
92 gboolean        gst_rdt_buffer_validate_data      (guint8 *data, guint len);
93 gboolean        gst_rdt_buffer_validate           (GstBuffer *buffer);
94
95 /* retrieving packets */
96 guint           gst_rdt_buffer_get_packet_count   (GstBuffer *buffer);
97 gboolean        gst_rdt_buffer_get_first_packet   (GstBuffer *buffer, GstRDTPacket *packet);
98 gboolean        gst_rdt_packet_move_to_next       (GstRDTPacket *packet);
99
100 /* working with packets */
101 GstRDTType      gst_rdt_packet_get_type           (GstRDTPacket *packet);
102 guint16         gst_rdt_packet_get_length         (GstRDTPacket *packet);
103 GstBuffer*      gst_rdt_packet_to_buffer          (GstRDTPacket *packet);
104
105
106 /* data packets */
107 guint16         gst_rdt_packet_data_get_seq       (GstRDTPacket *packet);
108 guint8 *        gst_rdt_packet_data_map           (GstRDTPacket *packet, guint *size);
109 gboolean        gst_rdt_packet_data_unmap         (GstRDTPacket *packet);
110 guint16         gst_rdt_packet_data_get_stream_id (GstRDTPacket *packet);
111 guint32         gst_rdt_packet_data_get_timestamp (GstRDTPacket *packet);
112
113 guint8          gst_rdt_packet_data_get_flags     (GstRDTPacket * packet);
114
115 /* utils */
116 gint            gst_rdt_buffer_compare_seqnum     (guint16 seqnum1, guint16 seqnum2);
117
118 G_END_DECLS
119
120 #endif /* __GST_RDTBUFFER_H__ */
121