media: add lock to protect state changes
[platform/upstream/gstreamer.git] / gst / rtsp-server / rtsp-stream-transport.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 #include <gst/rtsp/gstrtsprange.h>
22 #include <gst/rtsp/gstrtspurl.h>
23
24 #ifndef __GST_RTSP_STREAM_TRANSPORT_H__
25 #define __GST_RTSP_STREAM_TRANSPORT_H__
26
27 G_BEGIN_DECLS
28
29 /* types for the media */
30 #define GST_TYPE_RTSP_STREAM_TRANSPORT              (gst_rtsp_stream_transport_get_type ())
31 #define GST_IS_RTSP_STREAM_TRANSPORT(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_STREAM_TRANSPORT))
32 #define GST_IS_RTSP_STREAM_TRANSPORT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_STREAM_TRANSPORT))
33 #define GST_RTSP_STREAM_TRANSPORT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_STREAM_TRANSPORT, GstRTSPStreamTransportClass))
34 #define GST_RTSP_STREAM_TRANSPORT(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_STREAM_TRANSPORT, GstRTSPStreamTransport))
35 #define GST_RTSP_STREAM_TRANSPORT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_STREAM_TRANSPORT, GstRTSPStreamTransportClass))
36 #define GST_RTSP_STREAM_TRANSPORT_CAST(obj)         ((GstRTSPStreamTransport*)(obj))
37 #define GST_RTSP_STREAM_TRANSPORT_CLASS_CAST(klass) ((GstRTSPStreamTransportClass*)(klass))
38
39 typedef struct _GstRTSPStreamTransport GstRTSPStreamTransport;
40 typedef struct _GstRTSPStreamTransportClass GstRTSPStreamTransportClass;
41
42 #include "rtsp-stream.h"
43
44 typedef gboolean (*GstRTSPSendFunc)      (GstBuffer *buffer, guint8 channel, gpointer user_data);
45 typedef void     (*GstRTSPKeepAliveFunc) (gpointer user_data);
46
47 /**
48  * GstRTSPStreamTransport:
49  * @parent: parent instance
50  * @stream: the GstRTSPStream we manage
51  * @send_rtp: callback for sending RTP messages
52  * @send_rtcp: callback for sending RTCP messages
53  * @user_data: user data passed in the callbacks
54  * @notify: free function for the user_data.
55  * @keep_alive: keep alive callback
56  * @ka_user_data: data passed to @keep_alive
57  * @ka_notify: called when @ka_user_data is freed
58  * @active: if we are actively sending
59  * @timeout: if we timed out
60  * @transport: a transport description
61  * @rtpsource: the receiver rtp source object
62  *
63  * A Transport description for stream @idx
64  */
65 struct _GstRTSPStreamTransport {
66   GObject              parent;
67
68   GstRTSPStream       *stream;
69
70   GstRTSPSendFunc      send_rtp;
71   GstRTSPSendFunc      send_rtcp;
72   gpointer             user_data;
73   GDestroyNotify       notify;
74
75   GstRTSPKeepAliveFunc keep_alive;
76   gpointer             ka_user_data;
77   GDestroyNotify       ka_notify;
78   gboolean             active;
79   gboolean             timeout;
80
81   GstRTSPTransport    *transport;
82
83   GObject             *rtpsource;
84 };
85
86 struct _GstRTSPStreamTransportClass {
87   GObjectClass parent_class;
88 };
89
90 GType                    gst_rtsp_stream_transport_get_type (void);
91
92 GstRTSPStreamTransport * gst_rtsp_stream_transport_new           (GstRTSPStream *stream,
93                                                                   GstRTSPTransport *tr);
94
95 void                     gst_rtsp_stream_transport_set_transport (GstRTSPStreamTransport *trans,
96                                                                   GstRTSPTransport * tr);
97
98 void                     gst_rtsp_stream_transport_set_callbacks (GstRTSPStreamTransport *trans,
99                                                                   GstRTSPSendFunc send_rtp,
100                                                                   GstRTSPSendFunc send_rtcp,
101                                                                   gpointer user_data,
102                                                                   GDestroyNotify  notify);
103 void                     gst_rtsp_stream_transport_set_keepalive (GstRTSPStreamTransport *trans,
104                                                                   GstRTSPKeepAliveFunc keep_alive,
105                                                                   gpointer user_data,
106                                                                   GDestroyNotify  notify);
107
108 gboolean                 gst_rtsp_stream_transport_send_rtp      (GstRTSPStreamTransport *trans,
109                                                                   GstBuffer *buffer);
110 gboolean                 gst_rtsp_stream_transport_send_rtcp     (GstRTSPStreamTransport *trans,
111                                                                   GstBuffer *buffer);
112
113 void                     gst_rtsp_stream_transport_keep_alive    (GstRTSPStreamTransport *trans);
114
115 G_END_DECLS
116
117 #endif /* __GST_RTSP_STREAM_TRANSPORT_H__ */