]> git.sesse.net Git - vlc/blob - modules/access_output/dummy.c
* all: split muxer and access into independant part.
[vlc] / modules / access_output / dummy.c
1 /*****************************************************************************
2  * dummy.c
3  *****************************************************************************
4  * Copyright (C) 2001, 2002 VideoLAN
5  * $Id: dummy.c,v 1.2 2003/02/16 14:10:44 fenrir Exp $
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *          Eric Petit <titer@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include <stdlib.h>
29 #include <sys/types.h>
30 #include <sys/stat.h>
31 #include <string.h>
32 #include <errno.h>
33 #include <fcntl.h>
34
35 #include <vlc/vlc.h>
36 #include <vlc/input.h>
37 #include <vlc/sout.h>
38
39 #ifdef HAVE_UNISTD_H
40 #   include <unistd.h>
41 #elif defined( _MSC_VER ) && defined( _WIN32 ) && !defined( UNDER_CE )
42 #   include <io.h>
43 #endif
44
45 /*****************************************************************************
46  * Exported prototypes
47  *****************************************************************************/
48 static int     Open   ( vlc_object_t * );
49 static void    Close  ( vlc_object_t * );
50
51 static int     Write( sout_access_out_t *, sout_buffer_t * );
52 static int     Seek ( sout_access_out_t *, off_t  );
53
54 /*****************************************************************************
55  * Module descriptor
56  *****************************************************************************/
57 vlc_module_begin();
58     set_description( _("Dummy stream ouput") );
59     set_capability( "sout access", 0 );
60     add_shortcut( "dummy" );
61     set_callbacks( Open, Close );
62 vlc_module_end();
63
64
65 /*****************************************************************************
66  * Open: open the file
67  *****************************************************************************/
68 static int Open( vlc_object_t *p_this )
69 {
70     sout_access_out_t   *p_access = (sout_access_out_t*)p_this;
71
72     p_access->p_sys    = NULL;
73     p_access->pf_write = Write;
74     p_access->pf_seek  = Seek;
75
76     msg_Info( p_access, "dummy stream output access launched" );
77     return VLC_SUCCESS;
78 }
79
80 /*****************************************************************************
81  * Close: close the target
82  *****************************************************************************/
83 static void Close( vlc_object_t * p_this )
84 {
85     sout_access_out_t   *p_access = (sout_access_out_t*)p_this;
86     msg_Info( p_access, "Close" );
87 }
88
89 /*****************************************************************************
90  * Read: standard read on a file descriptor.
91  *****************************************************************************/
92 static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
93 {
94     size_t i_write = 0;
95
96     do
97     {
98         sout_buffer_t *p_next;
99         i_write += p_buffer->i_size;
100         p_next = p_buffer->p_next;
101         sout_BufferDelete( p_access->p_sout, p_buffer );
102         p_buffer = p_next;
103     } while( p_buffer );
104
105     msg_Dbg( p_access, "Dummy Skipped: len:"I64Fd, (int64_t)i_write );
106
107     return( i_write );
108 }
109
110 /*****************************************************************************
111  * Seek: seek to a specific location in a file
112  *****************************************************************************/
113 static int Seek( sout_access_out_t *p_access, off_t i_pos )
114 {
115     msg_Dbg( p_access, "Seek: pos:"I64Fd, (int64_t)i_pos );
116     return( 0 );
117 }
118
119