summaryrefslogtreecommitdiff
path: root/src/input/libreal
diff options
context:
space:
mode:
Diffstat (limited to 'src/input/libreal')
-rw-r--r--src/input/libreal/Makefile.am21
-rw-r--r--src/input/libreal/asmrp.c2
-rw-r--r--src/input/libreal/real.c11
-rw-r--r--src/input/libreal/rmff.c47
-rw-r--r--src/input/libreal/rmff.h12
-rw-r--r--src/input/libreal/sdpplin.c96
6 files changed, 59 insertions, 130 deletions
diff --git a/src/input/libreal/Makefile.am b/src/input/libreal/Makefile.am
index 5b10d1bca..c3a27ba02 100644
--- a/src/input/libreal/Makefile.am
+++ b/src/input/libreal/Makefile.am
@@ -1,19 +1,12 @@
+include $(top_srcdir)/misc/Makefile.quiet
include $(top_srcdir)/misc/Makefile.common
-AM_CPPFLAGS = -D_LARGEFILE64_SOURCE -I$(srcdir)/../librtsp
+AM_CFLAGS = $(DEFAULT_OCFLAGS) $(VISIBILITY_FLAG)
+AM_CPPFLAGS = -I$(top_srcdir)/src/input/librtsp $(AVUTIL_CFLAGS)
-noinst_LTLIBRARIES = libreal.la
-
-libreal_la_SOURCES = \
- real.c \
- asmrp.c \
- rmff.c \
- sdpplin.c
+noinst_HEADERS = real.h asmrp.h rmff.h sdpplin.h
-libreal_la_CFLAGS = $(VISIBILITY_FLAG)
+noinst_LTLIBRARIES = libreal.la
-noinst_HEADERS = \
- real.h \
- asmrp.h \
- rmff.h \
- sdpplin.h
+libreal_la_SOURCES = real.c asmrp.c rmff.c sdpplin.c
+libreal_la_LIBADD = $(AVUTIL_LIBS)
diff --git a/src/input/libreal/asmrp.c b/src/input/libreal/asmrp.c
index 2c02c2f13..070d9cb34 100644
--- a/src/input/libreal/asmrp.c
+++ b/src/input/libreal/asmrp.c
@@ -47,7 +47,7 @@
*/
#include "asmrp.h"
-#include "xineutils.h"
+#include <xine/xineutils.h>
#define ASMRP_SYM_NONE 0
#define ASMRP_SYM_EOF 1
diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c
index 9b72c7e57..7ce345717 100644
--- a/src/input/libreal/real.c
+++ b/src/input/libreal/real.c
@@ -37,8 +37,8 @@
#include "real.h"
#include "asmrp.h"
#include "sdpplin.h"
-#include "xine_internal.h"
-#include "xineutils.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
#include "bswap.h"
#define XOR_TABLE_LEN 37
@@ -317,14 +317,13 @@ void real_calc_response_and_checksum (char *response, char *chksum, char *challe
size_t ch_len, resp_len;
int i;
char *ptr;
- char buf[128];
+ char buf[128] = { 0, };
/* initialize return values */
memset(response, 0, 64);
memset(chksum, 0, 34);
/* initialize buffer */
- memset(buf, 0, 128);
ptr=buf;
_X_BE_32C(ptr, 0xa1e9149d);
ptr+=4;
@@ -354,10 +353,10 @@ void real_calc_response_and_checksum (char *response, char *chksum, char *challe
calc_response_string (response, buf);
/* add tail */
- resp_len = strlen (response);
- strcpy (&response[resp_len], "01d0a8e3");
+ strcat(response, "01d0a8e3");
/* calculate checksum */
+ resp_len = strlen (response);
for (i=0; i<resp_len/4; i++)
chksum[i] = response[i*4];
}
diff --git a/src/input/libreal/rmff.c b/src/input/libreal/rmff.c
index 82554a350..5690eb14b 100644
--- a/src/input/libreal/rmff.c
+++ b/src/input/libreal/rmff.c
@@ -31,7 +31,7 @@
#define LOG
*/
-#include "xineutils.h"
+#include <xine/xineutils.h>
#include "bswap.h"
#include "rmff.h"
@@ -275,7 +275,7 @@ int rmff_dump_header(rmff_header_t *h, void *buf_gen, int max) {
return written;
}
-void rmff_dump_pheader(rmff_pheader_t *h, char *data) {
+void rmff_dump_pheader(rmff_pheader_t *h, uint8_t *data) {
data[0]=(h->object_version>>8) & 0xff;
data[1]=h->object_version & 0xff;
@@ -359,29 +359,23 @@ static rmff_mdpr_t *rmff_scan_mdpr(const char *data)
mdpr->stream_name_size=data[40];
if (mdpr->size < 46 + mdpr->stream_name_size)
goto fail;
- mdpr->stream_name = malloc(mdpr->stream_name_size+1);
+ mdpr->stream_name = xine_memdup0(&data[41], mdpr->stream_name_size);
if (!mdpr->stream_name)
goto fail;
- memcpy(mdpr->stream_name, &data[41], mdpr->stream_name_size);
- mdpr->stream_name[mdpr->stream_name_size]=0;
mdpr->mime_type_size=data[41+mdpr->stream_name_size];
if (mdpr->size < 46 + mdpr->stream_name_size + mdpr->mime_type_size)
goto fail;
- mdpr->mime_type = malloc(mdpr->mime_type_size+1);
+ mdpr->mime_type = xine_memdup0(&data[42+mdpr->stream_name_size], mdpr->mime_type_size);
if (!mdpr->mime_type)
goto fail;
- memcpy(mdpr->mime_type, &data[42+mdpr->stream_name_size], mdpr->mime_type_size);
- mdpr->mime_type[mdpr->mime_type_size]=0;
mdpr->type_specific_len=_X_BE_32(&data[42+mdpr->stream_name_size+mdpr->mime_type_size]);
if (mdpr->size < 46 + mdpr->stream_name_size + mdpr->mime_type_size + mdpr->type_specific_len)
goto fail;
- mdpr->type_specific_data = malloc(mdpr->type_specific_len);
+ mdpr->type_specific_data = xine_memdup(&data[46+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len);
if (!mdpr->type_specific_data)
goto fail;
- memcpy(mdpr->type_specific_data,
- &data[46+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len);
return mdpr;
@@ -406,24 +400,17 @@ static rmff_cont_t *rmff_scan_cont(const char *data) {
lprintf("warning: unknown object version in CONT: 0x%04x\n", cont->object_version);
}
cont->title_len=_X_BE_16(&data[10]);
- cont->title = malloc(cont->title_len+1);
- memcpy(cont->title, &data[12], cont->title_len);
- cont->title[cont->title_len]=0;
+ cont->title = xine_memdup0(&data[12], cont->title_len);
pos=cont->title_len+12;
cont->author_len=_X_BE_16(&data[pos]);
- cont->author = malloc(cont->author_len+1);
- memcpy(cont->author, &data[pos+2], cont->author_len);
- cont->author[cont->author_len]=0;
+ cont->author = xine_memdup0(&data[pos+2], cont->author_len);
pos=pos+2+cont->author_len;
cont->copyright_len=_X_BE_16(&data[pos]);
- cont->copyright = malloc(cont->copyright_len+1);
- memcpy(cont->copyright, &data[pos+2], cont->copyright_len);
+ cont->copyright = xine_memdup0(&data[pos+2], cont->copyright_len);
cont->copyright[cont->copyright_len]=0;
pos=pos+2+cont->copyright_len;
cont->comment_len=_X_BE_16(&data[pos]);
- cont->comment = malloc(cont->comment_len+1);
- memcpy(cont->comment, &data[pos+2], cont->comment_len);
- cont->comment[cont->comment_len]=0;
+ cont->comment = xine_memdup0(&data[pos+2], cont->comment_len);
return cont;
}
@@ -488,11 +475,8 @@ rmff_header_t *rmff_scan_header(const char *data) {
break;
case MDPR_TAG:
mdpr=rmff_scan_mdpr(ptr);
- if (mdpr) /* FIXME: what to do if NULL? */
- {
- chunk_size=mdpr->size;
- header->streams[mdpr->stream_number]=mdpr;
- }
+ chunk_size=mdpr->size;
+ header->streams[mdpr->stream_number]=mdpr;
break;
case CONT_TAG:
header->cont=rmff_scan_cont(ptr);
@@ -516,6 +500,7 @@ rmff_header_t *rmff_scan_header(const char *data) {
return header;
}
+#if 0
rmff_header_t *rmff_scan_header_stream(int fd) {
rmff_header_t *header;
@@ -566,6 +551,7 @@ void rmff_scan_pheader(rmff_pheader_t *h, char *data) {
h->reserved=(uint8_t)data[10];
h->flags=(uint8_t)data[11];
}
+#endif
rmff_fileheader_t *rmff_new_fileheader(uint32_t num_headers) {
@@ -652,8 +638,7 @@ rmff_mdpr_t *rmff_new_mdpr(
mdpr->mime_type_size=strlen(mime_type);
}
mdpr->type_specific_len=type_specific_len;
- mdpr->type_specific_data = malloc(type_specific_len);
- memcpy(mdpr->type_specific_data,type_specific_data,type_specific_len);
+ mdpr->type_specific_data = xine_memdup(type_specific_data,type_specific_len);
mdpr->mlti_data=NULL;
mdpr->size=mdpr->stream_name_size+mdpr->mime_type_size+mdpr->type_specific_len+46;
@@ -712,6 +697,7 @@ rmff_data_t *rmff_new_dataheader(uint32_t num_packets, uint32_t next_data_header
return data;
}
+#if 0
void rmff_print_header(rmff_header_t *h) {
rmff_mdpr_t **stream;
@@ -778,6 +764,7 @@ void rmff_print_header(rmff_header_t *h) {
printf("next DATA : 0x%08x\n", h->data->next_data_header);
}
}
+#endif
void rmff_fix_header(rmff_header_t *h) {
@@ -886,6 +873,7 @@ void rmff_fix_header(rmff_header_t *h) {
}
}
+#if 0
int rmff_get_header_size(rmff_header_t *h) {
if (!h) return 0;
@@ -925,3 +913,4 @@ void rmff_free_header(rmff_header_t *h) {
}
free(h);
}
+#endif
diff --git a/src/input/libreal/rmff.h b/src/input/libreal/rmff.h
index 20b8b8960..996adc77d 100644
--- a/src/input/libreal/rmff.h
+++ b/src/input/libreal/rmff.h
@@ -35,7 +35,7 @@
#ifndef HAVE_RMFF_H
#define HAVE_RMFF_H
-#include "attributes.h"
+#include <xine/attributes.h>
#define RMFF_HEADER_SIZE 0x12
@@ -222,6 +222,7 @@ rmff_data_t *rmff_new_dataheader(
*/
rmff_header_t *rmff_scan_header(const char *data) XINE_MALLOC;
+#if 0
/*
* scans a data packet header. Notice, that this function does not allocate
* the header struct itself.
@@ -237,30 +238,35 @@ rmff_header_t *rmff_scan_header_stream(int fd) XINE_MALLOC;
* prints header information in human readible form to stdout
*/
void rmff_print_header(rmff_header_t *h);
+#endif
/*
* does some checks and fixes header if possible
*/
void rmff_fix_header(rmff_header_t *h);
+#if 0
/*
* returns the size of the header (incl. first data-header)
*/
int rmff_get_header_size(rmff_header_t *h);
+#endif
/*
* dumps the header <h> to <buffer>. <max> is the size of <buffer>
*/
-int rmff_dump_header(rmff_header_t *h, void *buf_gen, int max);
+int rmff_dump_header(rmff_header_t *h, void *buffer, int max);
/*
* dumps a packet header
*/
-void rmff_dump_pheader(rmff_pheader_t *h, char *data);
+void rmff_dump_pheader(rmff_pheader_t *h, uint8_t *data);
+#if 0
/*
* frees a header struct
*/
void rmff_free_header(rmff_header_t *h);
+#endif
#endif
diff --git a/src/input/libreal/sdpplin.c b/src/input/libreal/sdpplin.c
index b7e5218cb..c9f5afa93 100644
--- a/src/input/libreal/sdpplin.c
+++ b/src/input/libreal/sdpplin.c
@@ -33,68 +33,13 @@
#include "rmff.h"
#include "rtsp.h"
#include "sdpplin.h"
-#include "xineutils.h"
+#include <xine/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*/
- const size_t in_len = strlen(in);
- for (j=0; j<in_len; 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;
-}
+#ifdef HAVE_FFMPEG_AVUTIL_H
+# include <base64.h>
+#else
+# include <libavutil/base64.h>
+#endif
static char *nl(char *data) {
@@ -129,7 +74,6 @@ static sdpplin_stream_t *XINE_MALLOC sdpplin_parse_stream(char **data) {
sdpplin_stream_t *desc = calloc(1, sizeof(sdpplin_stream_t));
char *buf=xine_buffer_init(32);
- char *decoded=xine_buffer_init(32);
int handled;
if (filter(*data, "m=", &buf)) {
@@ -209,10 +153,10 @@ static sdpplin_stream_t *XINE_MALLOC 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 = malloc(desc->mlti_data_size);
- memcpy(desc->mlti_data, decoded, desc->mlti_data_size);
+ uint8_t decoded[32];
+ desc->mlti_data_size = av_base64_decode(decoded, buf, 32);
+ if ( desc->mlti_data_size > 0 ) {
+ desc->mlti_data = xine_memdup(decoded, desc->mlti_data_size);
handled=1;
*data=nl(*data);
lprintf("mlti_data_size: %i\n", desc->mlti_data_size);
@@ -237,7 +181,6 @@ static sdpplin_stream_t *XINE_MALLOC sdpplin_parse_stream(char **data) {
}
xine_buffer_free(buf);
- xine_buffer_free(decoded);
return desc;
}
@@ -247,9 +190,9 @@ sdpplin_t *sdpplin_parse(char *data) {
sdpplin_t *desc = calloc(1, 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;
@@ -272,8 +215,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);
@@ -281,8 +224,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);
@@ -290,8 +233,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);
@@ -299,8 +242,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);
@@ -339,7 +282,6 @@ sdpplin_t *sdpplin_parse(char *data) {
}
xine_buffer_free(buf);
- xine_buffer_free(decoded);
return desc;
}