From e417d83dceea9db2cafbdfc788300ff3bf7106d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20P=C3=B6lsterl?= Date: Fri, 12 Jun 2009 17:45:29 +0200 Subject: [PATCH] Added vmethod create_pipeline to GstRTSPMediaFactory The pipeline is created in this method and the GstRTSPMedia's element is added to it --- gst/rtsp-server/rtsp-media-factory.c | 22 ++++++++++++++++++++++ gst/rtsp-server/rtsp-media-factory.h | 3 +++ gst/rtsp-server/rtsp-media.c | 3 --- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/gst/rtsp-server/rtsp-media-factory.c b/gst/rtsp-server/rtsp-media-factory.c index 2a5833d8ff..fea0690ad3 100644 --- a/gst/rtsp-server/rtsp-media-factory.c +++ b/gst/rtsp-server/rtsp-media-factory.c @@ -40,6 +40,7 @@ static gchar * default_gen_key (GstRTSPMediaFactory *factory, const GstRTSPUrl * static GstElement * default_get_element (GstRTSPMediaFactory *factory, 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); G_DEFINE_TYPE (GstRTSPMediaFactory, gst_rtsp_media_factory, G_TYPE_OBJECT); @@ -79,6 +80,7 @@ gst_rtsp_media_factory_class_init (GstRTSPMediaFactoryClass * klass) klass->get_element = default_get_element; klass->construct = default_construct; klass->configure = default_configure; + klass->create_pipeline = default_create_pipeline; } static void @@ -471,6 +473,11 @@ default_construct (GstRTSPMediaFactory *factory, const GstRTSPUrl *url) media = gst_rtsp_media_new (); media->element = element; + if (!klass->create_pipeline) + goto no_pipeline; + + media->pipeline = klass->create_pipeline (factory, media); + collect_streams (factory, url, media); return media; @@ -481,6 +488,21 @@ no_element: g_critical ("could not create element"); return NULL; } +no_pipeline: + { + g_critical ("could not create pipeline"); + return FALSE; + } +} + +static GstElement* +default_create_pipeline (GstRTSPMediaFactory *factory, GstRTSPMedia *media) { + GstElement *pipeline; + + pipeline = gst_pipeline_new ("media-pipeline"); + gst_bin_add (GST_BIN_CAST (pipeline), media->element); + + return pipeline; } static void diff --git a/gst/rtsp-server/rtsp-media-factory.h b/gst/rtsp-server/rtsp-media-factory.h index ef3f6e8103..9ba51eb8f8 100644 --- a/gst/rtsp-server/rtsp-media-factory.h +++ b/gst/rtsp-server/rtsp-media-factory.h @@ -77,6 +77,8 @@ struct _GstRTSPMediaFactory { * pay%d to create the streams. * @configure: configure the media created with @construct. The default * implementation will configure the 'shared' property of the media. + * @create_pipeline: create a new pipeline or re-use an existing one and + * add the #GstRTSPMedia's element created by @construct to the pipeline. * * The #GstRTSPMediaFactory class structure. */ @@ -88,6 +90,7 @@ struct _GstRTSPMediaFactoryClass { GstElement * (*get_element) (GstRTSPMediaFactory *factory, const GstRTSPUrl *url); GstRTSPMedia * (*construct) (GstRTSPMediaFactory *factory, const GstRTSPUrl *url); void (*configure) (GstRTSPMediaFactory *factory, GstRTSPMedia *media); + GstElement * (*create_pipeline)(GstRTSPMediaFactory *factory, GstRTSPMedia *media); }; GType gst_rtsp_media_factory_get_type (void); diff --git a/gst/rtsp-server/rtsp-media.c b/gst/rtsp-server/rtsp-media.c index 49e3bca8f5..cbd4e8b53b 100644 --- a/gst/rtsp-server/rtsp-media.c +++ b/gst/rtsp-server/rtsp-media.c @@ -1268,7 +1268,6 @@ gst_rtsp_media_prepare (GstRTSPMedia *media) g_message ("preparing media %p", media); - media->pipeline = gst_pipeline_new ("media-pipeline"); bus = gst_pipeline_get_bus (GST_PIPELINE_CAST (media->pipeline)); /* add the pipeline bus to our custom mainloop */ @@ -1280,8 +1279,6 @@ gst_rtsp_media_prepare (GstRTSPMedia *media) klass = GST_RTSP_MEDIA_GET_CLASS (media); media->id = g_source_attach (media->source, klass->context); - gst_bin_add (GST_BIN_CAST (media->pipeline), media->element); - media->rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin"); /* add stuff to the bin */