Initial release including wifi display based on gst-rtsp-server-1.4.1
[platform/upstream/gstreamer.git] / gst / rtsp-server / rtsp-address-pool.h
1 /* GStreamer
2  * Copyright (C) 2012 Wim Taymans <wim.taymans at gmail.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., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #include <gst/gst.h>
21
22 #ifndef __GST_RTSP_ADDRESS_POOL_H__
23 #define __GST_RTSP_ADDRESS_POOL_H__
24
25 G_BEGIN_DECLS
26
27 #define GST_TYPE_RTSP_ADDRESS_POOL              (gst_rtsp_address_pool_get_type ())
28 #define GST_IS_RTSP_ADDRESS_POOL(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_ADDRESS_POOL))
29 #define GST_IS_RTSP_ADDRESS_POOL_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_ADDRESS_POOL))
30 #define GST_RTSP_ADDRESS_POOL_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_ADDRESS_POOL, GstRTSPAddressPoolClass))
31 #define GST_RTSP_ADDRESS_POOL(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_ADDRESS_POOL, GstRTSPAddressPool))
32 #define GST_RTSP_ADDRESS_POOL_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_ADDRESS_POOL, GstRTSPAddressPoolClass))
33 #define GST_RTSP_ADDRESS_POOL_CAST(obj)         ((GstRTSPAddressPool*)(obj))
34 #define GST_RTSP_ADDRESS_POOL_CLASS_CAST(klass) ((GstRTSPAddressPoolClass*)(klass))
35
36 /**
37  * GstRTSPAddressPoolResult:
38  * @GST_RTSP_ADDRESS_POOL_OK: no error
39  * @GST_RTSP_ADDRESS_POOL_EINVAL:invalid arguments were provided to a function
40  * @GST_RTSP_ADDRESS_POOL_ERESERVED: the addres has already been reserved
41  * @GST_RTSP_ADDRESS_POOL_ERANGE: the address is not in the pool
42  * @GST_RTSP_ADDRESS_POOL_ELAST: last error
43  *
44  * Result codes from RTSP address pool functions.
45  */
46 typedef enum {
47   GST_RTSP_ADDRESS_POOL_OK         =  0,
48   /* errors */
49   GST_RTSP_ADDRESS_POOL_EINVAL     = -1,
50   GST_RTSP_ADDRESS_POOL_ERESERVED  = -2,
51   GST_RTSP_ADDRESS_POOL_ERANGE     = -3,
52
53   GST_RTSP_ADDRESS_POOL_ELAST      = -4,
54 } GstRTSPAddressPoolResult;
55
56
57 typedef struct _GstRTSPAddress GstRTSPAddress;
58
59 typedef struct _GstRTSPAddressPool GstRTSPAddressPool;
60 typedef struct _GstRTSPAddressPoolClass GstRTSPAddressPoolClass;
61 typedef struct _GstRTSPAddressPoolPrivate GstRTSPAddressPoolPrivate;
62
63 /**
64  * GstRTSPAddress:
65  * @pool: the #GstRTSPAddressPool owner of this address
66  * @address: the address
67  * @port: the port number
68  * @n_ports: number of ports
69  * @ttl: TTL or 0 for unicast addresses
70  *
71  * An address
72  */
73 struct _GstRTSPAddress {
74   GstRTSPAddressPool *pool;
75
76   gchar *address;
77   guint16 port;
78   gint n_ports;
79   guint8 ttl;
80
81   /*<private >*/
82   gpointer priv;
83 };
84
85 GType gst_rtsp_address_get_type        (void);
86
87 GstRTSPAddress * gst_rtsp_address_copy (GstRTSPAddress *addr);
88 void             gst_rtsp_address_free (GstRTSPAddress *addr);
89
90 /**
91  * GstRTSPAddressFlags:
92  * @GST_RTSP_ADDRESS_FLAG_NONE: no flags
93  * @GST_RTSP_ADDRESS_FLAG_IPV4: an IPv4 address
94  * @GST_RTSP_ADDRESS_FLAG_IPV6: and IPv6 address
95  * @GST_RTSP_ADDRESS_FLAG_EVEN_PORT: address with an even port
96  * @GST_RTSP_ADDRESS_FLAG_MULTICAST: a multicast address
97  * @GST_RTSP_ADDRESS_FLAG_UNICAST: a unicast address
98  *
99  * Flags used to control allocation of addresses
100  */
101 typedef enum {
102   GST_RTSP_ADDRESS_FLAG_NONE      = 0,
103   GST_RTSP_ADDRESS_FLAG_IPV4      = (1 << 0),
104   GST_RTSP_ADDRESS_FLAG_IPV6      = (1 << 1),
105   GST_RTSP_ADDRESS_FLAG_EVEN_PORT = (1 << 2),
106   GST_RTSP_ADDRESS_FLAG_MULTICAST = (1 << 3),
107   GST_RTSP_ADDRESS_FLAG_UNICAST   = (1 << 4),
108 } GstRTSPAddressFlags;
109
110 /**
111  * GST_RTSP_ADDRESS_POOL_ANY_IPV4:
112  *
113  * Used with gst_rtsp_address_pool_add_range() to bind to all
114  * IPv4 addresses
115  */
116 #define GST_RTSP_ADDRESS_POOL_ANY_IPV4  "0.0.0.0"
117
118 /**
119  * GST_RTSP_ADDRESS_POOL_ANY_IPV6:
120  *
121  * Used with gst_rtsp_address_pool_add_range() to bind to all
122  * IPv6 addresses
123  */
124 #define GST_RTSP_ADDRESS_POOL_ANY_IPV6  "::"
125
126 /**
127  * GstRTSPAddressPool:
128  * @parent: the parent GObject
129  *
130  * An address pool, all member are private
131  */
132 struct _GstRTSPAddressPool {
133   GObject       parent;
134
135   /*< private >*/
136   GstRTSPAddressPoolPrivate *priv;
137   gpointer _gst_reserved[GST_PADDING];
138 };
139
140 /**
141  * GstRTSPAddressPoolClass:
142  *
143  * Opaque Address pool class.
144  */
145 struct _GstRTSPAddressPoolClass {
146   GObjectClass  parent_class;
147
148   /*< private >*/
149   gpointer _gst_reserved[GST_PADDING];
150 };
151
152 GType                  gst_rtsp_address_pool_get_type        (void);
153
154 /* create a new address pool */
155 GstRTSPAddressPool *   gst_rtsp_address_pool_new             (void);
156
157 void                   gst_rtsp_address_pool_clear           (GstRTSPAddressPool * pool);
158 void                   gst_rtsp_address_pool_dump            (GstRTSPAddressPool * pool);
159
160 gboolean               gst_rtsp_address_pool_add_range       (GstRTSPAddressPool * pool,
161                                                               const gchar *min_address,
162                                                               const gchar *max_address,
163                                                               guint16 min_port,
164                                                               guint16 max_port,
165                                                               guint8 ttl);
166
167 GstRTSPAddress *       gst_rtsp_address_pool_acquire_address (GstRTSPAddressPool * pool,
168                                                               GstRTSPAddressFlags flags,
169                                                               gint n_ports);
170
171 GstRTSPAddressPoolResult  gst_rtsp_address_pool_reserve_address (GstRTSPAddressPool * pool,
172                                                               const gchar *ip_address,
173                                                               guint port,
174                                                               guint n_ports,
175                                                               guint ttl,
176                                                               GstRTSPAddress ** address);
177
178 gboolean               gst_rtsp_address_pool_has_unicast_addresses (GstRTSPAddressPool * pool);
179
180 G_END_DECLS
181
182 #endif /* __GST_RTSP_ADDRESS_POOL_H__ */