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