1 /* GStreamer
2  * Copyright (C) <2007> Wim Taymans <wim.taymans@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 #ifndef __GST_SDP_DEMUX_H__
21 #define __GST_SDP_DEMUX_H__
22 
23 #include <gst/gst.h>
24 #include <gst/base/gstadapter.h>
25 #include <gio/gio.h>
26 
27 G_BEGIN_DECLS
28 
29 #define GST_TYPE_SDP_DEMUX \
30   (gst_sdp_demux_get_type())
31 #define GST_SDP_DEMUX(obj) \
32   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SDP_DEMUX,GstSDPDemux))
33 #define GST_SDP_DEMUX_CLASS(klass) \
34   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SDP_DEMUX,GstSDPDemuxClass))
35 #define GST_IS_SDP_DEMUX(obj) \
36   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SDP_DEMUX))
37 #define GST_IS_SDP_DEMUX_CLASS(klass) \
38   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SDP_DEMUX))
39 #define GST_SDP_DEMUX_CAST(obj) \
40   ((GstSDPDemux *)(obj))
41 
42 typedef struct _GstSDPDemux GstSDPDemux;
43 typedef struct _GstSDPDemuxClass GstSDPDemuxClass;
44 
45 #define GST_SDP_STREAM_GET_LOCK(sdp)   (&GST_SDP_DEMUX_CAST(sdp)->stream_rec_lock)
46 #define GST_SDP_STREAM_LOCK(sdp)       (g_rec_mutex_lock (GST_SDP_STREAM_GET_LOCK(sdp)))
47 #define GST_SDP_STREAM_UNLOCK(sdp)     (g_rec_mutex_unlock (GST_SDP_STREAM_GET_LOCK(sdp)))
48 
49 typedef struct _GstSDPStream GstSDPStream;
50 
51 struct _GstSDPStream {
52   gint          id;
53 
54   GstSDPDemux    *parent; /* parent, no extra ref to parent is taken */
55 
56   /* pad we expose or NULL when it does not have an actual pad */
57   GstPad       *srcpad;
58   GstFlowReturn last_ret;
59   gboolean      added;
60   gboolean      disabled;
61   GstCaps      *caps;
62   gboolean      eos;
63 
64   /* our udp sources */
65   GstElement   *udpsrc[2];
66   GstPad       *channelpad[2];
67   guint         rtp_port;
68   guint         rtcp_port;
69 
70   gchar        *destination;
71   guint         ttl;
72   gboolean      multicast;
73 
74   /* our udp sink back to the server */
75   GstElement   *udpsink;
76   GstPad       *rtcppad;
77 
78   /* state */
79   gint          pt;
80   gboolean      container;
81 };
82 
83 struct _GstSDPDemux {
84   GstBin           parent;
85 
86   GstPad          *sinkpad;
87   GstAdapter      *adapter;
88   GstState         target;
89 
90   /* task for UDP loop */
91   gboolean         ignore_timeout;
92 
93   gint             numstreams;
94   GRecMutex        stream_rec_lock;
95   GList           *streams;
96 
97   /* properties */
98   gboolean          debug;
99   guint64           udp_timeout;
100   guint             latency;
101   gboolean          redirect;
102 
103   /* session management */
104   GstElement      *session;
105   gulong           session_sig_id;
106   gulong           session_ptmap_id;
107   gulong           session_nmp_id;
108 };
109 
110 struct _GstSDPDemuxClass {
111   GstBinClass parent_class;
112 };
113 
114 GType gst_sdp_demux_get_type(void);
115 
116 G_END_DECLS
117 
118 #endif /* __GST_SDP_DEMUX_H__ */
119