[vlc-devel] [PATCH 11/26] sout:encoder: set callbacks of spu encoders with set_callback_spu_encoder
Steve Lhomme
robux4 at ycbcr.xyz
Mon Jan 18 08:32:50 UTC 2021
---
modules/codec/dvbsub.c | 21 +++++++++------------
modules/codec/substx3g.c | 9 +++------
modules/codec/t140.c | 12 ++++--------
modules/codec/webvtt/encvtt.c | 4 +---
modules/codec/webvtt/webvtt.c | 4 ++--
modules/codec/webvtt/webvtt.h | 2 +-
6 files changed, 20 insertions(+), 32 deletions(-)
diff --git a/modules/codec/dvbsub.c b/modules/codec/dvbsub.c
index 921c5593a9a..cf70bd7324f 100644
--- a/modules/codec/dvbsub.c
+++ b/modules/codec/dvbsub.c
@@ -110,8 +110,8 @@ static int Decode( decoder_t *, block_t * );
static void Flush( decoder_t * );
#ifdef ENABLE_SOUT
-static int OpenEncoder ( vlc_object_t * );
-static void CloseEncoder( vlc_object_t * );
+static int OpenEncoder ( encoder_t * );
+static void CloseEncoder( encoder_t * );
static block_t *Encode ( encoder_t *, subpicture_t * );
#endif
@@ -133,8 +133,7 @@ vlc_module_begin ()
# define ENC_CFG_PREFIX "sout-dvbsub-"
add_submodule ()
set_description( N_("DVB subtitles encoder") )
- set_capability( "spu encoder", 100 )
- set_callbacks( OpenEncoder, CloseEncoder )
+ set_callback_spu_encoder( OpenEncoder, CloseEncoder, 100 )
add_integer( ENC_CFG_PREFIX "x", -1, ENC_POSX_TEXT, ENC_POSX_LONGTEXT, false )
add_integer( ENC_CFG_PREFIX "y", -1, ENC_POSY_TEXT, ENC_POSY_LONGTEXT, false )
@@ -1693,9 +1692,8 @@ static void encode_object( encoder_t *, bs_t *, subpicture_t * );
/*****************************************************************************
* OpenEncoder: probe the encoder and return score
*****************************************************************************/
-static int OpenEncoder( vlc_object_t *p_this )
+static int OpenEncoder( encoder_t *p_enc )
{
- encoder_t *p_enc = (encoder_t *)p_this;
encoder_sys_t *p_sys;
if( ( p_enc->fmt_out.i_codec != VLC_CODEC_DVBS ) &&
@@ -1721,8 +1719,8 @@ static int OpenEncoder( vlc_object_t *p_this )
p_sys->i_regions = 0;
p_sys->p_regions = 0;
- p_sys->i_offset_x = var_CreateGetInteger( p_this, ENC_CFG_PREFIX "x" );
- p_sys->i_offset_y = var_CreateGetInteger( p_this, ENC_CFG_PREFIX "y" );
+ p_sys->i_offset_x = var_CreateGetInteger( p_enc, ENC_CFG_PREFIX "x" );
+ p_sys->i_offset_y = var_CreateGetInteger( p_enc, ENC_CFG_PREFIX "y" );
return VLC_SUCCESS;
}
@@ -2043,13 +2041,12 @@ static block_t *Encode( encoder_t *p_enc, subpicture_t *p_subpic )
/*****************************************************************************
* CloseEncoder: encoder destruction
*****************************************************************************/
-static void CloseEncoder( vlc_object_t *p_this )
+static void CloseEncoder( encoder_t *p_enc )
{
- encoder_t *p_enc = (encoder_t *)p_this;
encoder_sys_t *p_sys = p_enc->p_sys;
- var_Destroy( p_this , ENC_CFG_PREFIX "x" );
- var_Destroy( p_this , ENC_CFG_PREFIX "y" );
+ var_Destroy( p_enc , ENC_CFG_PREFIX "x" );
+ var_Destroy( p_enc , ENC_CFG_PREFIX "y" );
if( p_sys->i_regions ) free( p_sys->p_regions );
free( p_sys );
diff --git a/modules/codec/substx3g.c b/modules/codec/substx3g.c
index bc74c6fcd39..750fbd8d7c2 100644
--- a/modules/codec/substx3g.c
+++ b/modules/codec/substx3g.c
@@ -38,7 +38,7 @@ static int OpenDecoder ( vlc_object_t * );
static void CloseDecoder ( vlc_object_t * );
static int Decode( decoder_t *, block_t * );
#ifdef ENABLE_SOUT
-static int OpenEncoder ( vlc_object_t * );
+static int OpenEncoder ( encoder_t * );
static block_t * Encode( encoder_t *, subpicture_t * );
#endif
@@ -53,8 +53,7 @@ vlc_module_begin ()
add_submodule ()
set_description( N_("tx3g subtitles encoder") )
set_shortname( N_("tx3g subtitles encoder") )
- set_capability( "spu encoder", 101 )
- set_callback( OpenEncoder )
+ set_callback_spu_encoder( OpenEncoder, NULL, 101 )
#endif
vlc_module_end ()
@@ -605,10 +604,8 @@ static void FillExtradataTx3g( void **pp_extra, int *pi_extra )
}
}
-static int OpenEncoder( vlc_object_t *p_this )
+static int OpenEncoder( encoder_t *p_enc )
{
- encoder_t *p_enc = (encoder_t *)p_this;
-
if( p_enc->fmt_out.i_codec != VLC_CODEC_TX3G )
return VLC_EGENERIC;
diff --git a/modules/codec/t140.c b/modules/codec/t140.c
index 3e0bbc2447b..fe48284f65e 100644
--- a/modules/codec/t140.c
+++ b/modules/codec/t140.c
@@ -28,23 +28,19 @@
#include <vlc_codec.h>
#include <vlc_sout.h>
-static int Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
+static int Open ( encoder_t * );
vlc_module_begin ()
set_description( N_("T.140 text encoder") )
- set_capability( "spu encoder", 100 )
- set_callback( Open )
+ set_callback_spu_encoder( Open, NULL, 100 )
vlc_module_end ()
static block_t *Encode ( encoder_t *, subpicture_t * );
-static int Open( vlc_object_t *p_this )
+static int Open( encoder_t *p_enc )
{
- encoder_t *p_enc = (encoder_t *)p_this;
-
switch( p_enc->fmt_out.i_codec )
{
case VLC_CODEC_SUBT:
@@ -52,7 +48,7 @@ static int Open( vlc_object_t *p_this )
&& strcasecmp( p_enc->fmt_out.subs.psz_encoding, "utf8" )
&& strcasecmp( p_enc->fmt_out.subs.psz_encoding, "UTF-8" ) )
{
- msg_Err( p_this, "Only UTF-8 encoding supported" );
+ msg_Err( p_enc, "Only UTF-8 encoding supported" );
return VLC_EGENERIC;
}
case VLC_CODEC_ITU_T140:
diff --git a/modules/codec/webvtt/encvtt.c b/modules/codec/webvtt/encvtt.c
index e5c2b5dd91e..7c6875a46a0 100644
--- a/modules/codec/webvtt/encvtt.c
+++ b/modules/codec/webvtt/encvtt.c
@@ -31,10 +31,8 @@
static block_t *Encode ( encoder_t *, subpicture_t * );
-int webvtt_OpenEncoder( vlc_object_t *p_this )
+int webvtt_OpenEncoder( encoder_t *p_enc )
{
- encoder_t *p_enc = (encoder_t *)p_this;
-
if( p_enc->fmt_out.i_codec != VLC_CODEC_WEBVTT )
return VLC_EGENERIC;
diff --git a/modules/codec/webvtt/webvtt.c b/modules/codec/webvtt/webvtt.c
index 8da5f6d4e02..fa9ab6083b2 100644
--- a/modules/codec/webvtt/webvtt.c
+++ b/modules/codec/webvtt/webvtt.c
@@ -25,6 +25,7 @@
#include <vlc_common.h>
#include <vlc_charset.h>
#include <vlc_plugin.h>
+#include <vlc_codec.h>
#include "webvtt.h"
@@ -61,9 +62,8 @@ vlc_module_begin ()
#ifdef ENABLE_SOUT
add_submodule()
set_description( "WEBVTT text encoder" )
- set_capability( "spu encoder", 101 )
set_subcategory( SUBCAT_INPUT_SCODEC )
- set_callback( webvtt_OpenEncoder )
+ set_callback_spu_encoder( webvtt_OpenEncoder, NULL, 101 )
#endif
vlc_module_end ()
diff --git a/modules/codec/webvtt/webvtt.h b/modules/codec/webvtt/webvtt.h
index 5c78051e712..339c9312827 100644
--- a/modules/codec/webvtt/webvtt.h
+++ b/modules/codec/webvtt/webvtt.h
@@ -28,7 +28,7 @@ int webvtt_OpenDemuxStream (vlc_object_t *);
void webvtt_CloseDemux ( vlc_object_t * );
#ifdef ENABLE_SOUT
-int webvtt_OpenEncoder ( vlc_object_t * );
+int webvtt_OpenEncoder ( encoder_t * );
#endif
typedef struct webvtt_text_parser_t webvtt_text_parser_t;
--
2.29.2
More information about the vlc-devel
mailing list