diff options
author | phintuka <phintuka> | 2006-06-03 10:04:49 +0000 |
---|---|---|
committer | phintuka <phintuka> | 2006-06-03 10:04:49 +0000 |
commit | 0e345486181ef82b681dd6047f3b6ccb44c77146 (patch) | |
tree | a5401c7f97ab047a0afa890e6806d8537564102a /tools/backgroundwriter.h | |
parent | 321eb114c9fe9abd954ce4270595d53df6cccbae (diff) | |
download | xineliboutput-0e345486181ef82b681dd6047f3b6ccb44c77146.tar.gz xineliboutput-0e345486181ef82b681dd6047f3b6ccb44c77146.tar.bz2 |
Initial importxineliboutput-0_99rc4
Diffstat (limited to 'tools/backgroundwriter.h')
-rw-r--r-- | tools/backgroundwriter.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/backgroundwriter.h b/tools/backgroundwriter.h new file mode 100644 index 00000000..619b2a29 --- /dev/null +++ b/tools/backgroundwriter.h @@ -0,0 +1,62 @@ +/* + * backgroundwriter.h: Buffered socket/file writing thread + * + * See the main source file 'xineliboutput.c' for copyright information and + * how to reach the author. + * + * $Id: backgroundwriter.h,v 1.1 2006-06-03 10:04:27 phintuka Exp $ + * + */ + +#ifndef __BACKGROUNDWRITER_H +#define __BACKGROUNDWRITER_H + +#include <stdint.h> + +#include <vdr/thread.h> +#include <vdr/ringbuffer.h> + + +class cBackgroundWriter : public cThread { + + private: + cRingBufferLinear m_RingBuffer; + + volatile bool m_Active; + int m_fd; + + uint64_t m_PutPos; + uint64_t m_DiscardStart; + uint64_t m_DiscardEnd; + + protected: + virtual void Action(void); + + int Put(const uchar *Header, int HeaderCount, + const uchar *Data, int DataCount); + + public: + cBackgroundWriter(int fd, int Size = KILOBYTE(512)); + virtual ~cBackgroundWriter() ; + + // Return largest possible Put size + int Free(void); + + // Add PES frame to buffer + // + // Return value: + // Success: Count (all bytes pushed to queue) + // Error: 0 (write error ; socket disconnected) + // Buffer full: -Count (no bytes will be pushed to queue) + // + int Put(uint64_t StreamPos, const uchar *Data, int DataCount); + + // Drop all data (only complete frames) from buffer + void Clear(void); + + //bool Poll(int TimeoutMs); + bool Flush(int TimeoutMs); +}; + + +#endif |