From 16225d45be6777b188e8dfa96555d5d23f2e7472 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 11 Mar 2009 14:07:05 +0100 Subject: [PATCH] rtsp: keep track of amount of decoded bytes 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/rtsp/gstrtspconnection.c b/gst-libs/gst/rtsp/gstrtspconnection.c index d5369788b7..a66aa3d9c5 100644 --- a/gst-libs/gst/rtsp/gstrtspconnection.c +++ b/gst-libs/gst/rtsp/gstrtspconnection.c @@ -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; } }