Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

wvsyncstream.h

00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 2002 Net Integration Technologies, Inc.
00004  *
00005  * A throttled stream.
00006  */
00007 #ifndef __WVSYNCSTREAM_H
00008 #define __WVSYNCSTREAM_H
00009 
00010 #ifndef _WIN32
00011 #include <sys/time.h>
00012 #endif
00013 #include <time.h>
00014 #include "wvstream.h"
00015 #include "wvstreamclone.h"
00016 
00022 class WvSyncStream : public WvStreamClone
00023 {
00024     size_t bps;
00025     size_t avgchunk;
00026     size_t maxchunk;
00027     size_t availchunk;
00028     size_t usedchunk;
00029     size_t lowater, hiwater; // controls latency
00030     bool waiting;
00031     
00032     struct timeval reference; // last reference time taken
00033 
00034 public:
00043     WvSyncStream(WvStream *cloned, size_t bps,
00044         size_t avgchunk, size_t maxchunk);
00045     virtual ~WvSyncStream();
00046 
00057     WvSyncStream(WvStream *cloned, bool owner, int srate, int bits,
00058         int msec = 10);
00059        
00060     virtual size_t uread(void *buf, size_t count);
00061     virtual bool pre_select(SelectInfo &si);
00062     virtual bool post_select(SelectInfo &si);
00063 
00064 private:
00065     void init(size_t _bps, size_t _avgchunk, size_t _maxchunk);
00066     
00067     // updates availchunk to reflect the max amount of data available now
00068     void poll();
00069     // resets the timing information
00070     void resettimer();
00071 };
00072 
00073 #endif  // __WVSYNCSTREAM_H

Generated on Sun Jul 10 18:25:53 2005 for WvStreams by  doxygen 1.4.0