]> git.vomp.tv Git - vompclient.git/blob - vdr.h
Initial import
[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 "list.h"
34 #include "directory.h"
35 #include "recording.h"
36 #include "channel.h"
37
38  // FIXME do some tcp connection error checking and kill it!
39
40 class VDR
41 {
42   public:
43     VDR();
44     ~VDR();
45     static VDR* getInstance();
46
47     int init(int port);
48     int shutdown();
49
50     void findServers(std::vector<char*>& serverIPs);
51     void cancelFindingServer();
52     void setServerIP(char*);
53     int connect();
54     void disconnect();
55     ULLONG getResumePoint(char* fileName);  // uses configLoad
56
57     // protocol functions
58
59     int doLogin();
60
61     Directory* getRecordingsList();
62     char*      getRecordingSummary(char* fileName);
63     int        deleteRecording(char* fileName);
64     ULLONG     streamRecording(Recording* rec);
65
66     List*      getChannelsList(ULONG type);
67     int        streamChannel(ULONG number);
68
69     int        getBlock(UCHAR* buf, ULLONG position, int maxAmount);
70     int        stopStreaming();
71     int        getChannelSchedule(ULONG number);
72     int        configSave(char* section, char* key, char* value);
73     char*      configLoad(char* section, char* key);
74
75     // end
76
77     const static ULONG VIDEO = 1;
78     const static ULONG RADIO = 2;
79
80   private:
81     static VDR* instance;
82     Log* logger;
83     int initted;
84     int findingServer;
85     TCP* tcp;
86     int port;
87     char serverIP[16];
88     pthread_mutex_t mutex;
89
90     const static ULONG VDR_LOGIN               = 1;
91     const static ULONG VDR_GETRECORDINGLIST    = 2;
92     const static ULONG VDR_DELETERECORDING     = 3;
93     const static ULONG VDR_GETSUMMARY          = 4;
94     const static ULONG VDR_GETCHANNELLIST      = 5;
95     const static ULONG VDR_STREAMCHANNEL       = 6;
96     const static ULONG VDR_GETBLOCK            = 7;
97     const static ULONG VDR_STOPSTREAMING       = 8;
98     const static ULONG VDR_STREAMRECORDING     = 9;
99     const static ULONG VDR_GETCHANNELSCHEDULE  = 10;
100     const static ULONG VDR_CONFIGSAVE          = 11;
101     const static ULONG VDR_CONFIGLOAD          = 12;
102
103     long getSimpleReply();
104     char* getStringReply();
105 };
106
107 #endif