Mercurial > mplayer.hg
annotate libmpdemux/stream.h @ 4421:5dd78b21afbc
-sws 2 is default now
author | michael |
---|---|
date | Wed, 30 Jan 2002 15:32:43 +0000 |
parents | 760481d8421c |
children | 716b00618bfc |
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 | |
4189 | 86 #define stream_read_fourcc stream_read_dword_le |
87 | |
578 | 88 inline static unsigned int stream_read_word_le(stream_t *s){ |
89 int x,y; | |
90 x=stream_read_char(s); | |
91 y=stream_read_char(s); | |
92 return (y<<8)|x; | |
93 } | |
94 | |
95 inline static unsigned int stream_read_dword_le(stream_t *s){ | |
96 unsigned int y; | |
97 y=stream_read_char(s); | |
98 y|=stream_read_char(s)<<8; | |
99 y|=stream_read_char(s)<<16; | |
100 y|=stream_read_char(s)<<24; | |
101 return y; | |
102 } | |
103 | |
3998 | 104 inline static uint64_t stream_read_qword(stream_t *s){ |
105 uint64_t y; | |
106 y = 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 y=(y<<8)|stream_read_char(s); | |
113 y=(y<<8)|stream_read_char(s); | |
114 return y; | |
115 } | |
116 | |
2347 | 117 inline static int stream_read(stream_t *s,char* mem,int total){ |
118 int len=total; | |
578 | 119 while(len>0){ |
120 int x; | |
121 x=s->buf_len-s->buf_pos; | |
122 if(x==0){ | |
2347 | 123 if(!cache_stream_fill_buffer(s)) return total-len; // EOF |
578 | 124 x=s->buf_len-s->buf_pos; |
125 } | |
126 if(s->buf_pos>s->buf_len) printf("stream_read: WARNING! s->buf_pos>s->buf_len\n"); | |
127 if(x>len) x=len; | |
128 memcpy(mem,&s->buffer[s->buf_pos],x); | |
129 s->buf_pos+=x; mem+=x; len-=x; | |
130 } | |
2347 | 131 return total; |
578 | 132 } |
133 | |
134 inline static int stream_eof(stream_t *s){ | |
135 return s->eof; | |
136 } | |
137 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
138 inline static off_t stream_tell(stream_t *s){ |
578 | 139 return s->pos+s->buf_pos-s->buf_len; |
140 } | |
141 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
142 inline static int stream_seek(stream_t *s,off_t pos){ |
578 | 143 |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
144 // if(verbose>=3) printf("seek to 0x%qX\n",(long long)pos); |
578 | 145 |
146 if(pos<s->pos){ | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
998
diff
changeset
|
147 off_t x=pos-(s->pos-s->buf_len); |
578 | 148 if(x>=0){ |
149 s->buf_pos=x; | |
150 // putchar('*');fflush(stdout); | |
151 return 1; | |
152 } | |
153 } | |
154 | |
2322 | 155 return cache_stream_seek_long(s,pos); |
578 | 156 } |
157 | |
3962 | 158 inline static int stream_skip(stream_t *s,off_t len){ |
692 | 159 if(len<0 || (len>2*STREAM_BUFFER_SIZE && s->type!=STREAMTYPE_STREAM)){ |
578 | 160 // negative or big skip! |
1491 | 161 return stream_seek(s,stream_tell(s)+len); |
578 | 162 } |
163 while(len>0){ | |
164 int x=s->buf_len-s->buf_pos; | |
165 if(x==0){ | |
2322 | 166 if(!cache_stream_fill_buffer(s)) return 0; // EOF |
578 | 167 x=s->buf_len-s->buf_pos; |
168 } | |
169 if(x>len) x=len; | |
170 //memcpy(mem,&s->buf[s->buf_pos],x); | |
171 s->buf_pos+=x; len-=x; | |
172 } | |
1491 | 173 return 1; |
578 | 174 } |
175 | |
176 void stream_reset(stream_t *s); | |
177 stream_t* new_stream(int fd,int type); | |
178 void free_stream(stream_t *s); | |
2144 | 179 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
|
180 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
|
181 |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
182 //#ifdef USE_DVDREAD |
4407 | 183 struct config; |
2555
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
184 extern int dvd_title; |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
185 extern int dvd_chapter; |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4189
diff
changeset
|
186 extern int dvd_last_chapter; |
2555
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
187 extern int dvd_angle; |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4315
diff
changeset
|
188 int dvd_parse_chapter_range(struct config*, const char*); |
2555
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2347
diff
changeset
|
189 //#endif |
998
8c83e3ff26cc
Added ifndef to prevent multiple header file inclusion.
bertrand
parents:
692
diff
changeset
|
190 |
2935 | 191 #ifdef USE_DVDREAD |
192 | |
193 #include <dvdread/dvd_reader.h> | |
194 #include <dvdread/ifo_types.h> | |
195 #include <dvdread/ifo_read.h> | |
196 #include <dvdread/nav_read.h> | |
197 | |
198 typedef struct { | |
199 int id; // 0 - 31 mpeg; 128 - 159 ac3; 160 - 191 pcm | |
200 int language; | |
3751
d9d2ee82a243
subtitle_t + audio_stream_t -> stream_language_t (cleanup)
arpi
parents:
3726
diff
changeset
|
201 } stream_language_t; |
3048 | 202 |
203 typedef struct { | |
2935 | 204 dvd_reader_t *dvd; |
205 dvd_file_t *title; | |
206 ifo_handle_t *vmg_file; | |
207 tt_srpt_t *tt_srpt; | |
208 ifo_handle_t *vts_file; | |
209 vts_ptt_srpt_t *vts_ptt_srpt; | |
210 pgc_t *cur_pgc; | |
211 // | |
212 int cur_cell; | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4189
diff
changeset
|
213 int last_cell; |
2935 | 214 int cur_pack; |
215 int cell_last_pack; | |
216 // Navi: | |
217 int packs_left; | |
218 dsi_t dsi_pack; | |
219 int angle_seek; | |
220 // audio datas | |
221 int nr_of_channels; | |
3751
d9d2ee82a243
subtitle_t + audio_stream_t -> stream_language_t (cleanup)
arpi
parents:
3726
diff
changeset
|
222 stream_language_t audio_streams[32]; |
3048 | 223 // subtitles |
224 int nr_of_subtitles; | |
3751
d9d2ee82a243
subtitle_t + audio_stream_t -> stream_language_t (cleanup)
arpi
parents:
3726
diff
changeset
|
225 stream_language_t subtitles[32]; |
2935 | 226 } dvd_priv_t; |
227 | |
3753 | 228 int dvd_aid_from_lang(stream_t *stream, unsigned char* lang); |
229 int dvd_sid_from_lang(stream_t *stream, unsigned char* lang); | |
230 | |
2935 | 231 #endif |
232 | |
998
8c83e3ff26cc
Added ifndef to prevent multiple header file inclusion.
bertrand
parents:
692
diff
changeset
|
233 #endif // __STREAM_H |