WvStreams
wvencoderstream.h
00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Tunnel Vision Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * An stream wrapper for encoders.
00006  */
00007 #ifndef __WVENCODERSTREAM_H
00008 #define __WVENCODERSTREAM_H
00009 
00010 #include "wvstream.h"
00011 #include "wvstreamclone.h"
00012 #include "wvencoder.h"
00013 
00037 class WvEncoderStream : public WvStreamClone
00038 {
00039     bool is_closing;
00040     WvDynBuf readinbuf;
00041     WvDynBuf readoutbuf;
00042     WvDynBuf writeinbuf;
00043     //WvDynBuf writeoutbuf;
00044 
00045 public:
00047     WvEncoderChain readchain;
00048 
00050     WvEncoderChain writechain;
00051 
00073     size_t min_readsize;
00074 
00080     WvEncoderStream(WvStream *cloned);
00081     virtual ~WvEncoderStream();
00082 
00093     virtual void close();
00094 
00102     bool flush_read();
00103 
00117     bool flush_write();
00118 
00124     bool finish_read();
00125 
00133     bool finish_write();
00134 
00144     virtual bool isok() const;
00145 
00146     virtual size_t uread(void *buf, size_t size);
00147     virtual size_t uwrite(const void *buf, size_t size);
00148     
00149 protected:
00150     void pre_select(SelectInfo &si);
00151     bool post_select(SelectInfo &si);
00152     virtual bool flush_internal(time_t msec_timeout);
00153 
00154 private:
00155     void checkreadisok();
00156     void checkwriteisok();
00157     
00158     // pulls a chunk of specified size from the underlying stream
00159     void pull(size_t size);
00160 
00161     // pushes a chunk to the underlying stream
00162     bool push(bool flush, bool finish);
00163 
00164 public:
00165     const char *wstype() const { return "WvEncoderStream"; }
00166 };
00167 
00168 #endif // __WVENCODERSTREAM_H