]> git.sesse.net Git - vlc/commitdiff
stats: Initial import of a stat oriented module. Use with /vlc --ignore-config -I...
authorPierre d'Herbemont <pdherbemont@videolan.org>
Mon, 19 May 2008 17:14:54 +0000 (19:14 +0200)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Thu, 5 Jun 2008 19:14:31 +0000 (21:14 +0200)
configure.ac
modules/misc/Modules.am
modules/misc/stats/Modules.am [new file with mode: 0644]
modules/misc/stats/decoder.c [new file with mode: 0644]
modules/misc/stats/demux.c [new file with mode: 0644]
modules/misc/stats/encoder.c [new file with mode: 0644]
modules/misc/stats/stats.c [new file with mode: 0644]
modules/misc/stats/stats.h [new file with mode: 0644]

index 4453726b082065d4abb975e0faefcbb224ff7c6f..8220e701f0467178aebc765964095584ab916bbf 100644 (file)
@@ -1080,6 +1080,7 @@ dnl
 dnl  default modules
 dnl
 VLC_ADD_PLUGIN([dummy])
+VLC_ADD_PLUGIN([stats])
 VLC_ADD_PLUGIN([logger])
 VLC_ADD_PLUGIN([memcpy])
 dnl Demuxers:
@@ -5898,6 +5899,7 @@ AC_CONFIG_FILES([
   modules/misc/testsuite/Makefile
   modules/misc/playlist/Makefile
   modules/misc/osd/Makefile
+  modules/misc/stats/Makefile
   modules/misc/xml/Makefile
   modules/misc/probe/Makefile
   modules/mux/Makefile
index 6795ea9d2eb5cd2b1749eeb26e25761cd78faa08..c81f4de1a7e99d87f7608ee8e84af6852b449966 100644 (file)
@@ -1,4 +1,4 @@
-BASE_SUBDIRS = dummy memcpy notify testsuite playlist osd xml probe
+BASE_SUBDIRS = dummy memcpy notify testsuite playlist stats osd xml probe
 EXTRA_SUBDIRS = lua
 
 SUBDIRS = $(BASE_SUBDIRS)
diff --git a/modules/misc/stats/Modules.am b/modules/misc/stats/Modules.am
new file mode 100644 (file)
index 0000000..d166042
--- /dev/null
@@ -0,0 +1,8 @@
+SOURCES_stats = \
+       stats.c \
+       stats.h \
+       decoder.c \
+       demux.c \
+       encoder.c \
+       $(NULL)
+
diff --git a/modules/misc/stats/decoder.c b/modules/misc/stats/decoder.c
new file mode 100644 (file)
index 0000000..db11673
--- /dev/null
@@ -0,0 +1,86 @@
+/*****************************************************************************
+ * decoder.c: stats decoder plugin for vlc.
+ *****************************************************************************
+ * Copyright (C) 2002 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Samuel Hocevar <sam@zoy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc/vlc.h>
+#include <vlc_codec.h>
+
+#include "stats.h"
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block );
+
+/*****************************************************************************
+ * OpenDecoder: Open the decoder
+ *****************************************************************************/
+int OpenDecoder ( vlc_object_t *p_this )
+{
+    decoder_t *p_dec = (decoder_t*)p_this;
+
+    msg_Dbg( p_this, "opening stats decoder" );
+
+    /* Set callbacks */
+    p_dec->pf_decode_video = DecodeBlock;
+    p_dec->pf_decode_audio = NULL;
+    p_dec->pf_decode_sub = NULL;
+
+    return VLC_SUCCESS;
+}
+
+/****************************************************************************
+ * RunDecoder: the whole thing
+ ****************************************************************************/
+static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
+{
+    decoder_sys_t *p_sys = p_dec->p_sys;
+    block_t *p_block;
+
+    if( !pp_block || !*pp_block ) return NULL;
+    p_block = *pp_block;
+
+    if( p_block->i_buffer == kBufferSize )
+    {
+        msg_Dbg( p_dec, "got %d ms offset", (mdate() - *(mtime_t *)p_block->p_buffer) / 1000 );
+    }
+    else
+        msg_Dbg( p_dec, "got offset of size %d", p_block->i_buffer );
+
+    block_Release( p_block );
+    return NULL;
+}
+
+/*****************************************************************************
+ * CloseDecoder: decoder destruction
+ *****************************************************************************/
+void CloseDecoder ( vlc_object_t *p_this )
+{
+    msg_Dbg( p_this, "closing stats decoder" );
+}
diff --git a/modules/misc/stats/demux.c b/modules/misc/stats/demux.c
new file mode 100644 (file)
index 0000000..f2e9aec
--- /dev/null
@@ -0,0 +1,125 @@
+/*****************************************************************************
+ * input_dummy.c: dummy input plugin, to manage "vlc:***" special options
+ *****************************************************************************
+ * Copyright (C) 2001, 2002 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Samuel Hocevar <sam@zoy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc/vlc.h>
+#include <vlc_interface.h>
+#include <vlc_access.h>
+#include <vlc_demux.h>
+#include <vlc_playlist.h>
+
+#include "stats.h"
+
+
+/*****************************************************************************
+ * Demux
+ *****************************************************************************/
+
+
+struct demux_sys_t
+{
+    es_format_t     fmt;
+    es_out_id_t     *p_es;
+
+    date_t          pts;
+};
+
+static int Demux( demux_t * );
+static int DemuxControl( demux_t *, int, va_list );
+
+
+/*****************************************************************************
+ * OpenDemux
+ *****************************************************************************/
+int OpenDemux ( vlc_object_t *p_this )
+{
+    demux_t *p_demux = (demux_t*)p_this;
+    demux_sys_t *p_sys;
+
+    msg_Dbg( p_demux, "Init Stat demux" );
+
+    p_demux->pf_demux   = Demux;
+    p_demux->pf_control = DemuxControl;
+
+    p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
+    if( !p_demux->p_sys )
+        return VLC_ENOMEM;
+
+    date_Init( &p_sys->pts, 1, 1 );
+    date_Set( &p_sys->pts, 1 );
+
+    es_format_Init( &p_sys->fmt, VIDEO_ES, VLC_FOURCC('s','t','a','t') );
+    p_sys->fmt.video.i_width = 720;
+    p_sys->fmt.video.i_height= 480;
+
+    p_sys->p_es = es_out_Add( p_demux->out, &p_sys->fmt );
+
+    return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * CloseDemux
+ *****************************************************************************/
+void CloseDemux ( vlc_object_t *p_this )
+{
+    demux_t *p_demux = (demux_t*)p_this;
+
+    msg_Dbg( p_demux, "Closing Stat demux" );
+
+    free( p_demux->p_sys );
+}
+
+/*****************************************************************************
+ * Demux
+ *****************************************************************************/
+static int Demux( demux_t *p_demux )
+{
+    demux_sys_t *p_sys = p_demux->p_sys;
+
+    msg_Dbg( p_demux, "Demux" );
+
+    block_t * p_block = stream_Block( p_demux->s, kBufferSize );
+
+    p_block->i_dts = p_block->i_pts =
+        date_Increment( &p_sys->pts, kBufferSize );
+
+    //es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );
+
+    es_out_Send( p_demux->out, p_sys->p_es, p_block );
+
+    return 1;
+}
+
+static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
+{
+    return demux_vaControlHelper( p_demux->s,
+                                   0, 0, 0, 1,
+                                   i_query, args );
+}
diff --git a/modules/misc/stats/encoder.c b/modules/misc/stats/encoder.c
new file mode 100644 (file)
index 0000000..eff4a21
--- /dev/null
@@ -0,0 +1,111 @@
+/*****************************************************************************
+ * encoder.c: dummy encoder plugin for vlc.
+ *****************************************************************************
+ * Copyright (C) 2002 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Gildas Bazin <gbazin@netcourrier.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc/vlc.h>
+#include <vlc_codec.h>
+#include <vlc_vout.h>
+
+#include "stats.h"
+
+/*****************************************************************************
+ * encoder_sys_t
+ *****************************************************************************/
+struct encoder_sys_t
+{
+    int i;
+};
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict );
+static block_t *EncodeAudio( encoder_t *p_enc, picture_t *p_pict );
+
+/*****************************************************************************
+ * OpenDecoder: open the dummy encoder.
+ *****************************************************************************/
+int OpenEncoder ( vlc_object_t *p_this )
+{
+    encoder_t *p_enc = (encoder_t *)p_this;
+
+    p_enc->p_sys = malloc(sizeof(encoder_sys_t));
+
+    if( !p_enc->p_sys ) return VLC_ENOMEM;
+
+    p_enc->p_sys->i = 0;
+
+    msg_Dbg( p_this, "opening stats encoder" );
+
+    p_enc->pf_encode_video = EncodeVideo;
+    p_enc->pf_encode_audio = EncodeAudio;
+
+
+    return VLC_SUCCESS;
+}
+
+/****************************************************************************
+ * EncodeVideo: the whole thing
+ ****************************************************************************/
+static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
+{
+    (void)p_pict;
+    block_t * p_block = block_New( p_enc, kBufferSize );
+
+    *(mtime_t*)p_block->p_buffer = mdate();
+    p_block->i_buffer = kBufferSize;
+    p_block->i_length = kBufferSize;
+    p_block->i_dts = p_pict->date;
+
+    msg_Dbg( p_enc, "putting %dms", *(mtime_t*)p_block->p_buffer / 1000 );
+
+    return p_block;
+}
+
+/****************************************************************************
+ * EncodeVideo: the whole thing
+ ****************************************************************************/
+static block_t *EncodeAudio( encoder_t *p_enc, picture_t *p_pict )
+{
+    (void)p_pict;
+    (void)p_enc;
+    return NULL;
+}
+
+
+/*****************************************************************************
+ * CloseDecoder: decoder destruction
+ *****************************************************************************/
+void CloseEncoder ( vlc_object_t *p_this )
+{
+    encoder_t *p_enc = (encoder_t *)p_this;
+
+    msg_Dbg( p_this, "closing stats encoder" );
+    free( p_enc->p_sys );
+}
diff --git a/modules/misc/stats/stats.c b/modules/misc/stats/stats.c
new file mode 100644 (file)
index 0000000..751f3b3
--- /dev/null
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * stats.c : stats plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000, 2001 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Samuel Hocevar <sam@zoy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc/vlc.h>
+#include <vlc_plugin.h>
+
+#include "stats.h"
+
+/*****************************************************************************
+ * Module descriptor
+ *****************************************************************************/
+
+vlc_module_begin();
+    set_shortname( _("Stats"));
+    set_description( _("Stats encoder function") );
+    set_capability( "encoder", 0 );
+    add_shortcut( "stats" );
+    set_callbacks( OpenEncoder, CloseEncoder );
+    add_submodule();
+        set_section( N_( "Stats decoder" ), NULL );
+        set_description( _("Stats decoder function") );
+        set_capability( "decoder", 0 );
+        set_callbacks( OpenDecoder, CloseDecoder );
+    add_submodule();
+        set_section( N_( "Stats demux" ), NULL );
+        set_description( _("Stats demux function") );
+        set_capability( "demux", 0 );
+        set_callbacks( OpenDemux, CloseDemux );
+vlc_module_end();
+
diff --git a/modules/misc/stats/stats.h b/modules/misc/stats/stats.h
new file mode 100644 (file)
index 0000000..4125f4d
--- /dev/null
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * stats.h : stats plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000, 2001, 2002 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Samuel Hocevar <sam@zoy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * External prototypes
+ *****************************************************************************/
+
+int  OpenDecoder  ( vlc_object_t * );
+void CloseDecoder ( vlc_object_t * );
+
+int  OpenEncoder  ( vlc_object_t * );
+void CloseEncoder ( vlc_object_t * );
+
+int  OpenDemux    ( vlc_object_t * );
+void CloseDemux   ( vlc_object_t * );
+
+#define kBufferSize 0x500