rtsp: keep track of amount of decoded bytes
authorWim Taymans <wim.taymans@collabora.co.uk>
Wed, 11 Mar 2009 13:07:05 +0000 (14:07 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Wed, 11 Mar 2009 13:09:54 +0000 (14:09 +0100)
Keep track of the actual amount of decoded bytes, which can be less than 3 when
we decode the last bits of a base64 message.

gst-libs/gst/rtsp/gstrtspconnection.c

index d536978..a66aa3d 100644 (file)
@@ -103,6 +103,7 @@ typedef struct
   guint cin;
   gchar out[3];
   guint cout;
+  guint coutl;
 } DecodeCtx;
 
 static GstRTSPResult read_line (gint fd, guint8 * buffer, guint * idx,
@@ -976,7 +977,7 @@ fill_bytes (gint fd, guint8 * buffer, guint size, DecodeCtx * ctx)
     gint r;
 
     while (size > 0) {
-      while (size > 0 && ctx->cout < 3) {
+      while (size > 0 && ctx->cout < ctx->coutl) {
         /* we have some leftover bytes */
         *buffer++ = ctx->out[ctx->cout];
         ctx->cout++;
@@ -1000,6 +1001,7 @@ fill_bytes (gint fd, guint8 * buffer, guint size, DecodeCtx * ctx)
         r = g_base64_decode_step ((const gchar *) ctx->in, 4,
             (guchar *) ctx->out, &ctx->state, &ctx->save);
         ctx->cout = 0;
+        ctx->coutl = r;
         ctx->cin = 0;
       }
     }