-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStation.h
99 lines (90 loc) · 4.7 KB
/
Station.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
/*
* File: Station.h
* Author: Kai Niessen
*
* Created on 26. Februar 2013, 04:08
*/
#ifndef STATION_H
#define STATION_H
#include <Message.h>
#include <Bitmap.h>
#include <File.h>
#include <support/String.h>
#include <support/SupportDefs.h>
#include <MimeType.h>
#include <Directory.h>
#include "HttpUtils.h"
// Station flags
#define STATION_HAS_NAME 1
#define STATION_HAS_URI 2
#define STATION_URI_VALID 4
#define STATION_HAS_ENCODING 8
#define STATION_HAS_BITRATE 16
#define STATION_HAS_FORMAT 32 // frame rate and channels
#define STATION_HAS_META 64
class StreamPlayer;
class Station {
public:
Station(BString Name, BString Uri = B_EMPTY_STRING);
Station(const Station& orig);
virtual ~Station();
status_t InitCheck();
status_t Save();
status_t RetrieveStreamUrl();
status_t Probe();
status_t ProbeBuffer(BPositionIO* buffer);
static class Station* LoadFromPlsFile(BString Name);
static class Station* Load(BString Name, BEntry* entry);
static class Station* LoadIndirectUrl(BString& ShoutCastUrl);
static BDirectory* StationDirectory();
inline BString* Name() { return &fName; }
void SetName(BString name);
inline BUrl StreamUrl() { return fStreamUrl; }
inline void SetStreamUrl(BUrl uri) { fStreamUrl = uri; checkFlags(); unsaved = true; }
inline BUrl StationUrl() { return fStationUrl; }
inline void SetStation(BUrl sUrl) { fStationUrl = sUrl; checkFlags(); unsaved = true; }
inline BUrl Source() { return fSource; }
inline void SetSource(BUrl source) { fSource = source; checkFlags(); unsaved = true; }
inline BBitmap* Logo() { return fLogo; }
void SetLogo(BBitmap* logo) { if (fLogo) delete fLogo; fLogo = logo; unsaved = true; }
inline BString Genre() { return fGenre; }
inline void SetGenre(BString genre) { fGenre.SetTo(genre); unsaved = true; }
inline BString Country() { return fCountry; }
inline void SetCountry(BString country) { fCountry.SetTo(country); unsaved = true; }
inline BString Language() { return fLanguage; }
inline void SetLanguage(BString language) { fLanguage.SetTo(language); unsaved = true; }
inline int32 SampleRate() { return fSampleRate; }
inline int32 BitRate() { return fBitRate; }
void SetBitRate(int32 bitrate) { fBitRate = bitrate; unsaved = true; }
inline int32 Channels() { return fChannels; }
inline int32 Encoding() { return fEncoding; }
inline size_t FrameSize() { return fFrameSize; }
inline BMimeType* Mime() { return &fMime; }
inline int32 Flags() { return fFlags; }
inline bool Flags(int32 flags) { return (fFlags & flags) == flags; }
protected:
void checkFlags();
static char* regFind(const char* Text, const char* Pattern);
status_t parseUrlReference(const char* body, const char* mime);
void cleanName();
bool unsaved;
BString fName;
BUrl fStreamUrl;
BUrl fStationUrl;
BBitmap* fLogo;
uint32 fRating;
BString fGenre;
BString fCountry;
BString fLanguage;
BUrl fSource;
uint32 fBitRate;
uint32 fSampleRate;
uint32 fChannels;
size_t fFrameSize;
BMimeType fMime;
uint32 fEncoding;
uint32 fMetaInterval;
uint32 fFlags;
static BDirectory* fStationsDirectory;
};
#endif /* STATION_H */