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 #include "rtxsrc/rtxContext.h"
00032 #include "rtxsrc/rtxMemBuf.h"
00033
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037
00057 struct OSRTSTREAM;
00058
00064 typedef long (*OSRTStreamReadProc)
00065 (struct OSRTSTREAM* pStream, OSOCTET* pbuffer, size_t bufSize);
00066
00072 typedef long (*OSRTStreamBlockingReadProc)
00073 (struct OSRTSTREAM* pStream, OSOCTET* pbuffer, size_t toReadBytes);
00074
00080 typedef long (*OSRTStreamWriteProc)(struct OSRTSTREAM* pStream,
00081 const OSOCTET* data, size_t numocts);
00082
00088 typedef int (*OSRTStreamFlushProc)(struct OSRTSTREAM* pStream);
00089
00095 typedef int (*OSRTStreamCloseProc)(struct OSRTSTREAM* pStream);
00096
00102 typedef int (*OSRTStreamSkipProc)
00103 (struct OSRTSTREAM* pStream, size_t skipBytes);
00104
00110 typedef int (*OSRTStreamMarkProc)
00111 (struct OSRTSTREAM* pStream, size_t readAheadLimit);
00112
00118 typedef int (*OSRTStreamResetProc) (struct OSRTSTREAM* pStream);
00119
00120 #define OSRTSTRMF_INPUT 0x0001
00121 #define OSRTSTRMF_OUTPUT 0x0002
00122 #define OSRTSTRMF_BUFFERED 0x8000
00123 #define OSRTSTRMF_UNBUFFERED 0x4000
00124 #define OSRTSTRMF_POSMARKED 0x2000
00125
00126 #define OSRTSTRMF_BUF_INPUT (OSRTSTRMF_INPUT|OSRTSTRMF_BUFFERED)
00127 #define OSRTSTRMF_BUF_OUTPUT (OSRTSTRMF_OUTPUT|OSRTSTRMF_BUFFERED)
00128
00129
00130 #define OSRTSTRMID_FILE 1
00131 #define OSRTSTRMID_SOCKET 2
00132 #define OSRTSTRMID_MEMORY 3
00133 #define OSRTSTRMID_BUFFERED 4
00134 #define OSRTSTRMID_DIRECTBUF 5
00135 #define OSRTSTRMID_CTXTBUF 6
00136 #define OSRTSTRMID_ZLIB 7
00137 #define OSRTSTRMID_USER 1000
00138
00139 #define OSRTSTRM_K_BUFSIZE 1024
00140
00141 #define OSRTSTRM_K_INVALIDMARK ((size_t)-1)
00142
00143 #define OSRTSTREAM_BYTEINDEX(pctxt) \
00144 (((pctxt)->pStream->id == OSRTSTRMID_DIRECTBUF) ? \
00145 ((pctxt)->pStream->bytesProcessed + (pctxt)->buffer.byteIndex) : \
00146 ((pctxt)->pStream->ioBytes))
00147
00148 #define OSRTSTREAM_ID(pctxt) ((pctxt)->pStream->id)
00149 #define OSRTSTREAM_FLAGS(pctxt) ((pctxt)->pStream->flags)
00150
00156 typedef struct OSRTSTREAM {
00157 OSRTStreamReadProc read;
00158 OSRTStreamBlockingReadProc blockingRead;
00159 OSRTStreamWriteProc write;
00160 OSRTStreamFlushProc flush;
00161 OSRTStreamCloseProc close;
00162 OSRTStreamSkipProc skip;
00163 OSRTStreamMarkProc mark;
00164 OSRTStreamResetProc reset;
00165
00166 void* extra;
00167
00168 size_t bufsize;
00169 size_t readAheadLimit;
00170 size_t bytesProcessed;
00171 size_t markedBytesProcessed;
00172 size_t ioBytes;
00173 size_t nextMarkOffset;
00174
00175 OSUINT32 id;
00176
00181 OSRTMEMBUF* pCaptureBuf;
00182
00183 OSUINT16 flags;
00184 } OSRTSTREAM;
00185
00195 EXTERNRT int rtxStreamClose (OSCTXT* pctxt);
00196
00207 EXTERNRT int rtxStreamFlush (OSCTXT* pctxt);
00208
00218 EXTERNRT int rtxStreamInit (OSCTXT* pctxt);
00219
00236 EXTERNRT long rtxStreamRead
00237 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t bufSize);
00238
00255 EXTERNRT long rtxStreamBlockingRead
00256 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t readBytes);
00257
00269 EXTERNRT int rtxStreamSkip (OSCTXT* pctxt, size_t skipBytes);
00270
00283 EXTERNRT long rtxStreamWrite
00284 (OSCTXT* pctxt, const OSOCTET* data, size_t numocts);
00285
00300 EXTERNRT int rtxStreamGetIOBytes (OSCTXT* pctxt, size_t* pPos);
00301
00316 EXTERNRT int rtxStreamMark (OSCTXT* pctxt, size_t readAheadLimit);
00317
00327 EXTERNRT int rtxStreamReset (OSCTXT* pctxt);
00328
00339 EXTERNRT OSBOOL rtxStreamMarkSupported (OSCTXT* pctxt);
00340
00349 EXTERNRT OSBOOL rtxStreamIsOpened (OSCTXT* pctxt);
00350
00359 EXTERNRT OSBOOL rtxStreamIsReadable (OSCTXT* pctxt);
00360
00369 EXTERNRT OSBOOL rtxStreamIsWritable (OSCTXT* pctxt);
00370
00380 EXTERNRT int rtxStreamRelease (OSCTXT* pctxt);
00381
00392 EXTERNRT void rtxStreamSetCapture (OSCTXT* pctxt, OSRTMEMBUF* pmembuf);
00393
00406 EXTERNRT OSRTMEMBUF* rtxStreamGetCapture (OSCTXT* pctxt);
00407
00410 #ifdef __cplusplus
00411 }
00412 #endif
00413
00414 #endif
00415