rtsp-stream: obtain stream position from pad
[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., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, 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 typedef struct _GstRTSPSessionPrivate GstRTSPSessionPrivate;
41
42 /**
43  * GstRTSPFilterResult:
44  * @GST_RTSP_FILTER_REMOVE: Remove session
45  * @GST_RTSP_FILTER_KEEP: Keep session in the pool
46  * @GST_RTSP_FILTER_REF: Ref session in the result list
47  *
48  * Possible return values for gst_rtsp_session_pool_filter().
49  */
50 typedef enum
51 {
52   GST_RTSP_FILTER_REMOVE,
53   GST_RTSP_FILTER_KEEP,
54   GST_RTSP_FILTER_REF,
55 } GstRTSPFilterResult;
56
57 #include "rtsp-media.h"
58 #include "rtsp-session-media.h"
59
60 /**
61  * GstRTSPSession:
62  *
63  * Session information kept by the server for a specific client.
64  * One client session, identified with a session id, can handle multiple medias
65  * identified with the url of a media.
66  */
67 struct _GstRTSPSession {
68   GObject       parent;
69
70   /*< private >*/
71   GstRTSPSessionPrivate *priv;
72   gpointer _gst_reserved[GST_PADDING];
73 };
74
75 struct _GstRTSPSessionClass {
76   GObjectClass  parent_class;
77
78   /*< private >*/
79   gpointer _gst_reserved[GST_PADDING];
80 };
81
82 GST_EXPORT
83 GType                  gst_rtsp_session_get_type             (void);
84
85 /* create a new session */
86
87 GST_EXPORT
88 GstRTSPSession *       gst_rtsp_session_new                  (const gchar *sessionid);
89
90 GST_EXPORT
91 const gchar *          gst_rtsp_session_get_sessionid        (GstRTSPSession *session);
92
93 GST_EXPORT
94 gchar *                gst_rtsp_session_get_header           (GstRTSPSession *session);
95
96 GST_EXPORT
97 void                   gst_rtsp_session_set_timeout          (GstRTSPSession *session, guint timeout);
98
99 GST_EXPORT
100 guint                  gst_rtsp_session_get_timeout          (GstRTSPSession *session);
101
102 /* session timeout stuff */
103
104 GST_EXPORT
105 void                   gst_rtsp_session_touch                (GstRTSPSession *session);
106
107 GST_EXPORT
108 void                   gst_rtsp_session_prevent_expire       (GstRTSPSession *session);
109
110 GST_EXPORT
111 void                   gst_rtsp_session_allow_expire         (GstRTSPSession *session);
112
113 GST_EXPORT
114 gint                   gst_rtsp_session_next_timeout_usec    (GstRTSPSession *session, gint64 now);
115
116 GST_EXPORT
117 gboolean               gst_rtsp_session_is_expired_usec      (GstRTSPSession *session, gint64 now);
118 #ifndef GST_DISABLE_DEPRECATED
119 GST_EXPORT
120 gint                   gst_rtsp_session_next_timeout         (GstRTSPSession *session, GTimeVal *now);
121
122 GST_EXPORT
123 gboolean               gst_rtsp_session_is_expired           (GstRTSPSession *session, GTimeVal *now);
124 #endif
125
126 /* handle media in a session */
127
128 GST_EXPORT
129 GstRTSPSessionMedia *  gst_rtsp_session_manage_media         (GstRTSPSession *sess,
130                                                               const gchar *path,
131                                                               GstRTSPMedia *media);
132
133 GST_EXPORT
134 gboolean               gst_rtsp_session_release_media        (GstRTSPSession *sess,
135                                                               GstRTSPSessionMedia *media);
136 /* get media in a session */
137
138 GST_EXPORT
139 GstRTSPSessionMedia *  gst_rtsp_session_get_media            (GstRTSPSession *sess,
140                                                               const gchar *path,
141                                                               gint * matched);
142
143 /**
144  * GstRTSPSessionFilterFunc:
145  * @sess: a #GstRTSPSession object
146  * @media: a #GstRTSPSessionMedia in @sess
147  * @user_data: user data that has been given to gst_rtsp_session_filter()
148  *
149  * This function will be called by the gst_rtsp_session_filter(). An
150  * implementation should return a value of #GstRTSPFilterResult.
151  *
152  * When this function returns #GST_RTSP_FILTER_REMOVE, @media will be removed
153  * from @sess.
154  *
155  * A return value of #GST_RTSP_FILTER_KEEP will leave @media untouched in
156  * @sess.
157  *
158  * A value of GST_RTSP_FILTER_REF will add @media to the result #GList of
159  * gst_rtsp_session_filter().
160  *
161  * Returns: a #GstRTSPFilterResult.
162  */
163 typedef GstRTSPFilterResult (*GstRTSPSessionFilterFunc)  (GstRTSPSession *sess,
164                                                           GstRTSPSessionMedia *media,
165                                                           gpointer user_data);
166
167 GST_EXPORT
168 GList *                gst_rtsp_session_filter           (GstRTSPSession *sess,
169                                                           GstRTSPSessionFilterFunc func,
170                                                           gpointer user_data);
171
172
173 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
174 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPSession, gst_object_unref)
175 #endif
176
177 G_END_DECLS
178
179 #endif /* __GST_RTSP_SESSION_H__ */