WvStreams
wvencoderstream.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Tunnel Vision Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * An stream wrapper for encoders.
6  */
7 #ifndef __WVENCODERSTREAM_H
8 #define __WVENCODERSTREAM_H
9 
10 #include "wvstream.h"
11 #include "wvstreamclone.h"
12 #include "wvencoder.h"
13 
38 {
39  bool is_closing;
40  WvDynBuf readinbuf;
41  WvDynBuf readoutbuf;
42  WvDynBuf writeinbuf;
43  //WvDynBuf writeoutbuf;
44 
45 public:
48 
51 
73  size_t min_readsize;
74 
80  WvEncoderStream(WvStream *cloned);
81  virtual ~WvEncoderStream();
82 
93  virtual void close();
94 
102  bool flush_read();
103 
117  bool flush_write();
118 
124  bool finish_read();
125 
133  bool finish_write();
134 
144  virtual bool isok() const;
145 
146  virtual size_t uread(void *buf, size_t size);
147  virtual size_t uwrite(const void *buf, size_t size);
148 
149 protected:
150  void pre_select(SelectInfo &si);
151  bool post_select(SelectInfo &si);
152  virtual bool flush_internal(time_t msec_timeout);
153 
154 private:
155  void checkreadisok();
156  void checkwriteisok();
157 
158  // pulls a chunk of specified size from the underlying stream
159  void pull(size_t size);
160 
161  // pushes a chunk to the underlying stream
162  bool push(bool flush, bool finish);
163 
164 public:
165  const char *wstype() const { return "WvEncoderStream"; }
166 };
167 
168 #endif // __WVENCODERSTREAM_H
WvEncoderStream::uwrite
virtual size_t uwrite(const void *buf, size_t size)
unbuffered I/O functions; these ignore the buffer, which is handled by write().
Definition: wvencoderstream.cc:191
WvEncoderStream::post_select
bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.
Definition: wvencoderstream.cc:208
WvEncoderStream
WvEncoderStream chains a series of encoders on the input and output ports of the underlying stream to...
Definition: wvencoderstream.h:37
WvEncoderStream::flush_write
bool flush_write()
Flushes the write chain through to the stream's output buffer.
Definition: wvencoderstream.cc:79
WvEncoderStream::writechain
WvEncoderChain writechain
Encoder chain through which output data is passed.
Definition: wvencoderstream.h:50
WvEncoderStream::WvEncoderStream
WvEncoderStream(WvStream *cloned)
Creates an encoder stream.
Definition: wvencoderstream.cc:11
WvStream::flush
virtual bool flush(time_t msec_timeout)
flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a ti...
Definition: wvstream.cc:707
WvEncoderStream::isok
virtual bool isok() const
Defines isok() semantics for encoders.
Definition: wvencoderstream.cc:44
WvEncoderStream::finish_read
bool finish_read()
Calls flush() then finish() on the read chain of encoders.
Definition: wvencoderstream.cc:86
WvEncoderStream::uread
virtual size_t uread(void *buf, size_t size)
unbuffered I/O functions; these ignore the buffer, which is handled by read().
Definition: wvencoderstream.cc:178
WvEncoderStream::min_readsize
size_t min_readsize
Controls the minimum number of unencoded bytes the encoder should try to read at once from the underl...
Definition: wvencoderstream.h:73
IWvStream::SelectInfo
the data structure used by pre_select()/post_select() and internally by select().
Definition: iwvstream.h:50
WvStreamClone
WvStreamClone simply forwards all requests to the "cloned" stream.
Definition: wvstreamclone.h:23
WvEncoderStream::flush_internal
virtual bool flush_internal(time_t msec_timeout)
WvStream overrides.
Definition: wvencoderstream.cc:63
WvStream
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
Definition: wvstream.h:24
WvEncoderStream::flush_read
bool flush_read()
Flushes the read chain through to the stream's input buffer.
Definition: wvencoderstream.cc:70
WvEncoderStream::close
virtual void close()
Safely shuts down the stream.
Definition: wvencoderstream.cc:24
WvDynBufBase< unsigned char >
WvEncoderChain
An encoder chain owns a list of encoders that are used in sequence to transform data from a source bu...
Definition: wvencoder.h:549
WvEncoderStream::finish_write
bool finish_write()
Calls flush() then finish() on the write chain of encoders.
Definition: wvencoderstream.cc:98
WvEncoderStream::readchain
WvEncoderChain readchain
Encoder chain through which input data is passed.
Definition: wvencoderstream.h:47
WvEncoderStream::pre_select
void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
Definition: wvencoderstream.cc:199