expand tabs
[platform/upstream/gstreamer.git] / gst-libs / gst / netbuffer / gstnetbuffer.h
1 /* GStreamer
2  * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
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_NETBUFFER_H__
21 #define __GST_NETBUFFER_H__
22
23 #include <gst/gst.h>
24
25 G_BEGIN_DECLS
26
27 typedef struct _GstNetBuffer GstNetBuffer;
28 typedef struct _GstNetBufferClass GstNetBufferClass;
29
30 #define GST_TYPE_NETBUFFER            (gst_netbuffer_get_type())
31 #define GST_IS_NETBUFFER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_NETBUFFER))
32 #define GST_IS_NETBUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_NETBUFFER))
33 #define GST_NETBUFFER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_NETBUFFER, GstNetBufferClass))
34 #define GST_NETBUFFER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_NETBUFFER, GstNetBuffer))
35 #define GST_NETBUFFER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_NETBUFFER, GstNetBufferClass))
36
37 /* buffer for use in network sources and sinks.
38  *
39  * It contains the source or destination address of the buffer.
40  */
41 typedef enum {
42   GST_NET_TYPE_UNKNOWN,
43   GST_NET_TYPE_IP4,
44   GST_NET_TYPE_IP6,
45 } GstNetType;
46
47 typedef struct
48 {
49   GstNetType    type;
50   union {
51     guint8        ip6[16];
52     guint32       ip4;
53   } address;
54   guint16       port;
55   /*< private >*/
56   gpointer _gst_reserved[GST_PADDING];
57 } GstNetAddress;
58
59 struct _GstNetBuffer {
60   GstBuffer buffer;
61
62   GstNetAddress from;
63   GstNetAddress to;
64
65   /*< private >*/
66   gpointer _gst_reserved[GST_PADDING];
67 };
68
69 struct _GstNetBufferClass {
70   GstBufferClass  buffer_class;
71
72   /*< private >*/
73   gpointer _gst_reserved[GST_PADDING];
74 };
75
76 /* creating buffers */
77 GType           gst_netbuffer_get_type          (void);
78
79 GstNetBuffer*   gst_netbuffer_new               (void);
80
81 /* address operations */
82 void            gst_netaddress_set_ip4_address  (GstNetAddress *nadd, guint32 address, guint16 port);
83 void            gst_netaddress_set_ip6_address  (GstNetAddress *nadd, guint8 address[16], guint16 port);
84
85 GstNetType      gst_netaddress_get_net_type     (GstNetAddress *nadd);
86 gboolean        gst_netaddress_get_ip4_address  (GstNetAddress *nadd, guint32 *address, guint16 *port);
87 gboolean        gst_netaddress_get_ip6_address  (GstNetAddress *nadd, guint8 address[16], guint16 *port);
88
89 G_END_DECLS
90
91 #endif /* __GST_NETBUFFER_H__ */
92