[vlc-devel] [PATCH 12/17] Misc: Split block_t to vlc_frame_t and vlc_data_t
Denis Charmet
typx at dinauz.org
Mon Apr 22 19:10:41 CEST 2019
---
modules/misc/gnutls.c | 12 +++---
modules/misc/medialibrary/Thumbnailer.cpp | 10 ++---
modules/misc/rtsp.c | 30 +++++++-------
modules/misc/stats.c | 50 +++++++++++------------
modules/misc/xml/libxml.c | 1 -
5 files changed, 52 insertions(+), 51 deletions(-)
diff --git a/modules/misc/gnutls.c b/modules/misc/gnutls.c
index 8466000274..2c8f2f5e6e 100644
--- a/modules/misc/gnutls.c
+++ b/modules/misc/gnutls.c
@@ -36,7 +36,7 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_tls.h>
-#include <vlc_block.h>
+#include <vlc_data.h>
#include <vlc_dialog.h>
#include <gnutls/gnutls.h>
@@ -652,7 +652,7 @@ static int OpenServer(vlc_tls_server_t *crd, const char *cert, const char *key)
return VLC_ENOMEM;
}
- block_t *certblock = block_FilePath(cert, false);
+ vlc_data_t *certblock = vlc_data_FilePath(cert, false);
if (certblock == NULL)
{
msg_Err (crd, "cannot read certificate chain from %s: %s", cert,
@@ -660,12 +660,12 @@ static int OpenServer(vlc_tls_server_t *crd, const char *cert, const char *key)
goto error;
}
- block_t *keyblock = block_FilePath(key, false);
+ vlc_data_t *keyblock = vlc_data_FilePath(key, false);
if (keyblock == NULL)
{
msg_Err (crd, "cannot read private key from %s: %s", key,
vlc_strerror_c(errno));
- block_Release (certblock);
+ vlc_data_Release (certblock);
goto error;
}
@@ -679,8 +679,8 @@ static int OpenServer(vlc_tls_server_t *crd, const char *cert, const char *key)
val = gnutls_certificate_set_x509_key_mem (sys->x509_cred, &pub, &priv,
GNUTLS_X509_FMT_PEM);
- block_Release (keyblock);
- block_Release (certblock);
+ vlc_data_Release (keyblock);
+ vlc_data_Release (certblock);
if (val < 0)
{
msg_Err (crd, "cannot load X.509 key: %s", gnutls_strerror (val));
diff --git a/modules/misc/medialibrary/Thumbnailer.cpp b/modules/misc/medialibrary/Thumbnailer.cpp
index ffb8201459..d033cfc04a 100644
--- a/modules/misc/medialibrary/Thumbnailer.cpp
+++ b/modules/misc/medialibrary/Thumbnailer.cpp
@@ -26,7 +26,7 @@
#include <vlc_thumbnailer.h>
#include <vlc_fs.h>
-#include <vlc_block.h>
+#include <vlc_frame.h>
#include <vlc_url.h>
#include <vlc_cxx_helpers.hpp>
@@ -90,17 +90,17 @@ bool Thumbnailer::generate( medialibrary::MediaPtr media, const std::string& mrl
if ( ctx.thumbnail == nullptr )
return false;
- block_t* block;
- if ( picture_Export( VLC_OBJECT( m_ml ), &block, nullptr, ctx.thumbnail,
+ vlc_frame_t* frame;
+ if ( picture_Export( VLC_OBJECT( m_ml ), &frame, nullptr, ctx.thumbnail,
VLC_CODEC_JPEG, 512, 320 ) != VLC_SUCCESS )
return false;
- auto blockPtr = vlc::wrap_cptr( block, &block_Release );
+ auto framePtr = vlc::wrap_cptr( frame, &vlc_frame_Release );
std::string outputPath = m_thumbnailDir + std::to_string( media->id() ) + ".jpg";
auto f = vlc::wrap_cptr( vlc_fopen( outputPath.c_str(), "wb" ), &fclose );
if ( f == nullptr )
return false;
- if ( fwrite( block->p_buffer, block->i_buffer, 1, f.get() ) != 1 )
+ if ( fwrite( frame->p_buffer, frame->i_buffer, 1, f.get() ) != 1 )
return false;
auto thumbnailMrl = vlc::wrap_cptr( vlc_path2uri( outputPath.c_str(), nullptr ) );
if ( thumbnailMrl == nullptr )
diff --git a/modules/misc/rtsp.c b/modules/misc/rtsp.c
index e486c2d854..da24360ccd 100644
--- a/modules/misc/rtsp.c
+++ b/modules/misc/rtsp.c
@@ -34,7 +34,7 @@
#include <vlc_plugin.h>
#include <vlc_input.h>
#include <vlc_sout.h>
-#include <vlc_block.h>
+#include <vlc_data.h>
#include <vlc_httpd.h>
#include <vlc_vod.h>
@@ -180,7 +180,7 @@ typedef struct
/* */
vlc_thread_t thread;
- block_fifo_t *p_fifo_cmd;
+ vlc_data_fifo_t *p_fifo_cmd;
} vod_sys_t;
/* rtsp delayed command (to avoid deadlock between vlm/httpd) */
@@ -286,11 +286,11 @@ static int Open( vlc_object_t *p_this )
p_vod->pf_media_new = MediaNew;
p_vod->pf_media_del = MediaAskDel;
- p_sys->p_fifo_cmd = block_FifoNew();
+ p_sys->p_fifo_cmd = vlc_data_FifoNew();
if( vlc_clone( &p_sys->thread, CommandThread, p_vod, VLC_THREAD_PRIORITY_LOW ) )
{
msg_Err( p_vod, "cannot spawn rtsp vod thread" );
- block_FifoRelease( p_sys->p_fifo_cmd );
+ vlc_data_FifoRelease( p_sys->p_fifo_cmd );
free( p_sys->psz_path );
goto error;
}
@@ -321,19 +321,21 @@ static void Close( vlc_object_t * p_this )
/* Stop command thread */
CommandPush( p_vod, RTSP_CMD_TYPE_NONE, NULL, NULL, 0, 0.0, NULL );
vlc_join( p_sys->thread, NULL );
-
- while( block_FifoCount( p_sys->p_fifo_cmd ) > 0 )
+ vlc_fifo_Lock(p_sys->p_fifo_cmd);
+ vlc_data_t *p_block_cmd = vlc_data_FifoDequeueAllUnlocked(p_sys->p_fifo_cmd);
+ vlc_fifo_Unlock(p_sys->p_fifo_cmd);
+ while( p_block_cmd != NULL )
{
rtsp_cmd_t cmd;
- block_t *p_block_cmd = block_FifoGet( p_sys->p_fifo_cmd );
memcpy( &cmd, p_block_cmd->p_buffer, sizeof(cmd) );
- block_Release( p_block_cmd );
+ vlc_data_Release( p_block_cmd );
if ( cmd.i_type == RTSP_CMD_TYPE_DEL )
MediaDel(p_vod, cmd.p_media);
free( cmd.psz_session );
free( cmd.psz_arg );
+ p_block_cmd = p_block_cmd->p_next;
}
- block_FifoRelease( p_sys->p_fifo_cmd );
+ vlc_data_FifoRelease( p_sys->p_fifo_cmd );
httpd_HostDelete( p_sys->p_rtsp_host );
var_Destroy( p_this, "rtsp-session-timeout" );
@@ -743,7 +745,7 @@ static void CommandPush( vod_t *p_vod, rtsp_cmd_type_t i_type, vod_media_t *p_me
double f_arg, const char *psz_arg )
{
rtsp_cmd_t cmd;
- block_t *p_cmd;
+ vlc_data_t *p_cmd;
memset( &cmd, 0, sizeof(cmd) );
cmd.i_type = i_type;
@@ -757,11 +759,11 @@ static void CommandPush( vod_t *p_vod, rtsp_cmd_type_t i_type, vod_media_t *p_me
if( psz_arg )
cmd.psz_arg = strdup(psz_arg);
- p_cmd = block_Alloc( sizeof(rtsp_cmd_t) );
+ p_cmd = vlc_data_Alloc( sizeof(rtsp_cmd_t) );
memcpy( p_cmd->p_buffer, &cmd, sizeof(cmd) );
vod_sys_t *p_sys = p_vod->p_sys;
- block_FifoPut( p_sys->p_fifo_cmd, p_cmd );
+ vlc_data_FifoPut( p_sys->p_fifo_cmd, p_cmd );
}
static void* CommandThread( void *obj )
@@ -772,7 +774,7 @@ static void* CommandThread( void *obj )
for( ;; )
{
- block_t *p_block_cmd = block_FifoGet( p_sys->p_fifo_cmd );
+ vlc_data_t *p_block_cmd = vlc_data_FifoGet( p_sys->p_fifo_cmd );
rtsp_cmd_t cmd;
vod_media_t *p_media = NULL;
int i;
@@ -781,7 +783,7 @@ static void* CommandThread( void *obj )
break;
memcpy( &cmd, p_block_cmd->p_buffer, sizeof(cmd) );
- block_Release( p_block_cmd );
+ vlc_data_Release( p_block_cmd );
if( cmd.i_type == RTSP_CMD_TYPE_NONE )
break;
diff --git a/modules/misc/stats.c b/modules/misc/stats.c
index e99402a2b8..5f409cf983 100644
--- a/modules/misc/stats.c
+++ b/modules/misc/stats.c
@@ -40,11 +40,11 @@
#include <vlc_demux.h>
/*** Decoder ***/
-static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
+static int DecodeFrame( decoder_t *p_dec, vlc_frame_t *p_frame )
{
picture_t * p_pic = NULL;
- if( p_block == NULL ) /* No Drain */
+ if( p_frame == NULL ) /* No Drain */
return VLCDEC_SUCCESS;
if( !decoder_UpdateVideoFormat( p_dec ) )
@@ -52,13 +52,13 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
if( !p_pic )
goto error;
- if( p_block->i_buffer == kBufferSize )
+ if( p_frame->i_buffer == kBufferSize )
{
msg_Dbg( p_dec, "got %"PRIu64" ms",
- MS_FROM_VLC_TICK(*(vlc_tick_t *)p_block->p_buffer) );
+ MS_FROM_VLC_TICK(*(vlc_tick_t *)p_frame->p_buffer) );
msg_Dbg( p_dec, "got %"PRIu64" ms offset",
- MS_FROM_VLC_TICK(vlc_tick_now() - *(vlc_tick_t *)p_block->p_buffer) );
- *(vlc_tick_t *)(p_pic->p->p_pixels) = *(vlc_tick_t *)p_block->p_buffer;
+ MS_FROM_VLC_TICK(vlc_tick_now() - *(vlc_tick_t *)p_frame->p_buffer) );
+ *(vlc_tick_t *)(p_pic->p->p_pixels) = *(vlc_tick_t *)p_frame->p_buffer;
}
else
{
@@ -66,12 +66,12 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
*(vlc_tick_t *)(p_pic->p->p_pixels) = vlc_tick_now();
}
- p_pic->date = p_block->i_pts != VLC_TICK_INVALID ?
- p_block->i_pts : p_block->i_dts;
+ p_pic->date = p_frame->i_pts != VLC_TICK_INVALID ?
+ p_frame->i_pts : p_frame->i_dts;
p_pic->b_force = true;
error:
- block_Release( p_block );
+ vlc_frame_Release( p_frame );
decoder_QueueVideo( p_dec, p_pic );
return VLCDEC_SUCCESS;
}
@@ -83,7 +83,7 @@ static int OpenDecoder ( vlc_object_t *p_this )
msg_Dbg( p_this, "opening stats decoder" );
/* Set callbacks */
- p_dec->pf_decode = DecodeBlock;
+ p_dec->pf_decode = DecodeFrame;
/* */
p_dec->fmt_out.i_codec = VLC_CODEC_I420;
@@ -97,22 +97,22 @@ static int OpenDecoder ( vlc_object_t *p_this )
/*** Encoder ***/
#ifdef ENABLE_SOUT
-static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
+static vlc_frame_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
{
(void)p_pict;
- block_t * p_block = block_Alloc( kBufferSize );
+ vlc_frame_t * p_frame = vlc_frame_Alloc( kBufferSize );
- *(vlc_tick_t*)p_block->p_buffer = vlc_tick_now();
- p_block->i_buffer = kBufferSize;
- p_block->i_length = kBufferSize;
- p_block->i_dts = p_pict->date;
+ *(vlc_tick_t*)p_frame->p_buffer = vlc_tick_now();
+ p_frame->i_buffer = kBufferSize;
+ p_frame->i_length = kBufferSize;
+ p_frame->i_dts = p_pict->date;
msg_Dbg( p_enc, "putting %"PRIu64"ms",
- MS_FROM_VLC_TICK(*(vlc_tick_t*)p_block->p_buffer) );
- return p_block;
+ MS_FROM_VLC_TICK(*(vlc_tick_t*)p_frame->p_buffer) );
+ return p_frame;
}
-static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_abuff )
+static vlc_frame_t *EncodeAudio( encoder_t *p_enc, vlc_frame_t *p_abuff )
{
(void)p_abuff;
(void)p_enc;
@@ -145,18 +145,18 @@ static int Demux( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
- block_t * p_block = vlc_stream_Block( p_demux->s, kBufferSize );
+ vlc_frame_t * p_frame = vlc_stream_Frame( p_demux->s, kBufferSize );
- if( !p_block ) return 1;
+ if( !p_frame ) return 1;
- p_block->i_dts = p_block->i_pts = date_Increment( &p_sys->pts, kBufferSize );
+ p_frame->i_dts = p_frame->i_pts = date_Increment( &p_sys->pts, kBufferSize );
msg_Dbg( p_demux, "demux got %"PRId64" ms offset",
- MS_FROM_VLC_TICK(vlc_tick_now() - *(vlc_tick_t *)p_block->p_buffer) );
+ MS_FROM_VLC_TICK(vlc_tick_now() - *(vlc_tick_t *)p_frame->p_buffer) );
- //es_out_SetPCR( p_demux->out, p_block->i_pts );
+ //es_out_SetPCR( p_demux->out, p_frame->i_pts );
- es_out_Send( p_demux->out, p_sys->p_es, p_block );
+ es_out_Send( p_demux->out, p_sys->p_es, p_frame );
return 1;
}
diff --git a/modules/misc/xml/libxml.c b/modules/misc/xml/libxml.c
index 14dd887532..0898dea1b4 100644
--- a/modules/misc/xml/libxml.c
+++ b/modules/misc/xml/libxml.c
@@ -27,7 +27,6 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
-#include <vlc_block.h>
#include <vlc_stream.h>
#include <vlc_xml.h>
--
2.20.1
More information about the vlc-devel
mailing list