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 00028 class WvEncoderStream : public WvStreamClone 00029 { 00030 bool is_closing; 00031 bool is_eof; 00032 WvDynBuf readinbuf; 00033 WvDynBuf readoutbuf; 00034 WvDynBuf writeinbuf; 00035 WvDynBuf writeoutbuf; 00036 00037 public: 00039 WvEncoderChain readchain; 00040 00042 WvEncoderChain writechain; 00043 00052 size_t min_readsize; 00053 00059 WvEncoderStream(WvStream *cloned); 00060 virtual ~WvEncoderStream(); 00061 00072 virtual void close(); 00073 00081 bool flush_read(); 00082 00096 bool flush_write(); 00097 00103 bool finish_read(); 00104 00112 bool finish_write(); 00113 00123 virtual bool isok() const; 00124 00125 protected: 00126 bool pre_select(SelectInfo &si); 00127 virtual size_t uread(void *buf, size_t size); 00128 virtual size_t uwrite(const void *buf, size_t size); 00129 virtual bool flush_internal(time_t msec_timeout); 00130 00131 private: 00132 void checkreadisok(); 00133 void checkwriteisok(); 00134 00135 // pulls a chunk of specified size from the underlying stream 00136 void pull(size_t size); 00137 00138 // pushes a chunk to the underlying stream 00139 bool push(bool flush, bool finish); 00140 }; 00141 00142 #endif // __WVENCODERSTREAM_H