mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 13:41:48 +00:00
rfbsrc: fail more gracefully if source gets disconnected or geometry changes
Don't get caught in an infinite loop if the source gets disconnected and also support gracefully failing upon detecting the frame geometry has increased (rather than segfaulting). https://bugzilla.gnome.org/show_bug.cgi?id=635397
This commit is contained in:
parent
2056f4a633
commit
51c63587a1
2 changed files with 14 additions and 1 deletions
|
@ -79,6 +79,7 @@ rfb_decoder_new (void)
|
||||||
decoder->rect_width = 0;
|
decoder->rect_width = 0;
|
||||||
decoder->rect_height = 0;
|
decoder->rect_height = 0;
|
||||||
decoder->shared_flag = TRUE;
|
decoder->shared_flag = TRUE;
|
||||||
|
decoder->disconnected = FALSE;
|
||||||
decoder->data = NULL;
|
decoder->data = NULL;
|
||||||
decoder->data_len = 0;
|
decoder->data_len = 0;
|
||||||
|
|
||||||
|
@ -129,6 +130,9 @@ rfb_decoder_connect_tcp (RfbDecoder * decoder, gchar * addr, guint port)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
//rfb_decoder_use_file_descriptor (decoder, fd);
|
//rfb_decoder_use_file_descriptor (decoder, fd);
|
||||||
|
|
||||||
|
decoder->disconnected = FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +182,7 @@ rfb_decoder_read (RfbDecoder * decoder, guint32 len)
|
||||||
now = recv (decoder->fd, (char *) decoder->data + total, len - total, 0);
|
now = recv (decoder->fd, (char *) decoder->data + total, len - total, 0);
|
||||||
#endif
|
#endif
|
||||||
if (now <= 0) {
|
if (now <= 0) {
|
||||||
|
decoder->disconnected = TRUE;
|
||||||
GST_WARNING ("rfb read error on socket");
|
GST_WARNING ("rfb read error on socket");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -620,6 +625,13 @@ rfb_decoder_state_framebuffer_update_rectangle (RfbDecoder * decoder)
|
||||||
GST_DEBUG ("w:%d h:%d", w, h);
|
GST_DEBUG ("w:%d h:%d", w, h);
|
||||||
GST_DEBUG ("encoding: %d", encoding);
|
GST_DEBUG ("encoding: %d", encoding);
|
||||||
|
|
||||||
|
if (((w * h) + (x * y)) > (decoder->width * decoder->height)) {
|
||||||
|
GST_ERROR ("Desktop resize is unsupported.");
|
||||||
|
decoder->state = NULL;
|
||||||
|
decoder->disconnected = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
switch (encoding) {
|
switch (encoding) {
|
||||||
case ENCODING_TYPE_RAW:
|
case ENCODING_TYPE_RAW:
|
||||||
rfb_decoder_raw_encoding (decoder, x, y, w, h);
|
rfb_decoder_raw_encoding (decoder, x, y, w, h);
|
||||||
|
@ -641,7 +653,7 @@ rfb_decoder_state_framebuffer_update_rectangle (RfbDecoder * decoder)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
decoder->n_rects--;
|
decoder->n_rects--;
|
||||||
if (decoder->n_rects == 0) {
|
if (decoder->n_rects == 0 || decoder->disconnected == TRUE) {
|
||||||
decoder->state = NULL;
|
decoder->state = NULL;
|
||||||
} else {
|
} else {
|
||||||
decoder->state = rfb_decoder_state_framebuffer_update_rectangle;
|
decoder->state = rfb_decoder_state_framebuffer_update_rectangle;
|
||||||
|
|
|
@ -48,6 +48,7 @@ struct _RfbDecoder
|
||||||
|
|
||||||
/* settable properties */
|
/* settable properties */
|
||||||
gboolean shared_flag;
|
gboolean shared_flag;
|
||||||
|
gboolean disconnected;
|
||||||
|
|
||||||
/* readable properties */
|
/* readable properties */
|
||||||
gboolean inited;
|
gboolean inited;
|
||||||
|
|
Loading…
Reference in a new issue