Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenreader.h
Go to the documentation of this file.
00001 /* 00002 reader: reading input data 00003 00004 copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1 00005 see COPYING and AUTHORS files in distribution or http://mpg123.org 00006 initially written by Thomas Orgis (after code from Michael Hipp) 00007 */ 00008 00009 #ifndef MPG123_READER_H 00010 #define MPG123_READER_H 00011 00012 #include "config.h" 00013 #include "mpg123.h" 00014 00015 struct buffy 00016 { 00017 unsigned char *data; 00018 long size; 00019 long realsize; 00020 struct buffy *next; 00021 }; 00022 00023 struct bufferchain 00024 { 00025 struct buffy* first; /* The beginning of the chain. */ 00026 struct buffy* last; /* The end... of the chain. */ 00027 long size; /* Aggregated size of all buffies. */ 00028 /* These positions are relative to buffer chain beginning. */ 00029 long pos; /* Position in whole chain. */ 00030 long firstpos; /* The point of return on non-forget() */ 00031 /* The "real" filepos is fileoff + pos. */ 00032 off_t fileoff; /* Beginning of chain is at this file offset. */ 00033 }; 00034 00035 struct reader_data 00036 { 00037 off_t filelen; /* total file length or total buffer size */ 00038 off_t filepos; /* position in file or position in buffer chain */ 00039 int filept; 00040 /* Custom opaque I/O handle from the client. */ 00041 void *iohandle; 00042 int flags; 00043 long timeout_sec; 00044 long (*fdread) (mpg123_handle *, void *, size_t); 00045 /* User can replace the read and lseek functions. The r_* are the stored replacement functions or NULL. */ 00046 long (*r_read) (int fd, void *buf, size_t count); 00047 off_t (*r_lseek)(int fd, off_t offset, int whence); 00048 /* These are custom I/O routines for opaque user handles. 00049 They get picked if there's some iohandle set. */ 00050 long (*r_read_handle) (void *handle, void *buf, size_t count); 00051 off_t (*r_lseek_handle)(void *handle, off_t offset, int whence); 00052 /* An optional cleaner for the handle on closing the stream. */ 00053 void (*cleanup_handle)(void *handle); 00054 /* These two pointers are the actual workers (default map to POSIX read/lseek). */ 00055 long (*read) (int fd, void *buf, size_t count); 00056 off_t (*lseek)(int fd, off_t offset, int whence); 00057 /* Buffered readers want that abstracted, set internally. */ 00058 long (*fullread)(mpg123_handle *, unsigned char *, long); 00059 struct bufferchain buffer; /* Not dynamically allocated, these few struct bytes aren't worth the trouble. */ 00060 }; 00061 00062 /* start to use off_t to properly do LFS in future ... used to be long */ 00063 struct reader 00064 { 00065 int (*init) (mpg123_handle *); 00066 void (*close) (mpg123_handle *); 00067 long (*fullread) (mpg123_handle *, unsigned char *, long); 00068 int (*head_read) (mpg123_handle *, unsigned long *newhead); /* succ: TRUE, else <= 0 (FALSE or READER_MORE) */ 00069 int (*head_shift) (mpg123_handle *, unsigned long *head); /* succ: TRUE, else <= 0 (FALSE or READER_MORE) */ 00070 off_t (*skip_bytes) (mpg123_handle *, off_t len); /* succ: >=0, else error or READER_MORE */ 00071 int (*read_frame_body)(mpg123_handle *, unsigned char *, int size); 00072 int (*back_bytes) (mpg123_handle *, off_t bytes); 00073 int (*seek_frame) (mpg123_handle *, off_t num); 00074 off_t (*tell) (mpg123_handle *); 00075 void (*rewind) (mpg123_handle *); 00076 void (*forget) (mpg123_handle *); 00077 }; 00078 00079 /* Open a file by path or use an opened file descriptor. */ 00080 int open_stream(mpg123_handle *, const char *path, int fd); 00081 /* Open an external handle. */ 00082 int open_stream_handle(mpg123_handle *, void *iohandle); 00083 00084 /* feed based operation has some specials */ 00085 int open_feed(mpg123_handle *); 00086 /* externally called function, returns 0 on success, -1 on error */ 00087 int feed_more(mpg123_handle *fr, const unsigned char *in, long count); 00088 void feed_forget(mpg123_handle *fr); /* forget the data that has been read (free some buffers) */ 00089 off_t feed_set_pos(mpg123_handle *fr, off_t pos); /* Set position (inside available data if possible), return wanted byte offset of next feed. */ 00090 00091 void open_bad(mpg123_handle *); 00092 00093 #define READER_FD_OPENED 0x1 00094 #define READER_ID3TAG 0x2 00095 #define READER_SEEKABLE 0x4 00096 #define READER_BUFFERED 0x8 00097 #define READER_NONBLOCK 0x20 00098 #define READER_HANDLEIO 0x40 00099 00100 #define READER_STREAM 0 00101 #define READER_ICY_STREAM 1 00102 #define READER_FEED 2 00103 /* These two add a little buffering to enable small seeks for peek ahead. */ 00104 #define READER_BUF_STREAM 3 00105 #define READER_BUF_ICY_STREAM 4 00106 00107 #ifdef READ_SYSTEM 00108 #define READER_SYSTEM 5 00109 #define READERS 6 00110 #else 00111 #define READERS 5 00112 #endif 00113 00114 #define READER_ERROR MPG123_ERR 00115 #define READER_MORE MPG123_NEED_MORE 00116 00117 #endif Generated on Sat May 26 2012 04:22:17 for ReactOS by
1.7.6.1
|