/src/vlc/modules/demux/mpeg/ts_streamwrapper.h
Line | Count | Source |
1 | | /***************************************************************************** |
2 | | * ts_streamwrapper.c: Stream filter source wrapper |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 2020 VideoLabs, VLC authors and VideoLAN |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify it |
7 | | * under the terms of the GNU Lesser General Public License as published by |
8 | | * the Free Software Foundation; either version 2.1 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public License |
17 | | * along with this program; if not, write to the Free Software Foundation, |
18 | | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
19 | | *****************************************************************************/ |
20 | | #include <vlc_stream.h> |
21 | | |
22 | | static int ts_stream_wrapper_Control(stream_t *s, int i_query, va_list va) |
23 | 0 | { |
24 | 0 | stream_t *demuxstream = s->p_sys; |
25 | 0 | return demuxstream->pf_control(demuxstream, i_query, va); |
26 | 0 | } |
27 | | |
28 | | static ssize_t ts_stream_wrapper_Read(stream_t *s, void *buf, size_t len) |
29 | 0 | { |
30 | 0 | stream_t *demuxstream = s->p_sys; |
31 | 0 | return demuxstream->pf_read(demuxstream, buf, len); |
32 | 0 | } |
33 | | |
34 | | static block_t * ts_stream_wrapper_ReadBlock(stream_t *s, bool *restrict eof) |
35 | 0 | { |
36 | 0 | stream_t *demuxstream = s->p_sys; |
37 | 0 | return demuxstream->pf_block(demuxstream, eof); |
38 | 0 | } |
39 | | |
40 | | static int ts_stream_wrapper_Seek(stream_t *s, uint64_t pos) |
41 | 0 | { |
42 | 0 | stream_t *demuxstream = s->p_sys; |
43 | 0 | return demuxstream->pf_seek(demuxstream, pos); |
44 | 0 | } |
45 | | |
46 | | static void ts_stream_wrapper_Destroy(stream_t *s) |
47 | 0 | { |
48 | 0 | VLC_UNUSED(s); |
49 | 0 | } |
50 | | |
51 | | static stream_t * ts_stream_wrapper_New(stream_t *demuxstream) |
52 | 0 | { |
53 | 0 | stream_t *s = vlc_stream_CommonNew(VLC_OBJECT(demuxstream), |
54 | 0 | ts_stream_wrapper_Destroy); |
55 | 0 | if(s) |
56 | 0 | { |
57 | 0 | s->p_sys = demuxstream; |
58 | 0 | s->s = s; |
59 | 0 | if(demuxstream->pf_read) |
60 | 0 | s->pf_read = ts_stream_wrapper_Read; |
61 | 0 | if(demuxstream->pf_control) |
62 | 0 | s->pf_control = ts_stream_wrapper_Control; |
63 | 0 | if(demuxstream->pf_seek) |
64 | 0 | s->pf_seek = ts_stream_wrapper_Seek; |
65 | 0 | if(demuxstream->pf_block) |
66 | 0 | s->pf_block = ts_stream_wrapper_ReadBlock; |
67 | 0 | } |
68 | 0 | return s; |
69 | 0 | } |