2009-01-20 18:44:45 +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
|
2012-11-04 00:14:25 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2009-01-20 18:44:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "rtsp-media-factory.h"
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
#define GST_RTSP_MEDIA_FACTORY_GET_PRIVATE(obj) \
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_RTSP_MEDIA_FACTORY, GstRTSPMediaFactoryPrivate))
|
|
|
|
|
|
|
|
#define GST_RTSP_MEDIA_FACTORY_GET_LOCK(f) (&(GST_RTSP_MEDIA_FACTORY_CAST(f)->priv->lock))
|
|
|
|
#define GST_RTSP_MEDIA_FACTORY_LOCK(f) (g_mutex_lock(GST_RTSP_MEDIA_FACTORY_GET_LOCK(f)))
|
|
|
|
#define GST_RTSP_MEDIA_FACTORY_UNLOCK(f) (g_mutex_unlock(GST_RTSP_MEDIA_FACTORY_GET_LOCK(f)))
|
|
|
|
|
|
|
|
struct _GstRTSPMediaFactoryPrivate
|
|
|
|
{
|
|
|
|
GMutex lock;
|
|
|
|
gchar *launch;
|
|
|
|
gboolean shared;
|
|
|
|
gboolean eos_shutdown;
|
|
|
|
GstRTSPLowerTrans protocols;
|
|
|
|
GstRTSPAuth *auth;
|
|
|
|
guint buffer_size;
|
|
|
|
GstRTSPAddressPool *pool;
|
|
|
|
|
|
|
|
GMutex medias_lock;
|
|
|
|
GHashTable *medias;
|
|
|
|
};
|
|
|
|
|
2011-08-16 11:13:36 +00:00
|
|
|
#define DEFAULT_LAUNCH NULL
|
|
|
|
#define DEFAULT_SHARED FALSE
|
|
|
|
#define DEFAULT_EOS_SHUTDOWN FALSE
|
2011-08-16 13:15:19 +00:00
|
|
|
#define DEFAULT_PROTOCOLS GST_RTSP_LOWER_TRANS_UDP | GST_RTSP_LOWER_TRANS_TCP
|
2011-08-16 11:13:36 +00:00
|
|
|
#define DEFAULT_BUFFER_SIZE 0x80000
|
2009-01-22 14:33:29 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_LAUNCH,
|
2009-01-29 16:20:27 +00:00
|
|
|
PROP_SHARED,
|
2010-08-20 16:17:08 +00:00
|
|
|
PROP_EOS_SHUTDOWN,
|
2011-08-16 13:15:19 +00:00
|
|
|
PROP_PROTOCOLS,
|
2011-01-31 16:37:02 +00:00
|
|
|
PROP_BUFFER_SIZE,
|
2009-01-22 14:33:29 +00:00
|
|
|
PROP_LAST
|
|
|
|
};
|
2009-01-20 18:44:45 +00:00
|
|
|
|
2011-06-30 08:13:59 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SIGNAL_MEDIA_CONSTRUCTED,
|
2011-08-16 13:03:06 +00:00
|
|
|
SIGNAL_MEDIA_CONFIGURE,
|
2011-06-30 08:13:59 +00:00
|
|
|
SIGNAL_LAST
|
|
|
|
};
|
|
|
|
|
2011-01-12 17:14:48 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (rtsp_media_debug);
|
2009-11-21 18:20:23 +00:00
|
|
|
#define GST_CAT_DEFAULT rtsp_media_debug
|
|
|
|
|
2011-06-30 08:13:59 +00:00
|
|
|
static guint gst_rtsp_media_factory_signals[SIGNAL_LAST] = { 0 };
|
|
|
|
|
2010-12-11 09:48:42 +00:00
|
|
|
static void gst_rtsp_media_factory_get_property (GObject * object, guint propid,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_rtsp_media_factory_set_property (GObject * object, guint propid,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
2009-01-20 18:44:45 +00:00
|
|
|
static void gst_rtsp_media_factory_finalize (GObject * obj);
|
|
|
|
|
2010-12-11 09:48:42 +00:00
|
|
|
static gchar *default_gen_key (GstRTSPMediaFactory * factory,
|
|
|
|
const GstRTSPUrl * url);
|
2012-10-25 19:29:58 +00:00
|
|
|
static GstElement *default_create_element (GstRTSPMediaFactory * factory,
|
2010-12-11 09:48:42 +00:00
|
|
|
const GstRTSPUrl * url);
|
|
|
|
static GstRTSPMedia *default_construct (GstRTSPMediaFactory * factory,
|
|
|
|
const GstRTSPUrl * url);
|
|
|
|
static void default_configure (GstRTSPMediaFactory * factory,
|
|
|
|
GstRTSPMedia * media);
|
|
|
|
static GstElement *default_create_pipeline (GstRTSPMediaFactory * factory,
|
|
|
|
GstRTSPMedia * media);
|
2009-01-22 14:33:29 +00:00
|
|
|
|
|
|
|
G_DEFINE_TYPE (GstRTSPMediaFactory, gst_rtsp_media_factory, G_TYPE_OBJECT);
|
2009-01-20 18:44:45 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_rtsp_media_factory_class_init (GstRTSPMediaFactoryClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
g_type_class_add_private (klass, sizeof (GstRTSPMediaFactoryPrivate));
|
|
|
|
|
2009-01-20 18:44:45 +00:00
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2009-01-22 14:33:29 +00:00
|
|
|
gobject_class->get_property = gst_rtsp_media_factory_get_property;
|
|
|
|
gobject_class->set_property = gst_rtsp_media_factory_set_property;
|
2009-01-20 18:44:45 +00:00
|
|
|
gobject_class->finalize = gst_rtsp_media_factory_finalize;
|
|
|
|
|
2009-01-22 14:33:29 +00:00
|
|
|
/**
|
2012-10-01 17:46:15 +00:00
|
|
|
* GstRTSPMediaFactory::launch:
|
2009-01-22 14:33:29 +00:00
|
|
|
*
|
|
|
|
* The gst_parse_launch() line to use for constructing the pipeline in the
|
|
|
|
* default prepare vmethod.
|
|
|
|
*
|
|
|
|
* The pipeline description should return a GstBin as the toplevel element
|
|
|
|
* which can be accomplished by enclosing the dscription with brackets '('
|
|
|
|
* ')'.
|
|
|
|
*
|
|
|
|
* The description should return a pipeline with payloaders named pay0, pay1,
|
|
|
|
* etc.. Each of the payloaders will result in a stream.
|
2010-03-05 12:34:15 +00:00
|
|
|
*
|
|
|
|
* Support for dynamic payloaders can be accomplished by adding payloaders
|
|
|
|
* named dynpay0, dynpay1, etc..
|
2009-01-22 14:33:29 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class, PROP_LAUNCH,
|
2010-12-11 09:48:42 +00:00
|
|
|
g_param_spec_string ("launch", "Launch",
|
|
|
|
"A launch description of the pipeline", DEFAULT_LAUNCH,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2009-01-22 14:33:29 +00:00
|
|
|
|
2009-01-29 16:20:27 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_SHARED,
|
2010-12-11 09:48:42 +00:00
|
|
|
g_param_spec_boolean ("shared", "Shared",
|
|
|
|
"If media from this factory is shared", DEFAULT_SHARED,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2009-01-29 16:20:27 +00:00
|
|
|
|
2010-08-20 16:17:08 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_EOS_SHUTDOWN,
|
|
|
|
g_param_spec_boolean ("eos-shutdown", "EOS Shutdown",
|
2010-12-11 09:48:42 +00:00
|
|
|
"Send EOS down the pipeline before shutting down",
|
2010-08-20 16:17:08 +00:00
|
|
|
DEFAULT_EOS_SHUTDOWN, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2011-08-16 13:15:19 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_PROTOCOLS,
|
|
|
|
g_param_spec_flags ("protocols", "Protocols",
|
|
|
|
"Allowed lower transport protocols", GST_TYPE_RTSP_LOWER_TRANS,
|
|
|
|
DEFAULT_PROTOCOLS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2011-01-31 16:37:02 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_BUFFER_SIZE,
|
|
|
|
g_param_spec_uint ("buffer-size", "Buffer Size",
|
|
|
|
"The kernel UDP buffer size to use", 0, G_MAXUINT,
|
|
|
|
DEFAULT_BUFFER_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2011-06-30 08:13:59 +00:00
|
|
|
gst_rtsp_media_factory_signals[SIGNAL_MEDIA_CONSTRUCTED] =
|
|
|
|
g_signal_new ("media-constructed", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRTSPMediaFactoryClass,
|
|
|
|
media_constructed), NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1, GST_TYPE_RTSP_MEDIA);
|
|
|
|
|
2011-08-16 13:03:06 +00:00
|
|
|
gst_rtsp_media_factory_signals[SIGNAL_MEDIA_CONFIGURE] =
|
|
|
|
g_signal_new ("media-configure", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRTSPMediaFactoryClass,
|
|
|
|
media_configure), NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1, GST_TYPE_RTSP_MEDIA);
|
|
|
|
|
2009-01-29 16:20:27 +00:00
|
|
|
klass->gen_key = default_gen_key;
|
2012-10-25 19:29:58 +00:00
|
|
|
klass->create_element = default_create_element;
|
2009-01-29 16:20:27 +00:00
|
|
|
klass->construct = default_construct;
|
|
|
|
klass->configure = default_configure;
|
2009-06-12 15:45:29 +00:00
|
|
|
klass->create_pipeline = default_create_pipeline;
|
2009-11-21 18:20:23 +00:00
|
|
|
|
2011-01-12 17:14:48 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (rtsp_media_debug, "rtspmediafactory", 0,
|
|
|
|
"GstRTSPMediaFactory");
|
2009-01-20 18:44:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_rtsp_media_factory_init (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv =
|
|
|
|
GST_RTSP_MEDIA_FACTORY_GET_PRIVATE (factory);
|
|
|
|
factory->priv = priv;
|
|
|
|
|
|
|
|
priv->launch = g_strdup (DEFAULT_LAUNCH);
|
|
|
|
priv->shared = DEFAULT_SHARED;
|
|
|
|
priv->eos_shutdown = DEFAULT_EOS_SHUTDOWN;
|
|
|
|
priv->protocols = DEFAULT_PROTOCOLS;
|
|
|
|
priv->buffer_size = DEFAULT_BUFFER_SIZE;
|
|
|
|
|
|
|
|
g_mutex_init (&priv->lock);
|
|
|
|
g_mutex_init (&priv->medias_lock);
|
|
|
|
priv->medias = g_hash_table_new_full (g_str_hash, g_str_equal,
|
2010-12-11 09:48:42 +00:00
|
|
|
g_free, g_object_unref);
|
2009-01-20 18:44:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_rtsp_media_factory_finalize (GObject * obj)
|
|
|
|
{
|
2009-01-22 14:33:29 +00:00
|
|
|
GstRTSPMediaFactory *factory = GST_RTSP_MEDIA_FACTORY (obj);
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv = factory->priv;
|
2009-01-22 14:33:29 +00:00
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
g_hash_table_unref (priv->medias);
|
|
|
|
g_mutex_clear (&priv->medias_lock);
|
|
|
|
g_free (priv->launch);
|
|
|
|
g_mutex_clear (&priv->lock);
|
|
|
|
if (priv->auth)
|
|
|
|
g_object_unref (priv->auth);
|
|
|
|
if (priv->pool)
|
|
|
|
g_object_unref (priv->pool);
|
2009-01-22 14:33:29 +00:00
|
|
|
|
2009-01-20 18:44:45 +00:00
|
|
|
G_OBJECT_CLASS (gst_rtsp_media_factory_parent_class)->finalize (obj);
|
|
|
|
}
|
|
|
|
|
2009-01-22 14:33:29 +00:00
|
|
|
static void
|
2010-12-11 09:48:42 +00:00
|
|
|
gst_rtsp_media_factory_get_property (GObject * object, guint propid,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
2009-01-22 14:33:29 +00:00
|
|
|
{
|
|
|
|
GstRTSPMediaFactory *factory = GST_RTSP_MEDIA_FACTORY (object);
|
|
|
|
|
|
|
|
switch (propid) {
|
|
|
|
case PROP_LAUNCH:
|
|
|
|
g_value_take_string (value, gst_rtsp_media_factory_get_launch (factory));
|
|
|
|
break;
|
2009-01-29 16:20:27 +00:00
|
|
|
case PROP_SHARED:
|
|
|
|
g_value_set_boolean (value, gst_rtsp_media_factory_is_shared (factory));
|
|
|
|
break;
|
2010-08-20 16:17:08 +00:00
|
|
|
case PROP_EOS_SHUTDOWN:
|
2010-12-11 09:48:42 +00:00
|
|
|
g_value_set_boolean (value,
|
|
|
|
gst_rtsp_media_factory_is_eos_shutdown (factory));
|
2010-08-20 16:17:08 +00:00
|
|
|
break;
|
2011-08-16 13:15:19 +00:00
|
|
|
case PROP_PROTOCOLS:
|
|
|
|
g_value_set_flags (value, gst_rtsp_media_factory_get_protocols (factory));
|
|
|
|
break;
|
2011-01-31 16:37:02 +00:00
|
|
|
case PROP_BUFFER_SIZE:
|
|
|
|
g_value_set_uint (value,
|
|
|
|
gst_rtsp_media_factory_get_buffer_size (factory));
|
|
|
|
break;
|
2009-01-22 14:33:29 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-11 09:48:42 +00:00
|
|
|
gst_rtsp_media_factory_set_property (GObject * object, guint propid,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2009-01-22 14:33:29 +00:00
|
|
|
{
|
|
|
|
GstRTSPMediaFactory *factory = GST_RTSP_MEDIA_FACTORY (object);
|
|
|
|
|
|
|
|
switch (propid) {
|
|
|
|
case PROP_LAUNCH:
|
|
|
|
gst_rtsp_media_factory_set_launch (factory, g_value_get_string (value));
|
|
|
|
break;
|
2009-01-29 16:20:27 +00:00
|
|
|
case PROP_SHARED:
|
|
|
|
gst_rtsp_media_factory_set_shared (factory, g_value_get_boolean (value));
|
|
|
|
break;
|
2010-08-20 16:17:08 +00:00
|
|
|
case PROP_EOS_SHUTDOWN:
|
2010-12-11 09:48:42 +00:00
|
|
|
gst_rtsp_media_factory_set_eos_shutdown (factory,
|
|
|
|
g_value_get_boolean (value));
|
2010-08-20 16:17:08 +00:00
|
|
|
break;
|
2011-08-16 13:15:19 +00:00
|
|
|
case PROP_PROTOCOLS:
|
|
|
|
gst_rtsp_media_factory_set_protocols (factory, g_value_get_flags (value));
|
|
|
|
break;
|
2011-01-31 16:37:02 +00:00
|
|
|
case PROP_BUFFER_SIZE:
|
|
|
|
gst_rtsp_media_factory_set_buffer_size (factory,
|
|
|
|
g_value_get_uint (value));
|
|
|
|
break;
|
2009-01-22 14:33:29 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_new:
|
|
|
|
*
|
|
|
|
* Create a new #GstRTSPMediaFactory instance.
|
|
|
|
*
|
2009-01-22 16:58:19 +00:00
|
|
|
* Returns: a new #GstRTSPMediaFactory object.
|
2009-01-22 14:33:29 +00:00
|
|
|
*/
|
2009-01-20 18:44:45 +00:00
|
|
|
GstRTSPMediaFactory *
|
|
|
|
gst_rtsp_media_factory_new (void)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactory *result;
|
|
|
|
|
|
|
|
result = g_object_new (GST_TYPE_RTSP_MEDIA_FACTORY, NULL);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-01-22 14:33:29 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_launch:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @launch: the launch description
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* The gst_parse_launch() line to use for constructing the pipeline in the
|
|
|
|
* default prepare vmethod.
|
|
|
|
*
|
|
|
|
* The pipeline description should return a GstBin as the toplevel element
|
|
|
|
* which can be accomplished by enclosing the dscription with brackets '('
|
|
|
|
* ')'.
|
|
|
|
*
|
|
|
|
* The description should return a pipeline with payloaders named pay0, pay1,
|
|
|
|
* etc.. Each of the payloaders will result in a stream.
|
|
|
|
*/
|
|
|
|
void
|
2010-12-11 09:48:42 +00:00
|
|
|
gst_rtsp_media_factory_set_launch (GstRTSPMediaFactory * factory,
|
|
|
|
const gchar * launch)
|
2009-01-20 18:44:45 +00:00
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
2009-01-22 14:33:29 +00:00
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
g_return_if_fail (launch != NULL);
|
2009-01-20 18:44:45 +00:00
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
g_free (priv->launch);
|
|
|
|
priv->launch = g_strdup (launch);
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2009-01-22 14:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_launch:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get the gst_parse_launch() pipeline description that will be used in the
|
|
|
|
* default prepare vmethod.
|
|
|
|
*
|
|
|
|
* Returns: the configured launch description. g_free() after usage.
|
|
|
|
*/
|
|
|
|
gchar *
|
2010-12-11 09:48:42 +00:00
|
|
|
gst_rtsp_media_factory_get_launch (GstRTSPMediaFactory * factory)
|
2009-01-22 14:33:29 +00:00
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
2009-01-22 14:33:29 +00:00
|
|
|
gchar *result;
|
|
|
|
|
2009-01-29 16:20:27 +00:00
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
result = g_strdup (priv->launch);
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2009-01-29 16:20:27 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_shared:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @shared: the new value
|
|
|
|
*
|
|
|
|
* Configure if media created from this factory can be shared between clients.
|
|
|
|
*/
|
|
|
|
void
|
2010-12-11 09:48:42 +00:00
|
|
|
gst_rtsp_media_factory_set_shared (GstRTSPMediaFactory * factory,
|
2009-01-29 16:20:27 +00:00
|
|
|
gboolean shared)
|
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
2009-01-29 16:20:27 +00:00
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
priv->shared = shared;
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2009-01-29 16:20:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_is_shared:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get if media created from this factory can be shared between clients.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the media will be shared between clients.
|
|
|
|
*/
|
|
|
|
gboolean
|
2010-12-11 09:48:42 +00:00
|
|
|
gst_rtsp_media_factory_is_shared (GstRTSPMediaFactory * factory)
|
2009-01-29 16:20:27 +00:00
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
2009-01-29 16:20:27 +00:00
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), FALSE);
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
result = priv->shared;
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2009-01-20 18:44:45 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-08-20 16:17:08 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_eos_shutdown:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @eos_shutdown: the new value
|
|
|
|
*
|
|
|
|
* Configure if media created from this factory will have an EOS sent to the
|
|
|
|
* pipeline before shutdown.
|
|
|
|
*/
|
|
|
|
void
|
2010-12-11 09:48:42 +00:00
|
|
|
gst_rtsp_media_factory_set_eos_shutdown (GstRTSPMediaFactory * factory,
|
2010-08-20 16:17:08 +00:00
|
|
|
gboolean eos_shutdown)
|
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
2010-08-20 16:17:08 +00:00
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
priv->eos_shutdown = eos_shutdown;
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2010-08-20 16:17:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_is_eos_shutdown:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get if media created from this factory will have an EOS event sent to the
|
|
|
|
* pipeline before shutdown.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the media will receive EOS before shutdown.
|
|
|
|
*/
|
|
|
|
gboolean
|
2010-12-11 09:48:42 +00:00
|
|
|
gst_rtsp_media_factory_is_eos_shutdown (GstRTSPMediaFactory * factory)
|
2010-08-20 16:17:08 +00:00
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
2010-08-20 16:17:08 +00:00
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), FALSE);
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
result = priv->eos_shutdown;
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2010-08-20 16:17:08 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-01-31 16:37:02 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_buffer_size:
|
|
|
|
* @factory: a #GstRTSPMedia
|
|
|
|
* @size: the new value
|
|
|
|
*
|
|
|
|
* Set the kernel UDP buffer size.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_buffer_size (GstRTSPMediaFactory * factory,
|
|
|
|
guint size)
|
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
2011-01-31 16:37:02 +00:00
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2011-01-31 16:37:02 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
priv->buffer_size = size;
|
2011-01-31 16:37:02 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_buffer_size:
|
|
|
|
* @factory: a #GstRTSPMedia
|
|
|
|
*
|
|
|
|
* Get the kernel UDP buffer size.
|
|
|
|
*
|
|
|
|
* Returns: the kernel UDP buffer size.
|
|
|
|
*/
|
|
|
|
guint
|
|
|
|
gst_rtsp_media_factory_get_buffer_size (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
2011-01-31 16:37:02 +00:00
|
|
|
guint result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), 0);
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2011-01-31 16:37:02 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
result = priv->buffer_size;
|
2011-01-31 16:37:02 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-08-16 11:13:36 +00:00
|
|
|
/**
|
2012-11-14 16:23:59 +00:00
|
|
|
* gst_rtsp_media_factory_set_address_pool:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @pool: a #GstRTSPAddressPool
|
2011-08-16 11:13:36 +00:00
|
|
|
*
|
2012-11-14 16:23:59 +00:00
|
|
|
* configure @pool to be used as the address pool of @factory.
|
2011-08-16 11:13:36 +00:00
|
|
|
*/
|
|
|
|
void
|
2012-11-14 16:23:59 +00:00
|
|
|
gst_rtsp_media_factory_set_address_pool (GstRTSPMediaFactory * factory,
|
|
|
|
GstRTSPAddressPool * pool)
|
2011-08-16 11:13:36 +00:00
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
2012-11-14 16:23:59 +00:00
|
|
|
GstRTSPAddressPool *old;
|
|
|
|
|
2011-08-16 11:13:36 +00:00
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2011-08-16 11:13:36 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
if ((old = priv->pool) != pool)
|
|
|
|
priv->pool = pool ? g_object_ref (pool) : NULL;
|
2012-11-14 16:23:59 +00:00
|
|
|
else
|
|
|
|
old = NULL;
|
2011-08-16 11:13:36 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2012-11-14 16:23:59 +00:00
|
|
|
|
|
|
|
if (old)
|
|
|
|
g_object_unref (old);
|
2011-08-16 11:13:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-11-14 16:23:59 +00:00
|
|
|
* gst_rtsp_media_factory_get_address_pool:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
2011-08-16 11:13:36 +00:00
|
|
|
*
|
2012-11-14 16:23:59 +00:00
|
|
|
* Get the #GstRTSPAddressPool used as the address pool of @factory.
|
2011-08-16 11:13:36 +00:00
|
|
|
*
|
2012-11-14 16:23:59 +00:00
|
|
|
* Returns: (transfer full): the #GstRTSPAddressPool of @factory. g_object_unref() after
|
|
|
|
* usage.
|
2011-08-16 11:13:36 +00:00
|
|
|
*/
|
2012-11-14 16:23:59 +00:00
|
|
|
GstRTSPAddressPool *
|
|
|
|
gst_rtsp_media_factory_get_address_pool (GstRTSPMediaFactory * factory)
|
2011-08-16 11:13:36 +00:00
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
2012-11-14 16:23:59 +00:00
|
|
|
GstRTSPAddressPool *result;
|
2011-08-16 11:13:36 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2011-08-16 11:13:36 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
if ((result = priv->pool))
|
2012-11-14 16:23:59 +00:00
|
|
|
g_object_ref (result);
|
2011-08-16 11:13:36 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-01-12 11:07:40 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_auth:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @auth: a #GstRTSPAuth
|
|
|
|
*
|
|
|
|
* configure @auth to be used as the authentication manager of @factory.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_auth (GstRTSPMediaFactory * factory,
|
|
|
|
GstRTSPAuth * auth)
|
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
2011-01-12 11:07:40 +00:00
|
|
|
GstRTSPAuth *old;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2012-11-12 15:14:19 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
if ((old = priv->auth) != auth)
|
|
|
|
priv->auth = auth ? g_object_ref (auth) : NULL;
|
2012-11-12 15:14:19 +00:00
|
|
|
else
|
|
|
|
old = NULL;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
if (old)
|
|
|
|
g_object_unref (old);
|
2011-01-12 11:07:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_auth:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get the #GstRTSPAuth used as the authentication manager of @factory.
|
|
|
|
*
|
2012-10-01 17:46:15 +00:00
|
|
|
* Returns: (transfer full): the #GstRTSPAuth of @factory. g_object_unref() after
|
2011-01-12 11:07:40 +00:00
|
|
|
* usage.
|
|
|
|
*/
|
|
|
|
GstRTSPAuth *
|
2011-01-12 12:57:09 +00:00
|
|
|
gst_rtsp_media_factory_get_auth (GstRTSPMediaFactory * factory)
|
2011-01-12 11:07:40 +00:00
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
2011-01-12 11:07:40 +00:00
|
|
|
GstRTSPAuth *result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2012-11-12 15:14:19 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
if ((result = priv->auth))
|
2011-01-12 11:07:40 +00:00
|
|
|
g_object_ref (result);
|
2012-11-12 15:14:19 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2011-01-12 11:07:40 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-08-16 13:15:19 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_protocols:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @protocols: the new flags
|
|
|
|
*
|
|
|
|
* Configure the allowed lower transport for @factory.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_protocols (GstRTSPMediaFactory * factory,
|
|
|
|
GstRTSPLowerTrans protocols)
|
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
2011-08-16 13:15:19 +00:00
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2012-11-12 15:14:19 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
priv->protocols = protocols;
|
2012-11-12 15:14:19 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2011-08-16 13:15:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_protocols:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get the allowed protocols of @factory.
|
|
|
|
*
|
|
|
|
* Returns: a #GstRTSPLowerTrans
|
|
|
|
*/
|
|
|
|
GstRTSPLowerTrans
|
|
|
|
gst_rtsp_media_factory_get_protocols (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
2012-11-12 15:14:19 +00:00
|
|
|
GstRTSPLowerTrans res;
|
|
|
|
|
2011-08-16 13:15:19 +00:00
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory),
|
|
|
|
GST_RTSP_LOWER_TRANS_UNKNOWN);
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;
|
|
|
|
|
2012-11-12 15:14:19 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
res = priv->protocols;
|
2012-11-12 15:14:19 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return res;
|
2011-08-16 13:15:19 +00:00
|
|
|
}
|
|
|
|
|
2009-04-03 20:46:22 +00:00
|
|
|
static gboolean
|
2010-12-11 09:48:42 +00:00
|
|
|
compare_media (gpointer key, GstRTSPMedia * media1, GstRTSPMedia * media2)
|
2009-04-03 20:46:22 +00:00
|
|
|
{
|
|
|
|
return (media1 == media2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-11 09:48:42 +00:00
|
|
|
media_unprepared (GstRTSPMedia * media, GstRTSPMediaFactory * factory)
|
2009-04-03 20:46:22 +00:00
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv = factory->priv;;
|
|
|
|
|
|
|
|
g_mutex_lock (&priv->medias_lock);
|
|
|
|
g_hash_table_foreach_remove (priv->medias, (GHRFunc) compare_media, media);
|
|
|
|
g_mutex_unlock (&priv->medias_lock);
|
2009-04-03 20:46:22 +00:00
|
|
|
}
|
|
|
|
|
2009-01-22 14:33:29 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_construct:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
2009-01-22 16:58:19 +00:00
|
|
|
* @url: the url used
|
2009-01-22 14:33:29 +00:00
|
|
|
*
|
2012-10-25 19:29:58 +00:00
|
|
|
* Construct the media object and create its streams. Implementations
|
2009-01-22 14:33:29 +00:00
|
|
|
* should create the needed gstreamer elements and add them to the result
|
|
|
|
* object. No state changes should be performed on them yet.
|
|
|
|
*
|
2012-10-25 19:29:58 +00:00
|
|
|
* One or more GstRTSPStream objects should be created from the result
|
|
|
|
* with gst_rtsp_media_create_stream ().
|
|
|
|
*
|
|
|
|
* After the media is constructed, it can be configured and then prepared
|
|
|
|
* with gst_rtsp_media_prepare ().
|
2009-01-22 14:33:29 +00:00
|
|
|
*
|
2012-10-01 17:46:15 +00:00
|
|
|
* Returns: (transfer full): a new #GstRTSPMedia if the media could be prepared.
|
2009-01-22 14:33:29 +00:00
|
|
|
*/
|
2009-01-22 16:58:19 +00:00
|
|
|
GstRTSPMedia *
|
2010-12-11 09:48:42 +00:00
|
|
|
gst_rtsp_media_factory_construct (GstRTSPMediaFactory * factory,
|
|
|
|
const GstRTSPUrl * url)
|
2009-01-20 18:44:45 +00:00
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
2009-01-29 16:20:27 +00:00
|
|
|
gchar *key;
|
|
|
|
GstRTSPMedia *media;
|
2009-01-20 18:44:45 +00:00
|
|
|
GstRTSPMediaFactoryClass *klass;
|
|
|
|
|
2012-10-25 19:29:58 +00:00
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
|
|
|
|
g_return_val_if_fail (url != NULL, NULL);
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
priv = factory->priv;;
|
2009-01-20 18:44:45 +00:00
|
|
|
klass = GST_RTSP_MEDIA_FACTORY_GET_CLASS (factory);
|
|
|
|
|
2009-01-29 16:20:27 +00:00
|
|
|
/* convert the url to a key for the hashtable. NULL return or a NULL function
|
|
|
|
* will not cache anything for this factory. */
|
|
|
|
if (klass->gen_key)
|
|
|
|
key = klass->gen_key (factory, url);
|
|
|
|
else
|
|
|
|
key = NULL;
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
g_mutex_lock (&priv->medias_lock);
|
2009-01-29 16:20:27 +00:00
|
|
|
if (key) {
|
|
|
|
/* we have a key, see if we find a cached media */
|
2012-11-29 10:11:05 +00:00
|
|
|
media = g_hash_table_lookup (priv->medias, key);
|
2009-01-29 16:20:27 +00:00
|
|
|
if (media)
|
|
|
|
g_object_ref (media);
|
2010-12-11 09:48:42 +00:00
|
|
|
} else
|
2009-01-29 16:20:27 +00:00
|
|
|
media = NULL;
|
|
|
|
|
|
|
|
if (media == NULL) {
|
|
|
|
/* nothing cached found, try to create one */
|
2011-06-30 08:13:59 +00:00
|
|
|
if (klass->construct) {
|
2009-01-29 16:20:27 +00:00
|
|
|
media = klass->construct (factory, url);
|
2011-06-30 08:13:59 +00:00
|
|
|
if (media)
|
|
|
|
g_signal_emit (factory,
|
|
|
|
gst_rtsp_media_factory_signals[SIGNAL_MEDIA_CONSTRUCTED], 0, media,
|
|
|
|
NULL);
|
|
|
|
} else
|
2009-01-29 16:20:27 +00:00
|
|
|
media = NULL;
|
|
|
|
|
|
|
|
if (media) {
|
|
|
|
/* configure the media */
|
|
|
|
if (klass->configure)
|
|
|
|
klass->configure (factory, media);
|
|
|
|
|
2011-08-16 13:03:06 +00:00
|
|
|
g_signal_emit (factory,
|
|
|
|
gst_rtsp_media_factory_signals[SIGNAL_MEDIA_CONFIGURE], 0, media,
|
|
|
|
NULL);
|
|
|
|
|
2009-01-29 16:20:27 +00:00
|
|
|
/* check if we can cache this media */
|
|
|
|
if (gst_rtsp_media_is_shared (media)) {
|
|
|
|
/* insert in the hashtable, takes ownership of the key */
|
|
|
|
g_object_ref (media);
|
2012-11-29 10:11:05 +00:00
|
|
|
g_hash_table_insert (priv->medias, key, media);
|
2009-01-29 16:20:27 +00:00
|
|
|
key = NULL;
|
|
|
|
}
|
2009-04-03 20:46:22 +00:00
|
|
|
if (!gst_rtsp_media_is_reusable (media)) {
|
2010-12-11 09:48:42 +00:00
|
|
|
/* when not reusable, connect to the unprepare signal to remove the item
|
|
|
|
* from our cache when it gets unprepared */
|
2012-11-20 11:29:55 +00:00
|
|
|
g_signal_connect_object (media, "unprepared",
|
|
|
|
(GCallback) media_unprepared, factory, 0);
|
2009-04-03 20:46:22 +00:00
|
|
|
}
|
2009-01-29 16:20:27 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-29 10:11:05 +00:00
|
|
|
g_mutex_unlock (&priv->medias_lock);
|
2009-01-29 16:20:27 +00:00
|
|
|
|
|
|
|
if (key)
|
|
|
|
g_free (key);
|
2009-01-20 18:44:45 +00:00
|
|
|
|
2009-11-21 18:20:23 +00:00
|
|
|
GST_INFO ("constructed media %p for url %s", media, url->abspath);
|
2009-01-22 14:33:29 +00:00
|
|
|
|
2009-01-29 16:20:27 +00:00
|
|
|
return media;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2010-12-11 09:48:42 +00:00
|
|
|
default_gen_key (GstRTSPMediaFactory * factory, const GstRTSPUrl * url)
|
2009-01-29 16:20:27 +00:00
|
|
|
{
|
|
|
|
gchar *result;
|
2010-09-23 09:32:58 +00:00
|
|
|
const gchar *pre_query;
|
|
|
|
const gchar *query;
|
2009-01-29 16:20:27 +00:00
|
|
|
|
2010-09-23 09:32:58 +00:00
|
|
|
pre_query = url->query ? "?" : "";
|
|
|
|
query = url->query ? url->query : "";
|
|
|
|
|
2010-12-11 09:48:42 +00:00
|
|
|
result =
|
|
|
|
g_strdup_printf ("%u%s%s%s", url->port, url->abspath, pre_query, query);
|
2009-01-29 16:20:27 +00:00
|
|
|
|
|
|
|
return result;
|
2009-01-20 18:44:45 +00:00
|
|
|
}
|
|
|
|
|
2009-01-22 15:51:08 +00:00
|
|
|
static GstElement *
|
2012-10-25 19:29:58 +00:00
|
|
|
default_create_element (GstRTSPMediaFactory * factory, const GstRTSPUrl * url)
|
2009-01-20 18:44:45 +00:00
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv = factory->priv;
|
2009-01-22 15:51:08 +00:00
|
|
|
GstElement *element;
|
2009-01-22 14:33:29 +00:00
|
|
|
GError *error = NULL;
|
2009-01-20 18:44:45 +00:00
|
|
|
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2009-01-22 14:33:29 +00:00
|
|
|
/* we need a parse syntax */
|
2012-11-29 10:11:05 +00:00
|
|
|
if (priv->launch == NULL)
|
2009-01-22 14:33:29 +00:00
|
|
|
goto no_launch;
|
|
|
|
|
|
|
|
/* parse the user provided launch line */
|
2012-11-29 10:11:05 +00:00
|
|
|
element = gst_parse_launch (priv->launch, &error);
|
2009-01-22 14:33:29 +00:00
|
|
|
if (element == NULL)
|
|
|
|
goto parse_error;
|
|
|
|
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2009-01-29 16:20:27 +00:00
|
|
|
|
2009-01-22 14:33:29 +00:00
|
|
|
if (error != NULL) {
|
|
|
|
/* a recoverable error was encountered */
|
2009-11-21 18:20:23 +00:00
|
|
|
GST_WARNING ("recoverable parsing error: %s", error->message);
|
2009-01-22 14:33:29 +00:00
|
|
|
g_error_free (error);
|
|
|
|
}
|
2009-01-22 15:51:08 +00:00
|
|
|
return element;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
no_launch:
|
|
|
|
{
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2009-01-22 15:51:08 +00:00
|
|
|
g_critical ("no launch line specified");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
parse_error:
|
|
|
|
{
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
g_critical ("could not parse launch syntax (%s): %s", priv->launch,
|
2010-12-11 09:48:42 +00:00
|
|
|
(error ? error->message : "unknown reason"));
|
2009-01-22 15:51:08 +00:00
|
|
|
if (error)
|
|
|
|
g_error_free (error);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-23 14:18:04 +00:00
|
|
|
static GstRTSPMedia *
|
2010-12-11 09:48:42 +00:00
|
|
|
default_construct (GstRTSPMediaFactory * factory, const GstRTSPUrl * url)
|
2009-05-23 14:18:04 +00:00
|
|
|
{
|
|
|
|
GstRTSPMedia *media;
|
2012-11-29 10:11:05 +00:00
|
|
|
GstElement *element, *pipeline;
|
2009-05-23 14:18:04 +00:00
|
|
|
GstRTSPMediaFactoryClass *klass;
|
|
|
|
|
|
|
|
klass = GST_RTSP_MEDIA_FACTORY_GET_CLASS (factory);
|
|
|
|
|
2010-03-05 12:34:15 +00:00
|
|
|
if (!klass->create_pipeline)
|
|
|
|
goto no_create;
|
|
|
|
|
2012-10-25 19:29:58 +00:00
|
|
|
element = gst_rtsp_media_factory_create_element (factory, url);
|
2009-05-23 14:18:04 +00:00
|
|
|
if (element == NULL)
|
|
|
|
goto no_element;
|
|
|
|
|
|
|
|
/* create a new empty media */
|
2012-11-29 10:11:05 +00:00
|
|
|
media = gst_rtsp_media_new (element);
|
2009-05-23 14:18:04 +00:00
|
|
|
|
2012-10-25 19:29:58 +00:00
|
|
|
gst_rtsp_media_collect_streams (media);
|
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
pipeline = klass->create_pipeline (factory, media);
|
|
|
|
if (pipeline == NULL)
|
2010-03-05 12:34:15 +00:00
|
|
|
goto no_pipeline;
|
2009-06-12 15:45:29 +00:00
|
|
|
|
2009-01-22 16:58:19 +00:00
|
|
|
return media;
|
2009-01-22 14:33:29 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
2010-03-05 12:34:15 +00:00
|
|
|
no_create:
|
|
|
|
{
|
|
|
|
g_critical ("no create_pipeline function");
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-01-22 15:51:08 +00:00
|
|
|
no_element:
|
2009-01-22 14:33:29 +00:00
|
|
|
{
|
2009-01-22 15:51:08 +00:00
|
|
|
g_critical ("could not create element");
|
2009-01-22 14:33:29 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-06-12 15:45:29 +00:00
|
|
|
no_pipeline:
|
|
|
|
{
|
2010-03-05 12:34:15 +00:00
|
|
|
g_critical ("can't create pipeline");
|
|
|
|
g_object_unref (media);
|
|
|
|
return NULL;
|
2009-06-12 15:45:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-11 09:48:42 +00:00
|
|
|
static GstElement *
|
|
|
|
default_create_pipeline (GstRTSPMediaFactory * factory, GstRTSPMedia * media)
|
2010-03-05 12:34:15 +00:00
|
|
|
{
|
2009-06-12 15:45:29 +00:00
|
|
|
GstElement *pipeline;
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("media-pipeline");
|
2012-11-29 10:11:05 +00:00
|
|
|
gst_rtsp_media_take_pipeline (media, GST_PIPELINE_CAST (pipeline));
|
2009-06-12 15:45:29 +00:00
|
|
|
|
|
|
|
return pipeline;
|
2009-01-22 14:33:29 +00:00
|
|
|
}
|
2009-01-29 16:20:27 +00:00
|
|
|
|
|
|
|
static void
|
2010-12-11 09:48:42 +00:00
|
|
|
default_configure (GstRTSPMediaFactory * factory, GstRTSPMedia * media)
|
2009-01-29 16:20:27 +00:00
|
|
|
{
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPMediaFactoryPrivate *priv = factory->priv;
|
2010-08-20 16:17:08 +00:00
|
|
|
gboolean shared, eos_shutdown;
|
2011-01-31 16:37:02 +00:00
|
|
|
guint size;
|
2011-01-12 12:57:09 +00:00
|
|
|
GstRTSPAuth *auth;
|
2011-08-16 13:15:19 +00:00
|
|
|
GstRTSPLowerTrans protocols;
|
2012-11-14 16:23:59 +00:00
|
|
|
GstRTSPAddressPool *pool;
|
2009-01-29 16:20:27 +00:00
|
|
|
|
|
|
|
/* configure the sharedness */
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
shared = priv->shared;
|
|
|
|
eos_shutdown = priv->eos_shutdown;
|
|
|
|
size = priv->buffer_size;
|
|
|
|
protocols = priv->protocols;
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2009-01-29 16:20:27 +00:00
|
|
|
|
|
|
|
gst_rtsp_media_set_shared (media, shared);
|
2010-08-20 16:17:08 +00:00
|
|
|
gst_rtsp_media_set_eos_shutdown (media, eos_shutdown);
|
2011-01-31 16:37:02 +00:00
|
|
|
gst_rtsp_media_set_buffer_size (media, size);
|
2011-08-16 13:15:19 +00:00
|
|
|
gst_rtsp_media_set_protocols (media, protocols);
|
2011-01-12 12:57:09 +00:00
|
|
|
|
|
|
|
if ((auth = gst_rtsp_media_factory_get_auth (factory))) {
|
|
|
|
gst_rtsp_media_set_auth (media, auth);
|
|
|
|
g_object_unref (auth);
|
|
|
|
}
|
2012-11-14 16:23:59 +00:00
|
|
|
if ((pool = gst_rtsp_media_factory_get_address_pool (factory))) {
|
|
|
|
gst_rtsp_media_set_address_pool (media, pool);
|
|
|
|
g_object_unref (pool);
|
2011-08-16 11:27:39 +00:00
|
|
|
}
|
2009-01-29 16:20:27 +00:00
|
|
|
}
|
2012-10-12 04:11:36 +00:00
|
|
|
|
|
|
|
/**
|
2012-10-25 19:29:58 +00:00
|
|
|
* gst_rtsp_media_factory_create_element:
|
2012-10-12 04:11:36 +00:00
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @url: the url used
|
|
|
|
*
|
2012-10-25 19:29:58 +00:00
|
|
|
* Construct and return a #GstElement that is a #GstBin containing
|
|
|
|
* the elements to use for streaming the media.
|
|
|
|
*
|
|
|
|
* The bin should contain payloaders pay%d for each stream. The default
|
|
|
|
* implementation of this function returns the bin created from the
|
|
|
|
* launch parameter.
|
|
|
|
*
|
2012-10-12 04:11:36 +00:00
|
|
|
* Returns: (transfer floating) a new #GstElement.
|
|
|
|
*/
|
|
|
|
GstElement *
|
2012-10-25 19:29:58 +00:00
|
|
|
gst_rtsp_media_factory_create_element (GstRTSPMediaFactory * factory,
|
2012-10-12 04:11:36 +00:00
|
|
|
const GstRTSPUrl * url)
|
|
|
|
{
|
2012-10-25 19:29:58 +00:00
|
|
|
GstRTSPMediaFactoryClass *klass;
|
|
|
|
GstElement *result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
|
2012-11-28 11:10:14 +00:00
|
|
|
g_return_val_if_fail (url != NULL, NULL);
|
2012-10-25 19:29:58 +00:00
|
|
|
|
|
|
|
klass = GST_RTSP_MEDIA_FACTORY_GET_CLASS (factory);
|
|
|
|
|
|
|
|
if (klass->create_element)
|
|
|
|
result = klass->create_element (factory, url);
|
|
|
|
else
|
|
|
|
result = NULL;
|
|
|
|
|
|
|
|
return result;
|
2012-10-12 04:11:36 +00:00
|
|
|
}
|