summaryrefslogtreecommitdiff
path: root/src/input/libreal
diff options
context:
space:
mode:
Diffstat (limited to 'src/input/libreal')
-rw-r--r--src/input/libreal/asmrp.c72
-rw-r--r--src/input/libreal/real.c79
-rw-r--r--src/input/libreal/rmff.c54
-rw-r--r--src/input/libreal/sdpplin.c22
4 files changed, 87 insertions, 140 deletions
diff --git a/src/input/libreal/asmrp.c b/src/input/libreal/asmrp.c
index 49d3e63e5..928e137fb 100644
--- a/src/input/libreal/asmrp.c
+++ b/src/input/libreal/asmrp.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: asmrp.c,v 1.3 2003/10/12 18:52:55 mroi Exp $
+ * $Id: asmrp.c,v 1.4 2003/11/26 19:43:31 f1rmb Exp $
*
* a parser for real's asm rules
*
@@ -38,12 +38,15 @@
#include <stdio.h>
#include <string.h>
-#include "asmrp.h"
-
+#define LOG_MODULE "asmrp"
+#define LOG_VERBOSE
/*
#define LOG
*/
+#include "asmrp.h"
+#include "xineutils.h"
+
#define ASMRP_SYM_NONE 0
#define ASMRP_SYM_EOF 1
@@ -120,9 +123,7 @@ static void asmrp_getch (asmrp_t *p) {
p->ch = p->buf[p->pos];
p->pos++;
-#ifdef LOG
- printf ("%c\n", p->ch);
-#endif
+ lprintf ("%c\n", p->ch);
}
@@ -382,17 +383,13 @@ static int asmrp_set_id (asmrp_t *p, char *s, int v) {
p->sym_tab_num++;
p->sym_tab[i].id = strdup (s);
-#ifdef LOG
- printf ("new symbol '%s'\n", s);
-#endif
+ lprintf ("new symbol '%s'\n", s);
}
p->sym_tab[i].v = v;
-#ifdef LOG
- printf ("symbol '%s' assigned %d\n", s, v);
-#endif
+ lprintf ("symbol '%s' assigned %d\n", s, v);
return i;
}
@@ -403,9 +400,7 @@ static int asmrp_operand (asmrp_t *p) {
int i, ret;
-#ifdef LOG
- printf ("operand\n");
-#endif
+ lprintf ("operand\n");
ret = 0;
@@ -453,9 +448,7 @@ static int asmrp_operand (asmrp_t *p) {
abort();
}
-#ifdef LOG
- printf ("operand done, =%d\n", ret);
-#endif
+ lprintf ("operand done, =%d\n", ret);
return ret;
}
@@ -464,9 +457,7 @@ static int asmrp_comp_expression (asmrp_t *p) {
int a;
-#ifdef LOG
- printf ("comp_expression\n");
-#endif
+ lprintf ("comp_expression\n");
a = asmrp_operand (p);
@@ -502,9 +493,8 @@ static int asmrp_comp_expression (asmrp_t *p) {
}
-#ifdef LOG
- printf ("comp_expression done = %d\n", a);
-#endif
+ lprintf ("comp_expression done = %d\n", a);
+
return a;
}
@@ -512,9 +502,7 @@ static int asmrp_condition (asmrp_t *p) {
int a;
-#ifdef LOG
- printf ("condition\n");
-#endif
+ lprintf ("condition\n");
a = asmrp_comp_expression (p);
@@ -537,17 +525,14 @@ static int asmrp_condition (asmrp_t *p) {
}
}
-#ifdef LOG
- printf ("condition done = %d\n", a);
-#endif
+ lprintf ("condition done = %d\n", a);
+
return a;
}
static void asmrp_assignment (asmrp_t *p) {
-#ifdef LOG
- printf ("assignment\n");
-#endif
+ lprintf ("assignment\n");
if (p->sym != ASMRP_SYM_ID) {
printf ("error: identifier expected\n");
@@ -568,18 +553,14 @@ static void asmrp_assignment (asmrp_t *p) {
}
asmrp_get_sym (p);
-#ifdef LOG
- printf ("assignment done\n");
-#endif
+ lprintf ("assignment done\n");
}
static int asmrp_rule (asmrp_t *p) {
int ret;
-#ifdef LOG
- printf ("rule\n");
-#endif
+ lprintf ("rule\n");
ret = 1;
@@ -606,9 +587,7 @@ static int asmrp_rule (asmrp_t *p) {
}
}
-#ifdef LOG
- printf ("rule done = %d\n", ret);
-#endif
+ lprintf ("rule done = %d\n", ret);
if (p->sym != ASMRP_SYM_SEMICOLON) {
printf ("semicolon expected.\n");
@@ -624,9 +603,7 @@ static int asmrp_eval (asmrp_t *p, int *matches) {
int rule_num, num_matches;
-#ifdef LOG
- printf ("eval\n");
-#endif
+ lprintf ("eval\n");
asmrp_get_sym (p);
@@ -634,9 +611,8 @@ static int asmrp_eval (asmrp_t *p, int *matches) {
while (p->sym != ASMRP_SYM_EOF) {
if (asmrp_rule (p)) {
-#ifdef LOG
- printf ("rule #%d is true\n", rule_num);
-#endif
+ lprintf ("rule #%d is true\n", rule_num);
+
matches[num_matches] = rule_num;
num_matches++;
}
diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c
index 8122e169b..1cba7720b 100644
--- a/src/input/libreal/real.c
+++ b/src/input/libreal/real.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: real.c,v 1.8 2003/03/30 17:11:50 holstsn Exp $
+ * $Id: real.c,v 1.9 2003/11/26 19:43:31 f1rmb Exp $
*
* special functions for real streams.
* adopted from joschkas real tools.
@@ -27,15 +27,17 @@
#include <stdio.h>
#include <string.h>
-#include "real.h"
-#include "asmrp.h"
-#include "sdpplin.h"
-#include <xineutils.h>
-
+#define LOG_MODULE "real"
+#define LOG_VERBOSE
/*
#define LOG
*/
+#include "real.h"
+#include "asmrp.h"
+#include "sdpplin.h"
+#include "xineutils.h"
+
const unsigned char xor_table[] = {
0x05, 0x18, 0x74, 0xd0, 0x0d, 0x09, 0x02, 0x53,
0xc0, 0x01, 0x05, 0x05, 0x67, 0x03, 0x19, 0x70,
@@ -91,10 +93,10 @@ static void hash(char *field, char *param) {
memcpy(&b, &field[4], sizeof(uint32_t));
memcpy(&c, &field[8], sizeof(uint32_t));
memcpy(&d, &field[12], sizeof(uint32_t));
-
+
+ lprintf("hash input: %x %x %x %x\n", a, b, c, d);
+ lprintf("hash parameter:\n");
#ifdef LOG
- printf("real: hash input: %x %x %x %x\n", a, b, c, d);
- printf("real: hash parameter:\n");
hexdump(param, 64);
#endif
@@ -230,9 +232,7 @@ static void hash(char *field, char *param) {
b = ((~a | c) ^ d) + *((uint32_t*)(param+0x24)) + b - 0x14792C6F;
b = ((b << 0x15) | (b >> 0x0b)) + c;
-#ifdef LOG
- printf("real: hash output: %x %x %x %x\n", a, b, c, d);
-#endif
+ lprintf("hash output: %x %x %x %x\n", a, b, c, d);
*((uint32_t *)(field+0)) += a;
*((uint32_t *)(field+4)) += b;
@@ -255,9 +255,7 @@ static void call_hash (char *key, char *challenge, int len) {
if (a < (len << 3))
{
-#ifdef LOG
- printf("not verified: (len << 3) > a true\n");
-#endif
+ lprintf("not verified: (len << 3) > a true\n");
ptr2 += 4;
}
@@ -273,10 +271,7 @@ static void call_hash (char *key, char *challenge, int len) {
d = c + 0x3f;
while ( d < len ) {
-
-#ifdef LOG
- printf("not verified: while ( d < len )\n");
-#endif
+ lprintf("not verified: while ( d < len )\n");
hash(key, challenge+d-0x3f);
d += 64;
c += 64;
@@ -303,9 +298,7 @@ static void calc_response (char *result, char *field) {
if (i < 56) {
i = 56 - i;
} else {
-#ifdef LOG
- printf("not verified: ! (i < 56)\n");
-#endif
+ lprintf("not verified: ! (i < 56)\n");
i = 120 - i;
}
@@ -422,9 +415,7 @@ static int select_mlti_data(const char *mlti_chunk, int mlti_size, int selection
||(mlti_chunk[2] != 'T')
||(mlti_chunk[3] != 'I'))
{
-#ifdef LOG
- printf("libreal: MLTI tag not detected, copying data\n");
-#endif
+ lprintf("MLTI tag not detected, copying data\n");
memcpy(out, mlti_chunk, mlti_size);
return mlti_size;
}
@@ -503,9 +494,7 @@ rmff_header_t *real_parse_sdp(char *data, char *stream_rules, uint32_t bandwidth
desc->abstract);
header->data=rmff_new_dataheader(0,0);
header->streams=xine_xmalloc(sizeof(rmff_mdpr_t*)*(desc->stream_count+1));
-#ifdef LOG
- printf("number of streams: %u\n", desc->stream_count);
-#endif
+ lprintf("number of streams: %u\n", desc->stream_count);
for (i=0; i<desc->stream_count; i++) {
@@ -514,14 +503,11 @@ rmff_header_t *real_parse_sdp(char *data, char *stream_rules, uint32_t bandwidth
char b[64];
int rulematches[16];
-#ifdef LOG
- printf("calling asmrp_match with:\n%s\n%u\n", desc->stream[i]->asm_rule_book, bandwidth);
-#endif
+ lprintf("calling asmrp_match with:\n%s\n%u\n", desc->stream[i]->asm_rule_book, bandwidth);
+
n=asmrp_match(desc->stream[i]->asm_rule_book, bandwidth, rulematches);
for (j=0; j<n; j++) {
-#ifdef LOG
- printf("asmrp rule match: %u for stream %u\n", rulematches[j], desc->stream[i]->stream_id);
-#endif
+ lprintf("asmrp rule match: %u for stream %u\n", rulematches[j], desc->stream[i]->stream_id);
sprintf(b,"stream=%u;rule=%u,", desc->stream[i]->stream_id, rulematches[j]);
strcat(stream_rules, b);
}
@@ -596,16 +582,14 @@ int real_get_rdt_chunk(rtsp_t *rtsp_session, char *buffer) {
flags1=header[4];
if ((flags1!=0x40)&&(flags1!=0x42))
{
-#ifdef LOG
- printf("got flags1: 0x%02x\n",flags1);
-#endif
+ lprintf("got flags1: 0x%02x\n",flags1);
header[0]=header[5];
header[1]=header[6];
header[2]=header[7];
n=rtsp_read_data(rtsp_session, header+3, 5);
if (n<5) return 0;
+ lprintf("ignoring bytes:\n");
#ifdef LOG
- printf("ignoring bytes:\n");
hexdump(header, 8);
#endif
n=rtsp_read_data(rtsp_session, header+4, 4);
@@ -618,10 +602,9 @@ int real_get_rdt_chunk(rtsp_t *rtsp_session, char *buffer) {
if (n<6) return 0;
ts=BE_32(header);
-#ifdef LOG
- printf("ts: %u size: %u, flags: 0x%02x, unknown values: %u 0x%02x 0x%02x\n",
+ lprintf("ts: %u size: %u, flags: 0x%02x, unknown values: %u 0x%02x 0x%02x\n",
ts, size, flags1, unknown1, header[4], header[5]);
-#endif
+
size+=2;
ph.object_version=0;
@@ -653,9 +636,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwid
/* get challenge */
challenge1=strdup(rtsp_search_answers(rtsp_session,"RealChallenge1"));
-#ifdef LOG
- printf("real: Challenge1: %s\n", challenge1);
-#endif
+ lprintf("Challenge1: %s\n", challenge1);
/* request stream description */
rtsp_schedule_field(rtsp_session, "Accept: application/sdp");
@@ -691,9 +672,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwid
else
session_id=strdup(rtsp_search_answers(rtsp_session,"ETag"));
-#ifdef LOG
- printf("real: Stream description size: %i\n", size);
-#endif
+ lprintf("Stream description size: %i\n", size);
description=malloc(sizeof(char)*(size+1));
@@ -706,10 +685,8 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwid
if (!h) return NULL;
rmff_fix_header(h);
-#ifdef LOG
- printf("Title: %s\nCopyright: %s\nAuthor: %s\nStreams: %i\n",
- h->cont->title, h->cont->copyright, h->cont->author, h->prop->num_streams);
-#endif
+ lprintf("Title: %s\nCopyright: %s\nAuthor: %s\nStreams: %i\n",
+ h->cont->title, h->cont->copyright, h->cont->author, h->prop->num_streams);
/* setup our streams */
real_calc_response_and_checksum (challenge2, checksum, challenge1);
diff --git a/src/input/libreal/rmff.c b/src/input/libreal/rmff.c
index bbdd398ec..a87b80f0c 100644
--- a/src/input/libreal/rmff.c
+++ b/src/input/libreal/rmff.c
@@ -17,19 +17,23 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: rmff.c,v 1.3 2002/12/24 01:30:22 holstsn Exp $
+ * $Id: rmff.c,v 1.4 2003/11/26 19:43:31 f1rmb Exp $
*
* functions for real media file format
* adopted from joschkas real tools
*/
#include <xineutils.h>
-#include "rmff.h"
+#define LOG_MODULE "rmff"
+#define LOG_VERBOSE
/*
#define LOG
*/
+#include "xineutils.h"
+#include "rmff.h"
+
#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
(((uint8_t*)(x))[1] << 16) | \
@@ -777,16 +781,14 @@ void rmff_fix_header(rmff_header_t *h) {
if (h->prop) {
if (h->prop->size != 50)
{
-#ifdef LOG
- printf("rmff_fix_header: correcting prop.size from %i to %i\n", h->prop->size, 50);
-#endif
+ lprintf("rmff_fix_header: correcting prop.size from %i to %i\n", h->prop->size, 50);
+
h->prop->size=50;
}
if (h->prop->num_streams != num_streams)
{
-#ifdef LOG
- printf("rmff_fix_header: correcting prop.num_streams from %i to %i\n", h->prop->num_streams, num_streams);
-#endif
+ lprintf("rmff_fix_header: correcting prop.num_streams from %i to %i\n", h->prop->num_streams, num_streams);
+
h->prop->num_streams=num_streams;
}
num_headers++;
@@ -801,9 +803,8 @@ void rmff_fix_header(rmff_header_t *h) {
printf("rmff_fix_header: warning: no CONT chunk.\n");
if (!h->data) {
-#ifdef LOG
- printf("rmff_fix_header: no DATA chunk, creating one\n");
-#endif
+ lprintf("rmff_fix_header: no DATA chunk, creating one\n");
+
h->data=malloc(sizeof(rmff_data_t));
h->data->object_id=DATA_TAG;
h->data->object_version=0;
@@ -815,9 +816,8 @@ void rmff_fix_header(rmff_header_t *h) {
if (!h->fileheader) {
-#ifdef LOG
- printf("rmff_fix_header: no fileheader, creating one");
-#endif
+ lprintf("rmff_fix_header: no fileheader, creating one");
+
h->fileheader=malloc(sizeof(rmff_fileheader_t));
h->fileheader->object_id=RMF_TAG;
h->fileheader->size=34;
@@ -829,36 +829,32 @@ void rmff_fix_header(rmff_header_t *h) {
num_headers++;
if(h->fileheader->num_headers != num_headers) {
-#ifdef LOG
- printf("rmff_fix_header: setting num_headers from %i to %i\n", h->fileheader->num_headers, num_headers);
-#endif
+ lprintf("rmff_fix_header: setting num_headers from %i to %i\n", h->fileheader->num_headers, num_headers);
+
h->fileheader->num_headers=num_headers;
}
if(h->prop) {
if (h->prop->data_offset != header_size) {
-#ifdef LOG
- printf("rmff_fix_header: setting prop.data_offset from %i to %i\n", h->prop->data_offset, header_size);
-#endif
+ lprintf("rmff_fix_header: setting prop.data_offset from %i to %i\n", h->prop->data_offset, header_size);
+
h->prop->data_offset=header_size;
}
if (h->prop->num_packets == 0) {
int p=(int)(h->prop->avg_bit_rate/8.0*(h->prop->duration/1000.0)/h->prop->avg_packet_size);
-#ifdef LOG
- printf("rmff_fix_header: assuming prop.num_packets=%i\n", p);
-#endif
+
+ lprintf("rmff_fix_header: assuming prop.num_packets=%i\n", p);
+
h->prop->num_packets=p;
}
if (h->data->num_packets == 0) {
-#ifdef LOG
- printf("rmff_fix_header: assuming data.num_packets=%i\n", h->prop->num_packets);
-#endif
+ lprintf("rmff_fix_header: assuming data.num_packets=%i\n", h->prop->num_packets);
+
h->data->num_packets=h->prop->num_packets;
}
-#ifdef LOG
- printf("rmff_fix_header: assuming data.size=%i\n", h->prop->num_packets*h->prop->avg_packet_size);
-#endif
+ lprintf("rmff_fix_header: assuming data.size=%i\n", h->prop->num_packets*h->prop->avg_packet_size);
+
h->data->size=h->prop->num_packets*h->prop->avg_packet_size;
}
}
diff --git a/src/input/libreal/sdpplin.c b/src/input/libreal/sdpplin.c
index cd1c49275..fb803dd91 100644
--- a/src/input/libreal/sdpplin.c
+++ b/src/input/libreal/sdpplin.c
@@ -17,21 +17,23 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: sdpplin.c,v 1.1 2002/12/24 01:30:22 holstsn Exp $
+ * $Id: sdpplin.c,v 1.2 2003/11/26 19:43:31 f1rmb Exp $
*
* sdp/sdpplin parser.
*
*/
-#include "rmff.h"
-#include "rtsp.h"
-#include "sdpplin.h"
-#include <xineutils.h>
-
+#define LOG_MODULE "sdpplin"
+#define LOG_VERBOSE
/*
#define LOG
*/
+#include "rmff.h"
+#include "rtsp.h"
+#include "sdpplin.h"
+#include "xineutils.h"
+
/*
* Decodes base64 strings (based upon b64 package)
*/
@@ -195,9 +197,7 @@ static sdpplin_stream_t *sdpplin_parse_stream(char **data) {
memcpy(desc->mlti_data, decoded, desc->mlti_data_size);
handled=1;
*data=nl(*data);
-#ifdef LOG
- printf("mlti_data_size: %i\n", desc->mlti_data_size);
-#endif
+ lprintf("mlti_data_size: %i\n", desc->mlti_data_size);
}
if(filter(*data,"a=ASMRuleBook:string;",&buf)) {
@@ -238,9 +238,7 @@ sdpplin_t *sdpplin_parse(char *data) {
if (filter(data, "m=", &buf)) {
stream=sdpplin_parse_stream(&data);
-#ifdef LOG
- printf("got data for stream id %u\n", stream->stream_id);
-#endif
+ lprintf("got data for stream id %u\n", stream->stream_id);
desc->stream[stream->stream_id]=stream;
continue;
}