blob: 105239f8666b2092edbbd5fb5f1e797f83f004c7 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/*
* http.h: HTTP (/RTSP) helper classes
*
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
* $Id: http.h,v 1.1 2007-01-01 00:14:38 phintuka Exp $
*
*/
#ifndef XINELIBOUTPUT_HTTP_H_
#define XINELIBOUTPUT_HTTP_H_
#include <vdr/tools.h>
#define HTTP_REPLY_401 \
"HTTP/1.1 401 Unauthorized\r\n" \
"Connection: Close\r\n" \
"\r\n"
#define HTTP_REPLY_200_PRIMARY \
"HTTP/1.1 200 OK\r\n" \
"Content-Type: video/mpeg\r\n" \
"Connection: Close\r\n" \
"\r\n"
//"Content-Type: video/mp2p\r\n"
//
// cHeader
//
class cHeader : public cListObject
{
protected:
cString m_Name;
cString m_Value;
private:
cHeader();
public:
cHeader(const char *Name, const char *Value) :
m_Name(Name), m_Value(Value) {};
const cString& Name(void) { return m_Name; }
const cString& Value(void) { return m_Value; }
void SetValue(const char *Value) { m_Value = Value; }
};
//
// cHttpReq
//
class cHttpReq
{
private:
cString m_Name;
cString m_Uri;
cString m_Version;
cList<cHeader> m_Headers;
bool m_Valid;
public:
cHttpReq() : m_Valid(false) {}
bool SetCommand(const char *Command);
const cString& Name(void) { return m_Name; }
const cString& Uri(void) { return m_Uri; }
const cString& Version(void) { return m_Version; }
bool Valid(void) { return m_Valid; }
void AddHeader(const char *Header, bool Duplicate=false);
void AddHeader(const char *Name, const char *Value, bool Duplicate=false);
cHeader *Header(const char *Name);
void Reset(void);
};
//
// cConnState
//
class cConnState : public cHttpReq {};
//
// cHttpStreamer
//
class cBackgroundWriter;
#include <vdr/tools.h>
#include <vdr/thread.h>
#include "cxsocket.h"
class cHttpStreamer : protected cListObject, cThread
{
public:
cHttpStreamer(int fd_http, const char *filename, const char *Range=NULL);
virtual ~cHttpStreamer();
static void CloseAll(bool OnlyFinished = false);
private:
static cList<cHttpStreamer> m_Streamers;
cxSocket m_fds;
int m_fdf;
cString m_Filename;
int64_t m_FileSize;
int64_t m_Start;
int64_t m_End;
cBackgroundWriter *m_Writer;
cConnState *m_ConnState;
bool m_Finished;
virtual void Action(void);
void ParseRange(const char *Range);
bool ReadPipelined(void);
bool Seek(void);
};
#endif // XINELIBOUTPUT_HTTP_H_
|