rtsp-client: don't use g_object_unref on GstRTSPSessionMedia
[platform/upstream/gstreamer.git] / gst / rtsp-server / rtsp-session.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 <gst/gst.h>
21
22 #include <gst/rtsp/gstrtsptransport.h>
23
24 #ifndef __GST_RTSP_SESSION_H__
25 #define __GST_RTSP_SESSION_H__
26
27 G_BEGIN_DECLS
28
29 #define GST_TYPE_RTSP_SESSION              (gst_rtsp_session_get_type ())
30 #define GST_IS_RTSP_SESSION(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SESSION))
31 #define GST_IS_RTSP_SESSION_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SESSION))
32 #define GST_RTSP_SESSION_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SESSION, GstRTSPSessionClass))
33 #define GST_RTSP_SESSION(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SESSION, GstRTSPSession))
34 #define GST_RTSP_SESSION_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SESSION, GstRTSPSessionClass))
35 #define GST_RTSP_SESSION_CAST(obj)         ((GstRTSPSession*)(obj))
36 #define GST_RTSP_SESSION_CLASS_CAST(klass) ((GstRTSPSessionClass*)(klass))
37
38 typedef struct _GstRTSPSession GstRTSPSession;
39 typedef struct _GstRTSPSessionClass GstRTSPSessionClass;
40
41 typedef struct _GstRTSPSessionStream GstRTSPSessionStream;
42 typedef struct _GstRTSPSessionMedia GstRTSPSessionMedia;
43
44 #include "rtsp-media.h"
45
46 /**
47  * GstRTSPSessionStream:
48  * @trans: the media transport
49  * @media_stream: the controlled media stream
50  *
51  * Configuration of a stream. A stream is an audio or video stream related to a
52  * media.
53  */
54 struct _GstRTSPSessionStream
55 {
56   GstRTSPMediaTrans trans;
57
58   /* the stream of the media */
59   GstRTSPMediaStream *media_stream;
60 };
61
62 /**
63  * GstRTSPSessionMedia:
64  *
65  * State of a client session regarding a specific media identified by uri.
66  */
67 struct _GstRTSPSessionMedia
68 {
69   /* the url of the media */
70   GstRTSPUrl   *url;
71
72   /* the pipeline for the media */
73   GstRTSPMedia *media;
74
75   /* the server state */
76   GstRTSPState  state;
77
78   /* counter for channels */
79   guint         counter;
80
81   /* configuration for the different streams */
82   GArray       *streams;
83 };
84
85 /**
86  * GstRTSPSession:
87  * @sessionid: the session id of the session
88  * @timeout: the timeout of the session
89  * @create_time: the time when the session was created
90  * @last_access: the time the session was last accessed
91  * @expire_count: the expire prevention counter
92  * @media: a list of #GstRTSPSessionMedia managed in this session
93  *
94  * Session information kept by the server for a specific client.
95  * One client session, identified with a session id, can handle multiple medias
96  * identified with the url of a media.
97  */
98 struct _GstRTSPSession {
99   GObject       parent;
100
101   gchar        *sessionid;
102
103   guint         timeout;
104   GTimeVal      create_time;
105   GTimeVal      last_access;
106   gint          expire_count;
107
108   GList        *medias;
109 };
110
111 struct _GstRTSPSessionClass {
112   GObjectClass  parent_class;
113 };
114
115 GType                  gst_rtsp_session_get_type             (void);
116
117 /* create a new session */
118 GstRTSPSession *       gst_rtsp_session_new                  (const gchar *sessionid);
119
120 const gchar *          gst_rtsp_session_get_sessionid        (GstRTSPSession *session);
121
122 void                   gst_rtsp_session_set_timeout          (GstRTSPSession *session, guint timeout);
123 guint                  gst_rtsp_session_get_timeout          (GstRTSPSession *session);
124
125 /* session timeout stuff */
126 void                   gst_rtsp_session_touch                (GstRTSPSession *session);
127 void                   gst_rtsp_session_prevent_expire       (GstRTSPSession *session);
128 void                   gst_rtsp_session_allow_expire         (GstRTSPSession *session);
129 gint                   gst_rtsp_session_next_timeout         (GstRTSPSession *session, GTimeVal *now);
130 gboolean               gst_rtsp_session_is_expired           (GstRTSPSession *session, GTimeVal *now);
131
132 /* handle media in a session */
133 GstRTSPSessionMedia *  gst_rtsp_session_manage_media         (GstRTSPSession *sess,
134                                                               const GstRTSPUrl *uri,
135                                                               GstRTSPMedia *media);
136 gboolean               gst_rtsp_session_release_media        (GstRTSPSession *sess,
137                                                               GstRTSPSessionMedia *media);
138 /* get media in a session */
139 GstRTSPSessionMedia *  gst_rtsp_session_get_media            (GstRTSPSession *sess,
140                                                               const GstRTSPUrl *url);
141 /* control media */
142 gboolean               gst_rtsp_session_media_set_state      (GstRTSPSessionMedia *media, GstState state);
143
144 /* get stream config */
145 GstRTSPSessionStream * gst_rtsp_session_media_get_stream     (GstRTSPSessionMedia *media,
146                                                               guint idx);
147
148 gboolean               gst_rtsp_session_media_alloc_channels (GstRTSPSessionMedia *media,
149                                                               GstRTSPRange *range);
150
151 /* configure transport */
152 GstRTSPTransport *     gst_rtsp_session_stream_set_transport (GstRTSPSessionStream *stream,
153                                                               GstRTSPTransport *ct);
154 void                   gst_rtsp_session_stream_set_callbacks (GstRTSPSessionStream *stream,
155                                                               GstRTSPSendFunc send_rtp,
156                                                               GstRTSPSendFunc send_rtcp,
157                                                               gpointer user_data,
158                                                               GDestroyNotify  notify);
159 void                   gst_rtsp_session_stream_set_keepalive (GstRTSPSessionStream *stream,
160                                                               GstRTSPKeepAliveFunc keep_alive,
161                                                               gpointer user_data,
162                                                               GDestroyNotify  notify);
163
164 G_END_DECLS
165
166 #endif /* __GST_RTSP_SESSION_H__ */