2 * Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
3 * Copyright (C) 2015 Centricular Ltd
4 * Author: Sebastian Dröge <sebastian@centricular.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 * SECTION:rtsp-media-factory
23 * @short_description: A factory for media pipelines
24 * @see_also: #GstRTSPMountPoints, #GstRTSPMedia
26 * The #GstRTSPMediaFactory is responsible for creating or recycling
27 * #GstRTSPMedia objects based on the passed URL.
29 * The default implementation of the object can create #GstRTSPMedia objects
30 * containing a pipeline created from a launch description set with
31 * gst_rtsp_media_factory_set_launch().
33 * Media from a factory can be shared by setting the shared flag with
34 * gst_rtsp_media_factory_set_shared(). When a factory is shared,
35 * gst_rtsp_media_factory_construct() will return the same #GstRTSPMedia when
38 * Last reviewed on 2013-07-11 (1.0.0)
41 #include "rtsp-media-factory.h"
43 #define GST_RTSP_MEDIA_FACTORY_GET_PRIVATE(obj) \
44 (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_RTSP_MEDIA_FACTORY, GstRTSPMediaFactoryPrivate))
46 #define GST_RTSP_MEDIA_FACTORY_GET_LOCK(f) (&(GST_RTSP_MEDIA_FACTORY_CAST(f)->priv->lock))
47 #define GST_RTSP_MEDIA_FACTORY_LOCK(f) (g_mutex_lock(GST_RTSP_MEDIA_FACTORY_GET_LOCK(f)))
48 #define GST_RTSP_MEDIA_FACTORY_UNLOCK(f) (g_mutex_unlock(GST_RTSP_MEDIA_FACTORY_GET_LOCK(f)))
50 struct _GstRTSPMediaFactoryPrivate
52 GMutex lock; /* protects everything but medias */
53 GstRTSPPermissions *permissions;
56 GstRTSPSuspendMode suspend_mode;
57 gboolean eos_shutdown;
58 GstRTSPProfile profiles;
59 GstRTSPLowerTrans protocols;
61 GstRTSPAddressPool *pool;
62 GstRTSPTransportMode transport_mode;
63 gboolean stop_on_disconnect;
64 gchar *multicast_iface;
66 GstClockTime rtx_time;
70 GHashTable *medias; /* protected by medias_lock */
76 GstRTSPPublishClockMode publish_clock_mode;
79 #define DEFAULT_LAUNCH NULL
80 #define DEFAULT_SHARED FALSE
81 #define DEFAULT_SUSPEND_MODE GST_RTSP_SUSPEND_MODE_NONE
82 #define DEFAULT_EOS_SHUTDOWN FALSE
83 #define DEFAULT_PROFILES GST_RTSP_PROFILE_AVP
84 #define DEFAULT_PROTOCOLS GST_RTSP_LOWER_TRANS_UDP | GST_RTSP_LOWER_TRANS_UDP_MCAST | \
85 GST_RTSP_LOWER_TRANS_TCP
86 #define DEFAULT_BUFFER_SIZE 0x80000
87 #define DEFAULT_LATENCY 200
88 #define DEFAULT_TRANSPORT_MODE GST_RTSP_TRANSPORT_MODE_PLAY
89 #define DEFAULT_STOP_ON_DISCONNECT TRUE
103 PROP_STOP_ON_DISCONNECT,
110 SIGNAL_MEDIA_CONSTRUCTED,
111 SIGNAL_MEDIA_CONFIGURE,
115 GST_DEBUG_CATEGORY_STATIC (rtsp_media_debug);
116 #define GST_CAT_DEFAULT rtsp_media_debug
118 static guint gst_rtsp_media_factory_signals[SIGNAL_LAST] = { 0 };
120 static void gst_rtsp_media_factory_get_property (GObject * object, guint propid,
121 GValue * value, GParamSpec * pspec);
122 static void gst_rtsp_media_factory_set_property (GObject * object, guint propid,
123 const GValue * value, GParamSpec * pspec);
124 static void gst_rtsp_media_factory_finalize (GObject * obj);
126 static gchar *default_gen_key (GstRTSPMediaFactory * factory,
127 const GstRTSPUrl * url);
128 static GstElement *default_create_element (GstRTSPMediaFactory * factory,
129 const GstRTSPUrl * url);
130 static GstRTSPMedia *default_construct (GstRTSPMediaFactory * factory,
131 const GstRTSPUrl * url);
132 static void default_configure (GstRTSPMediaFactory * factory,
133 GstRTSPMedia * media);
134 static GstElement *default_create_pipeline (GstRTSPMediaFactory * factory,
135 GstRTSPMedia * media);
137 G_DEFINE_TYPE (GstRTSPMediaFactory, gst_rtsp_media_factory, G_TYPE_OBJECT);
140 gst_rtsp_media_factory_class_init (GstRTSPMediaFactoryClass * klass)
142 GObjectClass *gobject_class;
144 g_type_class_add_private (klass, sizeof (GstRTSPMediaFactoryPrivate));
146 gobject_class = G_OBJECT_CLASS (klass);
148 gobject_class->get_property = gst_rtsp_media_factory_get_property;
149 gobject_class->set_property = gst_rtsp_media_factory_set_property;
150 gobject_class->finalize = gst_rtsp_media_factory_finalize;
153 * GstRTSPMediaFactory::launch:
155 * The gst_parse_launch() line to use for constructing the pipeline in the
156 * default prepare vmethod.
158 * The pipeline description should return a GstBin as the toplevel element
159 * which can be accomplished by enclosing the description with brackets '('
162 * The description should return a pipeline with payloaders named pay0, pay1,
163 * etc.. Each of the payloaders will result in a stream.
165 * Support for dynamic payloaders can be accomplished by adding payloaders
166 * named dynpay0, dynpay1, etc..
168 g_object_class_install_property (gobject_class, PROP_LAUNCH,
169 g_param_spec_string ("launch", "Launch",
170 "A launch description of the pipeline", DEFAULT_LAUNCH,
171 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
173 g_object_class_install_property (gobject_class, PROP_SHARED,
174 g_param_spec_boolean ("shared", "Shared",
175 "If media from this factory is shared", DEFAULT_SHARED,
176 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
178 g_object_class_install_property (gobject_class, PROP_SUSPEND_MODE,
179 g_param_spec_enum ("suspend-mode", "Suspend Mode",
180 "Control how media will be suspended", GST_TYPE_RTSP_SUSPEND_MODE,
181 DEFAULT_SUSPEND_MODE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
183 g_object_class_install_property (gobject_class, PROP_EOS_SHUTDOWN,
184 g_param_spec_boolean ("eos-shutdown", "EOS Shutdown",
185 "Send EOS down the pipeline before shutting down",
186 DEFAULT_EOS_SHUTDOWN, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
188 g_object_class_install_property (gobject_class, PROP_PROFILES,
189 g_param_spec_flags ("profiles", "Profiles",
190 "Allowed transfer profiles", GST_TYPE_RTSP_PROFILE,
191 DEFAULT_PROFILES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
193 g_object_class_install_property (gobject_class, PROP_PROTOCOLS,
194 g_param_spec_flags ("protocols", "Protocols",
195 "Allowed lower transport protocols", GST_TYPE_RTSP_LOWER_TRANS,
196 DEFAULT_PROTOCOLS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
198 g_object_class_install_property (gobject_class, PROP_BUFFER_SIZE,
199 g_param_spec_uint ("buffer-size", "Buffer Size",
200 "The kernel UDP buffer size to use", 0, G_MAXUINT,
201 DEFAULT_BUFFER_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
203 g_object_class_install_property (gobject_class, PROP_LATENCY,
204 g_param_spec_uint ("latency", "Latency",
205 "Latency used for receiving media in milliseconds", 0, G_MAXUINT,
206 DEFAULT_LATENCY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
208 g_object_class_install_property (gobject_class, PROP_TRANSPORT_MODE,
209 g_param_spec_flags ("transport-mode", "Transport Mode",
210 "If media from this factory is for PLAY or RECORD",
211 GST_TYPE_RTSP_TRANSPORT_MODE, DEFAULT_TRANSPORT_MODE,
212 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
214 g_object_class_install_property (gobject_class, PROP_STOP_ON_DISCONNECT,
215 g_param_spec_boolean ("stop-on-disconnect", "Stop On Disconnect",
216 "If media from this factory should be stopped "
217 "when a client disconnects without TEARDOWN",
218 DEFAULT_STOP_ON_DISCONNECT,
219 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
221 g_object_class_install_property (gobject_class, PROP_CLOCK,
222 g_param_spec_object ("clock", "Clock",
223 "Clock to be used by the pipelines created for all "
224 "medias of this factory", GST_TYPE_CLOCK,
225 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
227 gst_rtsp_media_factory_signals[SIGNAL_MEDIA_CONSTRUCTED] =
228 g_signal_new ("media-constructed", G_TYPE_FROM_CLASS (klass),
229 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRTSPMediaFactoryClass,
230 media_constructed), NULL, NULL, g_cclosure_marshal_generic,
231 G_TYPE_NONE, 1, GST_TYPE_RTSP_MEDIA);
233 gst_rtsp_media_factory_signals[SIGNAL_MEDIA_CONFIGURE] =
234 g_signal_new ("media-configure", G_TYPE_FROM_CLASS (klass),
235 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRTSPMediaFactoryClass,
236 media_configure), NULL, NULL, g_cclosure_marshal_generic,
237 G_TYPE_NONE, 1, GST_TYPE_RTSP_MEDIA);
239 klass->gen_key = default_gen_key;
240 klass->create_element = default_create_element;
241 klass->construct = default_construct;
242 klass->configure = default_configure;
243 klass->create_pipeline = default_create_pipeline;
245 GST_DEBUG_CATEGORY_INIT (rtsp_media_debug, "rtspmediafactory", 0,
246 "GstRTSPMediaFactory");
250 gst_rtsp_media_factory_init (GstRTSPMediaFactory * factory)
252 GstRTSPMediaFactoryPrivate *priv =
253 GST_RTSP_MEDIA_FACTORY_GET_PRIVATE (factory);
254 factory->priv = priv;
256 priv->launch = g_strdup (DEFAULT_LAUNCH);
257 priv->shared = DEFAULT_SHARED;
258 priv->suspend_mode = DEFAULT_SUSPEND_MODE;
259 priv->eos_shutdown = DEFAULT_EOS_SHUTDOWN;
260 priv->profiles = DEFAULT_PROFILES;
261 priv->protocols = DEFAULT_PROTOCOLS;
262 priv->buffer_size = DEFAULT_BUFFER_SIZE;
263 priv->latency = DEFAULT_LATENCY;
264 priv->transport_mode = DEFAULT_TRANSPORT_MODE;
265 priv->stop_on_disconnect = DEFAULT_STOP_ON_DISCONNECT;
266 priv->publish_clock_mode = GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK;
268 g_mutex_init (&priv->lock);
269 g_mutex_init (&priv->medias_lock);
270 priv->medias = g_hash_table_new_full (g_str_hash, g_str_equal,
271 g_free, g_object_unref);
272 priv->media_gtype = GST_TYPE_RTSP_MEDIA;
276 gst_rtsp_media_factory_finalize (GObject * obj)
278 GstRTSPMediaFactory *factory = GST_RTSP_MEDIA_FACTORY (obj);
279 GstRTSPMediaFactoryPrivate *priv = factory->priv;
281 if (priv->permissions)
282 gst_rtsp_permissions_unref (priv->permissions);
283 g_hash_table_unref (priv->medias);
284 g_mutex_clear (&priv->medias_lock);
285 g_free (priv->launch);
286 g_mutex_clear (&priv->lock);
288 g_object_unref (priv->pool);
289 g_free (priv->multicast_iface);
291 G_OBJECT_CLASS (gst_rtsp_media_factory_parent_class)->finalize (obj);
295 gst_rtsp_media_factory_get_property (GObject * object, guint propid,
296 GValue * value, GParamSpec * pspec)
298 GstRTSPMediaFactory *factory = GST_RTSP_MEDIA_FACTORY (object);
302 g_value_take_string (value, gst_rtsp_media_factory_get_launch (factory));
305 g_value_set_boolean (value, gst_rtsp_media_factory_is_shared (factory));
307 case PROP_SUSPEND_MODE:
308 g_value_set_enum (value,
309 gst_rtsp_media_factory_get_suspend_mode (factory));
311 case PROP_EOS_SHUTDOWN:
312 g_value_set_boolean (value,
313 gst_rtsp_media_factory_is_eos_shutdown (factory));
316 g_value_set_flags (value, gst_rtsp_media_factory_get_profiles (factory));
319 g_value_set_flags (value, gst_rtsp_media_factory_get_protocols (factory));
321 case PROP_BUFFER_SIZE:
322 g_value_set_uint (value,
323 gst_rtsp_media_factory_get_buffer_size (factory));
326 g_value_set_uint (value, gst_rtsp_media_factory_get_latency (factory));
328 case PROP_TRANSPORT_MODE:
329 g_value_set_flags (value,
330 gst_rtsp_media_factory_get_transport_mode (factory));
332 case PROP_STOP_ON_DISCONNECT:
333 g_value_set_boolean (value,
334 gst_rtsp_media_factory_is_stop_on_disonnect (factory));
337 g_value_take_object (value, gst_rtsp_media_factory_get_clock (factory));
340 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
345 gst_rtsp_media_factory_set_property (GObject * object, guint propid,
346 const GValue * value, GParamSpec * pspec)
348 GstRTSPMediaFactory *factory = GST_RTSP_MEDIA_FACTORY (object);
352 gst_rtsp_media_factory_set_launch (factory, g_value_get_string (value));
355 gst_rtsp_media_factory_set_shared (factory, g_value_get_boolean (value));
357 case PROP_SUSPEND_MODE:
358 gst_rtsp_media_factory_set_suspend_mode (factory,
359 g_value_get_enum (value));
361 case PROP_EOS_SHUTDOWN:
362 gst_rtsp_media_factory_set_eos_shutdown (factory,
363 g_value_get_boolean (value));
366 gst_rtsp_media_factory_set_profiles (factory, g_value_get_flags (value));
369 gst_rtsp_media_factory_set_protocols (factory, g_value_get_flags (value));
371 case PROP_BUFFER_SIZE:
372 gst_rtsp_media_factory_set_buffer_size (factory,
373 g_value_get_uint (value));
376 gst_rtsp_media_factory_set_latency (factory, g_value_get_uint (value));
378 case PROP_TRANSPORT_MODE:
379 gst_rtsp_media_factory_set_transport_mode (factory,
380 g_value_get_flags (value));
382 case PROP_STOP_ON_DISCONNECT:
383 gst_rtsp_media_factory_set_stop_on_disconnect (factory,
384 g_value_get_boolean (value));
387 gst_rtsp_media_factory_set_clock (factory, g_value_get_object (value));
390 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
395 * gst_rtsp_media_factory_new:
397 * Create a new #GstRTSPMediaFactory instance.
399 * Returns: (transfer full): a new #GstRTSPMediaFactory object.
401 GstRTSPMediaFactory *
402 gst_rtsp_media_factory_new (void)
404 GstRTSPMediaFactory *result;
406 result = g_object_new (GST_TYPE_RTSP_MEDIA_FACTORY, NULL);
412 * gst_rtsp_media_factory_set_permissions:
413 * @factory: a #GstRTSPMediaFactory
414 * @permissions: (transfer none): a #GstRTSPPermissions
416 * Set @permissions on @factory.
419 gst_rtsp_media_factory_set_permissions (GstRTSPMediaFactory * factory,
420 GstRTSPPermissions * permissions)
422 GstRTSPMediaFactoryPrivate *priv;
424 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
426 priv = factory->priv;
428 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
429 if (priv->permissions)
430 gst_rtsp_permissions_unref (priv->permissions);
431 if ((priv->permissions = permissions))
432 gst_rtsp_permissions_ref (permissions);
433 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
437 * gst_rtsp_media_factory_get_permissions:
438 * @factory: a #GstRTSPMediaFactory
440 * Get the permissions object from @factory.
442 * Returns: (transfer full): a #GstRTSPPermissions object, unref after usage.
445 gst_rtsp_media_factory_get_permissions (GstRTSPMediaFactory * factory)
447 GstRTSPMediaFactoryPrivate *priv;
448 GstRTSPPermissions *result;
450 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
452 priv = factory->priv;
454 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
455 if ((result = priv->permissions))
456 gst_rtsp_permissions_ref (result);
457 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
463 * gst_rtsp_media_factory_add_role:
464 * @factory: a #GstRTSPMediaFactory
466 * @fieldname: the first field name
467 * @...: additional arguments
469 * A convenience method to add @role with @fieldname and additional arguments to
470 * the permissions of @factory. If @factory had no permissions, new permissions
471 * will be created and the role will be added to it.
474 gst_rtsp_media_factory_add_role (GstRTSPMediaFactory * factory,
475 const gchar * role, const gchar * fieldname, ...)
477 GstRTSPMediaFactoryPrivate *priv;
480 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
481 g_return_if_fail (role != NULL);
482 g_return_if_fail (fieldname != NULL);
484 priv = factory->priv;
486 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
487 if (priv->permissions == NULL)
488 priv->permissions = gst_rtsp_permissions_new ();
490 va_start (var_args, fieldname);
491 gst_rtsp_permissions_add_role_valist (priv->permissions, role, fieldname,
494 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
498 * gst_rtsp_media_factory_set_launch:
499 * @factory: a #GstRTSPMediaFactory
500 * @launch: the launch description
503 * The gst_parse_launch() line to use for constructing the pipeline in the
504 * default prepare vmethod.
506 * The pipeline description should return a GstBin as the toplevel element
507 * which can be accomplished by enclosing the description with brackets '('
510 * The description should return a pipeline with payloaders named pay0, pay1,
511 * etc.. Each of the payloaders will result in a stream.
514 gst_rtsp_media_factory_set_launch (GstRTSPMediaFactory * factory,
515 const gchar * launch)
517 GstRTSPMediaFactoryPrivate *priv;
519 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
520 g_return_if_fail (launch != NULL);
522 priv = factory->priv;
524 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
525 g_free (priv->launch);
526 priv->launch = g_strdup (launch);
527 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
531 * gst_rtsp_media_factory_get_launch:
532 * @factory: a #GstRTSPMediaFactory
534 * Get the gst_parse_launch() pipeline description that will be used in the
535 * default prepare vmethod.
537 * Returns: (transfer full): the configured launch description. g_free() after
541 gst_rtsp_media_factory_get_launch (GstRTSPMediaFactory * factory)
543 GstRTSPMediaFactoryPrivate *priv;
546 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
548 priv = factory->priv;
550 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
551 result = g_strdup (priv->launch);
552 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
558 * gst_rtsp_media_factory_set_suspend_mode:
559 * @factory: a #GstRTSPMediaFactory
560 * @mode: the new #GstRTSPSuspendMode
562 * Configure how media created from this factory will be suspended.
565 gst_rtsp_media_factory_set_suspend_mode (GstRTSPMediaFactory * factory,
566 GstRTSPSuspendMode mode)
568 GstRTSPMediaFactoryPrivate *priv;
570 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
572 priv = factory->priv;
574 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
575 priv->suspend_mode = mode;
576 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
580 * gst_rtsp_media_factory_get_suspend_mode:
581 * @factory: a #GstRTSPMediaFactory
583 * Get how media created from this factory will be suspended.
585 * Returns: a #GstRTSPSuspendMode.
588 gst_rtsp_media_factory_get_suspend_mode (GstRTSPMediaFactory * factory)
590 GstRTSPMediaFactoryPrivate *priv;
591 GstRTSPSuspendMode result;
593 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory),
594 GST_RTSP_SUSPEND_MODE_NONE);
596 priv = factory->priv;
598 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
599 result = priv->suspend_mode;
600 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
606 * gst_rtsp_media_factory_set_shared:
607 * @factory: a #GstRTSPMediaFactory
608 * @shared: the new value
610 * Configure if media created from this factory can be shared between clients.
613 gst_rtsp_media_factory_set_shared (GstRTSPMediaFactory * factory,
616 GstRTSPMediaFactoryPrivate *priv;
618 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
620 priv = factory->priv;
622 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
623 priv->shared = shared;
624 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
628 * gst_rtsp_media_factory_is_shared:
629 * @factory: a #GstRTSPMediaFactory
631 * Get if media created from this factory can be shared between clients.
633 * Returns: %TRUE if the media will be shared between clients.
636 gst_rtsp_media_factory_is_shared (GstRTSPMediaFactory * factory)
638 GstRTSPMediaFactoryPrivate *priv;
641 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), FALSE);
643 priv = factory->priv;
645 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
646 result = priv->shared;
647 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
653 * gst_rtsp_media_factory_set_eos_shutdown:
654 * @factory: a #GstRTSPMediaFactory
655 * @eos_shutdown: the new value
657 * Configure if media created from this factory will have an EOS sent to the
658 * pipeline before shutdown.
661 gst_rtsp_media_factory_set_eos_shutdown (GstRTSPMediaFactory * factory,
662 gboolean eos_shutdown)
664 GstRTSPMediaFactoryPrivate *priv;
666 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
668 priv = factory->priv;
670 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
671 priv->eos_shutdown = eos_shutdown;
672 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
676 * gst_rtsp_media_factory_is_eos_shutdown:
677 * @factory: a #GstRTSPMediaFactory
679 * Get if media created from this factory will have an EOS event sent to the
680 * pipeline before shutdown.
682 * Returns: %TRUE if the media will receive EOS before shutdown.
685 gst_rtsp_media_factory_is_eos_shutdown (GstRTSPMediaFactory * factory)
687 GstRTSPMediaFactoryPrivate *priv;
690 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), FALSE);
692 priv = factory->priv;
694 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
695 result = priv->eos_shutdown;
696 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
702 * gst_rtsp_media_factory_set_buffer_size:
703 * @factory: a #GstRTSPMedia
704 * @size: the new value
706 * Set the kernel UDP buffer size.
709 gst_rtsp_media_factory_set_buffer_size (GstRTSPMediaFactory * factory,
712 GstRTSPMediaFactoryPrivate *priv;
714 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
716 priv = factory->priv;
718 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
719 priv->buffer_size = size;
720 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
724 * gst_rtsp_media_factory_get_buffer_size:
725 * @factory: a #GstRTSPMedia
727 * Get the kernel UDP buffer size.
729 * Returns: the kernel UDP buffer size.
732 gst_rtsp_media_factory_get_buffer_size (GstRTSPMediaFactory * factory)
734 GstRTSPMediaFactoryPrivate *priv;
737 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), 0);
739 priv = factory->priv;
741 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
742 result = priv->buffer_size;
743 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
749 * gst_rtsp_media_factory_set_address_pool:
750 * @factory: a #GstRTSPMediaFactory
751 * @pool: (transfer none): a #GstRTSPAddressPool
753 * configure @pool to be used as the address pool of @factory.
756 gst_rtsp_media_factory_set_address_pool (GstRTSPMediaFactory * factory,
757 GstRTSPAddressPool * pool)
759 GstRTSPMediaFactoryPrivate *priv;
760 GstRTSPAddressPool *old;
762 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
764 priv = factory->priv;
766 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
767 if ((old = priv->pool) != pool)
768 priv->pool = pool ? g_object_ref (pool) : NULL;
771 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
774 g_object_unref (old);
778 * gst_rtsp_media_factory_get_address_pool:
779 * @factory: a #GstRTSPMediaFactory
781 * Get the #GstRTSPAddressPool used as the address pool of @factory.
783 * Returns: (transfer full): the #GstRTSPAddressPool of @factory. g_object_unref() after
787 gst_rtsp_media_factory_get_address_pool (GstRTSPMediaFactory * factory)
789 GstRTSPMediaFactoryPrivate *priv;
790 GstRTSPAddressPool *result;
792 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
794 priv = factory->priv;
796 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
797 if ((result = priv->pool))
798 g_object_ref (result);
799 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
805 * gst_rtsp_media_factory_set_multicast_iface:
806 * @factory: a #GstRTSPMediaFactory
807 * @multicast_iface: (transfer none): a multicast interface name
809 * configure @multicast_iface to be used for @factory.
812 gst_rtsp_media_factory_set_multicast_iface (GstRTSPMediaFactory * media_factory,
813 const gchar * multicast_iface)
815 GstRTSPMediaFactoryPrivate *priv;
818 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (media_factory));
820 priv = media_factory->priv;
822 GST_LOG_OBJECT (media_factory, "set multicast interface %s", multicast_iface);
824 g_mutex_lock (&priv->lock);
825 if ((old = priv->multicast_iface) != multicast_iface)
826 priv->multicast_iface = multicast_iface ? g_strdup (multicast_iface) : NULL;
829 g_mutex_unlock (&priv->lock);
836 * gst_rtsp_media_factory_get_multicast_iface:
837 * @factory: a #GstRTSPMediaFactory
839 * Get the multicast interface used for @factory.
841 * Returns: (transfer full): the multicast interface for @factory. g_free() after
845 gst_rtsp_media_factory_get_multicast_iface (GstRTSPMediaFactory * media_factory)
847 GstRTSPMediaFactoryPrivate *priv;
850 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (media_factory), NULL);
852 priv = media_factory->priv;
854 g_mutex_lock (&priv->lock);
855 if ((result = priv->multicast_iface))
856 result = g_strdup (result);
857 g_mutex_unlock (&priv->lock);
863 * gst_rtsp_media_factory_set_profiles:
864 * @factory: a #GstRTSPMediaFactory
865 * @profiles: the new flags
867 * Configure the allowed profiles for @factory.
870 gst_rtsp_media_factory_set_profiles (GstRTSPMediaFactory * factory,
871 GstRTSPProfile profiles)
873 GstRTSPMediaFactoryPrivate *priv;
875 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
877 priv = factory->priv;
879 GST_DEBUG_OBJECT (factory, "profiles %d", profiles);
881 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
882 priv->profiles = profiles;
883 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
887 * gst_rtsp_media_factory_get_profiles:
888 * @factory: a #GstRTSPMediaFactory
890 * Get the allowed profiles of @factory.
892 * Returns: a #GstRTSPProfile
895 gst_rtsp_media_factory_get_profiles (GstRTSPMediaFactory * factory)
897 GstRTSPMediaFactoryPrivate *priv;
900 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory),
901 GST_RTSP_PROFILE_UNKNOWN);
903 priv = factory->priv;
905 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
906 res = priv->profiles;
907 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
913 * gst_rtsp_media_factory_set_protocols:
914 * @factory: a #GstRTSPMediaFactory
915 * @protocols: the new flags
917 * Configure the allowed lower transport for @factory.
920 gst_rtsp_media_factory_set_protocols (GstRTSPMediaFactory * factory,
921 GstRTSPLowerTrans protocols)
923 GstRTSPMediaFactoryPrivate *priv;
925 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
927 priv = factory->priv;
929 GST_DEBUG_OBJECT (factory, "protocols %d", protocols);
931 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
932 priv->protocols = protocols;
933 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
937 * gst_rtsp_media_factory_get_protocols:
938 * @factory: a #GstRTSPMediaFactory
940 * Get the allowed protocols of @factory.
942 * Returns: a #GstRTSPLowerTrans
945 gst_rtsp_media_factory_get_protocols (GstRTSPMediaFactory * factory)
947 GstRTSPMediaFactoryPrivate *priv;
948 GstRTSPLowerTrans res;
950 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory),
951 GST_RTSP_LOWER_TRANS_UNKNOWN);
953 priv = factory->priv;
955 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
956 res = priv->protocols;
957 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
963 * gst_rtsp_media_factory_set_stop_on_disconnect:
964 * @factory: a #GstRTSPMediaFactory
965 * @stop_on_disconnect: the new value
967 * Configure if media created from this factory should be stopped
968 * when a client disconnects without sending TEARDOWN.
971 gst_rtsp_media_factory_set_stop_on_disconnect (GstRTSPMediaFactory * factory,
972 gboolean stop_on_disconnect)
974 GstRTSPMediaFactoryPrivate *priv;
976 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
978 priv = factory->priv;
980 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
981 priv->stop_on_disconnect = stop_on_disconnect;
982 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
986 * gst_rtsp_media_factory_is_stop_on_disconnect:
987 * @factory: a #GstRTSPMediaFactory
989 * Get if media created from this factory should be stopped when a client
990 * disconnects without sending TEARDOWN.
992 * Returns: %TRUE if the media will be stopped when a client disconnects
993 * without sending TEARDOWN.
996 gst_rtsp_media_factory_is_stop_on_disonnect (GstRTSPMediaFactory * factory)
998 GstRTSPMediaFactoryPrivate *priv;
1001 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), TRUE);
1003 priv = factory->priv;
1005 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1006 result = priv->stop_on_disconnect;
1007 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1013 * gst_rtsp_media_factory_set_retransmission_time:
1014 * @factory: a #GstRTSPMediaFactory
1015 * @time: a #GstClockTime
1017 * Configure the time to store for possible retransmission
1020 gst_rtsp_media_factory_set_retransmission_time (GstRTSPMediaFactory * factory,
1023 GstRTSPMediaFactoryPrivate *priv;
1025 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
1027 priv = factory->priv;
1029 GST_DEBUG_OBJECT (factory, "retransmission time %" G_GUINT64_FORMAT, time);
1031 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1032 priv->rtx_time = time;
1033 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1037 * gst_rtsp_media_factory_get_retransmission_time:
1038 * @factory: a #GstRTSPMediaFactory
1040 * Get the time that is stored for retransmission purposes
1042 * Returns: a #GstClockTime
1045 gst_rtsp_media_factory_get_retransmission_time (GstRTSPMediaFactory * factory)
1047 GstRTSPMediaFactoryPrivate *priv;
1050 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), 0);
1052 priv = factory->priv;
1054 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1055 res = priv->rtx_time;
1056 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1062 * gst_rtsp_media_factory_set_latency:
1063 * @factory: a #GstRTSPMediaFactory
1064 * @latency: latency in milliseconds
1066 * Configure the latency used for receiving media
1069 gst_rtsp_media_factory_set_latency (GstRTSPMediaFactory * factory,
1072 GstRTSPMediaFactoryPrivate *priv;
1074 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
1076 priv = factory->priv;
1078 GST_DEBUG_OBJECT (factory, "latency %ums", latency);
1080 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1081 priv->latency = latency;
1082 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1086 * gst_rtsp_media_factory_get_latency:
1087 * @factory: a #GstRTSPMediaFactory
1089 * Get the latency that is used for receiving media
1091 * Returns: latency in milliseconds
1094 gst_rtsp_media_factory_get_latency (GstRTSPMediaFactory * factory)
1096 GstRTSPMediaFactoryPrivate *priv;
1099 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), 0);
1101 priv = factory->priv;
1103 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1104 res = priv->latency;
1105 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1111 compare_media (gpointer key, GstRTSPMedia * media1, GstRTSPMedia * media2)
1113 return (media1 == media2);
1117 media_unprepared (GstRTSPMedia * media, GWeakRef * ref)
1119 GstRTSPMediaFactory *factory = g_weak_ref_get (ref);
1120 GstRTSPMediaFactoryPrivate *priv;
1125 priv = factory->priv;
1127 g_mutex_lock (&priv->medias_lock);
1128 g_hash_table_foreach_remove (priv->medias, (GHRFunc) compare_media, media);
1129 g_mutex_unlock (&priv->medias_lock);
1131 g_object_unref (factory);
1135 weak_ref_new (gpointer obj)
1137 GWeakRef *ref = g_slice_new (GWeakRef);
1139 g_weak_ref_init (ref, obj);
1144 weak_ref_free (GWeakRef * ref)
1146 g_weak_ref_clear (ref);
1147 g_slice_free (GWeakRef, ref);
1151 * gst_rtsp_media_factory_construct:
1152 * @factory: a #GstRTSPMediaFactory
1153 * @url: the url used
1155 * Construct the media object and create its streams. Implementations
1156 * should create the needed gstreamer elements and add them to the result
1157 * object. No state changes should be performed on them yet.
1159 * One or more GstRTSPStream objects should be created from the result
1160 * with gst_rtsp_media_create_stream ().
1162 * After the media is constructed, it can be configured and then prepared
1163 * with gst_rtsp_media_prepare ().
1165 * Returns: (transfer full): a new #GstRTSPMedia if the media could be prepared.
1168 gst_rtsp_media_factory_construct (GstRTSPMediaFactory * factory,
1169 const GstRTSPUrl * url)
1171 GstRTSPMediaFactoryPrivate *priv;
1173 GstRTSPMedia *media;
1174 GstRTSPMediaFactoryClass *klass;
1176 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
1177 g_return_val_if_fail (url != NULL, NULL);
1179 priv = factory->priv;
1180 klass = GST_RTSP_MEDIA_FACTORY_GET_CLASS (factory);
1182 /* convert the url to a key for the hashtable. NULL return or a NULL function
1183 * will not cache anything for this factory. */
1185 key = klass->gen_key (factory, url);
1189 g_mutex_lock (&priv->medias_lock);
1191 /* we have a key, see if we find a cached media */
1192 media = g_hash_table_lookup (priv->medias, key);
1194 g_object_ref (media);
1198 if (media == NULL) {
1199 /* nothing cached found, try to create one */
1200 if (klass->construct) {
1201 media = klass->construct (factory, url);
1203 g_signal_emit (factory,
1204 gst_rtsp_media_factory_signals[SIGNAL_MEDIA_CONSTRUCTED], 0, media,
1210 /* configure the media */
1211 if (klass->configure)
1212 klass->configure (factory, media);
1214 g_signal_emit (factory,
1215 gst_rtsp_media_factory_signals[SIGNAL_MEDIA_CONFIGURE], 0, media,
1218 /* check if we can cache this media */
1219 if (gst_rtsp_media_is_shared (media) && key) {
1220 /* insert in the hashtable, takes ownership of the key */
1221 g_object_ref (media);
1222 g_hash_table_insert (priv->medias, key, media);
1225 if (!gst_rtsp_media_is_reusable (media)) {
1226 /* when not reusable, connect to the unprepare signal to remove the item
1227 * from our cache when it gets unprepared */
1228 g_signal_connect_data (media, "unprepared",
1229 (GCallback) media_unprepared, weak_ref_new (factory),
1230 (GClosureNotify) weak_ref_free, 0);
1234 g_mutex_unlock (&priv->medias_lock);
1239 GST_INFO ("constructed media %p for url %s", media, url->abspath);
1245 * gst_rtsp_media_factory_set_media_gtype:
1246 * @factory: a #GstRTSPMediaFactory
1247 * @media_gtype: the GType of the class to create
1249 * Configure the GType of the GstRTSPMedia subclass to
1250 * create (by default, overridden construct vmethods
1251 * may of course do something different)
1256 gst_rtsp_media_factory_set_media_gtype (GstRTSPMediaFactory * factory,
1259 GstRTSPMediaFactoryPrivate *priv;
1261 g_return_if_fail (g_type_is_a (media_gtype, GST_TYPE_RTSP_MEDIA));
1263 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1264 priv = factory->priv;
1265 priv->media_gtype = media_gtype;
1266 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1270 * gst_rtsp_media_factory_get_media_gtype:
1271 * @factory: a #GstRTSPMediaFactory
1273 * Return the GType of the GstRTSPMedia subclass this
1274 * factory will create.
1279 gst_rtsp_media_factory_get_media_gtype (GstRTSPMediaFactory * factory)
1281 GstRTSPMediaFactoryPrivate *priv;
1284 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1285 priv = factory->priv;
1286 ret = priv->media_gtype;
1287 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1293 * gst_rtsp_media_factory_set_clock:
1294 * @factory: a #GstRTSPMediaFactory
1295 * @clock: the clock to be used by the media factory
1297 * Configures a specific clock to be used by the pipelines
1298 * of all medias created from this factory.
1303 gst_rtsp_media_factory_set_clock (GstRTSPMediaFactory * factory,
1306 GstRTSPMediaFactoryPrivate *priv;
1308 g_return_if_fail (GST_IS_CLOCK (clock) || clock == NULL);
1310 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1311 priv = factory->priv;
1312 priv->clock = clock ? gst_object_ref (clock) : NULL;
1313 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1317 * gst_rtsp_media_factory_get_clock:
1318 * @factory: a #GstRTSPMediaFactory
1320 * Returns the clock that is going to be used by the pipelines
1321 * of all medias created from this factory.
1323 * Returns: (transfer full): The GstClock
1328 gst_rtsp_media_factory_get_clock (GstRTSPMediaFactory * factory)
1330 GstRTSPMediaFactoryPrivate *priv;
1333 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1334 priv = factory->priv;
1335 ret = priv->clock ? gst_object_ref (priv->clock) : NULL;
1336 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1342 * gst_rtsp_media_factory_set_publish_clock_mode:
1343 * @factory: a #GstRTSPMediaFactory
1344 * @mode: the clock publish mode
1346 * Sets if and how the media clock should be published according to RFC7273.
1351 gst_rtsp_media_factory_set_publish_clock_mode (GstRTSPMediaFactory * factory,
1352 GstRTSPPublishClockMode mode)
1354 GstRTSPMediaFactoryPrivate *priv;
1356 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1357 priv = factory->priv;
1358 priv->publish_clock_mode = mode;
1359 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1363 * gst_rtsp_media_factory_get_publish_clock_mode:
1364 * @factory: a #GstRTSPMediaFactory
1366 * Gets if and how the media clock should be published according to RFC7273.
1368 * Returns: The GstRTSPPublishClockMode
1372 GstRTSPPublishClockMode
1373 gst_rtsp_media_factory_get_publish_clock_mode (GstRTSPMediaFactory * factory)
1375 GstRTSPMediaFactoryPrivate *priv;
1376 GstRTSPPublishClockMode ret;
1378 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1379 priv = factory->priv;
1380 ret = priv->publish_clock_mode;
1381 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1387 default_gen_key (GstRTSPMediaFactory * factory, const GstRTSPUrl * url)
1390 const gchar *pre_query;
1394 pre_query = url->query ? "?" : "";
1395 query = url->query ? url->query : "";
1397 gst_rtsp_url_get_port (url, &port);
1399 result = g_strdup_printf ("%u%s%s%s", port, url->abspath, pre_query, query);
1405 default_create_element (GstRTSPMediaFactory * factory, const GstRTSPUrl * url)
1407 GstRTSPMediaFactoryPrivate *priv = factory->priv;
1408 GstElement *element;
1409 GError *error = NULL;
1411 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1412 /* we need a parse syntax */
1413 if (priv->launch == NULL)
1416 /* parse the user provided launch line */
1418 gst_parse_launch_full (priv->launch, NULL, GST_PARSE_FLAG_PLACE_IN_BIN,
1420 if (element == NULL)
1423 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1425 if (error != NULL) {
1426 /* a recoverable error was encountered */
1427 GST_WARNING ("recoverable parsing error: %s", error->message);
1428 g_error_free (error);
1435 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1436 g_critical ("no launch line specified");
1441 g_critical ("could not parse launch syntax (%s): %s", priv->launch,
1442 (error ? error->message : "unknown reason"));
1443 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1445 g_error_free (error);
1450 static GstRTSPMedia *
1451 default_construct (GstRTSPMediaFactory * factory, const GstRTSPUrl * url)
1453 GstRTSPMedia *media;
1454 GstElement *element, *pipeline;
1455 GstRTSPMediaFactoryClass *klass;
1458 klass = GST_RTSP_MEDIA_FACTORY_GET_CLASS (factory);
1460 if (!klass->create_pipeline)
1463 element = gst_rtsp_media_factory_create_element (factory, url);
1464 if (element == NULL)
1467 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1468 media_gtype = factory->priv->media_gtype;
1469 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1471 /* create a new empty media */
1473 g_object_new (media_gtype, "element", element, "transport-mode",
1474 factory->priv->transport_mode, NULL);
1476 gst_rtsp_media_collect_streams (media);
1478 pipeline = klass->create_pipeline (factory, media);
1479 if (pipeline == NULL)
1487 g_critical ("no create_pipeline function");
1492 g_critical ("could not create element");
1497 g_critical ("can't create pipeline");
1498 g_object_unref (media);
1504 default_create_pipeline (GstRTSPMediaFactory * factory, GstRTSPMedia * media)
1506 GstElement *pipeline;
1508 pipeline = gst_pipeline_new ("media-pipeline");
1510 /* FIXME 2.0: This should be done by the caller, not the vfunc. Every
1511 * implementation of the vfunc has to call it otherwise at the end.
1512 * Also it does not allow use to add further behaviour here that could
1513 * be reused by subclasses that chain up */
1514 gst_rtsp_media_take_pipeline (media, GST_PIPELINE_CAST (pipeline));
1520 default_configure (GstRTSPMediaFactory * factory, GstRTSPMedia * media)
1522 GstRTSPMediaFactoryPrivate *priv = factory->priv;
1523 gboolean shared, eos_shutdown, stop_on_disconnect;
1525 GstRTSPSuspendMode suspend_mode;
1526 GstRTSPProfile profiles;
1527 GstRTSPLowerTrans protocols;
1528 GstRTSPAddressPool *pool;
1529 GstRTSPPermissions *perms;
1530 GstClockTime rtx_time;
1532 GstRTSPTransportMode transport_mode;
1534 gchar *multicast_iface;
1535 GstRTSPPublishClockMode publish_clock_mode;
1537 /* configure the sharedness */
1538 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1539 suspend_mode = priv->suspend_mode;
1540 shared = priv->shared;
1541 eos_shutdown = priv->eos_shutdown;
1542 size = priv->buffer_size;
1543 profiles = priv->profiles;
1544 protocols = priv->protocols;
1545 rtx_time = priv->rtx_time;
1546 latency = priv->latency;
1547 transport_mode = priv->transport_mode;
1548 stop_on_disconnect = priv->stop_on_disconnect;
1549 clock = priv->clock ? gst_object_ref (priv->clock) : NULL;
1550 publish_clock_mode = priv->publish_clock_mode;
1551 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1553 gst_rtsp_media_set_suspend_mode (media, suspend_mode);
1554 gst_rtsp_media_set_shared (media, shared);
1555 gst_rtsp_media_set_eos_shutdown (media, eos_shutdown);
1556 gst_rtsp_media_set_buffer_size (media, size);
1557 gst_rtsp_media_set_profiles (media, profiles);
1558 gst_rtsp_media_set_protocols (media, protocols);
1559 gst_rtsp_media_set_retransmission_time (media, rtx_time);
1560 gst_rtsp_media_set_latency (media, latency);
1561 gst_rtsp_media_set_transport_mode (media, transport_mode);
1562 gst_rtsp_media_set_stop_on_disconnect (media, stop_on_disconnect);
1563 gst_rtsp_media_set_publish_clock_mode (media, publish_clock_mode);
1566 gst_rtsp_media_set_clock (media, clock);
1567 gst_object_unref (clock);
1570 if ((pool = gst_rtsp_media_factory_get_address_pool (factory))) {
1571 gst_rtsp_media_set_address_pool (media, pool);
1572 g_object_unref (pool);
1574 if ((multicast_iface = gst_rtsp_media_factory_get_multicast_iface (factory))) {
1575 gst_rtsp_media_set_multicast_iface (media, multicast_iface);
1576 g_free (multicast_iface);
1578 if ((perms = gst_rtsp_media_factory_get_permissions (factory))) {
1579 gst_rtsp_media_set_permissions (media, perms);
1580 gst_rtsp_permissions_unref (perms);
1585 * gst_rtsp_media_factory_create_element:
1586 * @factory: a #GstRTSPMediaFactory
1587 * @url: the url used
1589 * Construct and return a #GstElement that is a #GstBin containing
1590 * the elements to use for streaming the media.
1592 * The bin should contain payloaders pay\%d for each stream. The default
1593 * implementation of this function returns the bin created from the
1596 * Returns: (transfer floating): a new #GstElement.
1599 gst_rtsp_media_factory_create_element (GstRTSPMediaFactory * factory,
1600 const GstRTSPUrl * url)
1602 GstRTSPMediaFactoryClass *klass;
1605 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
1606 g_return_val_if_fail (url != NULL, NULL);
1608 klass = GST_RTSP_MEDIA_FACTORY_GET_CLASS (factory);
1610 if (klass->create_element)
1611 result = klass->create_element (factory, url);
1619 * gst_rtsp_media_factory_set_transport_mode:
1620 * @factory: a #GstRTSPMediaFactory
1621 * @mode: the new value
1623 * Configure if this factory creates media for PLAY or RECORD modes.
1626 gst_rtsp_media_factory_set_transport_mode (GstRTSPMediaFactory * factory,
1627 GstRTSPTransportMode mode)
1629 GstRTSPMediaFactoryPrivate *priv;
1631 g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
1633 priv = factory->priv;
1635 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1636 priv->transport_mode = mode;
1637 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
1641 * gst_rtsp_media_factory_get_transport_mode:
1642 * @factory: a #GstRTSPMediaFactory
1644 * Get if media created from this factory can be used for PLAY or RECORD
1647 * Returns: The supported transport modes.
1649 GstRTSPTransportMode
1650 gst_rtsp_media_factory_get_transport_mode (GstRTSPMediaFactory * factory)
1652 GstRTSPMediaFactoryPrivate *priv;
1653 GstRTSPTransportMode result;
1655 g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), FALSE);
1657 priv = factory->priv;
1659 GST_RTSP_MEDIA_FACTORY_LOCK (factory);
1660 result = priv->transport_mode;
1661 GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);