00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028 #ifndef _RTXSTREAM_H_
00029 #define _RTXSTREAM_H_
00030
00031 #ifndef _NO_STREAM
00032
00033 #include "rtxsrc/rtxContext.h"
00034 #include "rtxsrc/rtxMemBuf.h"
00035
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039
00059 struct OSRTSTREAM;
00060
00066 typedef long (*OSRTStreamReadProc)
00067 (struct OSRTSTREAM* pStream, OSOCTET* pbuffer, size_t bufSize);
00068
00074 typedef long (*OSRTStreamBlockingReadProc)
00075 (struct OSRTSTREAM* pStream, OSOCTET* pbuffer, size_t toReadBytes);
00076
00082 typedef long (*OSRTStreamWriteProc)(struct OSRTSTREAM* pStream,
00083 const OSOCTET* data, size_t numocts);
00084
00090 typedef int (*OSRTStreamFlushProc)(struct OSRTSTREAM* pStream);
00091
00097 typedef int (*OSRTStreamCloseProc)(struct OSRTSTREAM* pStream);
00098
00104 typedef int (*OSRTStreamSkipProc)
00105 (struct OSRTSTREAM* pStream, size_t skipBytes);
00106
00112 typedef int (*OSRTStreamMarkProc)
00113 (struct OSRTSTREAM* pStream, size_t readAheadLimit);
00114
00120 typedef int (*OSRTStreamResetProc) (struct OSRTSTREAM* pStream);
00121
00127 typedef int (*OSRTStreamGetPosProc)
00128 (struct OSRTSTREAM* pStream, size_t* ppos);
00129
00135 typedef int (*OSRTStreamSetPosProc)
00136 (struct OSRTSTREAM* pStream, size_t pos);
00137
00138 #define OSRTSTRMF_INPUT 0x0001
00139 #define OSRTSTRMF_OUTPUT 0x0002
00140 #define OSRTSTRMF_BUFFERED 0x8000
00141 #define OSRTSTRMF_UNBUFFERED 0x4000
00142 #define OSRTSTRMF_POSMARKED 0x2000
00143 #define OSRTSTRMF_FIXINMEM 0x1000
00144
00145 #define OSRTSTRMF_BUF_INPUT (OSRTSTRMF_INPUT|OSRTSTRMF_BUFFERED)
00146 #define OSRTSTRMF_BUF_OUTPUT (OSRTSTRMF_OUTPUT|OSRTSTRMF_BUFFERED)
00147
00148
00149 #define OSRTSTRMID_FILE 1
00150 #define OSRTSTRMID_SOCKET 2
00151 #define OSRTSTRMID_MEMORY 3
00152 #define OSRTSTRMID_BUFFERED 4
00153 #define OSRTSTRMID_DIRECTBUF 5
00154 #define OSRTSTRMID_CTXTBUF 6
00155 #define OSRTSTRMID_ZLIB 7
00156 #define OSRTSTRMID_USER 1000
00157
00158 #define OSRTSTRM_K_BUFSIZE 1024
00159
00160 #define OSRTSTRM_K_INVALIDMARK ((size_t)-1)
00161
00162 #define OSRTSTREAM_BYTEINDEX(pctxt) \
00163 (((pctxt)->pStream->id == OSRTSTRMID_DIRECTBUF) ? \
00164 ((pctxt)->pStream->bytesProcessed + (pctxt)->buffer.byteIndex) : \
00165 ((pctxt)->pStream->ioBytes))
00166
00167 #define OSRTSTREAM_ID(pctxt) ((pctxt)->pStream->id)
00168 #define OSRTSTREAM_FLAGS(pctxt) ((pctxt)->pStream->flags)
00169
00175 typedef struct OSRTSTREAM {
00176 OSRTStreamReadProc read;
00177 OSRTStreamBlockingReadProc blockingRead;
00178 OSRTStreamWriteProc write;
00179 OSRTStreamFlushProc flush;
00180 OSRTStreamCloseProc close;
00181 OSRTStreamSkipProc skip;
00182 OSRTStreamMarkProc mark;
00183 OSRTStreamResetProc reset;
00184 OSRTStreamGetPosProc getPos;
00185 OSRTStreamSetPosProc setPos;
00186
00187 void* extra;
00188
00189 size_t bufsize;
00190 size_t readAheadLimit;
00191 size_t bytesProcessed;
00192 size_t markedBytesProcessed;
00193 size_t ioBytes;
00194 size_t nextMarkOffset;
00195 size_t segsize;
00196
00197 OSUINT32 id;
00198
00203 OSRTMEMBUF* pCaptureBuf;
00204
00205 OSUINT16 flags;
00206 } OSRTSTREAM;
00207
00217 EXTERNRT int rtxStreamClose (OSCTXT* pctxt);
00218
00229 EXTERNRT int rtxStreamFlush (OSCTXT* pctxt);
00230
00240 EXTERNRT int rtxStreamInit (OSCTXT* pctxt);
00241
00258 EXTERNRT long rtxStreamRead
00259 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t bufSize);
00260
00277 EXTERNRT long rtxStreamBlockingRead
00278 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t readBytes);
00279
00291 EXTERNRT int rtxStreamSkip (OSCTXT* pctxt, size_t skipBytes);
00292
00305 EXTERNRT long rtxStreamWrite
00306 (OSCTXT* pctxt, const OSOCTET* data, size_t numocts);
00307
00322 EXTERNRT int rtxStreamGetIOBytes (OSCTXT* pctxt, size_t* pPos);
00323
00338 EXTERNRT int rtxStreamMark (OSCTXT* pctxt, size_t readAheadLimit);
00339
00349 EXTERNRT int rtxStreamReset (OSCTXT* pctxt);
00350
00361 EXTERNRT OSBOOL rtxStreamMarkSupported (OSCTXT* pctxt);
00362
00371 EXTERNRT OSBOOL rtxStreamIsOpened (OSCTXT* pctxt);
00372
00381 EXTERNRT OSBOOL rtxStreamIsReadable (OSCTXT* pctxt);
00382
00391 EXTERNRT OSBOOL rtxStreamIsWritable (OSCTXT* pctxt);
00392
00402 EXTERNRT int rtxStreamRelease (OSCTXT* pctxt);
00403
00414 EXTERNRT void rtxStreamSetCapture (OSCTXT* pctxt, OSRTMEMBUF* pmembuf);
00415
00425 EXTERNRT OSRTMEMBUF* rtxStreamGetCapture (OSCTXT* pctxt);
00426
00435 EXTERNRT int rtxStreamGetPos (OSCTXT* pctxt, size_t* ppos);
00436
00445 EXTERNRT int rtxStreamSetPos (OSCTXT* pctxt, size_t pos);
00446
00449 #ifdef __cplusplus
00450 }
00451 #endif
00452
00453 #endif
00454 #endif
00455