/src/vlc/modules/demux/mkv/stream_io_callback.hpp
Line | Count | Source |
1 | | /***************************************************************************** |
2 | | * stream_io_callback.hpp : matroska demuxer |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 2003-2004 VLC authors and VideoLAN |
5 | | * |
6 | | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
7 | | * Steve Lhomme <steve.lhomme@free.fr> |
8 | | * |
9 | | * This program is free software; you can redistribute it and/or modify it |
10 | | * under the terms of the GNU Lesser General Public License as published by |
11 | | * the Free Software Foundation; either version 2.1 of the License, or |
12 | | * (at your option) any later version. |
13 | | * |
14 | | * This program is distributed in the hope that it will be useful, |
15 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | * GNU Lesser General Public License for more details. |
18 | | * |
19 | | * You should have received a copy of the GNU Lesser General Public License |
20 | | * along with this program; if not, write to the Free Software Foundation, |
21 | | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
22 | | *****************************************************************************/ |
23 | | |
24 | | #ifndef VLC_MKV_STREAM_IO_CALLBACK_HPP_ |
25 | | #define VLC_MKV_STREAM_IO_CALLBACK_HPP_ |
26 | | |
27 | | #ifdef HAVE_CONFIG_H |
28 | | # include "config.h" |
29 | | #endif |
30 | | |
31 | | #include <vlc_demux.h> |
32 | | |
33 | | #include <ebml/IOCallback.h> |
34 | | #include <ebml/EbmlStream.h> |
35 | | |
36 | | using namespace libebml; |
37 | | |
38 | | namespace mkv { |
39 | | |
40 | | /***************************************************************************** |
41 | | * Stream management |
42 | | *****************************************************************************/ |
43 | | class vlc_stream_io_callback: public IOCallback |
44 | | { |
45 | | private: |
46 | | stream_t *s; |
47 | | bool mb_eof; |
48 | | bool b_owner; |
49 | | |
50 | | public: |
51 | | vlc_stream_io_callback( stream_t *, bool owner ); |
52 | | |
53 | | virtual ~vlc_stream_io_callback() |
54 | 11.8k | { |
55 | 11.8k | if( b_owner ) |
56 | 0 | vlc_stream_Delete( s ); |
57 | 11.8k | } |
58 | | |
59 | 50.4k | bool IsEOF() const { return mb_eof; } |
60 | | |
61 | | uint32_t read ( void *p_buffer, size_t i_size) override; |
62 | | void setFilePointer ( int64_t i_offset, seek_mode mode = seek_beginning ) override; |
63 | | size_t write ( const void *p_buffer, size_t i_size) override; |
64 | | uint64_t getFilePointer ( void ) override; |
65 | 0 | void close ( void ) override { return; } |
66 | | }; |
67 | | |
68 | | class matroska_iostream_c : public EbmlStream |
69 | | { |
70 | | public: |
71 | | matroska_iostream_c(vlc_stream_io_callback & io) |
72 | 11.8k | :EbmlStream(io) |
73 | 11.8k | {} |
74 | | |
75 | 448k | inline vlc_stream_io_callback & I_O() { |
76 | 448k | return static_cast<vlc_stream_io_callback &>(EbmlStream::I_O()); |
77 | 448k | } |
78 | | |
79 | | private: |
80 | | // hide generic method |
81 | | using EbmlStream::I_O; |
82 | | }; |
83 | | |
84 | | |
85 | | } // namespace |
86 | | |
87 | | #endif |