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->flags & OSRTSTRMF_BUFFERED) ? \
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
00256 EXTERNRT int rtxStreamInitCtxtBuf (OSCTXT* pctxt);
00257
00269 EXTERNRT int rtxStreamRemoveCtxtBuf (OSCTXT* pctxt);
00270
00287 EXTERNRT long rtxStreamRead
00288 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t bufSize);
00289
00290 EXTERNRT long rtxStreamReadDirect
00291 (OSCTXT* pctxt, OSOCTET* pbuffer, OSSIZE bufSize);
00292
00309 EXTERNRT long rtxStreamBlockingRead
00310 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t readBytes);
00311
00323 EXTERNRT int rtxStreamSkip (OSCTXT* pctxt, size_t skipBytes);
00324
00337 EXTERNRT long rtxStreamWrite
00338 (OSCTXT* pctxt, const OSOCTET* data, size_t numocts);
00339
00354 EXTERNRT int rtxStreamGetIOBytes (OSCTXT* pctxt, size_t* pPos);
00355
00370 EXTERNRT int rtxStreamMark (OSCTXT* pctxt, size_t readAheadLimit);
00371
00381 EXTERNRT int rtxStreamReset (OSCTXT* pctxt);
00382
00393 EXTERNRT OSBOOL rtxStreamMarkSupported (OSCTXT* pctxt);
00394
00403 EXTERNRT OSBOOL rtxStreamIsOpened (OSCTXT* pctxt);
00404
00413 EXTERNRT OSBOOL rtxStreamIsReadable (OSCTXT* pctxt);
00414
00423 EXTERNRT OSBOOL rtxStreamIsWritable (OSCTXT* pctxt);
00424
00434 EXTERNRT int rtxStreamRelease (OSCTXT* pctxt);
00435
00446 EXTERNRT void rtxStreamSetCapture (OSCTXT* pctxt, OSRTMEMBUF* pmembuf);
00447
00457 EXTERNRT OSRTMEMBUF* rtxStreamGetCapture (OSCTXT* pctxt);
00458
00467 EXTERNRT int rtxStreamGetPos (OSCTXT* pctxt, size_t* ppos);
00468
00477 EXTERNRT int rtxStreamSetPos (OSCTXT* pctxt, size_t pos);
00478
00481 #ifdef __cplusplus
00482 }
00483 #endif
00484
00485 #endif
00486 #endif
00487