]> git.vomp.tv Git - vompserver.git/blob - vompclient.h
Add forgotten vdrcommand.h changes
[vompserver.git] / vompclient.h
1 /*
2     Copyright 2004-2008 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 /*
22   The new async protocol design forced the server side change from the mvpclient
23   class to the mess it is now. Maybe in a couple of versions time it will become
24   more apparent how better to design all this.
25   
26   The reason for the class split is that with the current Thread class system,
27   you can only have one thread per object. The vompclient class would have needed
28   two, one for RR stuff and one for the keepalives.
29   
30   So the new design is this: the VompClient class represents one connection from
31   one client as the MVPClient class did before. But because two threads are now
32   needed, a helper class VompClientRRProc contains all the RR processing functions,
33   and the thread needed to process them. All the state data is still kept in the
34   VompClient class.
35 */
36
37 #ifndef VOMPCLIENT_H
38 #define VOMPCLIENT_H
39
40 #include <stdio.h>
41 #include <pthread.h>
42 #include <signal.h>
43 #include <endian.h>
44
45 #include <unistd.h> // sleep
46
47 #ifndef VOMPSTANDALONE
48 class RecPlayer;
49 class MVPReceiver;
50 class cChannel;
51 class cRecordings;
52 class cPlugin;
53 #endif
54
55 #include "defines.h"
56 #include "tcp.h"
57 #include "config.h"
58 #include "media.h"
59 #include "i18n.h"
60 #include "vompclientrrproc.h"
61
62 class ResponsePacket;
63 class ServerMediaFile;
64 class SerializeBuffer;
65 class MediaPlayer;
66 class PictureReader;
67
68 class VompClient
69 {
70   friend class VompClientRRProc;
71   friend class PictureReader;
72
73   public:
74     VompClient(Config* baseConfig, char* configDir, int tsocket);
75     ~VompClient();
76
77     int run();
78     // not for external use
79     void run2();
80     static int getNrClients();
81
82   private:
83     static int nr_clients;
84     static void incClients();
85     static void decClients();
86     
87     static ULLONG ntohll(ULLONG a);
88     static ULLONG htonll(ULLONG a);
89     
90     VompClientRRProc rrproc;
91     pthread_t runThread;
92     int initted;
93     Log* log;
94     TCP tcp;
95     Config config;
96     Config* baseConfig;
97     I18n i18n;
98     bool loggedIn;
99     char* configDir;
100
101     void netLog();
102     FILE* netLogFile;
103
104     //void cleanConfig();
105
106 #ifndef VOMPSTANDALONE
107     cChannel* channelFromNumber(ULONG channelNumber);
108     void writeResumeData();
109
110     MVPReceiver* lp;
111     cRecordings* recordingManager;
112     RecPlayer* recplayer;
113     static cPlugin * scraper;
114     PictureReader * pict;
115
116 #endif
117     MediaPlayer *media;
118     ServerMediaFile *mediaprovider;
119     
120     void setCharset(int charset);
121     int charcoding; // 1= latin1 2= UTF-8
122     cCharSetConv *charconvutf8;
123     cCharSetConv *charconvsys;
124     
125     
126 };
127
128 #endif
129