/src/vlc/modules/demux/subtitle_helper.h
Line | Count | Source |
1 | | /***************************************************************************** |
2 | | * subtitle.h: subtitle helper functions |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 2015 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 | | |
21 | | inline static char * peek_Readline( stream_t *p_demuxstream, uint64_t *pi_offset ) |
22 | 1.51k | { |
23 | 1.51k | uint8_t *p_peek; |
24 | 1.51k | ssize_t i_peek = vlc_stream_Peek( p_demuxstream, (const uint8_t **) &p_peek, |
25 | 1.51k | *pi_offset + 2048 ); |
26 | 1.51k | if( i_peek < 0 || (uint64_t) i_peek < *pi_offset ) |
27 | 0 | return NULL; |
28 | | |
29 | 1.51k | const uint64_t i_bufsize = (uint64_t) i_peek - *pi_offset; |
30 | 1.51k | char *psz_line = NULL; |
31 | | |
32 | | /* Create a stream memory from that offset */ |
33 | 1.51k | stream_t *p_memorystream = vlc_stream_MemoryNew( p_demuxstream, |
34 | 1.51k | &p_peek[*pi_offset], |
35 | 1.51k | i_bufsize, true ); |
36 | 1.51k | if( p_memorystream ) |
37 | 1.51k | { |
38 | 1.51k | psz_line = vlc_stream_ReadLine( p_memorystream ); |
39 | | |
40 | 1.51k | *pi_offset += vlc_stream_Tell( p_memorystream ); |
41 | 1.51k | vlc_stream_Delete( p_memorystream ); |
42 | 1.51k | } |
43 | | |
44 | 1.51k | return psz_line; |
45 | 1.51k | } |