Mercurial > mplayer.hg
annotate libmpdemux/stream.h @ 3529:a86166b495a6
sse opt
author | michael |
---|---|
date | Sun, 16 Dec 2001 15:43:15 +0000 |
parents | b01551d725d4 |
children | e84d6c8ff59b |
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 |
45 void stream_enable_cache(stream_t *s,int size); | |
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 |
56 inline static int stream_read_char(stream_t *s){ | |
57 return (s->buf_pos<s->buf_len)?s->buffer[s->buf_pos++]: | |
2322 | 58 (cache_stream_fill_buffer(s)?s->buffer[s->buf_pos++]:-256); |
578 | 59 // if(s->buf_pos<s->buf_len) return s->buffer[s->buf_pos++]; |
60 // stream_fill_buffer(s); | |
61 // if(s->buf_pos<s->buf_len) return s->buffer[s->buf_pos++]; | |
62 // return 0; // EOF | |
63 } | |
64 | |
65 inline static unsigned int stream_read_word(stream_t *s){ | |
66 int x,y; | |
67 x=stream_read_char(s); | |
68 y=stream_read_char(s); | |
69 return (x<<8)|y; | |
70 } | |
71 | |
72 inline static unsigned int stream_read_dword(stream_t *s){ | |
73 unsigned int y; | |
74 y=stream_read_char(s); | |
75 y=(y<<8)|stream_read_char(s); | |
76 y=(y<<8)|stream_read_char(s); | |
77 y=(y<<8)|stream_read_char(s); | |
78 return y; | |
79 } | |
80 | |
81 inline static unsigned int stream_read_word_le(stream_t *s){ | |
82 int x,y; | |
83 x=stream_read_char(s); | |
84 y=stream_read_char(s); | |
85 return (y<<8)|x; | |
86 } | |
87 | |
88 inline static unsigned int stream_read_dword_le(stream_t *s){ | |
89 unsigned int y; | |
90 y=stream_read_char(s); | |
91 y|=stream_read_char(s)<<8; | |
92 y|=stream_read_char(s)<<16; | |
93 y|=stream_read_char(s)<<24; | |
94 return y; | |
95 } | |
96 | |
2347 | 97 inline static int stream_read(stream_t *s,char* mem,int total){ |
98 int len=total; | |
578 | 99 while(len>0){ |
100 int x; | |
101 x=s->buf_len-s->buf_pos; | |
102 if(x==0){ | |
2347 | 103 if(!cache_stream_fill_buffer(s)) return total-len; // EOF |
578 | 104 x=s->buf_len-s->buf_pos; |
105 } | |
106 if(s->buf_pos>s->buf_len) printf("stream_read: WARNING! s->buf_pos>s->buf_len\n"); | |
107 if(x>len) x=len; | |
108 memcpy(mem,&s->buffer[s->buf_pos],x); | |
109 s->buf_pos+=x; mem+=x; len-=x; | |
110 } | |
2347 | 111 return total; |
578 | 112 } |
113 | |
114 inline static int stream_eof(stream_t *s){ | |
115 return s->eof; | |
116 } | |
117 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
118 inline static off_t stream_tell(stream_t *s){ |
578 | 119 return s->pos+s->buf_pos-s->buf_len; |
120 } | |
121 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
122 inline static int stream_seek(stream_t *s,off_t pos){ |
578 | 123 |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
124 // if(verbose>=3) printf("seek to 0x%qX\n",(long long)pos); |
578 | 125 |
126 if(pos<s->pos){ | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
127 off_t x=pos-(s->pos-s->buf_len); |
578 | 128 if(x>=0){ |
129 s->buf_pos=x; | |
130 // putchar('*');fflush(stdout); | |
131 return 1; | |
132 } | |
133 } | |
134 | |
2322 | 135 return cache_stream_seek_long(s,pos); |
578 | 136 } |
137 | |
1491 | 138 inline static int stream_skip(stream_t *s,int len){ |
692 | 139 if(len<0 || (len>2*STREAM_BUFFER_SIZE && s->type!=STREAMTYPE_STREAM)){ |
578 | 140 // negative or big skip! |
1491 | 141 return stream_seek(s,stream_tell(s)+len); |
578 | 142 } |
143 while(len>0){ | |
144 int x=s->buf_len-s->buf_pos; | |
145 if(x==0){ | |
2322 | 146 if(!cache_stream_fill_buffer(s)) return 0; // EOF |
578 | 147 x=s->buf_len-s->buf_pos; |
148 } | |
149 if(x>len) x=len; | |
150 //memcpy(mem,&s->buf[s->buf_pos],x); | |
151 s->buf_pos+=x; len-=x; | |
152 } | |
1491 | 153 return 1; |
578 | 154 } |
155 | |
156 void stream_reset(stream_t *s); | |
157 stream_t* new_stream(int fd,int type); | |
158 void free_stream(stream_t *s); | |
2144 | 159 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
|
160 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
|
161 |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
162 //#ifdef USE_DVDREAD |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
163 extern int dvd_title; |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
164 extern int dvd_chapter; |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
165 extern int dvd_angle; |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
166 //#endif |
998
8c83e3ff26cc
Added ifndef to prevent multiple header file inclusion.
bertrand
parents:
692
diff
changeset
|
167 |
2935 | 168 #ifdef USE_DVDREAD |
169 | |
170 #include <dvdread/dvd_reader.h> | |
171 #include <dvdread/ifo_types.h> | |
172 #include <dvdread/ifo_read.h> | |
173 #include <dvdread/nav_read.h> | |
174 | |
175 typedef struct { | |
176 int id; // 0 - 31 mpeg; 128 - 159 ac3; 160 - 191 pcm | |
177 int language; | |
178 } audio_stream_t; | |
179 | |
180 typedef struct { | |
3048 | 181 int id; // 0 - 31 |
182 int language; | |
183 } subtitle_t; | |
184 | |
185 typedef struct { | |
2935 | 186 dvd_reader_t *dvd; |
187 dvd_file_t *title; | |
188 ifo_handle_t *vmg_file; | |
189 tt_srpt_t *tt_srpt; | |
190 ifo_handle_t *vts_file; | |
191 vts_ptt_srpt_t *vts_ptt_srpt; | |
192 pgc_t *cur_pgc; | |
193 // | |
194 int cur_cell; | |
195 int cur_pack; | |
196 int cell_last_pack; | |
197 // Navi: | |
198 int packs_left; | |
199 dsi_t dsi_pack; | |
200 int angle_seek; | |
201 // audio datas | |
202 int nr_of_channels; | |
203 audio_stream_t audio_streams[8]; | |
3048 | 204 // subtitles |
205 int nr_of_subtitles; | |
206 subtitle_t subtitles[32]; | |
2935 | 207 } dvd_priv_t; |
208 | |
209 #endif | |
210 | |
998
8c83e3ff26cc
Added ifndef to prevent multiple header file inclusion.
bertrand
parents:
692
diff
changeset
|
211 #endif // __STREAM_H |