rtxStream.h
Go to the documentation of this file.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
00122 #define OSRTSTRMF_INPUT 0x0001
00123 #define OSRTSTRMF_OUTPUT 0x0002
00124 #define OSRTSTRMF_BUFFERED 0x8000
00125 #define OSRTSTRMF_UNBUFFERED 0x4000
00126 #define OSRTSTRMF_POSMARKED 0x2000
00127 #define OSRTSTRMF_FIXINMEM 0x1000
00128
00129 #define OSRTSTRMF_BUF_INPUT (OSRTSTRMF_INPUT|OSRTSTRMF_BUFFERED)
00130 #define OSRTSTRMF_BUF_OUTPUT (OSRTSTRMF_OUTPUT|OSRTSTRMF_BUFFERED)
00131
00132
00133 #define OSRTSTRMID_FILE 1
00134 #define OSRTSTRMID_SOCKET 2
00135 #define OSRTSTRMID_MEMORY 3
00136 #define OSRTSTRMID_BUFFERED 4
00137 #define OSRTSTRMID_DIRECTBUF 5
00138 #define OSRTSTRMID_CTXTBUF 6
00139 #define OSRTSTRMID_ZLIB 7
00140 #define OSRTSTRMID_USER 1000
00141
00142 #define OSRTSTRM_K_BUFSIZE 1024
00143
00144 #define OSRTSTRM_K_INVALIDMARK ((size_t)-1)
00145
00146 #define OSRTSTREAM_BYTEINDEX(pctxt) \
00147 (((pctxt)->pStream->id == OSRTSTRMID_DIRECTBUF) ? \
00148 ((pctxt)->pStream->bytesProcessed + (pctxt)->buffer.byteIndex) : \
00149 ((pctxt)->pStream->ioBytes))
00150
00151 #define OSRTSTREAM_ID(pctxt) ((pctxt)->pStream->id)
00152 #define OSRTSTREAM_FLAGS(pctxt) ((pctxt)->pStream->flags)
00153
00159 typedef struct OSRTSTREAM {
00160 OSRTStreamReadProc read;
00161 OSRTStreamBlockingReadProc blockingRead;
00162 OSRTStreamWriteProc write;
00163 OSRTStreamFlushProc flush;
00164 OSRTStreamCloseProc close;
00165 OSRTStreamSkipProc skip;
00166 OSRTStreamMarkProc mark;
00167 OSRTStreamResetProc reset;
00168
00169 void* extra;
00170
00171 size_t bufsize;
00172 size_t readAheadLimit;
00173 size_t bytesProcessed;
00174 size_t markedBytesProcessed;
00175 size_t ioBytes;
00176 size_t nextMarkOffset;
00177
00178 OSUINT32 id;
00179
00184 OSRTMEMBUF* pCaptureBuf;
00185
00186 OSUINT16 flags;
00187 } OSRTSTREAM;
00188
00198 EXTERNRT int rtxStreamClose (OSCTXT* pctxt);
00199
00210 EXTERNRT int rtxStreamFlush (OSCTXT* pctxt);
00211
00221 EXTERNRT int rtxStreamInit (OSCTXT* pctxt);
00222
00239 EXTERNRT long rtxStreamRead
00240 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t bufSize);
00241
00258 EXTERNRT long rtxStreamBlockingRead
00259 (OSCTXT* pctxt, OSOCTET* pbuffer, size_t readBytes);
00260
00272 EXTERNRT int rtxStreamSkip (OSCTXT* pctxt, size_t skipBytes);
00273
00286 EXTERNRT long rtxStreamWrite
00287 (OSCTXT* pctxt, const OSOCTET* data, size_t numocts);
00288
00303 EXTERNRT int rtxStreamGetIOBytes (OSCTXT* pctxt, size_t* pPos);
00304
00319 EXTERNRT int rtxStreamMark (OSCTXT* pctxt, size_t readAheadLimit);
00320
00330 EXTERNRT int rtxStreamReset (OSCTXT* pctxt);
00331
00342 EXTERNRT OSBOOL rtxStreamMarkSupported (OSCTXT* pctxt);
00343
00352 EXTERNRT OSBOOL rtxStreamIsOpened (OSCTXT* pctxt);
00353
00362 EXTERNRT OSBOOL rtxStreamIsReadable (OSCTXT* pctxt);
00363
00372 EXTERNRT OSBOOL rtxStreamIsWritable (OSCTXT* pctxt);
00373
00383 EXTERNRT int rtxStreamRelease (OSCTXT* pctxt);
00384
00395 EXTERNRT void rtxStreamSetCapture (OSCTXT* pctxt, OSRTMEMBUF* pmembuf);
00396
00406 EXTERNRT OSRTMEMBUF* rtxStreamGetCapture (OSCTXT* pctxt);
00407
00410 #ifdef __cplusplus
00411 }
00412 #endif
00413
00414 #endif
00415 #endif
00416