Merge branch 'master' of git+ssh://git.collabora.co.uk/git/gst-rtsp-server
[platform/upstream/gstreamer.git] / gst / rtsp-server / rtsp-server.h
1 /* GStreamer
2  * Copyright (C) 2008 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., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <errno.h>
24 #include <string.h>
25 #include <sys/time.h>
26 #include <sys/types.h>
27 #include <netinet/in.h>
28 #include <netdb.h>
29 #include <sys/socket.h>
30 #include <sys/wait.h>
31 #include <fcntl.h>
32 #include <arpa/inet.h>
33
34 #include <gst/gst.h>
35
36 #include "rtsp-session-pool.h"
37 #include "rtsp-media-mapping.h"
38 #include "rtsp-client.h"
39
40 #ifndef __GST_RTSP_SERVER_H__
41 #define __GST_RTSP_SERVER_H__
42
43 G_BEGIN_DECLS
44
45 #define GST_TYPE_RTSP_SERVER              (gst_rtsp_server_get_type ())
46 #define GST_IS_RTSP_SERVER(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SERVER))
47 #define GST_IS_RTSP_SERVER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SERVER))
48 #define GST_RTSP_SERVER_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SERVER, GstRTSPServerClass))
49 #define GST_RTSP_SERVER(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SERVER, GstRTSPServer))
50 #define GST_RTSP_SERVER_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SERVER, GstRTSPServerClass))
51 #define GST_RTSP_SERVER_CAST(obj)         ((GstRTSPServer*)(obj))
52 #define GST_RTSP_SERVER_CLASS_CAST(klass) ((GstRTSPServerClass*)(klass))
53
54 typedef struct _GstRTSPServer GstRTSPServer;
55 typedef struct _GstRTSPServerClass GstRTSPServerClass;
56
57 struct _GstRTSPServer {
58   GObject       parent;
59
60   /* server information */
61   gint    port;
62   gint    backlog;
63   gchar  *host;
64   struct  sockaddr_in server_sin;
65
66   /* socket and channels */
67   GstPollFD    server_sock;
68   GIOChannel  *io_channel;
69   GSource     *io_watch;
70
71   /* sessions on this server */
72   GstRTSPSessionPool  *session_pool;
73
74   /* media mapper for this server */
75   GstRTSPMediaMapping *media_mapping;
76 };
77
78 /**
79  * GstRTSPServerClass:
80  *
81  * @accept_client: Create, configure, accept and return a new GstRTSPClient 
82  *   object that handles the new connection on @channel.
83  *
84  * The RTSP server class structure
85  */
86 struct _GstRTSPServerClass {
87   GObjectClass  parent_class;
88
89   GstRTSPClient * (*accept_client) (GstRTSPServer *server, GIOChannel *channel);
90 };
91
92 GType                 gst_rtsp_server_get_type             (void);
93
94 GstRTSPServer *       gst_rtsp_server_new                  (void);
95
96 void                  gst_rtsp_server_set_port             (GstRTSPServer *server, gint port);
97 gint                  gst_rtsp_server_get_port             (GstRTSPServer *server);
98
99 void                  gst_rtsp_server_set_backlog          (GstRTSPServer *server, gint backlog);
100 gint                  gst_rtsp_server_get_backlog          (GstRTSPServer *server);
101
102 void                  gst_rtsp_server_set_session_pool     (GstRTSPServer *server, GstRTSPSessionPool *pool);
103 GstRTSPSessionPool *  gst_rtsp_server_get_session_pool     (GstRTSPServer *server);
104
105 void                  gst_rtsp_server_set_media_mapping    (GstRTSPServer *server, GstRTSPMediaMapping *mapping);
106 GstRTSPMediaMapping * gst_rtsp_server_get_media_mapping    (GstRTSPServer *server);
107
108 gboolean              gst_rtsp_server_io_func              (GIOChannel *channel, GIOCondition condition,
109                                                             GstRTSPServer *server);
110
111 GIOChannel *          gst_rtsp_server_get_io_channel       (GstRTSPServer *server);
112 GSource *             gst_rtsp_server_create_watch         (GstRTSPServer *server);
113 guint                 gst_rtsp_server_attach               (GstRTSPServer *server, 
114                                                             GMainContext *context);
115
116 G_END_DECLS
117
118 #endif /* __GST_RTSP_SERVER_H__ */