Make the server handle arbitrary pipelines
[platform/upstream/gstreamer.git] / gst / rtsp-server / rtsp-media.c
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 "rtsp-media.h"
21
22 static void gst_rtsp_media_bin_finalize (GObject * obj);
23
24 G_DEFINE_TYPE (GstRTSPMediaBin, gst_rtsp_media_bin, G_TYPE_OBJECT);
25
26 static void
27 gst_rtsp_media_bin_class_init (GstRTSPMediaBinClass * klass)
28 {
29   GObjectClass *gobject_class;
30
31   gobject_class = G_OBJECT_CLASS (klass);
32
33   gobject_class->finalize = gst_rtsp_media_bin_finalize;
34 }
35
36 static void
37 gst_rtsp_media_bin_init (GstRTSPMediaBin * bin)
38 {
39   bin->streams = g_array_new (FALSE, TRUE, sizeof (GstRTSPMediaStream *));
40 }
41
42 static void
43 gst_rtsp_media_stream_free (GstRTSPMediaStream *stream)
44 {
45 }
46
47 static void
48 gst_rtsp_media_bin_finalize (GObject * obj)
49 {
50   GstRTSPMediaBin *bin;
51   guint i;
52
53   bin = GST_RTSP_MEDIA_BIN (obj);
54
55   for (i = 0; i < bin->streams->len; i++) {
56     GstRTSPMediaStream *stream;
57
58     stream = g_array_index (bin->streams, GstRTSPMediaStream *, i);
59
60     gst_rtsp_media_stream_free (stream);
61   }
62   g_array_free (bin->streams, TRUE);
63
64   G_OBJECT_CLASS (gst_rtsp_media_bin_parent_class)->finalize (obj);
65 }
66
67 /**
68  * gst_rtsp_media_bin_n_streams:
69  * @media: a #GstRTSPMediaBin
70  *
71  * Get the number of streams in this mediabin.
72  *
73  * Returns: The number of streams.
74  */
75 guint
76 gst_rtsp_media_bin_n_streams (GstRTSPMediaBin *bin)
77 {
78   g_return_val_if_fail (GST_IS_RTSP_MEDIA_BIN (bin), 0);
79
80   return bin->streams->len;
81 }
82
83 /**
84  * gst_rtsp_media_bin_get_stream:
85  * @bin: a #GstRTSPMediaBin
86  * @idx: the stream index
87  *
88  * Retrieve the stream with index @idx from @bin.
89  *
90  * Returns: the #GstRTSPMediaStream at index @idx.
91  */
92 GstRTSPMediaStream *
93 gst_rtsp_media_bin_get_stream (GstRTSPMediaBin *bin, guint idx)
94 {
95   GstRTSPMediaStream *res;
96   
97   g_return_val_if_fail (GST_IS_RTSP_MEDIA_BIN (bin), NULL);
98   g_return_val_if_fail (idx < bin->streams->len, NULL);
99
100   res = g_array_index (bin->streams, GstRTSPMediaStream *, idx);
101
102   return res;
103 }
104