128 d_time_to_exit =
false;
129 d_description_updated =
false;
130 d_nRows = d_nCols = d_nDepth = d_nChannels = 0;
131 d_new_log_request =
false;
132 d_request_lil = NULL;
133 d_request_lol = NULL;
134 d_request_ril = NULL;
135 d_request_rol = NULL;
136 d_new_log_result =
false;
141 d_new_throttle_request =
false;
142 d_throttle_count = -1;
143 d_frames_in_queue = 0;
148 bool time_to_exit(
void)
151 bool ret = d_time_to_exit;
154 void time_to_exit(
bool do_exit)
157 d_time_to_exit = do_exit;
165 bool get_imager_description(vrpn_int32 &nRows, vrpn_int32 &nCols,
166 vrpn_int32 &nDepth, vrpn_int32 &nChannels,
167 const char **channelBuffer)
170 bool ret = d_description_updated;
171 if (d_description_updated) {
175 nChannels = d_nChannels;
176 *channelBuffer = d_channel_buffer;
178 d_description_updated =
false;
181 bool set_imager_description(vrpn_int32 nRows, vrpn_int32 nCols,
182 vrpn_int32 nDepth, vrpn_int32 nChannels,
183 const char *channelBuffer)
189 d_nChannels = nChannels;
190 d_channel_buffer = channelBuffer;
191 d_description_updated =
true;
205 bool get_logfile_request(
char **lil,
char **lol,
char **ril,
char **rol)
208 bool ret = d_new_log_request;
209 if (d_new_log_request) {
212 if ((*lil =
new(std::nothrow)
char[strlen(d_request_lil) + 1]) != NULL) {
213 vrpn_strncpynull(*lil, d_request_lil, strlen(d_request_lil) + 1);
215 if ((*lol =
new(std::nothrow)
char[strlen(d_request_lol) + 1]) != NULL) {
216 vrpn_strncpynull(*lol, d_request_lol, strlen(d_request_lol) + 1);
218 if ((*ril =
new(std::nothrow)
char[strlen(d_request_ril) + 1]) != NULL) {
219 vrpn_strncpynull(*ril, d_request_ril, strlen(d_request_ril) + 1);
221 if ((*rol =
new(std::nothrow)
char[strlen(d_request_rol) + 1]) != NULL) {
222 vrpn_strncpynull(*rol, d_request_rol, strlen(d_request_rol) + 1);
227 delete[] d_request_lil;
228 d_request_lil = NULL;
229 delete[] d_request_lol;
230 d_request_lol = NULL;
231 delete[] d_request_ril;
232 d_request_ril = NULL;
233 delete[] d_request_rol;
234 d_request_rol = NULL;
236 fprintf(stderr,
"vrpn_Imager_Stream_Shared_State::get_logfile_request(): delete failed\n");
240 d_new_log_request =
false;
244 void set_logfile_request(
const char *lil,
const char *lol,
const char *ril,
253 delete[] d_request_lil;
255 fprintf(stderr,
"vrpn_Imager_Stream_Shared_State::set_logfile_request(): delete failed\n");
258 d_request_lil = NULL;
262 delete[] d_request_lol;
264 fprintf(stderr,
"vrpn_Imager_Stream_Shared_State::set_logfile_request(): delete failed\n");
267 d_request_lol = NULL;
271 delete[] d_request_ril;
273 fprintf(stderr,
"vrpn_Imager_Stream_Shared_State::set_logfile_request(): delete failed\n");
276 d_request_ril = NULL;
280 delete[] d_request_rol;
282 fprintf(stderr,
"vrpn_Imager_Stream_Shared_State::set_logfile_request(): delete failed\n");
285 d_request_rol = NULL;
290 if ((d_request_lil =
new(std::nothrow)
char[strlen(lil) + 1]) != NULL) {
291 vrpn_strncpynull(d_request_lil, lil, strlen(lil) + 1);
295 if ((d_request_lol =
new(std::nothrow)
char[strlen(lol) + 1]) != NULL) {
296 vrpn_strncpynull(d_request_lol, lol, strlen(lol) + 1);
300 if ((d_request_ril =
new(std::nothrow)
char[strlen(ril) + 1]) != NULL) {
301 vrpn_strncpynull(d_request_ril, ril, strlen(ril) + 1);
305 if ((d_request_rol =
new(std::nothrow)
char[strlen(rol) + 1]) != NULL) {
306 vrpn_strncpynull(d_request_rol, rol, strlen(rol) + 1);
310 d_new_log_request =
true;
323 bool get_logfile_result(
char **lil,
char **lol,
char **ril,
char **rol)
326 bool ret = d_new_log_result;
327 if (d_new_log_result) {
330 if (d_result_lil == NULL)
333 if ((*lil =
new(std::nothrow)
char[strlen(d_result_lil) + 1]) != NULL) {
334 vrpn_strncpynull(*lil, d_result_lil, strlen(d_result_lil) + 1);
337 if (d_result_lol == NULL)
340 if ((*lol =
new(std::nothrow)
char[strlen(d_result_lol) + 1]) != NULL) {
341 vrpn_strncpynull(*lol, d_result_lol, strlen(d_result_lol) + 1);
344 if (d_result_ril == NULL)
347 if ((*ril =
new(std::nothrow)
char[strlen(d_result_ril) + 1]) != NULL) {
348 vrpn_strncpynull(*ril, d_result_ril, strlen(d_result_ril) + 1);
351 if (d_result_rol == NULL)
354 if ((*rol =
new(std::nothrow)
char[strlen(d_result_rol) + 1]) != NULL) {
355 vrpn_strncpynull(*rol, d_result_rol, strlen(d_result_rol) + 1);
362 d_new_log_result =
false;
366 void set_logfile_result(
const char *lil,
const char *lol,
const char *ril,
373 delete[] d_result_lil;
375 fprintf(stderr,
"vrpn_Imager_Stream_Shared_State::set_logfile_result(): delete failed\n");
382 delete[] d_result_lol;
384 fprintf(stderr,
"vrpn_Imager_Stream_Shared_State::set_logfile_result(): delete failed\n");
391 delete[] d_result_ril;
393 fprintf(stderr,
"vrpn_Imager_Stream_Shared_State::set_logfile_result(): delete failed\n");
400 delete[] d_result_rol;
402 fprintf(stderr,
"vrpn_Imager_Stream_Shared_State::set_logfile_result(): delete failed\n");
410 if ((d_result_lil =
new(std::nothrow)
char[strlen(lil) + 1]) != NULL) {
411 vrpn_strncpynull(d_result_lil, lil, strlen(lil) + 1);
415 if ((d_result_lol =
new(std::nothrow)
char[strlen(lol) + 1]) != NULL) {
416 vrpn_strncpynull(d_result_lol, lol, strlen(lol) + 1);
420 if ((d_result_ril =
new(std::nothrow)
char[strlen(ril) + 1]) != NULL) {
421 vrpn_strncpynull(d_result_ril, ril, strlen(ril) + 1);
425 if ((d_result_rol =
new(std::nothrow)
char[strlen(rol) + 1]) != NULL) {
426 vrpn_strncpynull(d_result_rol, rol, strlen(rol) + 1);
430 d_new_log_result =
true;
439 void get_logfile_names(
char **local_in,
char **local_out,
char **remote_in,
443 if (d_result_lil == NULL)
446 *local_in =
new char[strlen(d_result_lil) + 1];
447 vrpn_strncpynull(*local_in, d_result_lil, strlen(d_result_lil) + 1);
449 if (d_result_lol == NULL)
452 *local_out =
new char[strlen(d_result_lol) + 1];
453 vrpn_strncpynull(*local_out, d_result_lol, strlen(d_result_lol) + 1);
455 if (d_result_ril == NULL)
458 *remote_in =
new char[strlen(d_result_ril) + 1];
459 vrpn_strncpynull(*remote_in, d_result_ril, strlen(d_result_ril) + 1);
461 if (d_result_rol == NULL)
464 *remote_out =
new char[strlen(d_result_rol) + 1];
465 vrpn_strncpynull(*remote_out, d_result_rol, strlen(d_result_rol) + 1);
471 bool get_throttle_request(vrpn_int32 *throttle_count)
474 bool ret = d_new_throttle_request;
475 if (d_new_throttle_request) {
476 *throttle_count = d_throttle_count;
478 d_new_throttle_request =
false;
481 void set_throttle_request(vrpn_int32 throttle_count)
484 d_throttle_count = throttle_count;
485 d_new_throttle_request =
true;
492 vrpn_int32 get_frames_in_queue(
void)
495 vrpn_int32 ret = d_frames_in_queue;
498 vrpn_int32 increment_frames_in_queue(
void)
502 vrpn_int32 ret = d_frames_in_queue;
505 vrpn_int32 decrement_frames_in_queue(
void)
509 vrpn_int32 ret = d_frames_in_queue;
515 vrpn_int32 get_logger_to_client_queue_size(
void)
518 vrpn_int32 ret = d_logger_to_client_messages.size();
524 bool ret = d_logger_to_client_messages.insert_back(p);
530 bool ret = d_logger_to_client_messages.retrieve_front(p);
542 bool d_description_updated;
547 vrpn_int32 d_nChannels;
548 const char *d_channel_buffer;
553 bool d_new_log_request;
566 bool d_new_log_result;
573 bool d_new_throttle_request;
574 vrpn_int32 d_throttle_count;
579 vrpn_int32 d_frames_in_queue;
628 virtual void handle_request_logging(
const char *local_in_logfile_name,
629 const char *local_out_logfile_name,
630 const char *remote_in_logfile_name,
631 const char *remote_out_logfile_name);
635 static int VRPN_CALLBACK
638 virtual void handle_request_logging_status();
645 virtual void handle_dropped_last_connection(
void);
649 static int VRPN_CALLBACK
656 virtual void handle_got_first_connection(
void);
657 vrpn_int32 got_first_connection_m_id;
659 static int VRPN_CALLBACK
684 void logging_thread_func(
void);
688 bool stop_logging_thread(
void);
692 char *d_imager_server_name;
696 bool d_ready_to_drop_old_connection;
701 open_new_log_connection(
const char *local_in_logfile_name,
702 const char *local_out_logfile_name,
703 const char *remote_in_logfile_name,
704 const char *remote_out_logfile_name);
718 bool make_new_logging_connection(
const char *local_in_logfile_name,
719 const char *local_out_logfile_name,
720 const char *remote_in_logfile_name,
721 const char *remote_out_logfile_name);
730 static void VRPN_CALLBACK
731 handle_image_description(
void *pvISB,
const struct timeval msg_time);
732 static int VRPN_CALLBACK
737 vrpn_int32 d_server_description_m_id;
739 vrpn_int32 d_server_begin_frame_m_id;
741 vrpn_int32 d_server_end_frame_m_id;
743 vrpn_int32 d_server_discarded_frames_m_id;
746 vrpn_int32 d_server_regionu8_m_id;
748 vrpn_int32 d_server_regionu12in16_m_id;
751 vrpn_int32 d_server_regionu16_m_id;
753 vrpn_int32 d_server_regionf32_m_id;
755 vrpn_int32 d_server_text_m_id;
756 vrpn_int32 d_server_ping_m_id;
757 vrpn_int32 d_server_pong_m_id;
774 vrpn_int32 transcode_type(vrpn_int32 type);
780 vrpn_uint16 d_server_dropped_due_to_throttle;
781 vrpn_int32 d_server_frames_to_send;