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"
|
|
|
|
|
2009-01-22 16:58:19 +00:00
|
|
|
static void gst_rtsp_media_finalize (GObject * obj);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-01-22 16:58:19 +00:00
|
|
|
G_DEFINE_TYPE (GstRTSPMedia, gst_rtsp_media, G_TYPE_OBJECT);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
|
|
|
static void
|
2009-01-22 16:58:19 +00:00
|
|
|
gst_rtsp_media_class_init (GstRTSPMediaClass * klass)
|
2008-10-09 12:29:12 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2009-01-22 16:58:19 +00:00
|
|
|
gobject_class->finalize = gst_rtsp_media_finalize;
|
2008-10-09 12:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-01-22 16:58:19 +00:00
|
|
|
gst_rtsp_media_init (GstRTSPMedia * media)
|
2008-10-09 12:29:12 +00:00
|
|
|
{
|
2009-01-22 16:58:19 +00:00
|
|
|
media->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
|
2009-01-22 16:58:19 +00:00
|
|
|
gst_rtsp_media_finalize (GObject * obj)
|
2008-10-09 12:29:12 +00:00
|
|
|
{
|
2009-01-22 16:58:19 +00:00
|
|
|
GstRTSPMedia *media;
|
2008-10-09 12:29:12 +00:00
|
|
|
guint i;
|
|
|
|
|
2009-01-22 16:58:19 +00:00
|
|
|
media = GST_RTSP_MEDIA (obj);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-01-22 16:58:19 +00:00
|
|
|
for (i = 0; i < media->streams->len; i++) {
|
2008-10-09 12:29:12 +00:00
|
|
|
GstRTSPMediaStream *stream;
|
|
|
|
|
2009-01-22 16:58:19 +00:00
|
|
|
stream = g_array_index (media->streams, GstRTSPMediaStream *, i);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
|
|
|
gst_rtsp_media_stream_free (stream);
|
|
|
|
}
|
2009-01-22 16:58:19 +00:00
|
|
|
g_array_free (media->streams, TRUE);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-01-22 16:58:19 +00:00
|
|
|
G_OBJECT_CLASS (gst_rtsp_media_parent_class)->finalize (obj);
|
2008-10-09 12:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-01-22 16:58:19 +00:00
|
|
|
* gst_rtsp_media_n_streams:
|
|
|
|
* @media: a #GstRTSPMedia
|
2008-10-09 12:29:12 +00:00
|
|
|
*
|
2009-01-22 16:58:19 +00:00
|
|
|
* Get the number of streams in this media.
|
2008-10-09 12:29:12 +00:00
|
|
|
*
|
|
|
|
* Returns: The number of streams.
|
|
|
|
*/
|
|
|
|
guint
|
2009-01-22 16:58:19 +00:00
|
|
|
gst_rtsp_media_n_streams (GstRTSPMedia *media)
|
2008-10-09 12:29:12 +00:00
|
|
|
{
|
2009-01-22 16:58:19 +00:00
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), 0);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-01-22 16:58:19 +00:00
|
|
|
return media->streams->len;
|
2008-10-09 12:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-01-22 16:58:19 +00:00
|
|
|
* gst_rtsp_media_get_stream:
|
|
|
|
* @media: a #GstRTSPMedia
|
2008-10-09 12:29:12 +00:00
|
|
|
* @idx: the stream index
|
|
|
|
*
|
2009-01-22 16:58:19 +00:00
|
|
|
* Retrieve the stream with index @idx from @media.
|
2008-10-09 12:29:12 +00:00
|
|
|
*
|
|
|
|
* Returns: the #GstRTSPMediaStream at index @idx.
|
|
|
|
*/
|
|
|
|
GstRTSPMediaStream *
|
2009-01-22 16:58:19 +00:00
|
|
|
gst_rtsp_media_get_stream (GstRTSPMedia *media, guint idx)
|
2008-10-09 12:29:12 +00:00
|
|
|
{
|
|
|
|
GstRTSPMediaStream *res;
|
|
|
|
|
2009-01-22 16:58:19 +00:00
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), NULL);
|
|
|
|
g_return_val_if_fail (idx < media->streams->len, NULL);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-01-22 16:58:19 +00:00
|
|
|
res = g_array_index (media->streams, GstRTSPMediaStream *, idx);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|