ARG_0,
ARG_HOST,
ARG_PORT,
+ ARG_VERSION,
};
#define RGB332_R(x) ((((x)&0x07) * 0x124)>>3)
g_object_class_install_property (gobject_class, ARG_PORT,
g_param_spec_int ("port", "Port", "Port",
1, 65535, 5900, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_VERSION,
+ g_param_spec_string ("version", "RFB protocol version",
+ "RFB protocol version", "3.3", G_PARAM_READWRITE));
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_rfb_src_start);
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_rfb_src_stop);
src->host = g_strdup ("127.0.0.1");
src->port = 5900;
+ src->version_major = 3;
+ src->version_minor = 3;
}
static void
G_OBJECT_CLASS (parent_class)->dispose (object);
}
+static void
+gst_rfb_property_set_version (GstRfbSrc * src, gchar * value)
+{
+ g_return_if_fail (src != NULL);
+ g_return_if_fail (value != NULL);
+
+ gchar *major = g_strdup (value);
+ gchar *minor = g_strrstr (value, ".");
+
+ g_return_if_fail (minor != NULL);
+
+ *minor++ = 0;
+
+ g_return_if_fail (g_ascii_isdigit (*major) == TRUE);
+ g_return_if_fail (g_ascii_isdigit (*minor) == TRUE);
+
+ src->version_major = g_ascii_digit_value (*major);
+ src->version_minor = g_ascii_digit_value (*minor);
+
+ GST_DEBUG ("Version major : %d", src->version_major);
+ GST_DEBUG ("Version minor : %d", src->version_minor);
+
+ g_free (major);
+ g_free (value);
+}
+
+static gchar *
+gst_rfb_property_get_version (GstRfbSrc * src)
+{
+ gchar *version = g_malloc (8);
+ gchar *major = g_strdup_printf ("%d", src->version_major);
+ gchar *minor = g_strdup_printf ("%d", src->version_minor);
+
+ g_stpcpy (version, major);
+ g_strlcat (version, ".", 8);
+ g_strlcat (version, minor, 8);
+
+ g_free (major);
+ g_free (minor);
+
+ return version;
+}
+
static void
gst_rfb_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
case ARG_PORT:
src->port = g_value_get_int (value);
break;
+ case ARG_VERSION:
+ gst_rfb_property_set_version (src, g_strdup (g_value_get_string (value)));
+ break;
default:
break;
}
GValue * value, GParamSpec * pspec)
{
GstRfbSrc *src = GST_RFB_SRC (object);
+ gchar *version;
switch (prop_id) {
case ARG_HOST:
case ARG_PORT:
g_value_set_int (value, src->port);
break;
+ case ARG_VERSION:
+ version = gst_rfb_property_get_version (src);
+ g_value_set_string (value, version);
+ g_free (version);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
#include "config.h"
#endif
-#include "rfbdecoder.h"
+#include "gst/gst.h"
#include <rfb.h>
#include <unistd.h>
#define RFB_SET_UINT16(ptr, val) (*(guint16 *)(ptr) = GUINT16_TO_BE (val))
#define RFB_SET_UINT8(ptr, val) (*(guint8 *)(ptr) = val)
+GST_DEBUG_CATEGORY_STATIC (rfbdecoder_debug);
+#define GST_CAT_DEFAULT rfbdecoder_debug
+
#if 0
struct _RfbSocketPrivate
{
return TRUE;
}
+/**
+ * rfb_decoder_iterate:
+ * @decoder: The rfb context
+ *
+ * Initializes the connection with the rfb server
+ *
+ * Returns: TRUE if initialization was succesfull, FALSE on fail.
+ */
gboolean
rfb_decoder_iterate (RfbDecoder * decoder)
{
+ GST_DEBUG_CATEGORY_INIT (rfbdecoder_debug, "rfbdecoder", 0, "Rfb source");
+
g_return_val_if_fail (decoder != NULL, FALSE);
g_return_val_if_fail (decoder->fd != -1, FALSE);
if (decoder->state == NULL) {
+ GST_DEBUG ("First iteration: set state to -> wait for protocol version");
decoder->state = rfb_decoder_state_wait_for_protocol_version;
}
- // g_print ("iterating...\n");
+ GST_DEBUG ("Executing next state in initialization");
return decoder->state (decoder);
}
rfb_decoder_send (decoder, data, 6);
}
+/**
+ * rfb_decoder_state_wait_for_protocol_version:
+ *
+ * Negotiate the rfb version used
+ *
+ * \TODO Support for versions 3.7 and 3.8
+ */
static gboolean
rfb_decoder_state_wait_for_protocol_version (RfbDecoder * decoder)
{
data = buffer->data;
- g_assert (memcmp (buffer->data, "RFB 003.00", 10) == 0);
- // g_print ("\"%.11s\"\n", buffer->data);
+ g_return_val_if_fail (memcmp (buffer->data, "RFB 003.00", 10) == 0, FALSE);
+ g_return_val_if_fail (*(buffer->data + 11) == 0x0a, FALSE);
+
+ GST_DEBUG ("\"%.11s\"", buffer->data);
+ *(buffer->data + 7) = 0x00;
+ *(buffer->data + 11) = 0x00;
+ decoder->protocol_major = atoi ((char *) (buffer->data + 4));
+ decoder->protocol_minor = atoi ((char *) (buffer->data + 8));
+ GST_DEBUG ("Major version : %d", decoder->protocol_major);
+ GST_DEBUG ("Minor version : %d", decoder->protocol_minor);
rfb_buffer_free (buffer);
+ if (decoder->protocol_major != 3) {
+ GST_INFO
+ ("A major protocol version of %d is not supported, falling back to 3",
+ decoder->protocol_major);
+ decoder->protocol_major = 3;
+ }
+ switch (decoder->protocol_minor) {
+ case 3:
+ break;
+ default:
+ GST_INFO ("Minor version %d is not supported, using 3",
+ decoder->protocol_minor);
+ decoder->protocol_minor = 3;
+ }
rfb_decoder_send (decoder, (guint8 *) "RFB 003.003\n", 12);
decoder->state = rfb_decoder_state_wait_for_security;