mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 05:56:31 +00:00
openh264: allow per feature registration
Split plugin into features including dynamic types which can be indiviually registered during a static build. More details here: https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199 https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/661 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2038>
This commit is contained in:
parent
7e0ad83f04
commit
8fa3dd4bf3
6 changed files with 129 additions and 21 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "gstopenh264elements.h"
|
||||||
#include "gstopenh264dec.h"
|
#include "gstopenh264dec.h"
|
||||||
|
|
||||||
#include <wels/codec_ver.h>
|
#include <wels/codec_ver.h>
|
||||||
|
@ -59,6 +60,7 @@ static GstFlowReturn gst_openh264dec_handle_frame (GstVideoDecoder * decoder,
|
||||||
GstVideoCodecFrame * frame);
|
GstVideoCodecFrame * frame);
|
||||||
static gboolean gst_openh264dec_decide_allocation (GstVideoDecoder * decoder,
|
static gboolean gst_openh264dec_decide_allocation (GstVideoDecoder * decoder,
|
||||||
GstQuery * query);
|
GstQuery * query);
|
||||||
|
static gboolean openh264dec_element_init (GstPlugin * plugin);
|
||||||
|
|
||||||
#if HAVE_OPENH264_MAIN_PROFILE
|
#if HAVE_OPENH264_MAIN_PROFILE
|
||||||
#define SUPPORTED_PROFILE_STR "profile=(string){ constrained-baseline, baseline, main, high, constrained-high, progressive-high }"
|
#define SUPPORTED_PROFILE_STR "profile=(string){ constrained-baseline, baseline, main, high, constrained-high, progressive-high }"
|
||||||
|
@ -88,6 +90,7 @@ G_DEFINE_TYPE_WITH_CODE (GstOpenh264Dec, gst_openh264dec,
|
||||||
GST_TYPE_VIDEO_DECODER,
|
GST_TYPE_VIDEO_DECODER,
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_openh264dec_debug_category, "openh264dec", 0,
|
GST_DEBUG_CATEGORY_INIT (gst_openh264dec_debug_category, "openh264dec", 0,
|
||||||
"debug category for openh264dec element"));
|
"debug category for openh264dec element"));
|
||||||
|
GST_ELEMENT_REGISTER_DEFINE_CUSTOM (openh264dec, openh264dec_element_init);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_openh264dec_class_init (GstOpenh264DecClass * klass)
|
gst_openh264dec_class_init (GstOpenh264DecClass * klass)
|
||||||
|
@ -448,3 +451,14 @@ gst_openh264dec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
openh264dec_element_init (GstPlugin * plugin)
|
||||||
|
{
|
||||||
|
if (openh264_element_init (plugin))
|
||||||
|
return gst_element_register (plugin, "openh264dec", GST_RANK_MARGINAL,
|
||||||
|
GST_TYPE_OPENH264DEC);
|
||||||
|
|
||||||
|
GST_ERROR ("Incorrect library version loaded, expecting %s", g_strCodecVer);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
56
ext/openh264/gstopenh264element.c
Normal file
56
ext/openh264/gstopenh264element.c
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2014, Ericsson AB. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or other
|
||||||
|
* materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
* OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <wels/codec_api.h>
|
||||||
|
#include <wels/codec_ver.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "gstopenh264elements.h"
|
||||||
|
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
openh264_element_init (GstPlugin * plugin)
|
||||||
|
{
|
||||||
|
static gsize res = FALSE;
|
||||||
|
|
||||||
|
if (g_once_init_enter (&res)) {
|
||||||
|
gsize value;
|
||||||
|
OpenH264Version libver;
|
||||||
|
/* g_stCodecVersion is the version detected at build time as defined in the
|
||||||
|
* headers and WelsGetCodecVersion() is the version detected at runtime.
|
||||||
|
* This is a safeguard to avoid crashes since OpenH264 has been changing
|
||||||
|
* ABI without changing the SONAME.
|
||||||
|
*/
|
||||||
|
libver = WelsGetCodecVersion ();
|
||||||
|
value = memcmp (&libver, &g_stCodecVersion, sizeof (libver)) == 0;
|
||||||
|
g_once_init_leave (&res, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
37
ext/openh264/gstopenh264elements.h
Normal file
37
ext/openh264/gstopenh264elements.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) <2020> The GStreamer Contributors.
|
||||||
|
*
|
||||||
|
* 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_OPENH264_ELEMENT_H__
|
||||||
|
#define __GST_OPENH264_ELEMENT_H__
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
gboolean openh264_element_init (GstPlugin * plugin);
|
||||||
|
|
||||||
|
GST_ELEMENT_REGISTER_DECLARE (openh264dec);
|
||||||
|
GST_ELEMENT_REGISTER_DECLARE (openh264enc);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GST_OPENH264_ELEMENT_H__ */
|
|
@ -27,6 +27,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "gstopenh264elements.h"
|
||||||
#include "gstopenh264enc.h"
|
#include "gstopenh264enc.h"
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
@ -162,6 +163,7 @@ static void gst_openh264enc_set_usage_type (GstOpenh264Enc * openh264enc,
|
||||||
gint usage_type);
|
gint usage_type);
|
||||||
static void gst_openh264enc_set_rate_control (GstOpenh264Enc * openh264enc,
|
static void gst_openh264enc_set_rate_control (GstOpenh264Enc * openh264enc,
|
||||||
gint rc_mode);
|
gint rc_mode);
|
||||||
|
static gboolean openh264enc_element_init (GstPlugin * plugin);
|
||||||
|
|
||||||
|
|
||||||
#define DEFAULT_BITRATE (128000)
|
#define DEFAULT_BITRATE (128000)
|
||||||
|
@ -235,6 +237,7 @@ G_DEFINE_TYPE_WITH_CODE (GstOpenh264Enc, gst_openh264enc,
|
||||||
G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL);
|
G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL);
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_openh264enc_debug_category, "openh264enc", 0,
|
GST_DEBUG_CATEGORY_INIT (gst_openh264enc_debug_category, "openh264enc", 0,
|
||||||
"debug category for openh264enc element"));
|
"debug category for openh264enc element"));
|
||||||
|
GST_ELEMENT_REGISTER_DEFINE_CUSTOM (openh264enc, openh264enc_element_init);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_openh264enc_class_init (GstOpenh264EncClass * klass)
|
gst_openh264enc_class_init (GstOpenh264EncClass * klass)
|
||||||
|
@ -1056,3 +1059,13 @@ gst_openh264enc_finish (GstVideoEncoder * encoder)
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
static gboolean
|
||||||
|
openh264enc_element_init (GstPlugin * plugin)
|
||||||
|
{
|
||||||
|
if (openh264_element_init (plugin))
|
||||||
|
return gst_element_register (plugin, "openh264enc", GST_RANK_MARGINAL,
|
||||||
|
GST_TYPE_OPENH264ENC);
|
||||||
|
|
||||||
|
GST_ERROR ("Incorrect library version loaded, expecting %s", g_strCodecVer);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
|
@ -31,31 +31,18 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include "gstopenh264elements.h"
|
||||||
#include <wels/codec_api.h>
|
|
||||||
#include <wels/codec_ver.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "gstopenh264dec.h"
|
|
||||||
#include "gstopenh264enc.h"
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
plugin_init (GstPlugin * plugin)
|
plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
/* g_stCodecVersion is the version detected at build time as defined in the
|
gboolean ret = FALSE;
|
||||||
* headers and WelsGetCodecVersion() is the version detected at runtime.
|
|
||||||
* This is a safeguard to avoid crashes since OpenH264 has been changing
|
ret |= GST_ELEMENT_REGISTER (openh264dec, plugin);
|
||||||
* ABI without changing the SONAME.
|
ret |= GST_ELEMENT_REGISTER (openh264enc, plugin);
|
||||||
*/
|
|
||||||
OpenH264Version libver = WelsGetCodecVersion ();
|
return ret;
|
||||||
if (memcmp (&libver, &g_stCodecVersion, sizeof (libver)) == 0) {
|
|
||||||
gst_element_register (plugin, "openh264dec", GST_RANK_MARGINAL,
|
|
||||||
GST_TYPE_OPENH264DEC);
|
|
||||||
gst_element_register (plugin, "openh264enc", GST_RANK_MARGINAL,
|
|
||||||
GST_TYPE_OPENH264ENC);
|
|
||||||
} else {
|
|
||||||
GST_ERROR ("Incorrect library version loaded, expecting %s", g_strCodecVer);
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
openh264_sources = [
|
openh264_sources = [
|
||||||
'gstopenh264dec.cpp',
|
'gstopenh264dec.cpp',
|
||||||
'gstopenh264enc.cpp',
|
'gstopenh264enc.cpp',
|
||||||
|
'gstopenh264element.c',
|
||||||
'gstopenh264plugin.c',
|
'gstopenh264plugin.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue