blob: 9e42ada74cb0f487fc3725536efdc7066ff635bd (
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
#ifndef VDR_LIVE_RECORDINGS_H
#define VDR_LIVE_RECORDINGS_H
#include <ctime>
#include <map>
#include <vector>
#include <vdr/recording.h>
#include "stdext.h"
namespace vdrlive {
// Forward declations from epg_events.h
class EpgEvent;
typedef std::tr1::shared_ptr<EpgEvent> EpgEventPtr;
class RecordingsManager;
typedef std::tr1::shared_ptr<RecordingsManager> RecordingsManagerPtr;
class RecordingsManager
{
friend RecordingsManagerPtr LiveRecordingsManager();
public:
/**
* generates a Md5 hash from a cRecording entry. It can be used
* to reidentify a recording.
*/
std::string Md5Hash(const cRecording* recording) const;
/**
* fetches a cRecording from VDR's Recordings collection. Returns
* NULL if recording was not found
*/
const cRecording* GetByMd5Hash(const std::string& hash) const;
private:
RecordingsManager();
cThreadLock m_recordingsLock;
};
class RecordingsTree
{
public:
class RecordingsItem;
typedef std::tr1::shared_ptr< RecordingsItem > RecordingsItemPtr;
typedef std::multimap< std::string, RecordingsItemPtr > Map;
class RecordingsItem
{
friend class RecordingsTree;
public:
virtual ~RecordingsItem();
virtual time_t StartTime() const = 0;
virtual bool IsDir() const = 0;
virtual bool IsArchived() const = 0;
virtual const std::string& Name() const { return m_name; }
virtual const std::string Id() const = 0;
virtual const std::string ArchiveId() const = 0;
virtual const cRecording* Recording() const { return 0; }
virtual const cRecordingInfo* RecInfo() const { return 0; }
protected:
RecordingsItem(const std::string& name);
private:
std::string m_name;
Map m_entries;
};
class RecordingsItemDir : public RecordingsItem
{
public:
RecordingsItemDir();
RecordingsItemDir(const std::string& name, int level);
virtual ~RecordingsItemDir();
virtual time_t StartTime() const { return 0; }
virtual bool IsDir() const { return true; }
virtual bool IsArchived() const { return false; }
virtual const std::string Id() const { std::string e; return e; }
virtual const std::string ArchiveId() const { std::string e; return e; }
private:
int m_level;
};
class RecordingsItemRec : public RecordingsItem
{
public:
RecordingsItemRec(const std::string& id, const std::string& name, cRecording* recording);
virtual ~RecordingsItemRec();
virtual time_t StartTime() const;
virtual bool IsDir() const { return false; }
virtual bool IsArchived() const ;
virtual const std::string Id() const { return m_id; }
virtual const std::string ArchiveId() const;
virtual const cRecording* Recording() const { return m_recording; }
virtual const cRecordingInfo* RecInfo() const { return m_recording->Info(); }
private:
cRecording *m_recording;
std::string m_id;
};
RecordingsTree(RecordingsManagerPtr recManPtr);
virtual ~RecordingsTree();
Map::iterator begin(const std::vector< std::string >& path);
Map::iterator end(const std::vector< std::string >&path);
int MaxLevel() const { return m_maxLevel; }
static EpgEventPtr CreateEpgEvent(const RecordingsItemPtr recItem);
private:
int m_maxLevel;
RecordingsItemPtr m_root;
RecordingsManagerPtr m_recManPtr;
Map::iterator findDir(RecordingsItemPtr& dir, const std::string& dirname);
};
/**
* return singleton instance of RecordingsManager as a shared Pointer.
* This ensures that after last use of the RecordingsManager it is
* deleted. After deletion of the original RecordingsManager a repeated
* call to this function creates a new RecordingsManager which is again
* kept alive as long references to it exist.
*/
RecordingsManagerPtr LiveRecordingsManager();
} // namespace vdrlive
#endif // VDR_LIVE_RECORDINGS_H
|