2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 //Find threading replacements
38 #include "directory.h"
39 #include "recording.h"
46 typedef vector<Event*> EventList;
47 typedef vector<Channel*> ChannelList;
48 typedef vector<RecTimer*> RecTimerList;
56 struct RecTimerSorter // : public binary_function<double, double, bool>
58 bool operator() (const RecTimer* a, const RecTimer* b)
60 return a->startTime < b->startTime;
66 bool operator() (const VDRServer& a, const VDRServer& b)
68 if (strcmp(b.name, a.name) > 0) return true;
73 struct RecordingSorter
75 bool operator() (const Recording* a, const Recording* b)
77 int c = strcmp(b->getProgName(), a->getProgName());
78 if (c > 0) return true;
79 if (c < 0) return false;
81 return a->start < b->start;
85 struct DirectorySorter
87 bool operator() (const Directory* a, const Directory* b)
89 int c = strcmp(b->name, a->name);
90 if (c > 0) return true;
101 static VDR* getInstance();
106 void findServers(vector<VDRServer>& servers);
107 void cancelFindingServer();
108 void setServerIP(char*);
111 bool isConnected() { return connected; }
112 ULLONG getResumePoint(char* fileName); // uses configLoad
114 void setReceiveWindow(size_t size);
116 // protocol functions
117 // for the following, if result == false then the connection has died
121 // getChannelSchedule
123 // isConnected can be called after the following to determine if still ok
124 // getRecordingSummary
128 // positionFromFrameNumber
138 Directory* getRecordingsList();
139 char* getRecordingSummary(char* fileName);
140 int deleteRecording(char* fileName);
141 ULLONG streamRecording(Recording* rec);
142 ULLONG rescanRecording();
143 ULLONG positionFromFrameNumber(ULONG frameNumber);
145 ChannelList* getChannelsList(ULONG type);
146 int streamChannel(ULONG number);
148 UCHAR* getBlock(ULLONG position, UINT maxAmount, UINT* amountReceived);
150 EventList* getChannelSchedule(ULONG number);
151 EventList* getChannelSchedule(ULONG number, time_t start, ULONG duration);
152 int configSave(char* section, char* key, const char* value);
153 char* configLoad(char* section, char* key);
154 ULONG setEventTimer(char* timerString);
156 RecTimerList* getRecTimersList();
160 const static ULONG VIDEO = 1;
161 const static ULONG RADIO = 2;
164 static VDR* instance;
173 pthread_mutex_t mutex;
182 const static ULONG VDR_LOGIN = 1;
183 const static ULONG VDR_GETRECORDINGLIST = 2;
184 const static ULONG VDR_DELETERECORDING = 3;
185 const static ULONG VDR_GETSUMMARY = 4;
186 const static ULONG VDR_GETCHANNELLIST = 5;
187 const static ULONG VDR_STREAMCHANNEL = 6;
188 const static ULONG VDR_GETBLOCK = 7;
189 const static ULONG VDR_STOPSTREAMING = 8;
190 const static ULONG VDR_STREAMRECORDING = 9;
191 const static ULONG VDR_GETCHANNELSCHEDULE = 10;
192 const static ULONG VDR_CONFIGSAVE = 11;
193 const static ULONG VDR_CONFIGLOAD = 12;
194 const static ULONG VDR_RESCANRECORDING = 13;
195 const static ULONG VDR_GETTIMERS = 14;
196 const static ULONG VDR_SETTIMER = 15;
197 const static ULONG VDR_POSFROMFRAME = 16;
202 char* extractString();
203 ULONG extractULONG();
204 ULLONG extractULLONG();