]> git.sesse.net Git - vlc/blob - modules/demux/mkv/stream_io_callback.cpp
Blind compile fix
[vlc] / modules / demux / mkv / stream_io_callback.cpp
1
2 /*****************************************************************************
3  * mkv.cpp : matroska demuxer
4  *****************************************************************************
5  * Copyright (C) 2003-2004 the VideoLAN team
6  * $Id$
7  *
8  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
9  *          Steve Lhomme <steve.lhomme@free.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25 #include "stream_io_callback.hpp"
26
27 #include "matroska_segment.hpp"
28 #include "demux.hpp"
29 /*****************************************************************************
30  * Stream managment
31  *****************************************************************************/
32 vlc_stream_io_callback::vlc_stream_io_callback( stream_t *s_, bool b_owner_ )
33 {
34     s = s_;
35     b_owner = b_owner_;
36     mb_eof = false;
37 }
38
39 uint32 vlc_stream_io_callback::read( void *p_buffer, size_t i_size )
40 {
41     if( i_size <= 0 || mb_eof )
42     {
43         return 0;
44     }
45
46     return stream_Read( s, p_buffer, i_size );
47 }
48 void vlc_stream_io_callback::setFilePointer(int64_t i_offset, seek_mode mode )
49 {
50     int64_t i_pos;
51
52     switch( mode )
53     {
54         case seek_beginning:
55             i_pos = i_offset;
56             break;
57         case seek_end:
58             i_pos = stream_Size( s ) - i_offset;
59             break;
60         default:
61             i_pos= stream_Tell( s ) + i_offset;
62             break;
63     }
64
65     if( i_pos < 0 || i_pos >= stream_Size( s ) )
66     {
67         mb_eof = true;
68         return;
69     }
70
71     mb_eof = false;
72     if( stream_Seek( s, i_pos ) )
73     {
74         mb_eof = true;
75     }
76     return;
77 }
78 size_t vlc_stream_io_callback::write( const void *p_buffer, size_t i_size )
79 {
80     return 0;
81 }
82 uint64 vlc_stream_io_callback::getFilePointer( void )
83 {
84     if ( s == NULL )
85         return 0;
86     return stream_Tell( s );
87 }
88 void vlc_stream_io_callback::close( void )
89 {
90     return;
91 }
92
93
94