gstreamer/gst/rtsp-server/rtsp-media.c

105 lines
2.6 KiB
C
Raw Normal View History

2008-10-09 12:29:12 +00:00
/* GStreamer
* Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "rtsp-media.h"
static void gst_rtsp_media_bin_finalize (GObject * obj);
2008-10-09 12:29:12 +00:00
G_DEFINE_TYPE (GstRTSPMediaBin, gst_rtsp_media_bin, G_TYPE_OBJECT);
2008-10-09 12:29:12 +00:00
static void
gst_rtsp_media_bin_class_init (GstRTSPMediaBinClass * klass)
2008-10-09 12:29:12 +00:00
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = gst_rtsp_media_bin_finalize;
2008-10-09 12:29:12 +00:00
}
static void
gst_rtsp_media_bin_init (GstRTSPMediaBin * bin)
2008-10-09 12:29:12 +00:00
{
bin->streams = g_array_new (FALSE, TRUE, sizeof (GstRTSPMediaStream *));
2008-10-09 12:29:12 +00:00
}
static void
gst_rtsp_media_stream_free (GstRTSPMediaStream *stream)
{
}
static void
gst_rtsp_media_bin_finalize (GObject * obj)
2008-10-09 12:29:12 +00:00
{
GstRTSPMediaBin *bin;
2008-10-09 12:29:12 +00:00
guint i;
bin = GST_RTSP_MEDIA_BIN (obj);
2008-10-09 12:29:12 +00:00
for (i = 0; i < bin->streams->len; i++) {
2008-10-09 12:29:12 +00:00
GstRTSPMediaStream *stream;
stream = g_array_index (bin->streams, GstRTSPMediaStream *, i);
2008-10-09 12:29:12 +00:00
gst_rtsp_media_stream_free (stream);
}
g_array_free (bin->streams, TRUE);
2008-10-09 12:29:12 +00:00
G_OBJECT_CLASS (gst_rtsp_media_bin_parent_class)->finalize (obj);
2008-10-09 12:29:12 +00:00
}
/**
* gst_rtsp_media_bin_n_streams:
* @media: a #GstRTSPMediaBin
2008-10-09 12:29:12 +00:00
*
* Get the number of streams in this mediabin.
2008-10-09 12:29:12 +00:00
*
* Returns: The number of streams.
*/
guint
gst_rtsp_media_bin_n_streams (GstRTSPMediaBin *bin)
2008-10-09 12:29:12 +00:00
{
g_return_val_if_fail (GST_IS_RTSP_MEDIA_BIN (bin), 0);
2008-10-09 12:29:12 +00:00
return bin->streams->len;
2008-10-09 12:29:12 +00:00
}
/**
* gst_rtsp_media_bin_get_stream:
* @bin: a #GstRTSPMediaBin
2008-10-09 12:29:12 +00:00
* @idx: the stream index
*
* Retrieve the stream with index @idx from @bin.
2008-10-09 12:29:12 +00:00
*
* Returns: the #GstRTSPMediaStream at index @idx.
*/
GstRTSPMediaStream *
gst_rtsp_media_bin_get_stream (GstRTSPMediaBin *bin, guint idx)
2008-10-09 12:29:12 +00:00
{
GstRTSPMediaStream *res;
g_return_val_if_fail (GST_IS_RTSP_MEDIA_BIN (bin), NULL);
g_return_val_if_fail (idx < bin->streams->len, NULL);
2008-10-09 12:29:12 +00:00
res = g_array_index (bin->streams, GstRTSPMediaStream *, idx);
2008-10-09 12:29:12 +00:00
return res;
}