diff options
Diffstat (limited to 'src/input/libreal/sdpplin.c')
-rw-r--r-- | src/input/libreal/sdpplin.c | 89 |
1 files changed, 15 insertions, 74 deletions
diff --git a/src/input/libreal/sdpplin.c b/src/input/libreal/sdpplin.c index 5b22e9044..ad65bd491 100644 --- a/src/input/libreal/sdpplin.c +++ b/src/input/libreal/sdpplin.c @@ -31,65 +31,8 @@ #include "sdpplin.h" #include "xineutils.h" -/* - * Decodes base64 strings (based upon b64 package) - */ - -static char *b64_decode(const char *in, char *out, int *size) -{ - char dtable[256]; /* Encode / decode table */ - int i,k; - size_t j; - - 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; - - k=0; - - /*CONSTANTCONDITION*/ - for (j=0; j<strlen(in); j+=4) - { - char a[4], b[4]; - - for (i = 0; i < 4; i++) { - int c = in[i+j]; - - if (dtable[c] & 0x80) { - fprintf(stderr, "Illegal character '%c' in input.\n", c); - *size = 0; - return NULL; - } - a[i] = (char) c; - b[i] = (char) dtable[c]; - } - xine_buffer_ensure_size(out, k+3); - out[k++] = (b[0] << 2) | (b[1] >> 4); - out[k++] = (b[1] << 4) | (b[2] >> 2); - out[k++] = (b[2] << 6) | b[3]; - i = a[2] == '=' ? 1 : (a[3] == '=' ? 2 : 3); - if (i < 3) { - out[k]=0; - *size=k; - return out; - } - } - out[k]=0; - *size=k; - return out; -} +/* libavutil from FFmpeg */ +#include <base64.h> static char *nl(char *data) { @@ -124,7 +67,6 @@ static sdpplin_stream_t *sdpplin_parse_stream(char **data) { sdpplin_stream_t *desc = xine_xmalloc(sizeof(sdpplin_stream_t)); char *buf=xine_buffer_init(32); - char *decoded=xine_buffer_init(32); int handled; if (filter(*data, "m=", &buf)) { @@ -197,9 +139,10 @@ static sdpplin_stream_t *sdpplin_parse_stream(char **data) { } if(filter(*data,"a=OpaqueData:buffer;",&buf)) { - decoded = b64_decode(buf, decoded, &(desc->mlti_data_size)); - if ( decoded != NULL ) { - desc->mlti_data = calloc(desc->mlti_data_size, sizeof(char)); + uint8_t decoded[32]; + desc->mlti_data_size = av_base64_decode(decoded, buf, 32); + if ( desc->mlti_data_size > 0 ) { + desc->mlti_data = malloc(sizeof(char)*desc->mlti_data_size); memcpy(desc->mlti_data, decoded, desc->mlti_data_size); handled=1; *data=nl(*data); @@ -225,7 +168,6 @@ static sdpplin_stream_t *sdpplin_parse_stream(char **data) { } xine_buffer_free(buf); - xine_buffer_free(decoded); return desc; } @@ -235,9 +177,9 @@ sdpplin_t *sdpplin_parse(char *data) { sdpplin_t *desc = xine_xmalloc(sizeof(sdpplin_t)); sdpplin_stream_t *stream; char *buf=xine_buffer_init(32); - char *decoded=xine_buffer_init(32); int handled; int len; + uint8_t decoded[32]; desc->stream = NULL; @@ -257,8 +199,8 @@ sdpplin_t *sdpplin_parse(char *data) { } if(filter(data,"a=Title:buffer;",&buf)) { - decoded=b64_decode(buf, decoded, &len); - if ( decoded != NULL ) { + len = av_base64_decode(decoded, buf, 32); + if ( len > 0 ) { desc->title=strdup(decoded); handled=1; data=nl(data); @@ -266,8 +208,8 @@ sdpplin_t *sdpplin_parse(char *data) { } if(filter(data,"a=Author:buffer;",&buf)) { - decoded=b64_decode(buf, decoded, &len); - if ( decoded != NULL ) { + len = av_base64_decode(decoded, buf, 32); + if ( len > 0 ) { desc->author=strdup(decoded); handled=1; data=nl(data); @@ -275,8 +217,8 @@ sdpplin_t *sdpplin_parse(char *data) { } if(filter(data,"a=Copyright:buffer;",&buf)) { - decoded=b64_decode(buf, decoded, &len); - if ( decoded != NULL ) { + len = av_base64_decode(decoded, buf, 32); + if ( len > 0 ) { desc->copyright=strdup(decoded); handled=1; data=nl(data); @@ -284,8 +226,8 @@ sdpplin_t *sdpplin_parse(char *data) { } if(filter(data,"a=Abstract:buffer;",&buf)) { - decoded=b64_decode(buf, decoded, &len); - if ( decoded != NULL ) { + len = av_base64_decode(decoded, buf, 32); + if ( len > 0 ) { desc->abstract=strdup(decoded); handled=1; data=nl(data); @@ -317,7 +259,6 @@ sdpplin_t *sdpplin_parse(char *data) { } xine_buffer_free(buf); - xine_buffer_free(decoded); return desc; } |