2 * Copyright (C) 2015-2017 YouView TV Ltd
3 * Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
5 * gstipcslavepipeline.c:
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
23 * SECTION:element-ipcslavepipeline
24 * @see_also: #GstIpcPipelineSink, #GstIpcPipelineSrc
26 * This is a GstPipeline subclass meant to embed one ore more ipcpipelinesrc
27 * elements, and be slaved transparently to the master pipeline, using one ore
28 * more ipcpipelinesink elements on the master.
30 * The actual pipeline slaving logic happens in ipcpipelinesrc. The only thing
31 * that this class actually does is that it watches the pipeline bus for
32 * messages and forwards them to the master pipeline through the ipcpipelinesrc
33 * elements that it contains.
35 * For more details about this mechanism and its uses, see the documentation
36 * of the ipcpipelinesink element.
45 #include "gstipcpipelinesrc.h"
46 #include "gstipcslavepipeline.h"
48 GST_DEBUG_CATEGORY_STATIC (gst_ipcslavepipeline_debug);
49 #define GST_CAT_DEFAULT gst_ipcslavepipeline_debug
52 GST_DEBUG_CATEGORY_INIT (gst_ipcslavepipeline_debug, "ipcslavepipeline", 0, "ipcslavepipeline element");
53 #define gst_ipc_slave_pipeline_parent_class parent_class
54 G_DEFINE_TYPE_WITH_CODE (GstIpcSlavePipeline, gst_ipc_slave_pipeline,
55 GST_TYPE_PIPELINE, _do_init);
57 static gboolean gst_ipc_slave_pipeline_post_message (GstElement * element,
58 GstMessage * message);
61 gst_ipc_slave_pipeline_class_init (GstIpcSlavePipelineClass * klass)
63 GstElementClass *element_class;
65 element_class = GST_ELEMENT_CLASS (klass);
67 element_class->post_message = gst_ipc_slave_pipeline_post_message;
69 gst_element_class_set_static_metadata (element_class,
70 "Inter-process slave pipeline",
72 "Contains the slave part of an inter-process pipeline",
73 "Vincent Penquerc'h <vincent.penquerch@collabora.co.uk");
77 gst_ipc_slave_pipeline_init (GstIpcSlavePipeline * isp)
82 send_message_if_ipcpipelinesrc (const GValue * v, GValue * r,
88 GstMessage *message = user_data;
90 e = g_value_get_object (v);
91 et = gst_element_factory_get_element_type (gst_element_get_factory (e));
92 if (et == GST_TYPE_IPC_PIPELINE_SRC) {
93 g_signal_emit_by_name (G_OBJECT (e), "forward-message", message, &ret);
95 /* if we succesfully sent this to the master and it's not ASYNC_DONE or EOS,
96 * we can skip sending it again through the other ipcpipelinesrcs */
97 if (ret && GST_MESSAGE_TYPE (message) != GST_MESSAGE_ASYNC_DONE &&
98 GST_MESSAGE_TYPE (message) != GST_MESSAGE_EOS)
105 gst_ipc_slave_pipeline_forward_message (GstIpcSlavePipeline * pipeline,
106 GstMessage * message)
110 it = gst_bin_iterate_sources (GST_BIN (pipeline));
111 gst_iterator_fold (it, send_message_if_ipcpipelinesrc, NULL, message);
112 gst_iterator_free (it);
116 gst_ipc_slave_pipeline_post_message (GstElement * element, GstMessage * message)
118 gst_ipc_slave_pipeline_forward_message (GST_IPC_SLAVE_PIPELINE
121 return GST_ELEMENT_CLASS (parent_class)->post_message (element, message);