]> git.vomp.tv Git - vompclient.git/blob - vdr.h
Finnish and French added, Timers screen code
[vompclient.git] / vdr.h
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
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.
10
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.
15
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
19 */
20
21 #ifndef VDR_H
22 #define VDR_H
23
24 #include <stdio.h>
25 #include <time.h>
26 #include <pthread.h>
27 #include <vector>
28 #include <algorithm>
29
30 #include "defines.h"
31 #include "log.h"
32 #include "dsock.h"
33 #include "tcp.h"
34 #include "directory.h"
35 #include "recording.h"
36 #include "channel.h"
37 #include "event.h"
38 #include "rectimer.h"
39
40 using namespace std;
41
42  // FIXME do some tcp connection error checking and kill it!
43
44 typedef vector<Event*> EventList;
45 typedef vector<Channel*> ChannelList;
46 typedef vector<RecTimer*> RecTimerList;
47
48 struct RecTimerSorter     // : public binary_function<double, double, bool>
49 {
50   bool operator() (const RecTimer* a, const RecTimer* b)
51   {
52     return a->startTime < b->startTime;
53   }
54 };
55
56 class VDR
57 {
58
59   public:
60     VDR();
61     ~VDR();
62     static VDR* getInstance();
63
64     int init(int port);
65     int shutdown();
66
67     void findServers(vector<char*>& serverIPs);
68     void cancelFindingServer();
69     void setServerIP(char*);
70     int connect();
71     void disconnect();
72     ULLONG getResumePoint(char* fileName);  // uses configLoad
73
74     // protocol functions
75
76     int doLogin();
77
78     Directory* getRecordingsList();
79     char*      getRecordingSummary(char* fileName);
80     int        deleteRecording(char* fileName);
81     ULLONG     streamRecording(Recording* rec);
82     ULLONG     rescanRecording();
83
84     ChannelList* getChannelsList(ULONG type);
85     int          streamChannel(ULONG number);
86
87     UCHAR*     getBlock(ULLONG position, UINT maxAmount, UINT* amountReceived);
88     int        stopStreaming();
89     EventList* getChannelSchedule(ULONG number);
90     EventList* getChannelSchedule(ULONG number, time_t start, ULONG duration);
91     int        configSave(char* section, char* key, const char* value);
92     char*      configLoad(char* section, char* key);
93
94     RecTimerList* getRecTimersList();
95
96     // end
97
98     const static ULONG VIDEO = 1;
99     const static ULONG RADIO = 2;
100
101   private:
102     static VDR* instance;
103     Log* logger;
104     int initted;
105     int findingServer;
106     TCP* tcp;
107     int port;
108     char serverIP[16];
109     bool connected;
110     pthread_mutex_t mutex;
111
112     UCHAR* packet;
113     ULONG packetLength;
114     ULONG packetPos;
115
116     const static ULONG VDR_LOGIN               = 1;
117     const static ULONG VDR_GETRECORDINGLIST    = 2;
118     const static ULONG VDR_DELETERECORDING     = 3;
119     const static ULONG VDR_GETSUMMARY          = 4;
120     const static ULONG VDR_GETCHANNELLIST      = 5;
121     const static ULONG VDR_STREAMCHANNEL       = 6;
122     const static ULONG VDR_GETBLOCK            = 7;
123     const static ULONG VDR_STOPSTREAMING       = 8;
124     const static ULONG VDR_STREAMRECORDING     = 9;
125     const static ULONG VDR_GETCHANNELSCHEDULE  = 10;
126     const static ULONG VDR_CONFIGSAVE          = 11;
127     const static ULONG VDR_CONFIGLOAD          = 12;
128     const static ULONG VDR_RESCANRECORDING     = 13;
129     const static ULONG VDR_GETTIMERS           = 14;
130
131     int  getPacket();
132     void freePacket();
133     int  serverError();
134     char*  extractString();
135     ULONG  extractULONG();
136     ULLONG extractULLONG();
137     long   extractLONG();
138 };
139
140 #endif