Mercurial > mplayer.hg
annotate libmpdemux/stream.h @ 3830:fc1db33734e7
WinID cleanup, support for Xv
author | arpi |
---|---|
date | Fri, 28 Dec 2001 13:24:27 +0000 |
parents | d3fc41a04cb7 |
children | 449fc79d1ae3 |
rev | line source |
---|---|
998
8c83e3ff26cc
Added ifndef to prevent multiple header file inclusion.
bertrand
parents:
692
diff
changeset
|
1 #ifndef __STREAM_H |
8c83e3ff26cc
Added ifndef to prevent multiple header file inclusion.
bertrand
parents:
692
diff
changeset
|
2 #define __STREAM_H |
578 | 3 |
4 #define STREAM_BUFFER_SIZE 2048 | |
5 | |
6 #define STREAMTYPE_FILE 0 | |
7 #define STREAMTYPE_VCD 1 | |
692 | 8 #define STREAMTYPE_STREAM 2 // same as FILE but no seeking (for stdin) |
1594 | 9 #define STREAMTYPE_DVD 3 |
2144 | 10 #define STREAMTYPE_MEMORY 4 |
2790 | 11 #define STREAMTYPE_TV 5 |
578 | 12 |
13 #define VCD_SECTOR_SIZE 2352 | |
14 #define VCD_SECTOR_OFFS 24 | |
15 #define VCD_SECTOR_DATA 2324 | |
16 | |
3043
02a43ca97b52
Added a new struct to stream_t to handle, network streaming.
bertrand
parents:
2935
diff
changeset
|
17 #ifdef STREAMING |
02a43ca97b52
Added a new struct to stream_t to handle, network streaming.
bertrand
parents:
2935
diff
changeset
|
18 #include "network.h" |
02a43ca97b52
Added a new struct to stream_t to handle, network streaming.
bertrand
parents:
2935
diff
changeset
|
19 #endif |
02a43ca97b52
Added a new struct to stream_t to handle, network streaming.
bertrand
parents:
2935
diff
changeset
|
20 |
578 | 21 int vcd_seek_to_track(int fd,int track); |
22 void vcd_read_toc(int fd); | |
23 | |
24 #ifdef VCD_CACHE | |
25 void vcd_cache_init(int s); | |
26 #endif | |
27 | |
28 typedef struct { | |
29 int fd; | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
30 off_t pos; |
578 | 31 int eof; |
32 int type; // 0=file 1=VCD | |
33 unsigned int buf_pos,buf_len; | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
34 off_t start_pos,end_pos; |
2322 | 35 unsigned int cache_pid; |
36 void* cache_data; | |
2144 | 37 void* priv; // used for DVD |
583 | 38 unsigned char buffer[STREAM_BUFFER_SIZE>VCD_SECTOR_SIZE?STREAM_BUFFER_SIZE:VCD_SECTOR_SIZE]; |
3043
02a43ca97b52
Added a new struct to stream_t to handle, network streaming.
bertrand
parents:
2935
diff
changeset
|
39 #ifdef STREAMING |
02a43ca97b52
Added a new struct to stream_t to handle, network streaming.
bertrand
parents:
2935
diff
changeset
|
40 streaming_ctrl_t *streaming_ctrl; |
02a43ca97b52
Added a new struct to stream_t to handle, network streaming.
bertrand
parents:
2935
diff
changeset
|
41 #endif |
578 | 42 } stream_t; |
43 | |
2322 | 44 #ifdef USE_STREAM_CACHE |
3600 | 45 void stream_enable_cache(stream_t *stream,int size,int min,int prefill); |
2322 | 46 #else |
47 // no cache | |
48 #define cache_stream_fill_buffer(x) stream_fill_buffer(x) | |
49 #define cache_stream_seek_long(x,y) stream_seek_long(x,y) | |
50 #define stream_enable_cache(x,y) | |
51 #endif | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
52 |
2322 | 53 int cache_stream_fill_buffer(stream_t *s); |
54 int cache_stream_seek_long(stream_t *s,off_t pos); | |
578 | 55 |
3726 | 56 #include <string.h> |
57 | |
578 | 58 inline static int stream_read_char(stream_t *s){ |
59 return (s->buf_pos<s->buf_len)?s->buffer[s->buf_pos++]: | |
2322 | 60 (cache_stream_fill_buffer(s)?s->buffer[s->buf_pos++]:-256); |
578 | 61 // if(s->buf_pos<s->buf_len) return s->buffer[s->buf_pos++]; |
62 // stream_fill_buffer(s); | |
63 // if(s->buf_pos<s->buf_len) return s->buffer[s->buf_pos++]; | |
64 // return 0; // EOF | |
65 } | |
66 | |
67 inline static unsigned int stream_read_word(stream_t *s){ | |
68 int x,y; | |
69 x=stream_read_char(s); | |
70 y=stream_read_char(s); | |
71 return (x<<8)|y; | |
72 } | |
73 | |
74 inline static unsigned int stream_read_dword(stream_t *s){ | |
75 unsigned int y; | |
76 y=stream_read_char(s); | |
77 y=(y<<8)|stream_read_char(s); | |
78 y=(y<<8)|stream_read_char(s); | |
79 y=(y<<8)|stream_read_char(s); | |
80 return y; | |
81 } | |
82 | |
83 inline static unsigned int stream_read_word_le(stream_t *s){ | |
84 int x,y; | |
85 x=stream_read_char(s); | |
86 y=stream_read_char(s); | |
87 return (y<<8)|x; | |
88 } | |
89 | |
90 inline static unsigned int stream_read_dword_le(stream_t *s){ | |
91 unsigned int y; | |
92 y=stream_read_char(s); | |
93 y|=stream_read_char(s)<<8; | |
94 y|=stream_read_char(s)<<16; | |
95 y|=stream_read_char(s)<<24; | |
96 return y; | |
97 } | |
98 | |
2347 | 99 inline static int stream_read(stream_t *s,char* mem,int total){ |
100 int len=total; | |
578 | 101 while(len>0){ |
102 int x; | |
103 x=s->buf_len-s->buf_pos; | |
104 if(x==0){ | |
2347 | 105 if(!cache_stream_fill_buffer(s)) return total-len; // EOF |
578 | 106 x=s->buf_len-s->buf_pos; |
107 } | |
108 if(s->buf_pos>s->buf_len) printf("stream_read: WARNING! s->buf_pos>s->buf_len\n"); | |
109 if(x>len) x=len; | |
110 memcpy(mem,&s->buffer[s->buf_pos],x); | |
111 s->buf_pos+=x; mem+=x; len-=x; | |
112 } | |
2347 | 113 return total; |
578 | 114 } |
115 | |
116 inline static int stream_eof(stream_t *s){ | |
117 return s->eof; | |
118 } | |
119 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
120 inline static off_t stream_tell(stream_t *s){ |
578 | 121 return s->pos+s->buf_pos-s->buf_len; |
122 } | |
123 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
124 inline static int stream_seek(stream_t *s,off_t pos){ |
578 | 125 |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
126 // if(verbose>=3) printf("seek to 0x%qX\n",(long long)pos); |
578 | 127 |
128 if(pos<s->pos){ | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
129 off_t x=pos-(s->pos-s->buf_len); |
578 | 130 if(x>=0){ |
131 s->buf_pos=x; | |
132 // putchar('*');fflush(stdout); | |
133 return 1; | |
134 } | |
135 } | |
136 | |
2322 | 137 return cache_stream_seek_long(s,pos); |
578 | 138 } |
139 | |
1491 | 140 inline static int stream_skip(stream_t *s,int len){ |
692 | 141 if(len<0 || (len>2*STREAM_BUFFER_SIZE && s->type!=STREAMTYPE_STREAM)){ |
578 | 142 // negative or big skip! |
1491 | 143 return stream_seek(s,stream_tell(s)+len); |
578 | 144 } |
145 while(len>0){ | |
146 int x=s->buf_len-s->buf_pos; | |
147 if(x==0){ | |
2322 | 148 if(!cache_stream_fill_buffer(s)) return 0; // EOF |
578 | 149 x=s->buf_len-s->buf_pos; |
150 } | |
151 if(x>len) x=len; | |
152 //memcpy(mem,&s->buf[s->buf_pos],x); | |
153 s->buf_pos+=x; len-=x; | |
154 } | |
1491 | 155 return 1; |
578 | 156 } |
157 | |
158 void stream_reset(stream_t *s); | |
159 stream_t* new_stream(int fd,int type); | |
160 void free_stream(stream_t *s); | |
2144 | 161 stream_t* new_memory_stream(unsigned char* data,int len); |
2555
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
162 stream_t* open_stream(char* filename,int vcd_track,int* file_format); |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
163 |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
164 //#ifdef USE_DVDREAD |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
165 extern int dvd_title; |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
166 extern int dvd_chapter; |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
167 extern int dvd_angle; |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
168 //#endif |
998
8c83e3ff26cc
Added ifndef to prevent multiple header file inclusion.
bertrand
parents:
692
diff
changeset
|
169 |
2935 | 170 #ifdef USE_DVDREAD |
171 | |
172 #include <dvdread/dvd_reader.h> | |
173 #include <dvdread/ifo_types.h> | |
174 #include <dvdread/ifo_read.h> | |
175 #include <dvdread/nav_read.h> | |
176 | |
177 typedef struct { | |
178 int id; // 0 - 31 mpeg; 128 - 159 ac3; 160 - 191 pcm | |
179 int language; | |
3751
d9d2ee82a243
subtitle_t + audio_stream_t -> stream_language_t (cleanup)
arpi
parents:
3726
diff
changeset
|
180 } stream_language_t; |
3048 | 181 |
182 typedef struct { | |
2935 | 183 dvd_reader_t *dvd; |
184 dvd_file_t *title; | |
185 ifo_handle_t *vmg_file; | |
186 tt_srpt_t *tt_srpt; | |
187 ifo_handle_t *vts_file; | |
188 vts_ptt_srpt_t *vts_ptt_srpt; | |
189 pgc_t *cur_pgc; | |
190 // | |
191 int cur_cell; | |
192 int cur_pack; | |
193 int cell_last_pack; | |
194 // Navi: | |
195 int packs_left; | |
196 dsi_t dsi_pack; | |
197 int angle_seek; | |
198 // audio datas | |
199 int nr_of_channels; | |
3751
d9d2ee82a243
subtitle_t + audio_stream_t -> stream_language_t (cleanup)
arpi
parents:
3726
diff
changeset
|
200 stream_language_t audio_streams[32]; |
3048 | 201 // subtitles |
202 int nr_of_subtitles; | |
3751
d9d2ee82a243
subtitle_t + audio_stream_t -> stream_language_t (cleanup)
arpi
parents:
3726
diff
changeset
|
203 stream_language_t subtitles[32]; |
2935 | 204 } dvd_priv_t; |
205 | |
3753 | 206 int dvd_aid_from_lang(stream_t *stream, unsigned char* lang); |
207 int dvd_sid_from_lang(stream_t *stream, unsigned char* lang); | |
208 | |
2935 | 209 #endif |
210 | |
998
8c83e3ff26cc
Added ifndef to prevent multiple header file inclusion.
bertrand
parents:
692
diff
changeset
|
211 #endif // __STREAM_H |