expose av_base64_decode and av_base64_encode
Originally committed as revision 8448 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
559fd1e795
commit
bd03c380ce
@ -210,13 +210,14 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr,
|
|||||||
int post, err, ch;
|
int post, err, ch;
|
||||||
char line[1024], *q;
|
char line[1024], *q;
|
||||||
char *auth_b64;
|
char *auth_b64;
|
||||||
|
int auth_b64_len = strlen(auth)* 4 / 3 + 12;
|
||||||
offset_t off = s->off;
|
offset_t off = s->off;
|
||||||
|
|
||||||
|
|
||||||
/* send http header */
|
/* send http header */
|
||||||
post = h->flags & URL_WRONLY;
|
post = h->flags & URL_WRONLY;
|
||||||
|
auth_b64 = av_malloc(auth_b64_len);
|
||||||
auth_b64 = av_base64_encode((uint8_t *)auth, strlen(auth));
|
av_base64_encode(auth_b64, auth_b64_len, (uint8_t *)auth, strlen(auth));
|
||||||
snprintf(s->buffer, sizeof(s->buffer),
|
snprintf(s->buffer, sizeof(s->buffer),
|
||||||
"%s %s HTTP/1.1\r\n"
|
"%s %s HTTP/1.1\r\n"
|
||||||
"User-Agent: %s\r\n"
|
"User-Agent: %s\r\n"
|
||||||
|
@ -18,7 +18,7 @@ OBJS= mathematics.o \
|
|||||||
|
|
||||||
HEADERS = avutil.h common.h mathematics.h integer.h rational.h \
|
HEADERS = avutil.h common.h mathematics.h integer.h rational.h \
|
||||||
intfloat_readwrite.h md5.h adler32.h log.h fifo.h lzo.h \
|
intfloat_readwrite.h md5.h adler32.h log.h fifo.h lzo.h \
|
||||||
random.h mem.h
|
random.h mem.h base64.h
|
||||||
|
|
||||||
NAME=avutil
|
NAME=avutil
|
||||||
LIBVERSION=$(LAVUVERSION)
|
LIBVERSION=$(LAVUVERSION)
|
||||||
|
@ -34,8 +34,8 @@ extern "C" {
|
|||||||
#define AV_STRINGIFY(s) AV_TOSTRING(s)
|
#define AV_STRINGIFY(s) AV_TOSTRING(s)
|
||||||
#define AV_TOSTRING(s) #s
|
#define AV_TOSTRING(s) #s
|
||||||
|
|
||||||
#define LIBAVUTIL_VERSION_INT ((49<<16)+(3<<8)+0)
|
#define LIBAVUTIL_VERSION_INT ((49<<16)+(4<<8)+0)
|
||||||
#define LIBAVUTIL_VERSION 49.3.0
|
#define LIBAVUTIL_VERSION 49.4.0
|
||||||
#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
|
#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
|
||||||
|
|
||||||
#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
|
#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
|
||||||
|
@ -70,7 +70,7 @@ int av_base64_decode(uint8_t * out, const char *in, int out_length)
|
|||||||
* fixed edge cases and made it work from data (vs. strings) by ryan.
|
* fixed edge cases and made it work from data (vs. strings) by ryan.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
char *av_base64_encode(uint8_t * src, int len)
|
char *av_base64_encode(char * buf, int buf_len, uint8_t * src, int len)
|
||||||
{
|
{
|
||||||
static const char b64[] =
|
static const char b64[] =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
@ -79,11 +79,10 @@ char *av_base64_encode(uint8_t * src, int len)
|
|||||||
int i_shift = 0;
|
int i_shift = 0;
|
||||||
int bytes_remaining = len;
|
int bytes_remaining = len;
|
||||||
|
|
||||||
if (len < UINT_MAX / 4) {
|
if (len >= UINT_MAX / 4 ||
|
||||||
ret = dst = av_malloc(len * 4 / 3 + 12);
|
buf_len < len * 4 / 3 + 12)
|
||||||
} else
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
ret = dst = buf;
|
||||||
if (len) { // special edge case, what should we really do here?
|
if (len) { // special edge case, what should we really do here?
|
||||||
while (bytes_remaining) {
|
while (bytes_remaining) {
|
||||||
i_bits = (i_bits << 8) + *src++;
|
i_bits = (i_bits << 8) + *src++;
|
||||||
|
@ -28,6 +28,7 @@ int av_base64_decode(uint8_t * out, const char *in, int out_length);
|
|||||||
/**
|
/**
|
||||||
* encodes base64
|
* encodes base64
|
||||||
* @param src data, not a string
|
* @param src data, not a string
|
||||||
|
* @param buf output string
|
||||||
*/
|
*/
|
||||||
char *av_base64_encode(uint8_t * src, int len);
|
char *av_base64_encode(char * buf, int buf_len, uint8_t * src, int len);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user