mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
gst/librfb/: Added offset-x, offset-y, width and height property for selecting a region from the screen
Original commit message from CVS: * gst/librfb/gstrfbsrc.c: * gst/librfb/rfbdecoder.c: * gst/librfb/rfbdecoder.h: Added offset-x, offset-y, width and height property for selecting a region from the screen
This commit is contained in:
parent
ab4038ce2e
commit
ada7510fd7
4 changed files with 96 additions and 5 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2007-09-21 Thijs Vermeir <thijsvermeir@gmail.com>
|
||||||
|
|
||||||
|
* gst/librfb/gstrfbsrc.c:
|
||||||
|
* gst/librfb/rfbdecoder.c:
|
||||||
|
* gst/librfb/rfbdecoder.h:
|
||||||
|
Added offset-x, offset-y, width and height property
|
||||||
|
for selecting a region from the screen
|
||||||
|
|
||||||
2007-09-21 Thijs Vermeir <thijsvermeir@gmail.com>
|
2007-09-21 Thijs Vermeir <thijsvermeir@gmail.com>
|
||||||
|
|
||||||
* gst/librfb/gstrfbsrc.c:
|
* gst/librfb/gstrfbsrc.c:
|
||||||
|
|
|
@ -38,6 +38,10 @@ enum
|
||||||
ARG_PORT,
|
ARG_PORT,
|
||||||
ARG_VERSION,
|
ARG_VERSION,
|
||||||
ARG_PASSWORD,
|
ARG_PASSWORD,
|
||||||
|
ARG_OFFSET_X,
|
||||||
|
ARG_OFFSET_Y,
|
||||||
|
ARG_WIDTH,
|
||||||
|
ARG_HEIGHT,
|
||||||
};
|
};
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (rfbsrc_debug);
|
GST_DEBUG_CATEGORY_STATIC (rfbsrc_debug);
|
||||||
|
@ -122,6 +126,18 @@ gst_rfb_src_class_init (GstRfbSrcClass * klass)
|
||||||
g_object_class_install_property (gobject_class, ARG_PASSWORD,
|
g_object_class_install_property (gobject_class, ARG_PASSWORD,
|
||||||
g_param_spec_string ("password", "Password for authentication",
|
g_param_spec_string ("password", "Password for authentication",
|
||||||
"Password for authentication", "", G_PARAM_WRITABLE));
|
"Password for authentication", "", G_PARAM_WRITABLE));
|
||||||
|
g_object_class_install_property (gobject_class, ARG_OFFSET_X,
|
||||||
|
g_param_spec_int ("offset-x", "x offset for screen scrapping",
|
||||||
|
"x offset for screen scrapping", 0, 65535, 0, G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class, ARG_OFFSET_Y,
|
||||||
|
g_param_spec_int ("offset-y", "y offset for screen scrapping",
|
||||||
|
"y offset for screen scrapping", 0, 65535, 0, G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class, ARG_WIDTH,
|
||||||
|
g_param_spec_int ("width", "width of screen", "width of screen", 0, 65535,
|
||||||
|
0, G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class, ARG_HEIGHT,
|
||||||
|
g_param_spec_int ("height", "height of screen", "height of screen", 0,
|
||||||
|
65535, 0, G_PARAM_READWRITE));
|
||||||
|
|
||||||
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_rfb_src_start);
|
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_rfb_src_start);
|
||||||
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_rfb_src_stop);
|
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_rfb_src_stop);
|
||||||
|
@ -222,6 +238,18 @@ gst_rfb_src_set_property (GObject * object, guint prop_id,
|
||||||
g_free (src->decoder->password);
|
g_free (src->decoder->password);
|
||||||
src->decoder->password = g_strdup (g_value_get_string (value));
|
src->decoder->password = g_strdup (g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
|
case ARG_OFFSET_X:
|
||||||
|
src->decoder->offset_x = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case ARG_OFFSET_Y:
|
||||||
|
src->decoder->offset_y = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case ARG_WIDTH:
|
||||||
|
src->decoder->rect_width = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case ARG_HEIGHT:
|
||||||
|
src->decoder->rect_height = g_value_get_int (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -246,6 +274,18 @@ gst_rfb_src_get_property (GObject * object, guint prop_id,
|
||||||
g_value_set_string (value, version);
|
g_value_set_string (value, version);
|
||||||
g_free (version);
|
g_free (version);
|
||||||
break;
|
break;
|
||||||
|
case ARG_OFFSET_X:
|
||||||
|
g_value_set_int (value, src->decoder->offset_x);
|
||||||
|
break;
|
||||||
|
case ARG_OFFSET_Y:
|
||||||
|
g_value_set_int (value, src->decoder->offset_y);
|
||||||
|
break;
|
||||||
|
case ARG_WIDTH:
|
||||||
|
g_value_set_int (value, src->decoder->rect_width);
|
||||||
|
break;
|
||||||
|
case ARG_HEIGHT:
|
||||||
|
g_value_set_int (value, src->decoder->rect_height);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -270,7 +310,6 @@ gst_rfb_src_start (GstBaseSrc * bsrc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
src->decoder = decoder;
|
|
||||||
src->inter = FALSE;
|
src->inter = FALSE;
|
||||||
|
|
||||||
while (!decoder->inited) {
|
while (!decoder->inited) {
|
||||||
|
@ -322,8 +361,10 @@ gst_rfb_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
|
||||||
gulong newsize;
|
gulong newsize;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
|
|
||||||
rfb_decoder_send_update_request (decoder, src->inter, 0, 0,
|
rfb_decoder_send_update_request (decoder, src->inter, decoder->offset_x,
|
||||||
decoder->width, decoder->height);
|
decoder->offset_y,
|
||||||
|
(decoder->rect_width ? decoder->rect_width : decoder->width),
|
||||||
|
(decoder->rect_height ? decoder->rect_height : decoder->height));
|
||||||
// src->inter = TRUE;
|
// src->inter = TRUE;
|
||||||
|
|
||||||
src->go = TRUE;
|
src->go = TRUE;
|
||||||
|
|
|
@ -62,6 +62,11 @@ rfb_decoder_new (void)
|
||||||
|
|
||||||
decoder->password = NULL;
|
decoder->password = NULL;
|
||||||
|
|
||||||
|
decoder->offset_x = 0;
|
||||||
|
decoder->offset_y = 0;
|
||||||
|
decoder->rect_width = 0;
|
||||||
|
decoder->rect_height = 0;
|
||||||
|
|
||||||
return decoder;
|
return decoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,6 +458,37 @@ rfb_decoder_state_wait_for_server_initialisation (RfbDecoder * decoder)
|
||||||
decoder->state = rfb_decoder_state_normal;
|
decoder->state = rfb_decoder_state_normal;
|
||||||
decoder->inited = TRUE;
|
decoder->inited = TRUE;
|
||||||
|
|
||||||
|
/* check if we need cropping */
|
||||||
|
|
||||||
|
if (decoder->offset_x > 0) {
|
||||||
|
if (decoder->offset_x > decoder->width) {
|
||||||
|
GST_WARNING ("Trying to crop more than the width of the server");
|
||||||
|
} else {
|
||||||
|
decoder->width -= decoder->offset_x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (decoder->offset_y > 0) {
|
||||||
|
if (decoder->offset_y > decoder->height) {
|
||||||
|
GST_WARNING ("Trying to crop more than the height of the server");
|
||||||
|
} else {
|
||||||
|
decoder->height -= decoder->offset_y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (decoder->rect_width > 0) {
|
||||||
|
if (decoder->rect_width > decoder->width) {
|
||||||
|
GST_WARNING ("Trying to crop more than the width of the server");
|
||||||
|
} else {
|
||||||
|
decoder->width = decoder->rect_width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (decoder->rect_height > 0) {
|
||||||
|
if (decoder->rect_height > decoder->height) {
|
||||||
|
GST_WARNING ("Trying to crop more than the height of the server");
|
||||||
|
} else {
|
||||||
|
decoder->height = decoder->rect_height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,8 +583,8 @@ rfb_decoder_state_framebuffer_update_rectangle (RfbDecoder * decoder)
|
||||||
|
|
||||||
buffer = rfb_decoder_read (decoder, 12);
|
buffer = rfb_decoder_read (decoder, 12);
|
||||||
|
|
||||||
x = RFB_GET_UINT16 (buffer + 0);
|
x = RFB_GET_UINT16 (buffer + 0) - decoder->offset_x;
|
||||||
y = RFB_GET_UINT16 (buffer + 2);
|
y = RFB_GET_UINT16 (buffer + 2) - decoder->offset_y;
|
||||||
w = RFB_GET_UINT16 (buffer + 4);
|
w = RFB_GET_UINT16 (buffer + 4);
|
||||||
h = RFB_GET_UINT16 (buffer + 6);
|
h = RFB_GET_UINT16 (buffer + 6);
|
||||||
encoding = RFB_GET_UINT32 (buffer + 8);
|
encoding = RFB_GET_UINT32 (buffer + 8);
|
||||||
|
|
|
@ -63,6 +63,12 @@ struct _RfbDecoder
|
||||||
|
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
|
||||||
|
/* information if we don't want to update the whole screen */
|
||||||
|
guint offset_x;
|
||||||
|
guint offset_y;
|
||||||
|
guint rect_width;
|
||||||
|
guint rect_height;
|
||||||
|
|
||||||
gint n_rects;
|
gint n_rects;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue