}
}
},
+ "encodebin2": {
+ "author": "Edward Hervey <edward.hervey@collabora.co.uk>",
+ "description": "Convenience encoding/muxing element",
+ "hierarchy": [
+ "GstEncodeBin2",
+ "GstEncodeBaseBin",
+ "GstBin",
+ "GstElement",
+ "GstObject",
+ "GInitiallyUnowned",
+ "GObject"
+ ],
+ "interfaces": [
+ "GstChildProxy"
+ ],
+ "klass": "Generic/Bin/Encoder",
+ "long-name": "Encoder Bin",
+ "pad-templates": {
+ "audio_%%u": {
+ "caps": "ANY",
+ "direction": "sink",
+ "presence": "request"
+ },
+ "private_%%u": {
+ "caps": "ANY",
+ "direction": "sink",
+ "presence": "request"
+ },
+ "src_%%u": {
+ "caps": "ANY",
+ "direction": "src",
+ "presence": "sometimes"
+ },
+ "video_%%u": {
+ "caps": "ANY",
+ "direction": "sink",
+ "presence": "request"
+ }
+ },
+ "rank": "none"
+ },
"streamcombiner": {
"author": "Edward Hervey <edward.hervey@collabora.co.uk>",
"description": "Recombines streams split by the streamsplitter element",
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
* (C) 2009 Nokia Corporation
* (C) 2016 Jan Schmidt <jan@centricular.com>
+ * (C) 2020 Thibault saunier <tsaunier@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
gobject_klass = (GObjectClass *) klass;
gstelement_klass = (GstElementClass *) klass;
+ GST_DEBUG_CATEGORY_INIT (gst_encode_base_bin_debug, "encodebasebin", 0,
+ "base encodebin");
gobject_klass->dispose = gst_encode_base_bin_dispose;
gobject_klass->set_property = gst_encode_base_bin_set_property;
gobject_klass->get_property = gst_encode_base_bin_get_property;
gst_encoding_profile_get_name (ebin->profile));
if (GST_IS_ENCODING_CONTAINER_PROFILE (ebin->profile)) {
- /* 1. Get the compatible muxer */
+ /* Get the compatible muxer */
muxer = _get_muxer (ebin);
if (G_UNLIKELY (muxer == NULL))
goto no_muxer;
ebin->muxer = muxer;
gst_bin_add ((GstBin *) ebin, muxer);
- /* 2. Ghost the muxer source pad */
-
- /* FIXME : We should figure out if it's a static/request/dyamic pad,
+ /* If the subclass exposes a static sourcepad, ghost the muxer
+ * output, otherwise expose the muxer srcpad if it has one,
+ * do not expose any srcpad if we are dealing with a muxing sink. */
+ /* FIXME : We should figure out if it's a static/request/dynamic pad,
* but for the time being let's assume it's a static pad :) */
muxerpad = gst_element_get_static_pad (muxer, "src");
- if (G_UNLIKELY (muxerpad == NULL))
- goto no_muxer_pad;
-
- if (!gst_ghost_pad_set_target (GST_GHOST_PAD (ebin->srcpad), muxerpad))
- goto no_muxer_ghost_pad;
+ if (ebin->srcpad) {
+ if (G_UNLIKELY (muxerpad == NULL))
+ goto no_muxer_pad;
+ if (!gst_ghost_pad_set_target (GST_GHOST_PAD (ebin->srcpad), muxerpad))
+ goto no_muxer_ghost_pad;
+
+ gst_object_unref (muxerpad);
+ } else if (muxerpad) {
+ GstPadTemplate *template =
+ gst_element_get_pad_template (GST_ELEMENT (ebin), "src_%u");
+ gchar *name;
+ GstPad *pad;
+
+ GST_OBJECT_LOCK (ebin);
+ name = g_strdup_printf ("src_%u", GST_ELEMENT (ebin)->numsrcpads);
+ GST_OBJECT_UNLOCK (ebin);
+
+ pad = gst_ghost_pad_new_from_template (name, muxerpad, template);
+ g_free (name);
+ if (!pad)
+ goto no_muxer_ghost_pad;
+
+ gst_element_add_pad (GST_ELEMENT (ebin), pad);
+ }
- gst_object_unref (muxerpad);
- /* 3. Activate fixed presence streams */
+ /* Activate fixed presence streams */
profiles =
gst_encoding_container_profile_get_profiles
(GST_ENCODING_CONTAINER_PROFILE (ebin->profile));
static void
gst_encode_base_bin_tear_down_profile (GstEncodeBaseBin * ebin)
{
+ GstElement *element = GST_ELEMENT (ebin);
+
if (G_UNLIKELY (ebin->profile == NULL))
return;
while (ebin->streams)
stream_group_remove (ebin, (StreamGroup *) ebin->streams->data);
- /* Set ghostpad target to NULL */
- gst_ghost_pad_set_target (GST_GHOST_PAD (ebin->srcpad), NULL);
+ if (ebin->srcpad) {
+ /* Set ghostpad target to NULL */
+ gst_ghost_pad_set_target (GST_GHOST_PAD (ebin->srcpad), NULL);
+ }
/* Remove muxer if present */
if (ebin->muxer) {
ebin->muxer = NULL;
}
+ if (!element->srcpads) {
+ while (element->srcpads)
+ gst_element_remove_pad (element, element->srcpads->data);
+ }
+
/* free/clear profile */
gst_encoding_profile_unref (ebin->profile);
ebin->profile = NULL;
/* GStreamer encoding bin
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
* (C) 2009 Nokia Corporation
+ * (C) 2016 Jan Schmidt <jan@centricular.com>
+ * (C) 2020 Thibault saunier <tsaunier@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* Boston, MA 02110-1301, USA.
*/
-#ifndef __GST_ENCODEBIN_H__
-#define __GST_ENCODEBIN_H__
+#pragma once
#include <gst/gst.h>
#include <gst/pbutils/pbutils.h>
#define GST_ENCODE_BASE_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ENCODE_BASE_BIN,GstEncodeBinClass))
#define GST_IS_ENCODE_BASE_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ENCODE_BASE_BIN))
#define GST_IS_ENCODE_BASE_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ENCODE_BASE_BIN))
+#define GST_ENCODE_BASE_BIN_GET_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS ((klass), GST_TYPE_ENCODE_BASE_BIN, GstEncodeBaseBinClass))
typedef struct _GstEncodeBaseBin GstEncodeBaseBin;
typedef struct _GstEncodeBaseBinClass GstEncodeBaseBinClass;
};
GType gst_encode_base_bin_get_type(void);
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstEncodeBaseBin, gst_object_unref)
-
-#endif /* __GST_ENCODEBIN_H__ */
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstEncodeBaseBin, gst_object_unref)
\ No newline at end of file
--- /dev/null
+/* GStreamer encoding bin
+ * Copyright (C) 2016 Jan Schmidt <jan@centricular.com>
+ * (C) 2020 Thibault saunier <tsaunier@igalia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "gstencodebasebin.h"
+#include "gstencodebin2.h"
+
+/**
+ * SECTION:element-encodebin2
+ *
+ * Encodebin2 is an updated version of #encodebin which has a request srcpad
+ * instead of having an always source pad. This makes the element more flexible
+ * and allows supporting muxing sinks for example.
+ *
+ * Based on the profile that was set (via the #GstEncodeBaseBin:profile
+ * property), EncodeBin will internally select and configure the required
+ * elements (encoders, muxers, but also audio and video converters) so that you
+ * can provide it raw or pre-encoded streams of data in input and have your
+ * encoded/muxed/converted stream in output.
+ *
+ * Since: 1.20
+ */
+
+enum
+{
+ PROP_0,
+};
+
+static GstStaticPadTemplate muxer_src_template =
+GST_STATIC_PAD_TEMPLATE ("src_%u", GST_PAD_SRC, GST_PAD_SOMETIMES,
+ GST_STATIC_CAPS_ANY);
+
+struct _GstEncodeBin2
+{
+ GstEncodeBaseBin parent;
+};
+
+G_DEFINE_TYPE (GstEncodeBin2, gst_encode_bin2, GST_TYPE_ENCODE_BASE_BIN);
+
+static void
+gst_encode_bin2_class_init (GstEncodeBin2Class * klass)
+{
+ GstElementClass *gstelement_klass = (GstElementClass *) klass;
+
+ gst_element_class_add_static_pad_template (gstelement_klass,
+ &muxer_src_template);
+}
+
+static void
+gst_encode_bin2_init (GstEncodeBin2 * encode_bin)
+{
+}
--- /dev/null
+/* GStreamer splitmux encoding bin
+ * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
+ * (C) 2009 Nokia Corporation
+ *
+ * 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
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include "gstencodebasebin.h"
+
+G_DECLARE_FINAL_TYPE (GstEncodeBin2, gst_encode_bin2, GST, ENCODE_BIN2, GstEncodeBaseBin);
\ No newline at end of file
encoding_sources = [
'gstencodebasebin.c',
'gstencodebin.c',
+ 'gstencodebin2.c',
'gstsmartencoder.c',
'gststreamcombiner.c',
'gststreamsplitter.c',
#include <gst/gst-i18n-plugin.h>
#include "gstencodebin.h"
+#include "gstencodebin2.h"
static gboolean
plugin_init (GstPlugin * plugin)
res = gst_element_register (plugin, "encodebin", GST_RANK_NONE,
gst_encode_bin_get_type ());
+ res |= gst_element_register (plugin, "encodebin2", GST_RANK_NONE,
+ gst_encode_bin2_get_type ());
+
return res;
}