Lines Matching refs:rc

202 rfb_send_resize_update_msg(struct rfb_softc *rc, int cfd)
216 srect_hdr.width = htons(rc->width);
217 srect_hdr.height = htons(rc->height);
223 rfb_recv_set_pixfmt_msg(struct rfb_softc *rc, int cfd)
232 rfb_recv_set_encodings_msg(struct rfb_softc *rc, int cfd)
245 rc->enc_raw_ok = true;
248 rc->enc_zlib_ok = true;
249 deflateInit(&rc->zstream, Z_BEST_SPEED);
252 rc->enc_resize_ok = true;
281 rfb_send_rect(struct rfb_softc *rc, int cfd, struct bhyvegc_image *gc,
314 if (rc->enc_zlib_ok) {
315 zbufp = rc->zbuf;
316 rc->zstream.total_in = 0;
317 rc->zstream.total_out = 0;
319 rc->zstream.next_in = (Bytef *)p;
320 rc->zstream.avail_in = w;
321 rc->zstream.next_out = (Bytef *)zbufp;
322 rc->zstream.avail_out = RFB_ZLIB_BUFSZ + 16 -
323 rc->zstream.total_out;
324 rc->zstream.data_type = Z_BINARY;
327 err = deflate(&rc->zstream, Z_SYNC_FLUSH);
330 rc->enc_zlib_ok = false;
331 deflateEnd(&rc->zstream);
334 zbufp = rc->zbuf + rc->zstream.total_out;
343 zlen = htonl(rc->zstream.total_out);
347 return (stream_write(cfd, rc->zbuf, rc->zstream.total_out));
353 zbufp = rc->zbuf;
367 total = stream_write(cfd, rc->zbuf, total);
373 rfb_send_all(struct rfb_softc *rc, int cfd, struct bhyvegc_image *gc)
399 if (rc->enc_zlib_ok) {
400 rc->zstream.next_in = (Bytef *)gc->data;
401 rc->zstream.avail_in = gc->width * gc->height *
403 rc->zstream.next_out = (Bytef *)rc->zbuf;
404 rc->zstream.avail_out = RFB_ZLIB_BUFSZ + 16;
405 rc->zstream.data_type = Z_BINARY;
407 rc->zstream.total_in = 0;
408 rc->zstream.total_out = 0;
411 err = deflate(&rc->zstream, Z_SYNC_FLUSH);
414 rc->enc_zlib_ok = false;
415 deflateEnd(&rc->zstream);
425 zlen = htonl(rc->zstream.total_out);
429 return (stream_write(cfd, rc->zbuf, rc->zstream.total_out));
450 rfb_send_screen(struct rfb_softc *rc, int cfd, int all)
467 pthread_mutex_lock(&rc->mtx);
468 if (rc->sending) {
469 pthread_mutex_unlock(&rc->mtx);
472 rc->sending = 1;
473 pthread_mutex_unlock(&rc->mtx);
478 retval = rfb_send_all(rc, cfd, gc_image);
489 rc->crc_width = gc_image->width;
490 rc->crc_height = gc_image->height;
492 w = rc->crc_width;
493 h = rc->crc_height;
494 xcells = howmany(rc->crc_width, PIX_PER_CELL);
495 ycells = howmany(rc->crc_height, PIX_PER_CELL);
511 crc_p = rc->crc_tmp - xcells;
512 orig_crc = rc->crc - xcells;
514 memset(rc->crc_tmp, 0, sizeof(uint32_t) * xcells * ycells);
522 if (rc->hw_crc)
546 if (rc->hw_crc)
570 retval = rfb_send_all(rc, cfd, gc_image);
575 crc_p = rc->crc_tmp;
589 nwrite = rfb_send_rect(rc, cfd,
604 pthread_mutex_lock(&rc->mtx);
605 rc->sending = 0;
606 pthread_mutex_unlock(&rc->mtx);
613 rfb_recv_update_msg(struct rfb_softc *rc, int cfd, int discardonly)
630 rc->width = gc_image->width;
631 rc->height = gc_image->height;
632 if (rc->enc_resize_ok)
633 rfb_send_resize_update_msg(rc, cfd);
639 rfb_send_screen(rc, cfd, 1);
643 rfb_recv_key_msg(struct rfb_softc *rc, int cfd)
653 rfb_recv_ptr_msg(struct rfb_softc *rc, int cfd)
663 rfb_recv_cuttext_msg(struct rfb_softc *rc, int cfd)
690 struct rfb_softc *rc;
698 rc = arg;
699 cfd = rc->cfd;
703 while (rc->cfd >= 0) {
719 if (rfb_send_screen(rc, cfd, 0) <= 0) {
732 rfb_handle(struct rfb_softc *rc, int cfd)
740 rc->cfd = cfd;
767 if (!rc->zbuf) {
768 rc->zbuf = malloc(RFB_ZLIB_BUFSZ + 16);
769 assert(rc->zbuf != NULL);
772 rfb_send_screen(rc, cfd, 1);
774 pthread_create(&tid, NULL, rfb_wr_thr, rc);
787 rfb_recv_set_pixfmt_msg(rc, cfd);
790 rfb_recv_set_encodings_msg(rc, cfd);
793 rfb_recv_update_msg(rc, cfd, 1);
796 rfb_recv_key_msg(rc, cfd);
799 rfb_recv_ptr_msg(rc, cfd);
802 rfb_recv_cuttext_msg(rc, cfd);
810 rc->cfd = -1;
812 if (rc->enc_zlib_ok)
813 deflateEnd(&rc->zstream);
819 struct rfb_softc *rc;
824 rc = arg;
834 rc->enc_raw_ok = false;
835 rc->enc_zlib_ok = false;
836 rc->enc_resize_ok = false;
838 cfd = accept(rc->sfd, NULL, NULL);
839 if (rc->conn_wait) {
840 pthread_mutex_lock(&rc->mtx);
841 pthread_cond_signal(&rc->cond);
842 pthread_mutex_unlock(&rc->mtx);
843 rc->conn_wait = 0;
845 rfb_handle(rc, cfd);
868 struct rfb_softc *rc;
872 rc = calloc(1, sizeof(struct rfb_softc));
874 rc->crc = calloc(howmany(RFB_MAX_WIDTH * RFB_MAX_HEIGHT, 32),
876 rc->crc_tmp = calloc(howmany(RFB_MAX_WIDTH * RFB_MAX_HEIGHT, 32),
878 rc->crc_width = RFB_MAX_WIDTH;
879 rc->crc_height = RFB_MAX_HEIGHT;
881 rc->sfd = socket(AF_INET, SOCK_STREAM, 0);
882 if (rc->sfd < 0) {
887 setsockopt(rc->sfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
897 if (bind(rc->sfd, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
902 if (listen(rc->sfd, 1) < 0) {
907 rc->hw_crc = sse42_supported();
909 rc->conn_wait = wait;
911 pthread_mutex_init(&rc->mtx, NULL);
912 pthread_cond_init(&rc->cond, NULL);
915 pthread_create(&rc->tid, NULL, rfb_thr, rc);
916 pthread_set_name_np(rc->tid, "rfb");
920 pthread_mutex_lock(&rc->mtx);
921 pthread_cond_wait(&rc->cond, &rc->mtx);
922 pthread_mutex_unlock(&rc->mtx);