diff options
author | David Schleef <ds@schleef.org> | 2005-05-17 07:11:56 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2005-05-17 07:11:56 +0000 |
commit | 9bc18a9a15e8ea20bf3fde066294b2866b751f6f (patch) | |
tree | 74e9875d5a45976fb5e7b4c6ef7ad1b651979949 /gst/librfb/rfbbytestream.c | |
parent | 1be79923f04722ba0cd3538bc9d80a2c5c509910 (diff) | |
download | gst-plugins-bad-9bc18a9a15e8ea20bf3fde066294b2866b751f6f.tar.gz gst-plugins-bad-9bc18a9a15e8ea20bf3fde066294b2866b751f6f.tar.bz2 gst-plugins-bad-9bc18a9a15e8ea20bf3fde066294b2866b751f6f.zip |
gst/librfb/: Some much needed hackage. Fixed #171659, but then went on to actually make it work with Vino, get timin...
Original commit message from CVS:
* gst/librfb/Makefile.am:
* gst/librfb/gstrfbsrc.c:
* gst/librfb/rfb.h:
* gst/librfb/rfbbuffer.c:
* gst/librfb/rfbbuffer.h:
* gst/librfb/rfbbytestream.c:
* gst/librfb/rfbbytestream.h:
* gst/librfb/rfbdecoder.c:
* gst/librfb/rfbdecoder.h:
Some much needed hackage. Fixed #171659, but then went on
to actually make it work with Vino, get timing correct,
make sure it doesn't leak, etc.
Diffstat (limited to 'gst/librfb/rfbbytestream.c')
-rw-r--r-- | gst/librfb/rfbbytestream.c | 138 |
1 files changed, 0 insertions, 138 deletions
diff --git a/gst/librfb/rfbbytestream.c b/gst/librfb/rfbbytestream.c deleted file mode 100644 index 729851b0..00000000 --- a/gst/librfb/rfbbytestream.c +++ /dev/null @@ -1,138 +0,0 @@ - -#include <rfbbytestream.h> -#include <string.h> - -#include <gst/gst.h> - - -RfbBytestream * -rfb_bytestream_new (void) -{ - return g_new0 (RfbBytestream, 1); -} - -int -rfb_bytestream_get (RfbBytestream * bs, int len) -{ - RfbBuffer *buffer; - - buffer = bs->get_buffer (len, bs->user_data); - - if (buffer) { - GST_DEBUG ("got buffer (%d bytes)", buffer->length); - bs->buffer_list = g_list_append (bs->buffer_list, buffer); - - bs->length += buffer->length; - - return len; - } else { - bs->disconnected = TRUE; - } - - return 0; -} - -gboolean -rfb_bytestream_check (RfbBytestream * bs, int len) -{ - while (bs->length < len) { - rfb_bytestream_get (bs, len - bs->length); - if (bs->disconnected) - return FALSE; - } - return TRUE; -} - -static int -rfb_bytestream_copy_nocheck (RfbBytestream * bs, RfbBuffer * buffer, int len) -{ - GList *item; - int offset; - int first_offset; - RfbBuffer *frombuf; - int n; - - offset = 0; - first_offset = bs->offset; - for (item = bs->buffer_list; item; item = g_list_next (item)) { - frombuf = (RfbBuffer *) item->data; - n = MIN (len, frombuf->length - first_offset); - GST_DEBUG ("copying %d bytes from %p", 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; -} - -int -rfb_bytestream_read (RfbBytestream * bs, RfbBuffer ** buffer, int len) -{ - RfbBuffer *buf; - int ret; - - if (bs->disconnected) - return 0; - - ret = rfb_bytestream_check (bs, len); - if (!ret) - return 0; - - buf = rfb_buffer_new_and_alloc (len); - rfb_bytestream_copy_nocheck (bs, buf, len); - - rfb_bytestream_flush (bs, len); - - *buffer = buf; - return len; -} - -int -rfb_bytestream_peek (RfbBytestream * bs, RfbBuffer ** buffer, int len) -{ - RfbBuffer *buf; - - if (bs->disconnected) - return 0; - - rfb_bytestream_check (bs, len); - - buf = rfb_buffer_new_and_alloc (len); - rfb_bytestream_copy_nocheck (bs, buf, len); - - *buffer = buf; - return len; -} - -int -rfb_bytestream_flush (RfbBytestream * bs, int len) -{ - GList *item; - RfbBuffer *buf; - int n; - - 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_list_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; -} |