-
Notifications
You must be signed in to change notification settings - Fork 0
/
Streamer.h
98 lines (81 loc) · 2.33 KB
/
Streamer.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
/*
* mp3stream - encode /dev/dsp and send it to a shoutcast server
* 2005 - bl0rg.net - public domain
*
* Streamer.h - streamer abstraction
*/
#ifndef STREAMER_H__
#define STREAMER_H__
#include <string>
#include "Url.h"
#include "Error.h"
class StreamerError : public Error {
public:
StreamerError(std::string msg) : Error(msg) { }
virtual ~StreamerError() { }
};
class Stream {
protected:
unsigned long bitrate;
std::string name;
std::string genre;
std::string url;
std::string publicStr;
std::string description;
std::string contentid;
public:
Stream(const unsigned long bitrate,
const std::string &name = "",
const std::string &genre = "",
const std::string &url = "",
const std::string &publicStr = "",
const std::string &description = "",
const std::string &contentid = "");
~Stream();
const unsigned long getBitrate() const { return bitrate; }
const std::string getName() const { return name; }
const std::string getGenre() const { return genre; }
const std::string getPublicStr() const { return publicStr; }
const std::string getDescription() const { return description; }
const std::string getContentid() const { return contentid; }
const std::string getUrl() const { return url; }
};
typedef enum {
XAudioLoginType = 0,
IcyLoginType,
FileLoginType,
NoneLoginType
} StreamerLoginType;
class Streamer {
protected:
int fd;
bool bConnected;
bool bLoggedIn;
Stream stream;
std::string host;
unsigned short port;
std::string path;
std::string password;
StreamerLoginType type;
void Connect();
void OpenFile();
void IcyLogin();
void XAudioLogin();
public:
Streamer(const Stream &stream, const Url &url);
Streamer(const Stream &stream, const std::string &host, unsigned short port,
const std::string &path, const std::string &password = "",
StreamerLoginType type = NoneLoginType);
~Streamer();
unsigned short getPort() const { return port; }
std::string getHost() const { return host; }
std::string getPath() const { return path; }
std::string getPassword() const { return password; }
unsigned long getBitrate() const { return stream.getBitrate(); }
std::string getUrl();
std::string getInfo();
void Login();
void Write(const unsigned char *buf, unsigned int len);
void Read(unsigned char *buf, unsigned int len);
};
#endif /* STREAMER_H__ */