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->bytesProcessed ))
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
00178 blockingRead;
00179 OSRTStreamWriteProc write;
00180 OSRTStreamFlushProc flush;
00181 OSRTStreamCloseProc close;
00182 OSRTStreamSkipProc skip;
00183 OSRTStreamMarkProc mark;
00184 OSRTStreamResetProc reset;
00185 OSRTStreamGetPosProc getPos;
00186 OSRTStreamSetPosProc setPos;
00188 void* extra;
00189 size_t bufsize;
00191 size_t readAheadLimit;
00193 size_t bytesProcessed;
00195 size_t markedBytesProcessed;
00197 size_t ioBytes;
00199 size_t nextMarkOffset;
00201 size_t segsize;
00202 OSUINT32 id;
00208 OSRTMEMBUF* pCaptureBuf;
00209
00210 OSUINT16 flags;
00211 } OSRTSTREAM;
00212
00222 EXTERNRT int rtxStreamClose (OSCTXT* pctxt);
00223
00234 EXTERNRT int rtxStreamFlush (OSCTXT* pctxt);
00235
00245 EXTERNRT int rtxStreamInit (OSCTXT* pctxt);
00246
00263 EXTERNRT long rtxStreamRead
00264 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t bufSize);
00265
00282 EXTERNRT long rtxStreamBlockingRead
00283 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t readBytes);
00284
00296 EXTERNRT int rtxStreamSkip (OSCTXT* pctxt, size_t skipBytes);
00297
00310 EXTERNRT long rtxStreamWrite
00311 (OSCTXT* pctxt, const OSOCTET* data, size_t numocts);
00312
00327 EXTERNRT int rtxStreamGetIOBytes (OSCTXT* pctxt, size_t* pPos);
00328
00343 EXTERNRT int rtxStreamMark (OSCTXT* pctxt, size_t readAheadLimit);
00344
00354 EXTERNRT int rtxStreamReset (OSCTXT* pctxt);
00355
00366 EXTERNRT OSBOOL rtxStreamMarkSupported (OSCTXT* pctxt);
00367
00376 EXTERNRT OSBOOL rtxStreamIsOpened (OSCTXT* pctxt);
00377
00386 EXTERNRT OSBOOL rtxStreamIsReadable (OSCTXT* pctxt);
00387
00396 EXTERNRT OSBOOL rtxStreamIsWritable (OSCTXT* pctxt);
00397
00407 EXTERNRT int rtxStreamRelease (OSCTXT* pctxt);
00408
00419 EXTERNRT void rtxStreamSetCapture (OSCTXT* pctxt, OSRTMEMBUF* pmembuf);
00420
00430 EXTERNRT OSRTMEMBUF* rtxStreamGetCapture (OSCTXT* pctxt);
00431
00440 EXTERNRT int rtxStreamGetPos (OSCTXT* pctxt, size_t* ppos);
00441
00450 EXTERNRT int rtxStreamSetPos (OSCTXT* pctxt, size_t pos);
00451
00454 #ifdef __cplusplus
00455 }
00456 #endif
00457
00458 #endif
00459 #endif
00460