2009-01-20 18:44:45 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
|
2015-01-09 11:40:47 +00:00
|
|
|
* Copyright (C) 2015 Centricular Ltd
|
|
|
|
* Author: Sebastian Dröge <sebastian@centricular.com>
|
2009-01-20 18:44:45 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
*/
|
2013-07-11 14:57:14 +00:00
|
|
|
/**
|
|
|
|
* SECTION:rtsp-media-factory
|
|
|
|
* @short_description: A factory for media pipelines
|
|
|
|
* @see_also: #GstRTSPMountPoints, #GstRTSPMedia
|
|
|
|
*
|
|
|
|
* The #GstRTSPMediaFactory is responsible for creating or recycling
|
|
|
|
* #GstRTSPMedia objects based on the passed URL.
|
|
|
|
*
|
|
|
|
* The default implementation of the object can create #GstRTSPMedia objects
|
|
|
|
* containing a pipeline created from a launch description set with
|
|
|
|
* gst_rtsp_media_factory_set_launch().
|
|
|
|
*
|
|
|
|
* Media from a factory can be shared by setting the shared flag with
|
|
|
|
* gst_rtsp_media_factory_set_shared(). When a factory is shared,
|
|
|
|
* gst_rtsp_media_factory_construct() will return the same #GstRTSPMedia when
|
|
|
|
* the url matches.
|
|
|
|
*
|
|
|
|
* Last reviewed on 2013-07-11 (1.0.0)
|
|
|
|
*/
|
2018-09-24 08:36:21 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2009-01-20 18:44:45 +00:00
|
|
|
|
2020-09-04 19:14:35 +00:00
|
|
|
#include "rtsp-server-internal.h"
|
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_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
|
|
|
|
{
|
2013-02-18 19:59:58 +00:00
|
|
|
GMutex lock; /* protects everything but medias */
|
2013-07-09 12:33:43 +00:00
|
|
|
GstRTSPPermissions *permissions;
|
2012-11-29 10:11:05 +00:00
|
|
|
gchar *launch;
|
|
|
|
gboolean shared;
|
2013-11-28 13:10:19 +00:00
|
|
|
GstRTSPSuspendMode suspend_mode;
|
2012-11-29 10:11:05 +00:00
|
|
|
gboolean eos_shutdown;
|
2014-03-03 15:55:48 +00:00
|
|
|
GstRTSPProfile profiles;
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPLowerTrans protocols;
|
|
|
|
guint buffer_size;
|
2023-06-26 06:25:36 +00:00
|
|
|
gboolean ensure_keyunit_on_start;
|
|
|
|
guint ensure_keyunit_on_start_timeout;
|
2015-03-03 13:42:07 +00:00
|
|
|
gint dscp_qos;
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPAddressPool *pool;
|
2015-01-28 17:54:01 +00:00
|
|
|
GstRTSPTransportMode transport_mode;
|
2015-12-09 16:24:24 +00:00
|
|
|
gboolean stop_on_disconnect;
|
2016-03-02 17:42:13 +00:00
|
|
|
gchar *multicast_iface;
|
2018-07-24 07:35:46 +00:00
|
|
|
guint max_mcast_ttl;
|
2018-09-06 14:17:33 +00:00
|
|
|
gboolean bind_mcast_address;
|
2020-09-04 19:14:35 +00:00
|
|
|
gboolean enable_rtcp;
|
2012-11-29 10:11:05 +00:00
|
|
|
|
2014-11-26 14:12:36 +00:00
|
|
|
GstClockTime rtx_time;
|
2015-01-19 12:20:39 +00:00
|
|
|
guint latency;
|
2018-03-29 20:49:26 +00:00
|
|
|
gboolean do_retransmission;
|
2014-11-26 14:12:36 +00:00
|
|
|
|
2012-11-29 10:11:05 +00:00
|
|
|
GMutex medias_lock;
|
2013-02-18 19:59:58 +00:00
|
|
|
GHashTable *medias; /* protected by medias_lock */
|
2015-03-02 14:49:42 +00:00
|
|
|
|
|
|
|
GType media_gtype;
|
2015-12-30 14:31:13 +00:00
|
|
|
|
|
|
|
GstClock *clock;
|
2015-12-30 16:39:05 +00:00
|
|
|
|
|
|
|
GstRTSPPublishClockMode publish_clock_mode;
|
2012-11-29 10:11:05 +00:00
|
|
|
};
|
|
|
|
|
2011-08-16 11:13:36 +00:00
|
|
|
#define DEFAULT_LAUNCH NULL
|
|
|
|
#define DEFAULT_SHARED FALSE
|
2013-11-28 13:10:19 +00:00
|
|
|
#define DEFAULT_SUSPEND_MODE GST_RTSP_SUSPEND_MODE_NONE
|
2011-08-16 11:13:36 +00:00
|
|
|
#define DEFAULT_EOS_SHUTDOWN FALSE
|
2014-03-03 15:55:48 +00:00
|
|
|
#define DEFAULT_PROFILES GST_RTSP_PROFILE_AVP
|
2013-08-16 14:16:00 +00:00
|
|
|
#define DEFAULT_PROTOCOLS GST_RTSP_LOWER_TRANS_UDP | GST_RTSP_LOWER_TRANS_UDP_MCAST | \
|
|
|
|
GST_RTSP_LOWER_TRANS_TCP
|
2011-08-16 11:13:36 +00:00
|
|
|
#define DEFAULT_BUFFER_SIZE 0x80000
|
2023-06-26 06:25:36 +00:00
|
|
|
#define DEFAULT_ENSURE_KEYUNIT_ON_START FALSE
|
|
|
|
#define DEFAULT_ENSURE_KEYUNIT_ON_START_TIMEOUT 100
|
2015-01-19 12:20:39 +00:00
|
|
|
#define DEFAULT_LATENCY 200
|
2018-07-24 07:35:46 +00:00
|
|
|
#define DEFAULT_MAX_MCAST_TTL 255
|
2018-09-06 14:17:33 +00:00
|
|
|
#define DEFAULT_BIND_MCAST_ADDRESS FALSE
|
2015-01-28 17:54:01 +00:00
|
|
|
#define DEFAULT_TRANSPORT_MODE GST_RTSP_TRANSPORT_MODE_PLAY
|
2015-12-09 16:24:24 +00:00
|
|
|
#define DEFAULT_STOP_ON_DISCONNECT TRUE
|
2018-03-29 20:49:26 +00:00
|
|
|
#define DEFAULT_DO_RETRANSMISSION FALSE
|
2015-03-03 13:42:07 +00:00
|
|
|
#define DEFAULT_DSCP_QOS (-1)
|
2020-09-04 19:14:35 +00:00
|
|
|
#define DEFAULT_ENABLE_RTCP TRUE
|
2009-01-22 14:33:29 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_LAUNCH,
|
2009-01-29 16:20:27 +00:00
|
|
|
PROP_SHARED,
|
2013-11-28 13:10:19 +00:00
|
|
|
PROP_SUSPEND_MODE,
|
2010-08-20 16:17:08 +00:00
|
|
|
PROP_EOS_SHUTDOWN,
|
2014-03-03 15:55:48 +00:00
|
|
|
PROP_PROFILES,
|
2011-08-16 13:15:19 +00:00
|
|
|
PROP_PROTOCOLS,
|
2011-01-31 16:37:02 +00:00
|
|
|
PROP_BUFFER_SIZE,
|
2023-06-26 06:25:36 +00:00
|
|
|
PROP_ENSURE_KEYUNIT_ON_START,
|
|
|
|
PROP_ENSURE_KEYUNIT_ON_START_TIMEOUT,
|
2015-01-19 12:20:39 +00:00
|
|
|
PROP_LATENCY,
|
2015-01-28 17:54:01 +00:00
|
|
|
PROP_TRANSPORT_MODE,
|
2015-12-09 16:24:24 +00:00
|
|
|
PROP_STOP_ON_DISCONNECT,
|
2015-12-30 14:31:13 +00:00
|
|
|
PROP_CLOCK,
|
2018-07-24 07:35:46 +00:00
|
|
|
PROP_MAX_MCAST_TTL,
|
2018-09-06 14:17:33 +00:00
|
|
|
PROP_BIND_MCAST_ADDRESS,
|
2015-03-03 13:42:07 +00:00
|
|
|
PROP_DSCP_QOS,
|
2020-09-04 19:14:35 +00:00
|
|
|
PROP_ENABLE_RTCP,
|
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
|
|
|
|
2018-06-24 10:44:26 +00:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (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;
|
|
|
|
|
|
|
|
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
|
2017-01-09 09:22:40 +00:00
|
|
|
* which can be accomplished by enclosing the description with brackets '('
|
2009-01-22 14:33:29 +00:00
|
|
|
* ')'.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2013-11-28 13:10:19 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_SUSPEND_MODE,
|
|
|
|
g_param_spec_enum ("suspend-mode", "Suspend Mode",
|
|
|
|
"Control how media will be suspended", GST_TYPE_RTSP_SUSPEND_MODE,
|
|
|
|
DEFAULT_SUSPEND_MODE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
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));
|
|
|
|
|
2014-03-03 15:55:48 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_PROFILES,
|
|
|
|
g_param_spec_flags ("profiles", "Profiles",
|
|
|
|
"Allowed transfer profiles", GST_TYPE_RTSP_PROFILE,
|
|
|
|
DEFAULT_PROFILES, 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));
|
|
|
|
|
2023-06-26 06:25:36 +00:00
|
|
|
/**
|
|
|
|
* GstRTSPMediaFactory:ensure-keyunit-on-start:
|
|
|
|
*
|
|
|
|
* If media from this factory should ensure a key unit when a client connects.
|
|
|
|
*
|
|
|
|
* This property will ensure that the stream always starts on a key unit
|
|
|
|
* instead of a delta unit which the client would not be able to decode.
|
|
|
|
*
|
|
|
|
* Note that this will only affect non-shared medias for now.
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class, PROP_ENSURE_KEYUNIT_ON_START,
|
|
|
|
g_param_spec_boolean ("ensure-keyunit-on-start",
|
|
|
|
"Ensure keyunit on start",
|
|
|
|
"If media from this factory should ensure a key unit when a client "
|
|
|
|
"connects.",
|
|
|
|
DEFAULT_ENSURE_KEYUNIT_ON_START,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstRTSPMediaFactory:ensure-keyunit-on-start-timeout:
|
|
|
|
*
|
|
|
|
* Timeout in milliseconds used to determine if a keyunit should be discarded
|
|
|
|
* when a client connects.
|
|
|
|
*
|
|
|
|
* If the timeout has been reached a new keyframe will be forced, otherwise
|
|
|
|
* the currently blocking keyframe will be used.
|
|
|
|
*
|
|
|
|
* This options is only relevant when ensure-keyunit-on-start is enabled.
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_ENSURE_KEYUNIT_ON_START_TIMEOUT,
|
|
|
|
g_param_spec_uint ("ensure-keyunit-on-start-timeout",
|
|
|
|
"Timeout for discarding old keyunit on start",
|
|
|
|
"Timeout in milliseconds used to determine if a keyunit should be "
|
|
|
|
"discarded when a client connects.", 0, G_MAXUINT,
|
|
|
|
DEFAULT_ENSURE_KEYUNIT_ON_START_TIMEOUT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2015-01-19 12:20:39 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_LATENCY,
|
|
|
|
g_param_spec_uint ("latency", "Latency",
|
|
|
|
"Latency used for receiving media in milliseconds", 0, G_MAXUINT,
|
|
|
|
DEFAULT_LATENCY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2015-01-28 17:54:01 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_TRANSPORT_MODE,
|
|
|
|
g_param_spec_flags ("transport-mode", "Transport Mode",
|
|
|
|
"If media from this factory is for PLAY or RECORD",
|
|
|
|
GST_TYPE_RTSP_TRANSPORT_MODE, DEFAULT_TRANSPORT_MODE,
|
2015-01-09 11:40:47 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2015-12-09 16:24:24 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_STOP_ON_DISCONNECT,
|
|
|
|
g_param_spec_boolean ("stop-on-disconnect", "Stop On Disconnect",
|
|
|
|
"If media from this factory should be stopped "
|
|
|
|
"when a client disconnects without TEARDOWN",
|
|
|
|
DEFAULT_STOP_ON_DISCONNECT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2015-12-30 14:31:13 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_CLOCK,
|
|
|
|
g_param_spec_object ("clock", "Clock",
|
|
|
|
"Clock to be used by the pipelines created for all "
|
|
|
|
"medias of this factory", GST_TYPE_CLOCK,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2018-07-24 07:35:46 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_MAX_MCAST_TTL,
|
|
|
|
g_param_spec_uint ("max-mcast-ttl", "Maximum multicast ttl",
|
|
|
|
"The maximum time-to-live value of outgoing multicast packets", 1,
|
|
|
|
255, DEFAULT_MAX_MCAST_TTL,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2018-09-06 14:17:33 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_BIND_MCAST_ADDRESS,
|
|
|
|
g_param_spec_boolean ("bind-mcast-address", "Bind mcast address",
|
|
|
|
"Whether the multicast sockets should be bound to multicast addresses "
|
|
|
|
"or INADDR_ANY",
|
|
|
|
DEFAULT_BIND_MCAST_ADDRESS,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2020-09-04 19:14:35 +00:00
|
|
|
/**
|
|
|
|
* GstRTSPMediaFactory:enable-rtcp:
|
|
|
|
*
|
|
|
|
* Whether the created media should send and receive RTCP
|
|
|
|
*
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class, PROP_ENABLE_RTCP,
|
|
|
|
g_param_spec_boolean ("enable-rtcp", "Enable RTCP",
|
|
|
|
"Whether the created media should send and receive RTCP",
|
|
|
|
DEFAULT_ENABLE_RTCP, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2015-03-03 13:42:07 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_DSCP_QOS,
|
|
|
|
g_param_spec_int ("dscp-qos", "DSCP QoS",
|
|
|
|
"The IP DSCP field to use", -1, 63,
|
|
|
|
DEFAULT_DSCP_QOS, 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,
|
2019-08-29 05:34:26 +00:00
|
|
|
media_constructed), NULL, NULL, NULL,
|
2011-06-30 08:13:59 +00:00
|
|
|
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,
|
2019-08-29 05:34:26 +00:00
|
|
|
media_configure), NULL, NULL, NULL,
|
2011-08-16 13:03:06 +00:00
|
|
|
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 =
|
2018-06-24 10:44:26 +00:00
|
|
|
gst_rtsp_media_factory_get_instance_private (factory);
|
2012-11-29 10:11:05 +00:00
|
|
|
factory->priv = priv;
|
|
|
|
|
|
|
|
priv->launch = g_strdup (DEFAULT_LAUNCH);
|
|
|
|
priv->shared = DEFAULT_SHARED;
|
2013-11-28 13:10:19 +00:00
|
|
|
priv->suspend_mode = DEFAULT_SUSPEND_MODE;
|
2012-11-29 10:11:05 +00:00
|
|
|
priv->eos_shutdown = DEFAULT_EOS_SHUTDOWN;
|
2014-03-03 15:55:48 +00:00
|
|
|
priv->profiles = DEFAULT_PROFILES;
|
2012-11-29 10:11:05 +00:00
|
|
|
priv->protocols = DEFAULT_PROTOCOLS;
|
|
|
|
priv->buffer_size = DEFAULT_BUFFER_SIZE;
|
2023-06-26 06:25:36 +00:00
|
|
|
priv->ensure_keyunit_on_start = DEFAULT_ENSURE_KEYUNIT_ON_START;
|
|
|
|
priv->ensure_keyunit_on_start_timeout =
|
|
|
|
DEFAULT_ENSURE_KEYUNIT_ON_START_TIMEOUT;
|
2015-01-19 12:20:39 +00:00
|
|
|
priv->latency = DEFAULT_LATENCY;
|
2015-01-28 17:54:01 +00:00
|
|
|
priv->transport_mode = DEFAULT_TRANSPORT_MODE;
|
2015-12-09 16:24:24 +00:00
|
|
|
priv->stop_on_disconnect = DEFAULT_STOP_ON_DISCONNECT;
|
2015-12-30 16:39:05 +00:00
|
|
|
priv->publish_clock_mode = GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK;
|
2018-03-29 20:49:26 +00:00
|
|
|
priv->do_retransmission = DEFAULT_DO_RETRANSMISSION;
|
2018-07-24 07:35:46 +00:00
|
|
|
priv->max_mcast_ttl = DEFAULT_MAX_MCAST_TTL;
|
2018-09-06 14:17:33 +00:00
|
|
|
priv->bind_mcast_address = DEFAULT_BIND_MCAST_ADDRESS;
|
2020-09-04 19:14:35 +00:00
|
|
|
priv->enable_rtcp = DEFAULT_ENABLE_RTCP;
|
2015-03-03 13:42:07 +00:00
|
|
|
priv->dscp_qos = DEFAULT_DSCP_QOS;
|
2012-11-29 10:11:05 +00:00
|
|
|
|
|
|
|
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);
|
2015-03-02 14:49:42 +00:00
|
|
|
priv->media_gtype = GST_TYPE_RTSP_MEDIA;
|
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
|
|
|
|
2018-06-29 22:20:57 +00:00
|
|
|
if (priv->clock)
|
|
|
|
gst_object_unref (priv->clock);
|
2013-09-05 06:53:55 +00:00
|
|
|
if (priv->permissions)
|
|
|
|
gst_rtsp_permissions_unref (priv->permissions);
|
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->pool)
|
|
|
|
g_object_unref (priv->pool);
|
2016-03-02 17:42:13 +00:00
|
|
|
g_free (priv->multicast_iface);
|
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;
|
2013-11-28 13:10:19 +00:00
|
|
|
case PROP_SUSPEND_MODE:
|
|
|
|
g_value_set_enum (value,
|
|
|
|
gst_rtsp_media_factory_get_suspend_mode (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;
|
2014-03-03 15:55:48 +00:00
|
|
|
case PROP_PROFILES:
|
|
|
|
g_value_set_flags (value, gst_rtsp_media_factory_get_profiles (factory));
|
|
|
|
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;
|
2023-06-26 06:25:36 +00:00
|
|
|
case PROP_ENSURE_KEYUNIT_ON_START:
|
|
|
|
g_value_set_boolean (value,
|
|
|
|
gst_rtsp_media_factory_get_ensure_keyunit_on_start (factory));
|
|
|
|
break;
|
|
|
|
case PROP_ENSURE_KEYUNIT_ON_START_TIMEOUT:
|
|
|
|
g_value_set_uint (value,
|
|
|
|
gst_rtsp_media_factory_get_ensure_keyunit_on_start_timeout (factory));
|
|
|
|
break;
|
2015-01-19 12:20:39 +00:00
|
|
|
case PROP_LATENCY:
|
|
|
|
g_value_set_uint (value, gst_rtsp_media_factory_get_latency (factory));
|
|
|
|
break;
|
2015-01-28 17:54:01 +00:00
|
|
|
case PROP_TRANSPORT_MODE:
|
|
|
|
g_value_set_flags (value,
|
|
|
|
gst_rtsp_media_factory_get_transport_mode (factory));
|
2015-01-09 11:40:47 +00:00
|
|
|
break;
|
2015-12-09 16:24:24 +00:00
|
|
|
case PROP_STOP_ON_DISCONNECT:
|
|
|
|
g_value_set_boolean (value,
|
|
|
|
gst_rtsp_media_factory_is_stop_on_disonnect (factory));
|
|
|
|
break;
|
2015-12-30 14:31:13 +00:00
|
|
|
case PROP_CLOCK:
|
|
|
|
g_value_take_object (value, gst_rtsp_media_factory_get_clock (factory));
|
|
|
|
break;
|
2018-07-24 07:35:46 +00:00
|
|
|
case PROP_MAX_MCAST_TTL:
|
|
|
|
g_value_set_uint (value,
|
|
|
|
gst_rtsp_media_factory_get_max_mcast_ttl (factory));
|
2018-09-19 12:31:56 +00:00
|
|
|
break;
|
2018-09-06 14:17:33 +00:00
|
|
|
case PROP_BIND_MCAST_ADDRESS:
|
|
|
|
g_value_set_boolean (value,
|
|
|
|
gst_rtsp_media_factory_is_bind_mcast_address (factory));
|
|
|
|
break;
|
2015-03-03 13:42:07 +00:00
|
|
|
case PROP_DSCP_QOS:
|
|
|
|
g_value_set_int (value, gst_rtsp_media_factory_get_dscp_qos (factory));
|
|
|
|
break;
|
2020-09-04 19:14:35 +00:00
|
|
|
case PROP_ENABLE_RTCP:
|
|
|
|
g_value_set_boolean (value,
|
|
|
|
gst_rtsp_media_factory_is_enable_rtcp (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;
|
2013-11-28 13:10:19 +00:00
|
|
|
case PROP_SUSPEND_MODE:
|
|
|
|
gst_rtsp_media_factory_set_suspend_mode (factory,
|
|
|
|
g_value_get_enum (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;
|
2014-03-03 15:55:48 +00:00
|
|
|
case PROP_PROFILES:
|
|
|
|
gst_rtsp_media_factory_set_profiles (factory, g_value_get_flags (value));
|
|
|
|
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;
|
2023-06-26 06:25:36 +00:00
|
|
|
case PROP_ENSURE_KEYUNIT_ON_START:
|
|
|
|
gst_rtsp_media_factory_set_ensure_keyunit_on_start (factory,
|
|
|
|
g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
case PROP_ENSURE_KEYUNIT_ON_START_TIMEOUT:
|
|
|
|
gst_rtsp_media_factory_set_ensure_keyunit_on_start_timeout (factory,
|
|
|
|
g_value_get_uint (value));
|
|
|
|
break;
|
2015-01-19 12:20:39 +00:00
|
|
|
case PROP_LATENCY:
|
|
|
|
gst_rtsp_media_factory_set_latency (factory, g_value_get_uint (value));
|
|
|
|
break;
|
2015-01-28 17:54:01 +00:00
|
|
|
case PROP_TRANSPORT_MODE:
|
|
|
|
gst_rtsp_media_factory_set_transport_mode (factory,
|
|
|
|
g_value_get_flags (value));
|
2015-01-09 11:40:47 +00:00
|
|
|
break;
|
2015-12-09 16:24:24 +00:00
|
|
|
case PROP_STOP_ON_DISCONNECT:
|
|
|
|
gst_rtsp_media_factory_set_stop_on_disconnect (factory,
|
|
|
|
g_value_get_boolean (value));
|
|
|
|
break;
|
2015-12-30 14:31:13 +00:00
|
|
|
case PROP_CLOCK:
|
|
|
|
gst_rtsp_media_factory_set_clock (factory, g_value_get_object (value));
|
2016-01-15 07:01:37 +00:00
|
|
|
break;
|
2018-07-24 07:35:46 +00:00
|
|
|
case PROP_MAX_MCAST_TTL:
|
|
|
|
gst_rtsp_media_factory_set_max_mcast_ttl (factory,
|
|
|
|
g_value_get_uint (value));
|
2018-09-19 12:31:56 +00:00
|
|
|
break;
|
2018-09-06 14:17:33 +00:00
|
|
|
case PROP_BIND_MCAST_ADDRESS:
|
|
|
|
gst_rtsp_media_factory_set_bind_mcast_address (factory,
|
|
|
|
g_value_get_boolean (value));
|
|
|
|
break;
|
2015-03-03 13:42:07 +00:00
|
|
|
case PROP_DSCP_QOS:
|
|
|
|
gst_rtsp_media_factory_set_dscp_qos (factory, g_value_get_int (value));
|
|
|
|
break;
|
2020-09-04 19:14:35 +00:00
|
|
|
case PROP_ENABLE_RTCP:
|
|
|
|
gst_rtsp_media_factory_set_enable_rtcp (factory,
|
|
|
|
g_value_get_boolean (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.
|
|
|
|
*
|
2014-03-23 20:24:48 +00:00
|
|
|
* Returns: (transfer full): 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;
|
|
|
|
}
|
|
|
|
|
2013-07-09 12:33:43 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_permissions:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
2018-02-09 23:07:25 +00:00
|
|
|
* @permissions: (transfer none) (nullable): a #GstRTSPPermissions
|
2013-07-09 12:33:43 +00:00
|
|
|
*
|
|
|
|
* Set @permissions on @factory.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_permissions (GstRTSPMediaFactory * factory,
|
|
|
|
GstRTSPPermissions * permissions)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
if (priv->permissions)
|
|
|
|
gst_rtsp_permissions_unref (priv->permissions);
|
|
|
|
if ((priv->permissions = permissions))
|
|
|
|
gst_rtsp_permissions_ref (permissions);
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_permissions:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get the permissions object from @factory.
|
|
|
|
*
|
2018-02-09 23:07:25 +00:00
|
|
|
* Returns: (transfer full) (nullable): a #GstRTSPPermissions object, unref after usage.
|
2013-07-09 12:33:43 +00:00
|
|
|
*/
|
|
|
|
GstRTSPPermissions *
|
|
|
|
gst_rtsp_media_factory_get_permissions (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
GstRTSPPermissions *result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
if ((result = priv->permissions))
|
|
|
|
gst_rtsp_permissions_ref (result);
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-07-12 14:17:57 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_add_role:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @role: a role
|
|
|
|
* @fieldname: the first field name
|
|
|
|
* @...: additional arguments
|
|
|
|
*
|
|
|
|
* A convenience method to add @role with @fieldname and additional arguments to
|
|
|
|
* the permissions of @factory. If @factory had no permissions, new permissions
|
|
|
|
* will be created and the role will be added to it.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_add_role (GstRTSPMediaFactory * factory,
|
|
|
|
const gchar * role, const gchar * fieldname, ...)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
va_list var_args;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
g_return_if_fail (role != NULL);
|
|
|
|
g_return_if_fail (fieldname != NULL);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
if (priv->permissions == NULL)
|
|
|
|
priv->permissions = gst_rtsp_permissions_new ();
|
|
|
|
|
|
|
|
va_start (var_args, fieldname);
|
|
|
|
gst_rtsp_permissions_add_role_valist (priv->permissions, role, fieldname,
|
|
|
|
var_args);
|
|
|
|
va_end (var_args);
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
2018-03-02 00:36:23 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_add_role_from_structure:
|
|
|
|
*
|
|
|
|
* A convenience wrapper around gst_rtsp_permissions_add_role_from_structure().
|
|
|
|
* If @factory had no permissions, new permissions will be created and the
|
|
|
|
* role will be added to it.
|
2018-03-02 15:24:23 +00:00
|
|
|
*
|
|
|
|
* Since: 1.14
|
2018-03-02 00:36:23 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_add_role_from_structure (GstRTSPMediaFactory * factory,
|
|
|
|
GstStructure * structure)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
g_return_if_fail (GST_IS_STRUCTURE (structure));
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
if (priv->permissions == NULL)
|
|
|
|
priv->permissions = gst_rtsp_permissions_new ();
|
|
|
|
|
|
|
|
gst_rtsp_permissions_add_role_from_structure (priv->permissions, structure);
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
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
|
2017-01-09 09:22:40 +00:00
|
|
|
* which can be accomplished by enclosing the description with brackets '('
|
2009-01-22 14:33:29 +00:00
|
|
|
* ')'.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2018-02-09 23:07:25 +00:00
|
|
|
* Returns: (transfer full) (nullable): the configured launch description. g_free() after
|
2014-03-23 20:24:48 +00:00
|
|
|
* usage.
|
2009-01-22 14:33:29 +00:00
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-11-28 13:10:19 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_suspend_mode:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @mode: the new #GstRTSPSuspendMode
|
|
|
|
*
|
|
|
|
* Configure how media created from this factory will be suspended.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_suspend_mode (GstRTSPMediaFactory * factory,
|
|
|
|
GstRTSPSuspendMode mode)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv->suspend_mode = mode;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_suspend_mode:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get how media created from this factory will be suspended.
|
|
|
|
*
|
|
|
|
* Returns: a #GstRTSPSuspendMode.
|
|
|
|
*/
|
|
|
|
GstRTSPSuspendMode
|
|
|
|
gst_rtsp_media_factory_get_suspend_mode (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
GstRTSPSuspendMode result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory),
|
|
|
|
GST_RTSP_SUSPEND_MODE_NONE);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
result = priv->suspend_mode;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-01-29 16:20:27 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2023-06-26 06:25:36 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_ensure_keyunit_on_start:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @ensure_keyunit_on_start: the new value
|
|
|
|
*
|
|
|
|
* If media from this factory should ensure a key unit when a client connects.
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_ensure_keyunit_on_start (GstRTSPMediaFactory *
|
|
|
|
factory, gboolean ensure_keyunit_on_start)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv->ensure_keyunit_on_start = ensure_keyunit_on_start;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_ensure_keyunit_on_start:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get ensure-keyunit-on-start flag.
|
|
|
|
*
|
|
|
|
* Returns: The ensure-keyunit-on-start flag.
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_rtsp_media_factory_get_ensure_keyunit_on_start (GstRTSPMediaFactory *
|
|
|
|
factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), FALSE);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
result = priv->ensure_keyunit_on_start;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_ensure_keyunit_on_start_timeout:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @timeout: the new value
|
|
|
|
*
|
|
|
|
* Configures medias from this factory to consider keyunits older than timeout
|
|
|
|
* to be expired. Expired keyunits will be discarded.
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_ensure_keyunit_on_start_timeout (GstRTSPMediaFactory
|
|
|
|
* factory, guint timeout)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv->ensure_keyunit_on_start_timeout = timeout;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_ensure_keyunit_on_start_timeout:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get ensure-keyunit-on-start-timeout time.
|
|
|
|
*
|
|
|
|
* Returns: The ensure-keyunit-on-start-timeout time.
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
*/
|
|
|
|
guint
|
|
|
|
gst_rtsp_media_factory_get_ensure_keyunit_on_start_timeout (GstRTSPMediaFactory
|
|
|
|
* factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
guint result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), FALSE);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
result = priv->ensure_keyunit_on_start_timeout;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-03-03 13:42:07 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_dscp_qos:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @dscp_qos: a new dscp qos value (0-63, or -1 to disable)
|
|
|
|
*
|
|
|
|
* Configure the media dscp qos to @dscp_qos.
|
|
|
|
*
|
|
|
|
* Since: 1.18
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_dscp_qos (GstRTSPMediaFactory * factory,
|
|
|
|
gint dscp_qos)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
|
|
|
if (dscp_qos < -1 || dscp_qos > 63) {
|
|
|
|
GST_WARNING_OBJECT (factory, "trying to set illegal dscp qos %d", dscp_qos);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv->dscp_qos = dscp_qos;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_dscp_qos:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get the configured media DSCP QoS.
|
|
|
|
*
|
|
|
|
* Returns: the media DSCP QoS value or -1 if disabled.
|
|
|
|
*
|
|
|
|
* Since: 1.18
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
gst_rtsp_media_factory_get_dscp_qos (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
guint result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), 0);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
result = priv->dscp_qos;
|
|
|
|
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
|
2018-02-09 23:07:25 +00:00
|
|
|
* @pool: (transfer none) (nullable): 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
|
|
|
*
|
2018-02-09 23:07:25 +00:00
|
|
|
* Returns: (transfer full) (nullable): the #GstRTSPAddressPool of @factory. g_object_unref() after
|
2012-11-14 16:23:59 +00:00
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2016-03-02 17:42:13 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_multicast_iface:
|
2017-04-13 17:20:10 +00:00
|
|
|
* @factory: a #GstRTSPMediaFactory
|
2018-02-09 23:07:25 +00:00
|
|
|
* @multicast_iface: (transfer none) (nullable): a multicast interface name
|
2016-03-02 17:42:13 +00:00
|
|
|
*
|
2017-04-13 17:20:10 +00:00
|
|
|
* configure @multicast_iface to be used for @factory.
|
2016-03-02 17:42:13 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_multicast_iface (GstRTSPMediaFactory * media_factory,
|
|
|
|
const gchar * multicast_iface)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
gchar *old;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (media_factory));
|
|
|
|
|
|
|
|
priv = media_factory->priv;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (media_factory, "set multicast interface %s", multicast_iface);
|
|
|
|
|
|
|
|
g_mutex_lock (&priv->lock);
|
|
|
|
if ((old = priv->multicast_iface) != multicast_iface)
|
|
|
|
priv->multicast_iface = multicast_iface ? g_strdup (multicast_iface) : NULL;
|
|
|
|
else
|
|
|
|
old = NULL;
|
|
|
|
g_mutex_unlock (&priv->lock);
|
|
|
|
|
|
|
|
if (old)
|
2016-09-18 13:58:55 +00:00
|
|
|
g_free (old);
|
2016-03-02 17:42:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_multicast_iface:
|
2017-04-13 17:20:10 +00:00
|
|
|
* @factory: a #GstRTSPMediaFactory
|
2016-03-02 17:42:13 +00:00
|
|
|
*
|
2017-04-13 17:20:10 +00:00
|
|
|
* Get the multicast interface used for @factory.
|
2016-03-02 17:42:13 +00:00
|
|
|
*
|
2018-02-09 23:07:25 +00:00
|
|
|
* Returns: (transfer full) (nullable): the multicast interface for @factory. g_free() after
|
2016-03-02 17:42:13 +00:00
|
|
|
* usage.
|
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
gst_rtsp_media_factory_get_multicast_iface (GstRTSPMediaFactory * media_factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
gchar *result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (media_factory), NULL);
|
|
|
|
|
|
|
|
priv = media_factory->priv;
|
|
|
|
|
|
|
|
g_mutex_lock (&priv->lock);
|
|
|
|
if ((result = priv->multicast_iface))
|
|
|
|
result = g_strdup (result);
|
|
|
|
g_mutex_unlock (&priv->lock);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-03-03 15:55:48 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_profiles:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @profiles: the new flags
|
|
|
|
*
|
|
|
|
* Configure the allowed profiles for @factory.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_profiles (GstRTSPMediaFactory * factory,
|
|
|
|
GstRTSPProfile profiles)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (factory, "profiles %d", profiles);
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv->profiles = profiles;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_profiles:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get the allowed profiles of @factory.
|
|
|
|
*
|
|
|
|
* Returns: a #GstRTSPProfile
|
|
|
|
*/
|
|
|
|
GstRTSPProfile
|
|
|
|
gst_rtsp_media_factory_get_profiles (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
GstRTSPProfile res;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory),
|
|
|
|
GST_RTSP_PROFILE_UNKNOWN);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
res = priv->profiles;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2014-03-03 15:55:48 +00:00
|
|
|
GST_DEBUG_OBJECT (factory, "protocols %d", protocols);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-12-09 16:24:24 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_stop_on_disconnect:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @stop_on_disconnect: the new value
|
|
|
|
*
|
|
|
|
* Configure if media created from this factory should be stopped
|
|
|
|
* when a client disconnects without sending TEARDOWN.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_stop_on_disconnect (GstRTSPMediaFactory * factory,
|
|
|
|
gboolean stop_on_disconnect)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv->stop_on_disconnect = stop_on_disconnect;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_is_stop_on_disconnect:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get if media created from this factory should be stopped when a client
|
|
|
|
* disconnects without sending TEARDOWN.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the media will be stopped when a client disconnects
|
|
|
|
* without sending TEARDOWN.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_rtsp_media_factory_is_stop_on_disonnect (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), TRUE);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
result = priv->stop_on_disconnect;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-11-26 14:12:36 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_retransmission_time:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @time: a #GstClockTime
|
|
|
|
*
|
|
|
|
* Configure the time to store for possible retransmission
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_retransmission_time (GstRTSPMediaFactory * factory,
|
|
|
|
GstClockTime time)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (factory, "retransmission time %" G_GUINT64_FORMAT, time);
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv->rtx_time = time;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_retransmission_time:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get the time that is stored for retransmission purposes
|
|
|
|
*
|
|
|
|
* Returns: a #GstClockTime
|
|
|
|
*/
|
|
|
|
GstClockTime
|
|
|
|
gst_rtsp_media_factory_get_retransmission_time (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
GstClockTime res;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), 0);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
res = priv->rtx_time;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2018-03-29 20:49:26 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_do_retransmission:
|
|
|
|
*
|
|
|
|
* Set whether retransmission requests will be sent for
|
|
|
|
* receiving media
|
|
|
|
*
|
|
|
|
* Since: 1.16
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_do_retransmission (GstRTSPMediaFactory * factory,
|
2018-04-04 07:06:06 +00:00
|
|
|
gboolean do_retransmission)
|
2018-03-29 20:49:26 +00:00
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (factory, "Do retransmission %d", do_retransmission);
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv->do_retransmission = do_retransmission;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_do_retransmission:
|
|
|
|
*
|
|
|
|
* Returns: Whether retransmission requests will be sent for receiving media
|
|
|
|
*
|
|
|
|
* Since: 1.16
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_rtsp_media_factory_get_do_retransmission (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), 0);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
res = priv->do_retransmission;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2015-01-19 12:20:39 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_latency:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @latency: latency in milliseconds
|
|
|
|
*
|
|
|
|
* Configure the latency used for receiving media
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_latency (GstRTSPMediaFactory * factory,
|
|
|
|
guint latency)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (factory, "latency %ums", latency);
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv->latency = latency;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_latency:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get the latency that is used for receiving media
|
|
|
|
*
|
|
|
|
* Returns: latency in milliseconds
|
|
|
|
*/
|
|
|
|
guint
|
|
|
|
gst_rtsp_media_factory_get_latency (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
guint res;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), 0);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
res = priv->latency;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
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
|
2013-03-22 22:25:07 +00:00
|
|
|
media_unprepared (GstRTSPMedia * media, GWeakRef * ref)
|
2009-04-03 20:46:22 +00:00
|
|
|
{
|
2013-03-22 22:25:07 +00:00
|
|
|
GstRTSPMediaFactory *factory = g_weak_ref_get (ref);
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
if (!factory)
|
|
|
|
return;
|
|
|
|
|
2015-03-10 09:39:22 +00:00
|
|
|
priv = factory->priv;
|
2012-11-29 10:11:05 +00:00
|
|
|
|
|
|
|
g_mutex_lock (&priv->medias_lock);
|
|
|
|
g_hash_table_foreach_remove (priv->medias, (GHRFunc) compare_media, media);
|
|
|
|
g_mutex_unlock (&priv->medias_lock);
|
2013-03-22 22:25:07 +00:00
|
|
|
|
|
|
|
g_object_unref (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GWeakRef *
|
|
|
|
weak_ref_new (gpointer obj)
|
|
|
|
{
|
2023-01-24 20:13:50 +00:00
|
|
|
GWeakRef *ref = g_new (GWeakRef, 1);
|
2013-03-22 22:25:07 +00:00
|
|
|
|
|
|
|
g_weak_ref_init (ref, obj);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weak_ref_free (GWeakRef * ref)
|
|
|
|
{
|
|
|
|
g_weak_ref_clear (ref);
|
2023-01-24 20:13:50 +00:00
|
|
|
g_free (ref);
|
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
|
|
|
*
|
2023-05-11 18:09:25 +00:00
|
|
|
* The returned media will be locked and must be unlocked afterwards.
|
|
|
|
*
|
2022-10-15 09:40:04 +00:00
|
|
|
* Returns: (transfer full) (nullable): 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);
|
|
|
|
|
2015-03-10 09:39:22 +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);
|
2023-05-11 18:09:25 +00:00
|
|
|
if (media) {
|
2009-01-29 16:20:27 +00:00
|
|
|
g_object_ref (media);
|
2023-05-11 18:09:25 +00:00
|
|
|
g_mutex_unlock (&priv->medias_lock);
|
|
|
|
|
|
|
|
/* now need to check if the media is curently in the process of being
|
|
|
|
* unprepared. That always happens while the lock is taken, so take it
|
|
|
|
* here now and then check if we can really use the media */
|
|
|
|
gst_rtsp_media_lock (media);
|
|
|
|
if (!gst_rtsp_media_can_be_shared (media)) {
|
|
|
|
gst_rtsp_media_unlock (media);
|
|
|
|
g_object_unref (media);
|
|
|
|
media = NULL;
|
|
|
|
}
|
2009-01-29 16:20:27 +00:00
|
|
|
|
2023-05-11 18:09:25 +00:00
|
|
|
if (media) {
|
|
|
|
if (key)
|
|
|
|
g_free (key);
|
|
|
|
|
|
|
|
GST_INFO ("reusing cached media %p for url %s", media, url->abspath);
|
|
|
|
|
|
|
|
return media;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_mutex_lock (&priv->medias_lock);
|
|
|
|
}
|
|
|
|
}
|
2009-01-29 16:20:27 +00:00
|
|
|
|
2023-05-11 18:09:25 +00:00
|
|
|
/* nothing cached found, try to create one */
|
|
|
|
if (klass->construct) {
|
|
|
|
media = klass->construct (factory, url);
|
|
|
|
if (media)
|
2011-08-16 13:03:06 +00:00
|
|
|
g_signal_emit (factory,
|
2023-05-11 18:09:25 +00:00
|
|
|
gst_rtsp_media_factory_signals[SIGNAL_MEDIA_CONSTRUCTED], 0, media,
|
2011-08-16 13:03:06 +00:00
|
|
|
NULL);
|
2023-05-11 18:09:25 +00:00
|
|
|
}
|
2011-08-16 13:03:06 +00:00
|
|
|
|
2023-05-11 18:09:25 +00:00
|
|
|
if (media) {
|
|
|
|
gst_rtsp_media_lock (media);
|
|
|
|
|
|
|
|
/* configure the media */
|
|
|
|
if (klass->configure)
|
|
|
|
klass->configure (factory, media);
|
|
|
|
|
|
|
|
g_signal_emit (factory,
|
|
|
|
gst_rtsp_media_factory_signals[SIGNAL_MEDIA_CONFIGURE], 0, media, NULL);
|
|
|
|
|
|
|
|
/* check if we can cache this media */
|
|
|
|
if (gst_rtsp_media_is_shared (media) && key) {
|
|
|
|
/* insert in the hashtable, takes ownership of the key */
|
|
|
|
g_object_ref (media);
|
|
|
|
g_hash_table_insert (priv->medias, key, media);
|
|
|
|
key = NULL;
|
|
|
|
}
|
|
|
|
if (!gst_rtsp_media_is_reusable (media)) {
|
|
|
|
/* when not reusable, connect to the unprepare signal to remove the item
|
|
|
|
* from our cache when it gets unprepared */
|
|
|
|
g_signal_connect_data (media, "unprepared",
|
|
|
|
(GCallback) media_unprepared, weak_ref_new (factory),
|
|
|
|
(GClosureNotify) weak_ref_free, 0);
|
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;
|
|
|
|
}
|
|
|
|
|
2015-03-02 14:49:42 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_media_gtype:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @media_gtype: the GType of the class to create
|
|
|
|
*
|
|
|
|
* Configure the GType of the GstRTSPMedia subclass to
|
|
|
|
* create (by default, overridden construct vmethods
|
|
|
|
* may of course do something different)
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_media_gtype (GstRTSPMediaFactory * factory,
|
|
|
|
GType media_gtype)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (g_type_is_a (media_gtype, GST_TYPE_RTSP_MEDIA));
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv = factory->priv;
|
|
|
|
priv->media_gtype = media_gtype;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_media_gtype:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Return the GType of the GstRTSPMedia subclass this
|
|
|
|
* factory will create.
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
GType
|
|
|
|
gst_rtsp_media_factory_get_media_gtype (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
GType ret;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv = factory->priv;
|
|
|
|
ret = priv->media_gtype;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-12-30 14:31:13 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_clock:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
2018-02-13 17:59:16 +00:00
|
|
|
* @clock: (nullable): the clock to be used by the media factory
|
2015-12-30 14:31:13 +00:00
|
|
|
*
|
|
|
|
* Configures a specific clock to be used by the pipelines
|
|
|
|
* of all medias created from this factory.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_clock (GstRTSPMediaFactory * factory,
|
|
|
|
GstClock * clock)
|
|
|
|
{
|
2018-07-12 18:01:54 +00:00
|
|
|
GstClock **clock_p;
|
2015-12-30 14:31:13 +00:00
|
|
|
|
2018-07-12 18:01:54 +00:00
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
2015-12-30 14:31:13 +00:00
|
|
|
g_return_if_fail (GST_IS_CLOCK (clock) || clock == NULL);
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2018-07-12 18:01:54 +00:00
|
|
|
clock_p = &factory->priv->clock;
|
|
|
|
gst_object_replace ((GstObject **) clock_p, (GstObject *) clock);
|
2015-12-30 14:31:13 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_clock:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Returns the clock that is going to be used by the pipelines
|
|
|
|
* of all medias created from this factory.
|
|
|
|
*
|
2022-10-15 09:40:04 +00:00
|
|
|
* Returns: (transfer full) (nullable): The GstClock
|
2015-12-30 14:31:13 +00:00
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
GstClock *
|
|
|
|
gst_rtsp_media_factory_get_clock (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
GstClock *ret;
|
|
|
|
|
2018-07-12 18:01:54 +00:00
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
|
|
|
|
|
2015-12-30 14:31:13 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv = factory->priv;
|
|
|
|
ret = priv->clock ? gst_object_ref (priv->clock) : NULL;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-12-30 16:39:05 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_publish_clock_mode:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @mode: the clock publish mode
|
|
|
|
*
|
|
|
|
* Sets if and how the media clock should be published according to RFC7273.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_publish_clock_mode (GstRTSPMediaFactory * factory,
|
|
|
|
GstRTSPPublishClockMode mode)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv = factory->priv;
|
|
|
|
priv->publish_clock_mode = mode;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_publish_clock_mode:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Gets if and how the media clock should be published according to RFC7273.
|
|
|
|
*
|
|
|
|
* Returns: The GstRTSPPublishClockMode
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
GstRTSPPublishClockMode
|
|
|
|
gst_rtsp_media_factory_get_publish_clock_mode (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
GstRTSPPublishClockMode ret;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv = factory->priv;
|
|
|
|
ret = priv->publish_clock_mode;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-07-24 07:35:46 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_max_mcast_ttl:
|
|
|
|
* @factory: a #GstRTSPMedia
|
|
|
|
* @ttl: the new multicast ttl value
|
|
|
|
*
|
|
|
|
* Set the maximum time-to-live value of outgoing multicast packets.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the requested ttl has been set successfully.
|
2019-04-23 11:38:05 +00:00
|
|
|
*
|
|
|
|
* Since: 1.16
|
2018-07-24 07:35:46 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_rtsp_media_factory_set_max_mcast_ttl (GstRTSPMediaFactory * factory,
|
|
|
|
guint ttl)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), FALSE);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
if (ttl == 0 || ttl > DEFAULT_MAX_MCAST_TTL) {
|
|
|
|
GST_WARNING_OBJECT (factory, "The requested mcast TTL value is not valid.");
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
priv->max_mcast_ttl = ttl;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_get_max_mcast_ttl:
|
|
|
|
* @factory: a #GstRTSPMedia
|
|
|
|
*
|
|
|
|
* Get the the maximum time-to-live value of outgoing multicast packets.
|
|
|
|
*
|
|
|
|
* Returns: the maximum time-to-live value of outgoing multicast packets.
|
2019-04-23 11:38:05 +00:00
|
|
|
*
|
|
|
|
* Since: 1.16
|
2018-07-24 07:35:46 +00:00
|
|
|
*/
|
|
|
|
guint
|
|
|
|
gst_rtsp_media_factory_get_max_mcast_ttl (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
guint result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), 0);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
result = priv->max_mcast_ttl;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-09-06 14:17:33 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_bind_mcast_address:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @bind_mcast_addr: the new value
|
|
|
|
*
|
|
|
|
* Decide whether the multicast socket should be bound to a multicast address or
|
|
|
|
* INADDR_ANY.
|
2019-04-23 11:38:05 +00:00
|
|
|
*
|
|
|
|
* Since: 1.16
|
2018-09-06 14:17:33 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_bind_mcast_address (GstRTSPMediaFactory * factory,
|
|
|
|
gboolean bind_mcast_addr)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv->bind_mcast_address = bind_mcast_addr;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_is_bind_mcast_address:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Check if multicast sockets are configured to be bound to multicast addresses.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if multicast sockets are configured to be bound to multicast addresses.
|
2019-04-23 11:38:05 +00:00
|
|
|
*
|
|
|
|
* Since: 1.16
|
2018-09-06 14:17:33 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_rtsp_media_factory_is_bind_mcast_address (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), FALSE);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
result = priv->bind_mcast_address;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-04 19:14:35 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_set_enable_rtcp:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
* @enable: the new value
|
|
|
|
*
|
|
|
|
* Decide whether the created media should send and receive RTCP
|
|
|
|
*
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_media_factory_set_enable_rtcp (GstRTSPMediaFactory * factory,
|
|
|
|
gboolean enable)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
priv->enable_rtcp = enable;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_media_factory_is_enable_rtcp:
|
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Check if created media will send and receive RTCP
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if created media will send and receive RTCP
|
|
|
|
*
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_rtsp_media_factory_is_enable_rtcp (GstRTSPMediaFactory * factory)
|
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), FALSE);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
result = priv->enable_rtcp;
|
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-01-29 16:20:27 +00:00
|
|
|
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;
|
2015-08-12 05:33:44 +00:00
|
|
|
guint16 port;
|
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 : "";
|
|
|
|
|
2015-08-12 05:33:44 +00:00
|
|
|
gst_rtsp_url_get_port (url, &port);
|
|
|
|
|
|
|
|
result = g_strdup_printf ("%u%s%s%s", 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 */
|
2016-12-01 16:04:34 +00:00
|
|
|
element =
|
|
|
|
gst_parse_launch_full (priv->launch, NULL, GST_PARSE_FLAG_PLACE_IN_BIN,
|
|
|
|
&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:
|
|
|
|
{
|
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"));
|
2013-02-18 19:59:58 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
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;
|
2015-03-02 14:49:42 +00:00
|
|
|
GType media_gtype;
|
2020-09-04 19:14:35 +00:00
|
|
|
gboolean enable_rtcp;
|
2009-05-23 14:18:04 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-03-02 14:49:42 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
|
|
|
media_gtype = factory->priv->media_gtype;
|
2020-09-04 19:14:35 +00:00
|
|
|
enable_rtcp = factory->priv->enable_rtcp;
|
2015-03-02 14:49:42 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
2009-05-23 14:18:04 +00:00
|
|
|
/* create a new empty media */
|
2016-12-02 14:38:04 +00:00
|
|
|
media =
|
|
|
|
g_object_new (media_gtype, "element", element, "transport-mode",
|
|
|
|
factory->priv->transport_mode, NULL);
|
2009-05-23 14:18:04 +00:00
|
|
|
|
2020-09-04 19:14:35 +00:00
|
|
|
/* We need to call this prior to collecting streams */
|
|
|
|
gst_rtsp_media_set_enable_rtcp (media, enable_rtcp);
|
2023-06-26 06:25:36 +00:00
|
|
|
gst_rtsp_media_set_ensure_keyunit_on_start (media,
|
|
|
|
gst_rtsp_media_factory_get_ensure_keyunit_on_start (factory));
|
2020-09-04 19:14:35 +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");
|
2015-12-30 14:30:38 +00:00
|
|
|
|
|
|
|
/* FIXME 2.0: This should be done by the caller, not the vfunc. Every
|
|
|
|
* implementation of the vfunc has to call it otherwise at the end.
|
|
|
|
* Also it does not allow use to add further behaviour here that could
|
|
|
|
* be reused by subclasses that chain up */
|
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;
|
2015-12-09 16:24:24 +00:00
|
|
|
gboolean shared, eos_shutdown, stop_on_disconnect;
|
2011-01-31 16:37:02 +00:00
|
|
|
guint size;
|
2023-06-26 06:25:36 +00:00
|
|
|
gboolean ensure_keyunit_on_start;
|
|
|
|
guint ensure_keyunit_on_start_timeout;
|
2015-03-03 13:42:07 +00:00
|
|
|
gint dscp_qos;
|
2013-11-28 13:10:19 +00:00
|
|
|
GstRTSPSuspendMode suspend_mode;
|
2014-03-03 15:55:48 +00:00
|
|
|
GstRTSPProfile profiles;
|
2011-08-16 13:15:19 +00:00
|
|
|
GstRTSPLowerTrans protocols;
|
2012-11-14 16:23:59 +00:00
|
|
|
GstRTSPAddressPool *pool;
|
2013-07-09 14:38:39 +00:00
|
|
|
GstRTSPPermissions *perms;
|
2014-11-26 14:12:36 +00:00
|
|
|
GstClockTime rtx_time;
|
2015-01-19 12:20:39 +00:00
|
|
|
guint latency;
|
2015-01-28 17:54:01 +00:00
|
|
|
GstRTSPTransportMode transport_mode;
|
2015-12-30 14:31:13 +00:00
|
|
|
GstClock *clock;
|
2016-03-02 17:42:13 +00:00
|
|
|
gchar *multicast_iface;
|
2015-12-30 16:39:05 +00:00
|
|
|
GstRTSPPublishClockMode publish_clock_mode;
|
2018-07-24 07:35:46 +00:00
|
|
|
guint ttl;
|
2018-09-06 14:17:33 +00:00
|
|
|
gboolean bind_mcast;
|
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);
|
2013-11-28 13:10:19 +00:00
|
|
|
suspend_mode = priv->suspend_mode;
|
2012-11-29 10:11:05 +00:00
|
|
|
shared = priv->shared;
|
|
|
|
eos_shutdown = priv->eos_shutdown;
|
|
|
|
size = priv->buffer_size;
|
2023-06-26 06:25:36 +00:00
|
|
|
ensure_keyunit_on_start = priv->ensure_keyunit_on_start;
|
|
|
|
ensure_keyunit_on_start_timeout = priv->ensure_keyunit_on_start_timeout;
|
2015-03-03 13:42:07 +00:00
|
|
|
dscp_qos = priv->dscp_qos;
|
2014-03-03 15:55:48 +00:00
|
|
|
profiles = priv->profiles;
|
2012-11-29 10:11:05 +00:00
|
|
|
protocols = priv->protocols;
|
2014-11-26 14:12:36 +00:00
|
|
|
rtx_time = priv->rtx_time;
|
2015-01-19 12:20:39 +00:00
|
|
|
latency = priv->latency;
|
2015-01-28 17:54:01 +00:00
|
|
|
transport_mode = priv->transport_mode;
|
2015-12-09 16:24:24 +00:00
|
|
|
stop_on_disconnect = priv->stop_on_disconnect;
|
2015-12-30 14:31:13 +00:00
|
|
|
clock = priv->clock ? gst_object_ref (priv->clock) : NULL;
|
2015-12-30 16:39:05 +00:00
|
|
|
publish_clock_mode = priv->publish_clock_mode;
|
2018-07-24 07:35:46 +00:00
|
|
|
ttl = priv->max_mcast_ttl;
|
2018-09-06 14:17:33 +00:00
|
|
|
bind_mcast = priv->bind_mcast_address;
|
2010-12-11 12:41:24 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
2009-01-29 16:20:27 +00:00
|
|
|
|
2013-11-28 13:10:19 +00:00
|
|
|
gst_rtsp_media_set_suspend_mode (media, suspend_mode);
|
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);
|
2023-06-26 06:25:36 +00:00
|
|
|
gst_rtsp_media_set_ensure_keyunit_on_start (media, ensure_keyunit_on_start);
|
|
|
|
gst_rtsp_media_set_ensure_keyunit_on_start_timeout (media,
|
|
|
|
ensure_keyunit_on_start_timeout);
|
2015-03-03 13:42:07 +00:00
|
|
|
gst_rtsp_media_set_dscp_qos (media, dscp_qos);
|
2014-03-03 15:55:48 +00:00
|
|
|
gst_rtsp_media_set_profiles (media, profiles);
|
2011-08-16 13:15:19 +00:00
|
|
|
gst_rtsp_media_set_protocols (media, protocols);
|
2014-11-26 14:12:36 +00:00
|
|
|
gst_rtsp_media_set_retransmission_time (media, rtx_time);
|
2018-03-29 20:49:26 +00:00
|
|
|
gst_rtsp_media_set_do_retransmission (media, priv->do_retransmission);
|
2015-01-19 12:20:39 +00:00
|
|
|
gst_rtsp_media_set_latency (media, latency);
|
2015-01-28 17:54:01 +00:00
|
|
|
gst_rtsp_media_set_transport_mode (media, transport_mode);
|
2015-12-09 16:24:24 +00:00
|
|
|
gst_rtsp_media_set_stop_on_disconnect (media, stop_on_disconnect);
|
2015-12-30 16:39:05 +00:00
|
|
|
gst_rtsp_media_set_publish_clock_mode (media, publish_clock_mode);
|
2018-07-24 07:35:46 +00:00
|
|
|
gst_rtsp_media_set_max_mcast_ttl (media, ttl);
|
2018-09-06 14:17:33 +00:00
|
|
|
gst_rtsp_media_set_bind_mcast_address (media, bind_mcast);
|
2011-01-12 12:57:09 +00:00
|
|
|
|
2015-12-30 14:31:13 +00:00
|
|
|
if (clock) {
|
|
|
|
gst_rtsp_media_set_clock (media, clock);
|
|
|
|
gst_object_unref (clock);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2016-03-02 17:42:13 +00:00
|
|
|
if ((multicast_iface = gst_rtsp_media_factory_get_multicast_iface (factory))) {
|
|
|
|
gst_rtsp_media_set_multicast_iface (media, multicast_iface);
|
|
|
|
g_free (multicast_iface);
|
|
|
|
}
|
2013-07-09 14:38:39 +00:00
|
|
|
if ((perms = gst_rtsp_media_factory_get_permissions (factory))) {
|
|
|
|
gst_rtsp_media_set_permissions (media, perms);
|
|
|
|
gst_rtsp_permissions_unref (perms);
|
|
|
|
}
|
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.
|
|
|
|
*
|
2013-11-22 00:30:53 +00:00
|
|
|
* The bin should contain payloaders pay\%d for each stream. The default
|
2012-10-25 19:29:58 +00:00
|
|
|
* implementation of this function returns the bin created from the
|
|
|
|
* launch parameter.
|
|
|
|
*
|
2022-10-15 09:40:04 +00:00
|
|
|
* Returns: (transfer floating) (nullable): a new #GstElement.
|
2012-10-12 04:11:36 +00:00
|
|
|
*/
|
|
|
|
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
|
|
|
}
|
2015-01-09 11:40:47 +00:00
|
|
|
|
|
|
|
/**
|
2015-01-28 17:54:01 +00:00
|
|
|
* gst_rtsp_media_factory_set_transport_mode:
|
2015-01-09 11:40:47 +00:00
|
|
|
* @factory: a #GstRTSPMediaFactory
|
2015-01-28 17:54:01 +00:00
|
|
|
* @mode: the new value
|
2015-01-09 11:40:47 +00:00
|
|
|
*
|
2015-01-28 17:54:01 +00:00
|
|
|
* Configure if this factory creates media for PLAY or RECORD modes.
|
2015-01-09 11:40:47 +00:00
|
|
|
*/
|
|
|
|
void
|
2015-01-28 17:54:01 +00:00
|
|
|
gst_rtsp_media_factory_set_transport_mode (GstRTSPMediaFactory * factory,
|
|
|
|
GstRTSPTransportMode mode)
|
2015-01-09 11:40:47 +00:00
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2015-01-28 17:54:01 +00:00
|
|
|
priv->transport_mode = mode;
|
2015-01-09 11:40:47 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-01-28 17:54:01 +00:00
|
|
|
* gst_rtsp_media_factory_get_transport_mode:
|
2015-01-09 11:40:47 +00:00
|
|
|
* @factory: a #GstRTSPMediaFactory
|
|
|
|
*
|
|
|
|
* Get if media created from this factory can be used for PLAY or RECORD
|
|
|
|
* methods.
|
|
|
|
*
|
2017-10-26 12:43:19 +00:00
|
|
|
* Returns: The transport mode.
|
2015-01-09 11:40:47 +00:00
|
|
|
*/
|
2015-01-28 17:54:01 +00:00
|
|
|
GstRTSPTransportMode
|
|
|
|
gst_rtsp_media_factory_get_transport_mode (GstRTSPMediaFactory * factory)
|
2015-01-09 11:40:47 +00:00
|
|
|
{
|
|
|
|
GstRTSPMediaFactoryPrivate *priv;
|
2015-01-28 17:54:01 +00:00
|
|
|
GstRTSPTransportMode result;
|
2015-01-09 11:40:47 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), FALSE);
|
|
|
|
|
|
|
|
priv = factory->priv;
|
|
|
|
|
|
|
|
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
|
2015-01-28 17:54:01 +00:00
|
|
|
result = priv->transport_mode;
|
2015-01-09 11:40:47 +00:00
|
|
|
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|