2 * Copyright (C) <2007> Mike Smith <msmith@xiph.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * SECTION:gstrtspbase64
22 * @short_description: Helper functions to handle Base64
24 * Last reviewed on 2007-07-24 (0.10.14)
33 #include "gstrtspbase64.h"
36 * gst_rtsp_base64_encode:
37 * @data: the binary data to encode
38 * @len: the length of @data
40 * Encode a sequence of binary data into its Base-64 stringified representation.
42 * Deprecated: Use g_base64_encode()
44 * Returns: a newly allocated, zero-terminated Base-64 encoded string
47 /* This isn't efficient, but it doesn't need to be */
48 #ifndef GST_REMOVE_DEPRECATED
50 gst_rtsp_base64_encode (const gchar * data, gsize len)
52 return g_base64_encode ((const guchar *) data, len);
57 * gst_rtsp_base64_decode_ip:
58 * @data: the base64 encoded data
59 * @len: location for output length or NULL
61 * Decode the base64 string pointed to by @data in-place. When @len is not #NULL
62 * it will contain the length of the decoded data.
64 /* FIXME: Deprecate this once we depend on GLib 2.20 and
65 * use g_base64_decode_inplace then.
68 gst_rtsp_base64_decode_ip (gchar * data, gsize * len)
70 gint input_length, output_length, state = 0;
73 g_return_if_fail (data != NULL);
75 input_length = strlen (data);
77 g_return_if_fail (input_length > 1);
80 g_base64_decode_step (data, input_length, (guchar *) data, &state, &save);