mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
API: gst_rtsp_base64_decode_ip()
Original commit message from CVS: * docs/libs/gst-plugins-base-libs-sections.txt: * gst-libs/gst/rtsp/gstrtspbase64.c: (gst_rtsp_base64_decode_ip): * gst-libs/gst/rtsp/gstrtspbase64.h: API: gst_rtsp_base64_decode_ip() Added function to decode Base64 in-place.
This commit is contained in:
parent
58afe32d55
commit
2c35823bdf
4 changed files with 71 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
|||
2007-07-26 Wim Taymans <wim.taymans@gmail.com>
|
||||
|
||||
* docs/libs/gst-plugins-base-libs-sections.txt:
|
||||
* gst-libs/gst/rtsp/gstrtspbase64.c: (gst_rtsp_base64_decode_ip):
|
||||
* gst-libs/gst/rtsp/gstrtspbase64.h:
|
||||
API: gst_rtsp_base64_decode_ip()
|
||||
Added function to decode Base64 in-place.
|
||||
|
||||
2007-07-26 Jan Schmidt <thaytan@mad.scientist.com>
|
||||
|
||||
* tests/check/libs/.cvsignore:
|
||||
|
|
|
@ -1007,6 +1007,7 @@ gst_rtsp_transport_free
|
|||
<FILE>gstrtspbase64</FILE>
|
||||
<INCLUDE>gst/rtsp/gstrtspbase64.h</INCLUDE>
|
||||
gst_rtsp_base64_encode
|
||||
gst_rtsp_base64_decode_ip
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
/**
|
||||
* SECTION:gstrtspbase64
|
||||
* @short_description: Helper function to encode into Base64
|
||||
* @short_description: Helper functions to handle Base64
|
||||
*
|
||||
* Last reviewed on 2007-07-24 (0.10.14)
|
||||
*/
|
||||
|
@ -28,6 +28,8 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "gstrtspbase64.h"
|
||||
|
||||
static char base64table[64] = {
|
||||
|
@ -85,3 +87,60 @@ gst_rtsp_base64_encode (const gchar * data, gsize len)
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_base64_decode_ip:
|
||||
* @data: the base64 encoded data
|
||||
* @len: location for output length or NULL
|
||||
*
|
||||
* Decode the base64 string pointed to by @data in-place. When @len is not #NULL
|
||||
* it will contain the length of the decoded data.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_base64_decode_ip (gchar * data, gsize * len)
|
||||
{
|
||||
char dtable[256];
|
||||
int i, j, k = 0, n = strlen (data);
|
||||
|
||||
for (i = 0; i < 255; i++)
|
||||
dtable[i] = 0x80;
|
||||
for (i = 'A'; i <= 'Z'; i++)
|
||||
dtable[i] = 0 + (i - 'A');
|
||||
for (i = 'a'; i <= 'z'; i++)
|
||||
dtable[i] = 26 + (i - 'a');
|
||||
for (i = '0'; i <= '9'; i++)
|
||||
dtable[i] = 52 + (i - '0');
|
||||
dtable['+'] = 62;
|
||||
dtable['/'] = 63;
|
||||
dtable['='] = 0;
|
||||
|
||||
for (j = 0; j < n; j += 4) {
|
||||
char a[4], b[4];
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
int c = data[i + j];
|
||||
|
||||
if (dtable[c] & 0x80) {
|
||||
if (len)
|
||||
*len = 0;
|
||||
return;
|
||||
}
|
||||
a[i] = (char) c;
|
||||
b[i] = (char) dtable[c];
|
||||
}
|
||||
data[k++] = (b[0] << 2) | (b[1] >> 4);
|
||||
data[k++] = (b[1] << 4) | (b[2] >> 2);
|
||||
data[k++] = (b[2] << 6) | b[3];
|
||||
i = a[2] == '=' ? 1 : (a[3] == '=' ? 2 : 3);
|
||||
if (i < 3) {
|
||||
data[k] = 0;
|
||||
if (len)
|
||||
*len = k;
|
||||
return;
|
||||
}
|
||||
}
|
||||
data[k] = 0;
|
||||
if (len)
|
||||
*len = k;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gchar *gst_rtsp_base64_encode(const gchar *data, gsize len);
|
||||
gchar *gst_rtsp_base64_encode (const gchar *data, gsize len);
|
||||
void gst_rtsp_base64_decode_ip (gchar *data, gsize *len);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue