Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / gst-libs / gst / rtsp / gstrtspbase64.c
1 /* GStreamer
2  * Copyright (C) <2007> Mike Smith <msmith@xiph.org>
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 /**
21  * SECTION:gstrtspbase64
22  * @short_description: Helper functions to handle Base64
23  *
24  * Last reviewed on 2007-07-24 (0.10.14)
25  */
26
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
31 #include <string.h>
32
33 #include "gstrtspbase64.h"
34
35 /**
36  * gst_rtsp_base64_encode:
37  * @data: the binary data to encode
38  * @len: the length of @data
39  *
40  * Encode a sequence of binary data into its Base-64 stringified representation.
41  *
42  * Deprecated: Use g_base64_encode()
43  *
44  * Returns: a newly allocated, zero-terminated Base-64 encoded string
45  * representing @data.
46  */
47 /* This isn't efficient, but it doesn't need to be */
48 #ifndef GST_REMOVE_DEPRECATED
49 #ifdef GST_DISABLE_DEPRECATED
50 gchar *gst_rtsp_base64_encode (const gchar * data, gsize len);
51 #endif
52 gchar *
53 gst_rtsp_base64_encode (const gchar * data, gsize len)
54 {
55   return g_base64_encode ((const guchar *) data, len);
56 }
57 #endif
58
59 /**
60  * gst_rtsp_base64_decode_ip:
61  * @data: the base64 encoded data
62  * @len: location for output length or NULL
63  *
64  * Decode the base64 string pointed to by @data in-place. When @len is not #NULL
65  * it will contain the length of the decoded data.
66  *
67  * Deprecated: use g_base64_decode_inplace() instead.
68  */
69 #ifndef GST_REMOVE_DEPRECATED
70 #ifdef GST_DISABLE_DEPRECATED
71 void gst_rtsp_base64_decode_ip (gchar * data, gsize * len);
72 #endif
73 void
74 gst_rtsp_base64_decode_ip (gchar * data, gsize * len)
75 {
76   gint input_length, output_length, state = 0;
77   guint save = 0;
78
79   g_return_if_fail (data != NULL);
80
81   input_length = strlen (data);
82
83   g_return_if_fail (input_length > 1);
84
85   output_length =
86       g_base64_decode_step (data, input_length, (guchar *) data, &state, &save);
87
88   if (len)
89     *len = output_length;
90 }
91 #endif