Mercurial > mplayer.hg
annotate libmpdemux/stream.h @ 3039:80189681c02b
Removed the field number limitation.
We can add as much field as we want.
author | bertrand |
---|---|
date | Tue, 20 Nov 2001 22:14:16 +0000 |
parents | bc6cb25ad067 |
children | 02a43ca97b52 |
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 | |
17 int vcd_seek_to_track(int fd,int track); | |
18 void vcd_read_toc(int fd); | |
19 | |
20 #ifdef VCD_CACHE | |
21 void vcd_cache_init(int s); | |
22 #endif | |
23 | |
24 typedef struct { | |
25 int fd; | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
26 off_t pos; |
578 | 27 int eof; |
28 int type; // 0=file 1=VCD | |
29 unsigned int buf_pos,buf_len; | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
30 off_t start_pos,end_pos; |
2322 | 31 unsigned int cache_pid; |
32 void* cache_data; | |
2144 | 33 void* priv; // used for DVD |
583 | 34 unsigned char buffer[STREAM_BUFFER_SIZE>VCD_SECTOR_SIZE?STREAM_BUFFER_SIZE:VCD_SECTOR_SIZE]; |
578 | 35 } stream_t; |
36 | |
2322 | 37 #ifdef USE_STREAM_CACHE |
38 void stream_enable_cache(stream_t *s,int size); | |
39 #else | |
40 // no cache | |
41 #define cache_stream_fill_buffer(x) stream_fill_buffer(x) | |
42 #define cache_stream_seek_long(x,y) stream_seek_long(x,y) | |
43 #define stream_enable_cache(x,y) | |
44 #endif | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
45 |
2322 | 46 int cache_stream_fill_buffer(stream_t *s); |
47 int cache_stream_seek_long(stream_t *s,off_t pos); | |
578 | 48 |
49 inline static int stream_read_char(stream_t *s){ | |
50 return (s->buf_pos<s->buf_len)?s->buffer[s->buf_pos++]: | |
2322 | 51 (cache_stream_fill_buffer(s)?s->buffer[s->buf_pos++]:-256); |
578 | 52 // if(s->buf_pos<s->buf_len) return s->buffer[s->buf_pos++]; |
53 // stream_fill_buffer(s); | |
54 // if(s->buf_pos<s->buf_len) return s->buffer[s->buf_pos++]; | |
55 // return 0; // EOF | |
56 } | |
57 | |
58 inline static unsigned int stream_read_word(stream_t *s){ | |
59 int x,y; | |
60 x=stream_read_char(s); | |
61 y=stream_read_char(s); | |
62 return (x<<8)|y; | |
63 } | |
64 | |
65 inline static unsigned int stream_read_dword(stream_t *s){ | |
66 unsigned int y; | |
67 y=stream_read_char(s); | |
68 y=(y<<8)|stream_read_char(s); | |
69 y=(y<<8)|stream_read_char(s); | |
70 y=(y<<8)|stream_read_char(s); | |
71 return y; | |
72 } | |
73 | |
74 inline static unsigned int stream_read_word_le(stream_t *s){ | |
75 int x,y; | |
76 x=stream_read_char(s); | |
77 y=stream_read_char(s); | |
78 return (y<<8)|x; | |
79 } | |
80 | |
81 inline static unsigned int stream_read_dword_le(stream_t *s){ | |
82 unsigned int y; | |
83 y=stream_read_char(s); | |
84 y|=stream_read_char(s)<<8; | |
85 y|=stream_read_char(s)<<16; | |
86 y|=stream_read_char(s)<<24; | |
87 return y; | |
88 } | |
89 | |
2347 | 90 inline static int stream_read(stream_t *s,char* mem,int total){ |
91 int len=total; | |
578 | 92 while(len>0){ |
93 int x; | |
94 x=s->buf_len-s->buf_pos; | |
95 if(x==0){ | |
2347 | 96 if(!cache_stream_fill_buffer(s)) return total-len; // EOF |
578 | 97 x=s->buf_len-s->buf_pos; |
98 } | |
99 if(s->buf_pos>s->buf_len) printf("stream_read: WARNING! s->buf_pos>s->buf_len\n"); | |
100 if(x>len) x=len; | |
101 memcpy(mem,&s->buffer[s->buf_pos],x); | |
102 s->buf_pos+=x; mem+=x; len-=x; | |
103 } | |
2347 | 104 return total; |
578 | 105 } |
106 | |
107 inline static int stream_eof(stream_t *s){ | |
108 return s->eof; | |
109 } | |
110 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
111 inline static off_t stream_tell(stream_t *s){ |
578 | 112 return s->pos+s->buf_pos-s->buf_len; |
113 } | |
114 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
115 inline static int stream_seek(stream_t *s,off_t pos){ |
578 | 116 |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
117 // if(verbose>=3) printf("seek to 0x%qX\n",(long long)pos); |
578 | 118 |
119 if(pos<s->pos){ | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
120 off_t x=pos-(s->pos-s->buf_len); |
578 | 121 if(x>=0){ |
122 s->buf_pos=x; | |
123 // putchar('*');fflush(stdout); | |
124 return 1; | |
125 } | |
126 } | |
127 | |
2322 | 128 return cache_stream_seek_long(s,pos); |
578 | 129 } |
130 | |
1491 | 131 inline static int stream_skip(stream_t *s,int len){ |
692 | 132 if(len<0 || (len>2*STREAM_BUFFER_SIZE && s->type!=STREAMTYPE_STREAM)){ |
578 | 133 // negative or big skip! |
1491 | 134 return stream_seek(s,stream_tell(s)+len); |
578 | 135 } |
136 while(len>0){ | |
137 int x=s->buf_len-s->buf_pos; | |
138 if(x==0){ | |
2322 | 139 if(!cache_stream_fill_buffer(s)) return 0; // EOF |
578 | 140 x=s->buf_len-s->buf_pos; |
141 } | |
142 if(x>len) x=len; | |
143 //memcpy(mem,&s->buf[s->buf_pos],x); | |
144 s->buf_pos+=x; len-=x; | |
145 } | |
1491 | 146 return 1; |
578 | 147 } |
148 | |
149 void stream_reset(stream_t *s); | |
150 stream_t* new_stream(int fd,int type); | |
151 void free_stream(stream_t *s); | |
2144 | 152 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
|
153 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
|
154 |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
155 //#ifdef USE_DVDREAD |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
156 extern int dvd_title; |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
157 extern int dvd_chapter; |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
158 extern int dvd_angle; |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
159 //#endif |
998
8c83e3ff26cc
Added ifndef to prevent multiple header file inclusion.
bertrand
parents:
692
diff
changeset
|
160 |
2935 | 161 #ifdef USE_DVDREAD |
162 | |
163 #include <dvdread/dvd_reader.h> | |
164 #include <dvdread/ifo_types.h> | |
165 #include <dvdread/ifo_read.h> | |
166 #include <dvdread/nav_read.h> | |
167 | |
168 typedef struct { | |
169 int id; // 0 - 31 mpeg; 128 - 159 ac3; 160 - 191 pcm | |
170 int language; | |
171 } audio_stream_t; | |
172 | |
173 typedef struct { | |
174 dvd_reader_t *dvd; | |
175 dvd_file_t *title; | |
176 ifo_handle_t *vmg_file; | |
177 tt_srpt_t *tt_srpt; | |
178 ifo_handle_t *vts_file; | |
179 vts_ptt_srpt_t *vts_ptt_srpt; | |
180 pgc_t *cur_pgc; | |
181 // | |
182 int cur_cell; | |
183 int cur_pack; | |
184 int cell_last_pack; | |
185 // Navi: | |
186 int packs_left; | |
187 dsi_t dsi_pack; | |
188 int angle_seek; | |
189 // audio datas | |
190 int nr_of_channels; | |
191 audio_stream_t audio_streams[8]; | |
192 } dvd_priv_t; | |
193 | |
194 #endif | |
195 | |
998
8c83e3ff26cc
Added ifndef to prevent multiple header file inclusion.
bertrand
parents:
692
diff
changeset
|
196 #endif // __STREAM_H |