-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstream.h
132 lines (118 loc) · 3.93 KB
/
stream.h
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
132
/*
* MP3/MPlayer plugin to VDR (C++)
*
* (C) 2001-2009 Stefan Huelswitt <s.huelswitt@gmx.de>
*
* This code is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
*/
#ifndef ___STREAM_H
#define ___STREAM_H
#include "decoder.h"
class cNet;
// ----------------------------------------------------------------
#if 0
class cIO : public cFileInfo {
protected:
bool log;
unsigned long long readpos;
public:
cIO(const char *Filename, bool Log);
virtual ~cIO();
virtual bool Open(void)=0;
virtual void Close(void)=0;
virtual int Read(unsigned char *Data, int Size)=0;
virtual unsigned char *StreamInit(int Size) { return 0; }
virtual int Stream(const unsigned char *rest) { return -1; }
virtual bool Seek(unsigned long long pos, int whence) { return -1; }
virtual unsigned long long Tell(void) { return readpos; }
};
// ----------------------------------------------------------------
class cStreamIO {
private:
int size, fill;
unsigned char *data;
protected:
void StreamClear(bool all);
public:
cStreamIO(void);
virtual ~cStreamIO();
virtual unsigned char *StreamInit(int Size);
virtual int Stream(const unsigned char *rest);
virtual int Read(unsigned char *Data, int Size)=0;
};
// ----------------------------------------------------------------
class cFileIO : public cIO, public cStreamIO {
protected:
int fd;
public:
cFileIO(const char *Filename, bool Log);
virtual ~cFileIO();
virtual bool Open(void);
virtual void Close(void);
virtual int Read(unsigned char *Data, int Size);
virtual bool Seek(unsigned long long pos, int whence);
};
#endif
// ----------------------------------------------------------------
class cStream : public cFileInfo {
private:
int fd;
bool ismmap;
protected:
unsigned char *buffer;
unsigned long long readpos, buffpos;
unsigned long fill;
public:
cStream(const char *Filename);
virtual ~cStream();
virtual bool Open(bool log=true);
virtual void Close(void);
virtual bool Stream(unsigned char *&data, unsigned long &len, const unsigned char *rest=NULL);
virtual bool Seek(unsigned long long pos=0);
virtual unsigned long long BufferPos(void) { return buffpos; }
};
// ----------------------------------------------------------------
class cNetStream : public cStream {
private:
cNet *net;
char *host, *path, *auth;
int port, cc;
//
char *icyName, *icyUrl, *icyTitle;
int metaInt, metaCnt;
bool icyChanged;
//
bool ParseURL(const char *line, bool log);
bool ParseURLFile(const char *name, bool log);
bool SendRequest(void);
bool GetHTTPResponse(void);
bool ParseHeader(const char *buff, const char *name, char **value);
bool ParseMetaData(void);
char *ParseMetaString(char *buff, const char *name, char **value);
public:
cNetStream(const char *Filename);
virtual ~cNetStream();
virtual bool Open(bool log=true);
virtual void Close(void);
virtual bool Stream(unsigned char *&data, unsigned long &len, const unsigned char *rest=NULL);
virtual bool Seek(unsigned long long pos=0);
bool Valid(void) { return ParseURLFile(Filename,false); }
const char *IcyName(void) const { return icyName; }
const char *IcyUrl(void) const { return icyUrl; }
const char *IcyTitle(void) const { return icyTitle; }
bool IcyChanged(void);
};
#endif //___STREAM_H