blob: ea69de679d3beeb1581a354c9e2f86d682a8d5ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*
* 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.3 2006-12-15 16:35:31 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;
bool m_Raw; /* stream without stream_tcp_header_t */
int m_fd;
uint64_t m_PutPos;
uint64_t m_DiscardStart;
uint64_t m_DiscardEnd;
int m_BufferOverflows;
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), bool Raw = false);
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 Flush(int TimeoutMs);
};
#endif
|