summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2007-02-26 10:00:28 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2007-02-26 10:00:28 +0000
commitff1a71edf954d99028b919e36bfd514aa47aa238 (patch)
tree438e0c19bd2b49a0f1559784364d9126cbf8ad48 /gst
parent682312a29687e88e388e61e7aa9c6479c0ed8b3a (diff)
downloadgstreamer-plugins-good-ff1a71edf954d99028b919e36bfd514aa47aa238.tar.gz
gst/rtsp/base64.*: Commit missing files for base64 encoding.
Original commit message from CVS: * gst/rtsp/base64.c: (util_base64_encode): * gst/rtsp/base64.h: Commit missing files for base64 encoding.
Diffstat (limited to 'gst')
-rw-r--r--gst/rtsp/base64.c70
-rw-r--r--gst/rtsp/base64.h31
2 files changed, 101 insertions, 0 deletions
diff --git a/gst/rtsp/base64.c b/gst/rtsp/base64.c
new file mode 100644
index 000000000..171e09ade
--- /dev/null
+++ b/gst/rtsp/base64.c
@@ -0,0 +1,70 @@
+/* GStreamer
+ * Copyright (C) <2007> Mike Smith <msmith@xiph.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "base64.h"
+
+static char base64table[64] = {
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P',
+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e',
+ 'f',
+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
+ 'v',
+ 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
+};
+
+/* This isn't efficient, but it doesn't need to be */
+gchar *
+util_base64_encode (gchar * data, gint len)
+{
+ gchar *out = g_malloc (len * 4 / 3 + 4);
+ gchar *result = out;
+ int chunk;
+
+ while (len > 0) {
+ chunk = (len > 3) ? 3 : len;
+ *out++ = base64table[(*data & 0xFC) >> 2];
+ *out++ = base64table[((*data & 0x03) << 4) | ((*(data + 1) & 0xF0) >> 4)];
+ switch (chunk) {
+ case 3:
+ *out++ =
+ base64table[((*(data + 1) & 0x0F) << 2) | ((*(data +
+ 2) & 0xC0) >> 6)];
+ *out++ = base64table[(*(data + 2)) & 0x3F];
+ break;
+ case 2:
+ *out++ = base64table[((*(data + 1) & 0x0F) << 2)];
+ *out++ = '=';
+ break;
+ case 1:
+ *out++ = '=';
+ *out++ = '=';
+ break;
+ }
+ data += chunk;
+ len -= chunk;
+ }
+ *out = 0;
+
+ return result;
+}
diff --git a/gst/rtsp/base64.h b/gst/rtsp/base64.h
new file mode 100644
index 000000000..4efebb650
--- /dev/null
+++ b/gst/rtsp/base64.h
@@ -0,0 +1,31 @@
+/* GStreamer
+ * Copyright (C) <2007> Mike Smith <msmith@xiph.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __BASE64_H__
+#define __BASE64_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gchar *util_base64_encode(gchar *data, gint len);
+
+G_END_DECLS
+
+#endif