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