]> git.sesse.net Git - vlc/blobdiff - modules/misc/dummy/vout.c
demux: provide both URL and file path as with access
[vlc] / modules / misc / dummy / vout.c
index 7ec402e9de31b4db7aeb3f3424ff09dfaf432a98..02c492264364535f7434b3fa061b397181f04a97 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
- * vout_dummy.c: Dummy video output display method for testing purposes
+ * vout.c: Dummy video output display method for testing purposes
  *****************************************************************************
- * Copyright (C) 2000, 2001 VideoLAN
- * $Id: vout.c,v 1.4 2003/03/28 11:34:52 sigmunau Exp $
+ * Copyright (C) 2000-2009 the VideoLAN team
+ * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -10,7 +10,7 @@
  * 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
  *
  * 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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                                /* free() */
-#include <string.h>                                            /* strerror() */
 
-#include <vlc/vlc.h>
-#include <vlc/vout.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
-#define DUMMY_WIDTH 16
-#define DUMMY_HEIGHT 16
-#define DUMMY_MAX_DIRECTBUFFERS 10
+#include <vlc_common.h>
+#include <vlc_vout_display.h>
+#include "dummy.h"
 
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int  Init       ( vout_thread_t * );
-static void End        ( vout_thread_t * );
-static int  Manage     ( vout_thread_t * );
-static void Render     ( vout_thread_t *, picture_t * );
-static void Display    ( vout_thread_t *, picture_t * );
-static void SetPalette ( vout_thread_t *, u16 *, u16 *, u16 * );
+struct vout_display_sys_t {
+    picture_pool_t *pool;
+};
+static picture_pool_t *Pool(vout_display_t *, unsigned count);
+static void            Display(vout_display_t *, picture_t *);
+static void            DisplayStat(vout_display_t *, picture_t *);
+static int             Control(vout_display_t *, int, va_list);
+static void            Manage (vout_display_t *);
 
 /*****************************************************************************
- * OpenVideo: activates dummy video thread output method
- *****************************************************************************
- * This function initializes a dummy vout method.
+ * OpenVideo: activates dummy vout display method
  *****************************************************************************/
-int E_(OpenVideo) ( vlc_object_t *p_this )
+static int OpenVideoCommon(vlc_object_t *object, bool display_stat)
 {
-    vout_thread_t * p_vout = (vout_thread_t *)p_this;
-
-    p_vout->pf_init = Init;
-    p_vout->pf_end = End;
-    p_vout->pf_manage = Manage;
-    p_vout->pf_render = Render;
-    p_vout->pf_display = Display;
+    vout_display_t *vd = (vout_display_t *)object;
+    vout_display_sys_t *sys;
+
+    vd->sys = sys = calloc(1, sizeof(*sys));
+    if (!sys)
+        return VLC_EGENERIC;
+    sys->pool = NULL;
+
+    /* p_vd->info is not modified */
+
+    char *chroma = var_CreateGetNonEmptyString(vd, "dummy-chroma");
+    if (chroma) {
+        vlc_fourcc_t fcc = vlc_fourcc_GetCodecFromString(VIDEO_ES, chroma);
+        if (fcc != 0) {
+            msg_Dbg(vd, "forcing chroma 0x%.8x (%4.4s)", fcc, (char*)&fcc);
+            vd->fmt.i_chroma = fcc;
+        }
+        free(chroma);
+    }
+    vd->pool    = Pool;
+    vd->prepare = NULL;
+    vd->display = display_stat ? DisplayStat : Display;
+    vd->control = Control;
+    vd->manage  = Manage;
 
     return VLC_SUCCESS;
 }
-
-/*****************************************************************************
- * Init: initialize dummy video thread output method
- *****************************************************************************/
-static int Init( vout_thread_t *p_vout )
+int OpenVideo(vlc_object_t *object)
 {
-    int i_index, i_chroma;
-    char *psz_chroma;
-    picture_t *p_pic;
-    vlc_bool_t b_chroma = 0;
-
-    psz_chroma = config_GetPsz( p_vout, "dummy-chroma" );
-    if( psz_chroma )
-    {
-        if( strlen( psz_chroma ) >= 4 )
-        {
-            i_chroma = VLC_FOURCC( psz_chroma[0], psz_chroma[1],
-                                   psz_chroma[2], psz_chroma[3] );
-            b_chroma = 1;
-        }
-
-        free( psz_chroma );
-    }
-
-    I_OUTPUTPICTURES = 0;
-
-    /* Initialize the output structure */
-    if( b_chroma )
-    {
-        msg_Dbg( p_vout, "forcing chroma 0x%.8x (%4.4s)",
-                         i_chroma, (char*)&i_chroma );
-        p_vout->output.i_chroma = i_chroma;
-        if ( i_chroma == VLC_FOURCC( 'R', 'G', 'B', '2' ) )
-        {
-            p_vout->output.pf_setpalette = SetPalette;
-        }
-        p_vout->output.i_width  = p_vout->render.i_width;
-        p_vout->output.i_height = p_vout->render.i_height;
-        p_vout->output.i_aspect = p_vout->render.i_aspect;
-    }
-    else
-    {
-        p_vout->output.i_chroma = VLC_FOURCC('R','V','1','6');
-        p_vout->output.i_rmask  = 0xf800;
-        p_vout->output.i_gmask  = 0x07e0;
-        p_vout->output.i_bmask  = 0x001f;
-        p_vout->output.i_width  = p_vout->render.i_width;
-        p_vout->output.i_height = p_vout->render.i_height;
-        p_vout->output.i_aspect = p_vout->render.i_aspect;
-    }
-
-    /* Try to initialize DUMMY_MAX_DIRECTBUFFERS direct buffers */
-    while( I_OUTPUTPICTURES < DUMMY_MAX_DIRECTBUFFERS )
-    {
-        p_pic = NULL;
-
-        /* Find an empty picture slot */
-        for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
-        {
-            if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
-            {
-                p_pic = p_vout->p_picture + i_index;
-                break;
-            }
-        }
-
-        /* Allocate the picture */
-        if( p_pic == NULL )
-        {
-            break;
-        }
-
-        vout_AllocatePicture( p_vout, p_pic, p_vout->output.i_width,
-                              p_vout->output.i_height,
-                              p_vout->output.i_chroma );
-
-        if( p_pic->i_planes == 0 )
-        {
-            break;
-        }
-
-        p_pic->i_status = DESTROYED_PICTURE;
-        p_pic->i_type   = DIRECT_PICTURE;
-
-        PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
+    return OpenVideoCommon(object, false);
+}
+int OpenVideoStat(vlc_object_t *object)
+{
+    return OpenVideoCommon(object, true);
+}
 
-        I_OUTPUTPICTURES++;
-    }
+void CloseVideo(vlc_object_t *object)
+{
+    vout_display_t *vd = (vout_display_t *)object;
+    vout_display_sys_t *sys = vd->sys;
 
-    return( 0 );
+    if (sys->pool)
+        picture_pool_Delete(sys->pool);
+    free(sys);
 }
 
-/*****************************************************************************
- * End: terminate dummy video thread output method
- *****************************************************************************/
-static void End( vout_thread_t *p_vout )
+static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
 {
-    int i_index;
-
-    /* Free the fake output buffers we allocated */
-    for( i_index = I_OUTPUTPICTURES ; i_index ; )
-    {
-        i_index--;
-        free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
-    }
+    vout_display_sys_t *sys = vd->sys;
+    if (!sys->pool)
+        sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
+    return sys->pool;
 }
 
-/*****************************************************************************
- * Manage: handle dummy events
- *****************************************************************************
- * This function should be called regularly by video output thread. It manages
- * console events. It returns a non null value on error.
- *****************************************************************************/
-static int Manage( vout_thread_t *p_vout )
+static void Display(vout_display_t *vd, picture_t *picture)
 {
-    return( 0 );
+    VLC_UNUSED(vd);
+    picture_Release(picture);
 }
 
-/*****************************************************************************
- * Render: render previously calculated output
- *****************************************************************************/
-static void Render( vout_thread_t *p_vout, picture_t *p_pic )
+static void DisplayStat(vout_display_t *vd, picture_t *picture)
 {
-    /* No need to do anything, the fake direct buffers stay as they are */
+    VLC_UNUSED(vd);
+    if (vd->fmt.i_width*vd->fmt.i_height >= sizeof(mtime_t)) {
+        mtime_t date;
+        memcpy(&date, picture->p->p_pixels, sizeof(date));
+        msg_Dbg(vd, "VOUT got %"PRIu64" ms offset",
+                (mdate() - date) / 1000 );
+    }
+    picture_Release(picture);
 }
 
-/*****************************************************************************
- * Display: displays previously rendered output
- *****************************************************************************/
-static void Display( vout_thread_t *p_vout, picture_t *p_pic )
+static int Control(vout_display_t *vd, int query, va_list args)
 {
-    /* No need to do anything, the fake direct buffers stay as they are */
+    VLC_UNUSED(vd);
+    VLC_UNUSED(query);
+    VLC_UNUSED(args);
+    return VLC_SUCCESS;
 }
 
-/*****************************************************************************
- * SetPalette: set the palette for the picture
- *****************************************************************************/
-static void SetPalette ( vout_thread_t *p_vout, u16 *red, u16 *green,
-                         u16 *blue )
+static void Manage(vout_display_t *vd)
 {
-    /* No need to do anything, the fake direct buffers stay as they are */
-}    
+    VLC_UNUSED(vd);
+}