docs: update docs
[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 typedef struct _GstRTSPAddress GstRTSPAddress;
37
38 typedef struct _GstRTSPAddressPool GstRTSPAddressPool;
39 typedef struct _GstRTSPAddressPoolClass GstRTSPAddressPoolClass;
40 typedef struct _GstRTSPAddressPoolPrivate GstRTSPAddressPoolPrivate;
41
42 /**
43  * GstRTSPAddress:
44  * @pool: the #GstRTSPAddressPool owner of this address
45  * @address: the address
46  * @port: the port number
47  * @n_ports: number of ports
48  * @ttl: TTL or 0 for unicast addresses
49  *
50  * An address
51  */
52 struct _GstRTSPAddress {
53   GstRTSPAddressPool *pool;
54
55   gchar *address;
56   guint16 port;
57   gint n_ports;
58   guint8 ttl;
59
60   /*<private >*/
61   gpointer priv;
62 };
63
64 GType gst_rtsp_address_get_type        (void);
65
66 GstRTSPAddress * gst_rtsp_address_copy (GstRTSPAddress *addr);
67 void             gst_rtsp_address_free (GstRTSPAddress *addr);
68
69 /**
70  * GstRTSPAddressFlags:
71  * @GST_RTSP_ADDRESS_FLAG_NONE: no flags
72  * @GST_RTSP_ADDRESS_FLAG_IPV4: an IPv4 address
73  * @GST_RTSP_ADDRESS_FLAG_IPV6: and IPv6 address
74  * @GST_RTSP_ADDRESS_FLAG_EVEN_PORT: address with an even port
75  * @GST_RTSP_ADDRESS_FLAG_MULTICAST: a multicast address
76  * @GST_RTSP_ADDRESS_FLAG_UNICAST: a unicast address
77  *
78  * Flags used to control allocation of addresses
79  */
80 typedef enum {
81   GST_RTSP_ADDRESS_FLAG_NONE      = 0,
82   GST_RTSP_ADDRESS_FLAG_IPV4      = (1 << 0),
83   GST_RTSP_ADDRESS_FLAG_IPV6      = (1 << 1),
84   GST_RTSP_ADDRESS_FLAG_EVEN_PORT = (1 << 2),
85   GST_RTSP_ADDRESS_FLAG_MULTICAST = (1 << 3),
86   GST_RTSP_ADDRESS_FLAG_UNICAST   = (1 << 4),
87 } GstRTSPAddressFlags;
88
89 /**
90  * GST_RTSP_ADDRESS_POOL_ANY_IPV4:
91  *
92  * Used with gst_rtsp_address_pool_add_range_unicast() to bind to all
93  * IPv4 addresses
94  */
95 #define GST_RTSP_ADDRESS_POOL_ANY_IPV4  "0.0.0.0"
96
97 /**
98  * GST_RTSP_ADDRESS_POOL_ANY_IPV6:
99  *
100  * Used with gst_rtsp_address_pool_add_range_unicast() to bind to all
101  * IPv6 addresses
102  */
103 #define GST_RTSP_ADDRESS_POOL_ANY_IPV6  "::"
104
105 /**
106  * GstRTSPAddressPool:
107  * @parent: the parent GObject
108  *
109  * An address pool, all member are private
110  */
111 struct _GstRTSPAddressPool {
112   GObject       parent;
113
114   /*< private >*/
115   GstRTSPAddressPoolPrivate *priv;
116 };
117
118 /**
119  * GstRTSPAddressPoolClass:
120  *
121  * Opaque Address pool class.
122  */
123 struct _GstRTSPAddressPoolClass {
124   GObjectClass  parent_class;
125 };
126
127 GType                  gst_rtsp_address_pool_get_type        (void);
128
129 /* create a new address pool */
130 GstRTSPAddressPool *   gst_rtsp_address_pool_new             (void);
131
132 void                   gst_rtsp_address_pool_clear           (GstRTSPAddressPool * pool);
133 void                   gst_rtsp_address_pool_dump            (GstRTSPAddressPool * pool);
134
135 gboolean               gst_rtsp_address_pool_add_range       (GstRTSPAddressPool * pool,
136                                                               const gchar *min_address,
137                                                               const gchar *max_address,
138                                                               guint16 min_port,
139                                                               guint16 max_port,
140                                                               guint8 ttl);
141
142 gboolean               gst_rtsp_address_pool_add_range_unicast (GstRTSPAddressPool * pool,
143                                                               const gchar *min_address,
144                                                               const gchar *max_address,
145                                                               guint16 min_port,
146                                                               guint16 max_port);
147
148 GstRTSPAddress *       gst_rtsp_address_pool_acquire_address (GstRTSPAddressPool * pool,
149                                                               GstRTSPAddressFlags flags,
150                                                               gint n_ports);
151
152 GstRTSPAddress *       gst_rtsp_address_pool_reserve_address (GstRTSPAddressPool * pool,
153                                                               const gchar *address,
154                                                               guint port,
155                                                               guint n_ports,
156                                                               guint ttl);
157
158 gboolean               gst_rtsp_address_pool_has_unicast_addresses (GstRTSPAddressPool * pool);
159
160 G_END_DECLS
161
162 #endif /* __GST_RTSP_ADDRESS_POOL_H__ */