[vlc-devel] commit: Added a new "video splitter" module type. (Laurent Aimar )

git version control git at videolan.org
Sat Jun 6 19:59:09 CEST 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Jun  6 15:51:53 2009 +0200| [36306a1881d4001e929ca0ea8edf1b48fa9060d3] | committer: Laurent Aimar 

Added a new "video splitter" module type.

It will be used to create multiple video from one without having to fake
a video output (and all its overhead).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=36306a1881d4001e929ca0ea8edf1b48fa9060d3
---

 include/vlc_video_splitter.h |  159 ++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am              |    1 +
 src/libvlccore.sym           |    2 +
 src/misc/filter.c            |   38 ++++++++++
 4 files changed, 200 insertions(+), 0 deletions(-)

diff --git a/include/vlc_video_splitter.h b/include/vlc_video_splitter.h
new file mode 100644
index 0000000..7f13096
--- /dev/null
+++ b/include/vlc_video_splitter.h
@@ -0,0 +1,159 @@
+/*****************************************************************************
+ * vlc_video_splitter.h: "video splitter" related structures and functions
+ *****************************************************************************
+ * Copyright (C) 2009 Laurent Aimar
+ * $Id$
+ *
+ * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ 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.
+ *****************************************************************************/
+
+#ifndef VLC_VIDEO_SPLITTER_H
+#define VLC_VIDEO_SPLITTER_H 1
+
+#include <vlc_es.h>
+#include <vlc_picture.h>
+#include <vlc_mouse.h>
+
+/**
+ * \file
+ * This file defines the structure and types used by video splitter filters.
+ */
+
+typedef struct video_splitter_t video_splitter_t;
+typedef struct video_splitter_sys_t video_splitter_sys_t;
+typedef struct video_splitter_owner_t video_splitter_owner_t;
+
+/** Structure describing a video splitter output properties
+ */
+typedef struct
+{
+    /* Video format of the output */
+    video_format_t fmt;
+
+    /* Window hints */
+    struct
+    {
+        /* Position
+         * Use (-1,-1) if you do not wish to force a position.
+         */
+        int i_x;
+        int i_y;
+
+        /* Alignment inside the window
+         * Use 0 for default.
+         */
+        int i_align;
+    } window;
+
+    /* Video output module
+     * Use NULL for default
+     */
+    char *psz_module;
+
+} video_splitter_output_t;
+
+/** Structure describing a video splitter
+ */
+struct video_splitter_t
+{
+    VLC_COMMON_MEMBERS
+
+    /* Module properties */
+    module_t        *p_module;
+
+    /* configuration */
+    config_chain_t  *p_cfg;
+
+    /* Input format
+     * It is filled by the creator and cannot be modified.
+     */
+    video_format_t  fmt;
+
+    /* Output formats
+     *
+     * It can only be set in the open() function and must remain
+     * constant.
+     * The module is responsible for the allocation and deallocation.
+     */
+    int                     i_output;
+    video_splitter_output_t *p_output;
+
+    int             (*pf_filter)( video_splitter_t *, picture_t *pp_dst[],
+                                  picture_t *p_src );
+    int             (*pf_mouse) ( video_splitter_t *, vlc_mouse_t *,
+                                  int i_index,
+                                  const vlc_mouse_t *p_old, const vlc_mouse_t *p_new );
+
+    video_splitter_sys_t *p_sys;
+
+    /* Buffer allocation */
+    int  (*pf_picture_new) ( video_splitter_t *, picture_t *pp_picture[] );
+    void (*pf_picture_del) ( video_splitter_t *, picture_t *pp_picture[] );
+    video_splitter_owner_t *p_owner;
+};
+
+/**
+ * It will create an array of pictures suitable as output.
+ *
+ * You must either returned them through pf_filter or by calling
+ * video_splitter_DeletePicture.
+ *
+ * If VLC_SUCCESS is not returned, pp_picture values are undefined.
+ */
+static inline int video_splitter_NewPicture( video_splitter_t *p_splitter,
+                                             picture_t *pp_picture[] )
+{
+    int i_ret = p_splitter->pf_picture_new( p_splitter, pp_picture );
+    if( i_ret )
+        msg_Warn( p_splitter, "can't get output pictures" );
+    return i_ret;
+}
+
+/**
+ * It will release an array of pictures created by video_splitter_NewPicture.
+ * Provided for convenience.
+ */
+static inline void video_splitter_DeletePicture( video_splitter_t *p_splitter,
+                                                 picture_t *pp_picture[] )
+{
+    p_splitter->pf_picture_del( p_splitter, pp_picture );
+}
+
+/* */
+VLC_EXPORT( video_splitter_t *, video_splitter_New, ( vlc_object_t *, const char *psz_name, const video_format_t * ) );
+VLC_EXPORT( void, video_splitter_Delete, ( video_splitter_t * ) );
+
+static inline int video_splitter_Filter( video_splitter_t *p_splitter,
+                                         picture_t *pp_dst[], picture_t *p_src )
+{
+    return p_splitter->pf_filter( p_splitter, pp_dst, p_src );
+}
+static inline int video_splitter_Mouse( video_splitter_t *p_splitter,
+                                        vlc_mouse_t *p_mouse,
+                                        int i_index,
+                                        const vlc_mouse_t *p_old, const vlc_mouse_t *p_new )
+{
+    if( !p_splitter->pf_mouse )
+    {
+        *p_mouse = *p_new;
+        return VLC_SUCCESS;
+    }
+    return p_splitter->pf_mouse( p_splitter, p_mouse, i_index, p_old, p_new );
+}
+
+#endif /* VLC_VIDEO_SPLITTER_H */
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 42250be..449bcdc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -93,6 +93,7 @@ pluginsinclude_HEADERS = \
 	../include/vlc_url.h \
 	../include/vlc_variables.h \
 	../include/vlc_vlm.h \
+	../include/vlc_video_splitter.h \
 	../include/vlc_vout.h \
 	../include/vlc_window.h \
 	../include/vlc_xml.h \
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 8c81d00..d588c37 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -445,6 +445,8 @@ __var_Type
 video_format_FixRgb
 video_format_IsSimilar
 video_format_Setup
+video_splitter_Delete
+video_splitter_New
 vlc_avcodec_mutex
 vlc_b64_decode
 vlc_b64_decode_binary
diff --git a/src/misc/filter.c b/src/misc/filter.c
index 801fae7..7ced511 100644
--- a/src/misc/filter.c
+++ b/src/misc/filter.c
@@ -106,3 +106,41 @@ void filter_DeleteBlend( filter_t *p_blend )
     vlc_object_release( p_blend );
 }
 
+/* */
+#include <vlc_video_splitter.h>
+
+video_splitter_t *video_splitter_New( vlc_object_t *p_this,
+                                      const char *psz_name,
+                                      const video_format_t *p_fmt )
+{
+    video_splitter_t *p_splitter = vlc_custom_create( p_this, sizeof(*p_splitter),
+                                           VLC_OBJECT_GENERIC, "video splitter" );
+    if( !p_splitter )
+        return NULL;
+
+    video_format_Copy( &p_splitter->fmt, p_fmt );
+
+    /* */
+    vlc_object_attach( p_splitter, p_this );
+
+    p_splitter->p_module = module_need( p_splitter, "video splitter", psz_name, true );
+    if( ! p_splitter->p_module )
+    {
+        video_splitter_Delete( p_splitter );
+        return NULL;
+    }
+
+    return p_splitter;
+}
+
+void video_splitter_Delete( video_splitter_t *p_splitter )
+{
+    if( p_splitter->p_module )
+        module_unneed( p_splitter, p_splitter->p_module );
+
+    video_format_Clean( &p_splitter->fmt );
+
+    vlc_object_detach( p_splitter );
+    vlc_object_release( p_splitter );
+}
+




More information about the vlc-devel mailing list