encodebin: Split implementation into a base class

Create EncodeBaseBin as a base class for the existing
encodebin to allow other implementations.

Co-authored with Jan Schmidt <jan@centricular.com>
This commit is contained in:
Thibault Saunier 2020-11-13 13:06:32 -03:00
parent a62af4ff27
commit 5aa5faecf0
7 changed files with 2731 additions and 2420 deletions

View file

@ -1967,6 +1967,7 @@
"description": "Convenience encoding/muxing element",
"hierarchy": [
"GstEncodeBin",
"GstEncodeBaseBin",
"GstBin",
"GstElement",
"GstObject",
@ -2175,6 +2176,137 @@
"filename": "gstencoding",
"license": "LGPL",
"other-types": {
"GstEncodeBaseBin": {
"hierarchy": [
"GstEncodeBaseBin",
"GstBin",
"GstElement",
"GstObject",
"GInitiallyUnowned",
"GObject"
],
"interfaces": [
"GstChildProxy"
],
"kind": "object",
"properties": {
"audio-jitter-tolerance": {
"blurb": "Amount of timestamp jitter/imperfection to allow on audio streams before inserting/dropping samples (ns)",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "20000000",
"max": "18446744073709551615",
"min": "0",
"mutable": "null",
"readable": true,
"type": "guint64",
"writable": true
},
"avoid-reencoding": {
"blurb": "Whether to re-encode portions of compatible video streams that lay on segment boundaries",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "false",
"mutable": "null",
"readable": true,
"type": "gboolean",
"writable": true
},
"flags": {
"blurb": "Flags to control behaviour",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "(none)",
"mutable": "null",
"readable": true,
"type": "GstEncodeBinFlags",
"writable": true
},
"profile": {
"blurb": "The GstEncodingProfile to use",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"mutable": "null",
"readable": true,
"type": "GstEncodingProfile",
"writable": true
},
"queue-buffers-max": {
"blurb": "Max. number of buffers in the queue (0=disable)",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "200",
"max": "-1",
"min": "0",
"mutable": "null",
"readable": true,
"type": "guint",
"writable": true
},
"queue-bytes-max": {
"blurb": "Max. amount of data in the queue (bytes, 0=disable)",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "10485760",
"max": "-1",
"min": "0",
"mutable": "null",
"readable": true,
"type": "guint",
"writable": true
},
"queue-time-max": {
"blurb": "Max. amount of data in the queue (in ns, 0=disable)",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "1000000000",
"max": "18446744073709551615",
"min": "0",
"mutable": "null",
"readable": true,
"type": "guint64",
"writable": true
}
},
"signals": {
"request-pad": {
"action": true,
"args": [
{
"name": "arg0",
"type": "GstCaps"
}
],
"return-type": "GstPad",
"when": "last"
},
"request-profile-pad": {
"action": true,
"args": [
{
"name": "arg0",
"type": "gchararray"
}
],
"return-type": "GstPad",
"when": "last"
}
}
},
"GstEncodeBinFlags": {
"kind": "flags",
"values": [

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,95 @@
/* GStreamer 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.
*/
#ifndef __GST_ENCODEBIN_H__
#define __GST_ENCODEBIN_H__
#include <gst/gst.h>
#include <gst/pbutils/pbutils.h>
#define GST_TYPE_ENCODE_BASE_BIN (gst_encode_base_bin_get_type())
#define GST_ENCODE_BASE_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ENCODE_BASE_BIN,GstEncodeBin))
#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))
typedef struct _GstEncodeBaseBin GstEncodeBaseBin;
typedef struct _GstEncodeBaseBinClass GstEncodeBaseBinClass;
typedef enum
{
GST_ENCODEBIN_FLAG_NO_AUDIO_CONVERSION = (1 << 0),
GST_ENCODEBIN_FLAG_NO_VIDEO_CONVERSION = (1 << 1)
} GstEncodeBaseBinFlags;
struct _GstEncodeBaseBin
{
GstBin parent;
/* the profile field is only valid if it could be entirely setup */
GstEncodingProfile *profile;
GList *streams; /* List of StreamGroup, not sorted */
GstElement *muxer;
/* Ghostpad with changing target */
GstPad *srcpad;
/* TRUE if in PAUSED/PLAYING */
gboolean active;
/* available muxers, encoders and parsers */
GList *muxers;
GList *formatters;
GList *encoders;
GList *parsers;
/* Increasing counter for unique pad name */
guint last_pad_id;
/* Cached caps for identification */
GstCaps *raw_video_caps;
GstCaps *raw_audio_caps;
/* GstCaps *raw_text_caps; */
guint queue_buffers_max;
guint queue_bytes_max;
guint64 queue_time_max;
guint64 tolerance;
gboolean avoid_reencoding;
GstEncodeBaseBinFlags flags;
};
struct _GstEncodeBaseBinClass
{
GstBinClass parent;
/* Action Signals */
GstPad *(*request_pad) (GstEncodeBaseBin * encodebin, GstCaps * caps);
GstPad *(*request_profile_pad) (GstEncodeBaseBin * encodebin,
const gchar * profilename);
};
GType gst_encode_base_bin_get_type(void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstEncodeBaseBin, gst_object_unref)
#endif /* __GST_ENCODEBIN_H__ */

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,7 @@
/* GStreamer encoding bin
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
* (C) 2009 Nokia Corporation
* (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
@ -18,21 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_ENCODEBIN_H__
#define __GST_ENCODEBIN_H__
#pragma once
#include <gst/gst.h>
#include <gst/pbutils/pbutils.h>
#include "gstencodebasebin.h"
#define GST_TYPE_ENCODE_BIN (gst_encode_bin_get_type())
#define GST_ENCODE_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ENCODE_BIN,GstEncodeBin))
#define GST_ENCODE_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ENCODE_BIN,GstEncodeBinClass))
#define GST_IS_ENCODE_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ENCODE_BIN))
#define GST_IS_ENCODE_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ENCODE_BIN))
typedef struct _GstEncodeBin GstEncodeBin;
typedef struct _GstEncodeBinClass GstEncodeBinClass;
GType gst_encode_bin_get_type(void);
#endif /* __GST_ENCODEBIN_H__ */
G_DECLARE_FINAL_TYPE (GstEncodeBin, gst_encode_bin, GST, ENCODE_BIN, GstEncodeBaseBin);

View file

@ -1,8 +1,11 @@
encoding_sources = ['gstencodebin.c',
encoding_sources = [
'gstencodebasebin.c',
'gstencodebin.c',
'gstsmartencoder.c',
'gststreamcombiner.c',
'gststreamsplitter.c',
]
'plugin.c',
]
gstencoding = library('gstencoding',
encoding_sources,

53
gst/encoding/plugin.c Normal file
View file

@ -0,0 +1,53 @@
/* GStreamer encoding bin
* Copyright (C) 2016 Jan Schmidt <jan@centricular.com>
* (C) 2020 Thibault Saunier <tsaunier@igalia.com>
* (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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/gst-i18n-plugin.h>
#include "gstencodebin.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
gboolean res;
#ifdef ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
LOCALEDIR);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif /* ENABLE_NLS */
res = gst_element_register (plugin, "encodebin", GST_RANK_NONE,
gst_encode_bin_get_type ());
return res;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
encoding,
"various encoding-related elements", plugin_init, VERSION, GST_LICENSE,
GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)