2 #include "devicedvbinput.inc"
5 #include <netinet/in.h>
6 #include <sys/socket.h>
9 #include "renderfarm.inc"
10 #include "renderfarmclient.h"
11 #include "tunerserver.h"
17 TunerServer::TunerServer(RenderFarmClientThread *client)
19 this->client = client;
29 connection_closed = 0;
33 TunerServer::~TunerServer()
40 void TunerServer::main_loop()
47 error = client->write_int64(1);
52 error = client->write_int64(0);
62 int64_t command = client->read_int64(&error);
67 // Assume read error was connection closing.
70 //printf("TunerServerThread::run 1 command=%d\n", command);
76 int current_power = 0;
78 error = get_signal_strength(¤t_power, ¤t_lock);
79 error = client->write_int64(error);
81 error = client->write_int64(current_power);
83 error = client->write_int64(current_lock);
87 case NETTUNE_SET_TABLE:
88 table = client->read_int64(&error);
91 case NETTUNE_SET_CHANNEL:
92 channel = client->read_int64(&error);
95 case NETTUNE_SET_AUDIO_PID:
96 audio_pid = client->read_int64(&error);
99 case NETTUNE_SET_VIDEO_PID:
100 video_pid = client->read_int64(&error);
105 // Get requested size
106 int size = client->read_int64(&error);
107 if(temp_allocated < size)
110 temp = new unsigned char[size];
111 temp_allocated = size;
114 // Get number of bytes read and buffer
115 int bytes_read = read_data(temp, size);
116 error = client->write_int64(bytes_read);
118 error = client->write_socket((char*)temp, bytes_read);
124 printf("TunerServerThread::run audio_pid=0x%x video_pid=0x%x table=%d channel=%d\n",
129 error = open_tuner();
130 error = client->write_int64(error);
141 printf("TunerServerThread::run: connection closed\n");
147 int TunerServer::get_channel()
152 int TunerServer::get_table()
157 int TunerServer::get_audio_pid()
162 int TunerServer::get_video_pid()
167 int TunerServer::get_device_number()
169 return device_number;
173 int TunerServer::open_tuner()
178 int TunerServer::close_tuner()
184 int TunerServer::get_signal_strength(int *current_power, int *current_lock)
189 int TunerServer::read_data(unsigned char *data, int size)
200 // c-file-style: "linux"