mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
gst/librfb/: remove the rfbbytestream dead code
Original commit message from CVS: * gst/librfb/Makefile.am: * gst/librfb/rfb.h: * gst/librfb/rfbbytestream.c: * gst/librfb/rfbbytestream.h: * gst/librfb/rfbdecoder.c: * gst/librfb/rfbdecoder.h: remove the rfbbytestream dead code
This commit is contained in:
parent
c205b740d4
commit
48b7ba004d
7 changed files with 10 additions and 256 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2007-10-16 Thijs Vermeir <thijsvermeir@gmail.com>
|
||||
|
||||
* gst/librfb/Makefile.am:
|
||||
* gst/librfb/rfb.h:
|
||||
* gst/librfb/rfbbytestream.c:
|
||||
* gst/librfb/rfbbytestream.h:
|
||||
* gst/librfb/rfbdecoder.c:
|
||||
* gst/librfb/rfbdecoder.h:
|
||||
remove the rfbbytestream dead code
|
||||
|
||||
2007-10-16 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||
|
||||
patch by: Alessandro Decina
|
||||
|
|
|
@ -11,7 +11,6 @@ libgstrfbsrc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
|||
librfb_la_SOURCES = \
|
||||
rfbbuffer.c \
|
||||
rfbdecoder.c \
|
||||
rfbbytestream.c \
|
||||
d3des.c \
|
||||
vncauth.c
|
||||
librfb_la_CFLAGS = $(GST_CFLAGS) -I$(srcdir)/..
|
||||
|
@ -21,7 +20,6 @@ noinst_HEADERS = \
|
|||
rfb.h \
|
||||
rfbdecoder.h \
|
||||
rfbbuffer.h \
|
||||
rfbbytestream.h \
|
||||
rfbcontext.h \
|
||||
rfbutil.h \
|
||||
gstrfbsrc.h \
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define _RFB_RFB_H_
|
||||
|
||||
#include <librfb/rfbdecoder.h>
|
||||
#include <librfb/rfbbytestream.h>
|
||||
#include <librfb/rfbbuffer.h>
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,149 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rfbbytestream.h>
|
||||
#include <string.h>
|
||||
|
||||
static gint rfb_bytestream_copy_nocheck (RfbBytestream * bs,
|
||||
RfbBuffer * buffer, gint len);
|
||||
|
||||
RfbBytestream *
|
||||
rfb_bytestream_new (void)
|
||||
{
|
||||
return g_new0 (RfbBytestream, 1);
|
||||
}
|
||||
|
||||
void
|
||||
rfb_bytestream_free (RfbBytestream * bs)
|
||||
{
|
||||
g_return_if_fail (bs != NULL);
|
||||
|
||||
g_slist_free (bs->buffer_list);
|
||||
g_free (bs);
|
||||
}
|
||||
|
||||
gint
|
||||
rfb_bytestream_get (RfbBytestream * bs, gint len)
|
||||
{
|
||||
RfbBuffer *buffer;
|
||||
|
||||
g_return_val_if_fail (bs != NULL, 0);
|
||||
|
||||
buffer = bs->get_buffer (len, bs->user_data);
|
||||
|
||||
if (buffer) {
|
||||
// g_print ("got buffer (%d bytes)\n", buffer->length);
|
||||
bs->buffer_list = g_slist_append (bs->buffer_list, buffer);
|
||||
|
||||
bs->length += buffer->length;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
gboolean
|
||||
rfb_bytestream_check (RfbBytestream * bs, gint len)
|
||||
{
|
||||
g_return_val_if_fail (bs != NULL, FALSE);
|
||||
|
||||
while (bs->length < len) {
|
||||
rfb_bytestream_get (bs, len - bs->length);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gint
|
||||
rfb_bytestream_read (RfbBytestream * bs, RfbBuffer ** buffer, gint len)
|
||||
{
|
||||
RfbBuffer *buf;
|
||||
|
||||
g_return_val_if_fail (bs != NULL, 0);
|
||||
g_return_val_if_fail (buffer != NULL, 0);
|
||||
|
||||
rfb_bytestream_check (bs, len);
|
||||
|
||||
buf = rfb_buffer_new_and_alloc (len);
|
||||
rfb_bytestream_copy_nocheck (bs, buf, len);
|
||||
|
||||
rfb_bytestream_flush (bs, len);
|
||||
|
||||
*buffer = buf;
|
||||
return len;
|
||||
}
|
||||
|
||||
gint
|
||||
rfb_bytestream_peek (RfbBytestream * bs, RfbBuffer ** buffer, gint len)
|
||||
{
|
||||
RfbBuffer *buf;
|
||||
|
||||
g_return_val_if_fail (bs != NULL, 0);
|
||||
g_return_val_if_fail (buffer != NULL, 0);
|
||||
|
||||
rfb_bytestream_check (bs, len);
|
||||
|
||||
buf = rfb_buffer_new_and_alloc (len);
|
||||
rfb_bytestream_copy_nocheck (bs, buf, len);
|
||||
|
||||
*buffer = buf;
|
||||
return len;
|
||||
}
|
||||
|
||||
gint
|
||||
rfb_bytestream_flush (RfbBytestream * bs, gint len)
|
||||
{
|
||||
GSList *item;
|
||||
RfbBuffer *buf;
|
||||
gint n;
|
||||
|
||||
g_return_val_if_fail (bs != NULL, 0);
|
||||
|
||||
while ((item = bs->buffer_list)) {
|
||||
buf = (RfbBuffer *) item->data;
|
||||
|
||||
n = MIN (buf->length - bs->offset, len);
|
||||
if (n <= len) {
|
||||
bs->offset = 0;
|
||||
bs->buffer_list = g_slist_delete_link (bs->buffer_list, item);
|
||||
rfb_buffer_free (buf);
|
||||
} else {
|
||||
bs->offset = bs->offset + len;
|
||||
}
|
||||
bs->length -= n;
|
||||
len -= n;
|
||||
if (len == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_assert_not_reached ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static gint
|
||||
rfb_bytestream_copy_nocheck (RfbBytestream * bs, RfbBuffer * buffer, gint len)
|
||||
{
|
||||
GSList *item;
|
||||
gint offset;
|
||||
gint first_offset;
|
||||
RfbBuffer *frombuf;
|
||||
gint n;
|
||||
|
||||
offset = 0;
|
||||
first_offset = bs->offset;
|
||||
for (item = bs->buffer_list; item; item = item->next) {
|
||||
frombuf = (RfbBuffer *) item->data;
|
||||
n = MIN (len, frombuf->length - first_offset);
|
||||
// g_print ("copying %d bytes from %p\n", n, frombuf);
|
||||
memcpy (buffer->data + offset, frombuf->data + first_offset, n);
|
||||
first_offset = 0;
|
||||
len -= n;
|
||||
offset += n;
|
||||
if (len == 0)
|
||||
return len;
|
||||
}
|
||||
|
||||
g_assert_not_reached ();
|
||||
return 0;
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
#ifndef _LIBRFB_BYTESTREAM_H_
|
||||
#define _LIBRFB_BYTESTREAM_H_
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <librfb/rfbbuffer.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _RfbBytestream RfbBytestream;
|
||||
|
||||
struct _RfbBytestream
|
||||
{
|
||||
RfbBuffer * (* get_buffer) (gint length, gpointer user_data);
|
||||
|
||||
gpointer user_data;
|
||||
|
||||
GSList *buffer_list;
|
||||
gint length;
|
||||
gint offset;
|
||||
};
|
||||
|
||||
RfbBytestream *rfb_bytestream_new (void);
|
||||
void rfb_bytestream_free (RfbBytestream * bs);
|
||||
|
||||
gint rfb_bytestream_read (RfbBytestream * bs,
|
||||
RfbBuffer ** buffer,
|
||||
gint len);
|
||||
gint rfb_bytestream_peek (RfbBytestream * bs,
|
||||
RfbBuffer ** buffer,
|
||||
gint len);
|
||||
gint rfb_bytestream_flush (RfbBytestream * bs,
|
||||
gint len);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
|
@ -48,9 +48,6 @@ static gboolean rfb_decoder_state_framebuffer_update_rectangle (RfbDecoder *
|
|||
decoder);
|
||||
static gboolean rfb_decoder_state_set_colour_map_entries (RfbDecoder * decoder);
|
||||
static gboolean rfb_decoder_state_server_cut_text (RfbDecoder * decoder);
|
||||
static RfbBuffer *rfb_socket_get_buffer (gint length, gpointer user_data);
|
||||
static gint rfb_socket_send_buffer (guint8 * buffer, gint length,
|
||||
gpointer user_data);
|
||||
|
||||
RfbDecoder *
|
||||
rfb_decoder_new (void)
|
||||
|
@ -58,7 +55,6 @@ rfb_decoder_new (void)
|
|||
RfbDecoder *decoder = g_new0 (RfbDecoder, 1);
|
||||
|
||||
decoder->fd = -1;
|
||||
decoder->bytestream = rfb_bytestream_new ();
|
||||
|
||||
decoder->password = NULL;
|
||||
|
||||
|
@ -75,28 +71,10 @@ rfb_decoder_free (RfbDecoder * decoder)
|
|||
{
|
||||
g_return_if_fail (decoder != NULL);
|
||||
|
||||
rfb_bytestream_free (decoder->bytestream);
|
||||
if (decoder->fd >= 0)
|
||||
close (decoder->fd);
|
||||
}
|
||||
|
||||
void
|
||||
rfb_decoder_use_file_descriptor (RfbDecoder * decoder, gint fd)
|
||||
{
|
||||
g_return_if_fail (decoder != NULL);
|
||||
g_return_if_fail (decoder->fd == -1);
|
||||
g_return_if_fail (!decoder->inited);
|
||||
g_return_if_fail (fd >= 0);
|
||||
|
||||
decoder->fd = fd;
|
||||
|
||||
decoder->bytestream->get_buffer = rfb_socket_get_buffer;
|
||||
decoder->bytestream->user_data = GINT_TO_POINTER (fd);
|
||||
|
||||
decoder->send_data = rfb_socket_send_buffer;
|
||||
decoder->buffer_handler_data = GINT_TO_POINTER (fd);
|
||||
}
|
||||
|
||||
gboolean
|
||||
rfb_decoder_connect_tcp (RfbDecoder * decoder, gchar * addr, guint port)
|
||||
{
|
||||
|
@ -631,46 +609,3 @@ rfb_decoder_state_server_cut_text (RfbDecoder * decoder)
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static RfbBuffer *
|
||||
rfb_socket_get_buffer (gint length, gpointer user_data)
|
||||
{
|
||||
RfbBuffer *buffer;
|
||||
gint fd = GPOINTER_TO_INT (user_data);
|
||||
gint ret;
|
||||
|
||||
buffer = rfb_buffer_new ();
|
||||
|
||||
buffer->data = g_malloc (length);
|
||||
buffer->free_data = (RfbBufferFreeFunc) g_free;
|
||||
|
||||
// g_print ("calling read(%d, %p, %d)\n", fd, buffer->data, length);
|
||||
ret = read (fd, buffer->data, length);
|
||||
if (ret <= 0) {
|
||||
g_critical ("read: %s", strerror (errno));
|
||||
rfb_buffer_free (buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buffer->length = ret;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static gint
|
||||
rfb_socket_send_buffer (guint8 * buffer, gint length, gpointer user_data)
|
||||
{
|
||||
gint fd = GPOINTER_TO_INT (user_data);
|
||||
gint ret;
|
||||
|
||||
// g_print ("calling write(%d, %p, %d)\n", fd, buffer, length);
|
||||
ret = write (fd, buffer, length);
|
||||
if (ret < 0) {
|
||||
g_critical ("write: %s", strerror (errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_assert (ret == length);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define _LIBRFB_DECODER_H_
|
||||
|
||||
#include <glib.h>
|
||||
#include <librfb/rfbbytestream.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -32,7 +31,6 @@ struct _RfbDecoder
|
|||
gpointer buffer_handler_data;
|
||||
|
||||
gint fd;
|
||||
RfbBytestream *bytestream;
|
||||
|
||||
gpointer decoder_private;
|
||||
|
||||
|
|
Loading…
Reference in a new issue