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