-identify output: use ordered chapters length for ID_LENGTH
[mplayer/glamo.git] / TOOLS / realcodecs / rv30.c
blobbf02fe3a785e3fe93f7576115b8c26ab626fc0b1
1 /*
2 * This is a small DLL that works as a wrapper for the actual realrv30.so.6.0
3 * DLL from RealPlayer 8.0.
5 * This file is part of MPlayer.
7 * MPlayer is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * MPlayer is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 Assuming that RACloseCodec is the last call.
26 #include <stddef.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <dlfcn.h>
30 #include <sys/time.h>
32 typedef unsigned long ulong;
34 ulong (*pncOpen)(ulong,ulong);
35 ulong (*pncClose)(ulong);
36 ulong (*pncGetUIName)(ulong,ulong);
37 ulong (*pncGetVersion)(ulong,ulong);
38 ulong (*pncQueryMediaFormat)(ulong,ulong,ulong,ulong);
39 ulong (*pncPreferredMediaFormat)(ulong,ulong,ulong,ulong);
40 ulong (*pncGetMediaFormats)(ulong,ulong,ulong,ulong);
41 ulong (*pncStreamOpen)(ulong,ulong,ulong);
43 ulong (*pnsOpenSettingsBox)(ulong,ulong);
44 ulong (*pnsGetIPNUnknown)(ulong);
45 ulong (*pnsSetDataCallback)(ulong,ulong,ulong,ulong);
46 ulong (*pnsSetProperty)(ulong,ulong,ulong);
47 ulong (*pnsGetProperty)(ulong,ulong,ulong);
48 ulong (*pnsClose)(ulong);
49 ulong (*pnsGetStreamHeaderSize)(ulong,ulong);
50 ulong (*pnsGetStreamHeader)(ulong,ulong);
51 ulong (*pnsInput)(ulong,ulong,ulong);
52 ulong (*pnsSetOutputPacketSize)(ulong,ulong,ulong,ulong);
53 ulong (*pnsGetInputBufferSize)(ulong,ulong);
55 void (*setDLLAccessPath)(ulong);
57 int b_dlOpened=0;
58 void *handle=NULL;
60 /* exits program when failure */
61 void loadSyms(void) {
62 fputs("loadSyms()\n", stderr);
63 if (!b_dlOpened) {
64 char *error;
66 fputs("opening dll...\n", stderr);
67 handle = dlopen ("/usr/local/RealPlayer8/Codecs/realrv30.so.6.0", RTLD_LAZY);
68 if (!handle) {
69 fputs (dlerror(), stderr);
70 exit(1);
73 pncOpen = dlsym(handle, "PNCodec_Open");
74 if ((error = dlerror()) != NULL) {
75 fprintf (stderr, "dlsym(pncOpen): %s\n", error);
76 exit(1);
78 pncClose = dlsym(handle, "PNCodec_Close");
79 if ((error = dlerror()) != NULL) {
80 fprintf (stderr, "dlsym(pncClose): %s\n", error);
81 exit(1);
83 pncGetUIName = dlsym(handle, "PNCodec_GetUIName");
84 if ((error = dlerror()) != NULL) {
85 fprintf (stderr, "dlsym(pncGetUIName): %s\n", error);
86 exit(1);
88 pncGetVersion = dlsym(handle, "PNCodec_GetVersion");
89 if ((error = dlerror()) != NULL) {
90 fprintf (stderr, "dlsym(pncGetVersion): %s\n", error);
91 exit(1);
93 pncQueryMediaFormat = dlsym(handle, "PNCodec_QueryMediaFormat");
94 if ((error = dlerror()) != NULL) {
95 fprintf (stderr, "dlsym(pncQueryMediaFormat): %s\n", error);
96 exit(1);
98 pncPreferredMediaFormat = dlsym(handle, "PNCodec_PreferredMediaFormat");
99 if ((error = dlerror()) != NULL) {
100 fprintf (stderr, "dlsym(pncPreferredMediaFormat): %s\n", error);
101 exit(1);
103 pncGetMediaFormats = dlsym(handle, "PNCodec_GetMediaFormats");
104 if ((error = dlerror()) != NULL) {
105 fprintf (stderr, "dlsym(pncGetMediaFormats): %s\n", error);
106 exit(1);
108 pncStreamOpen = dlsym(handle, "PNCodec_StreamOpen");
109 if ((error = dlerror()) != NULL) {
110 fprintf (stderr, "dlsym(pncStreamOpen): %s\n", error);
111 exit(1);
114 pnsOpenSettingsBox = dlsym(handle, "PNStream_OpenSettingsBox");
115 if ((error = dlerror()) != NULL) {
116 fprintf (stderr, "dlsym(pnsOpenSettingsBox): %s\n", error);
117 exit(1);
119 pnsGetIPNUnknown = dlsym(handle, "PNStream_GetIPNUnknown");
120 if ((error = dlerror()) != NULL) {
121 fprintf (stderr, "dlsym(pnsGetIPNUnknown): %s\n", error);
122 exit(1);
124 pnsSetDataCallback = dlsym(handle, "PNStream_SetDataCallback");
125 if ((error = dlerror()) != NULL) {
126 fprintf (stderr, "dlsym(pnsSetDataCallback): %s\n", error);
127 exit(1);
129 pnsSetProperty = dlsym(handle, "PNStream_SetProperty");
130 if ((error = dlerror()) != NULL) {
131 fprintf (stderr, "dlsym(pnsSetProperty): %s\n", error);
132 exit(1);
134 pnsGetProperty = dlsym(handle, "PNStream_GetProperty");
135 if ((error = dlerror()) != NULL) {
136 fprintf (stderr, "dlsym(pnsGetProperty): %s\n", error);
137 exit(1);
139 pnsClose = dlsym(handle, "PNStream_Close");
140 if ((error = dlerror()) != NULL) {
141 fprintf (stderr, "dlsym(pnsClose): %s\n", error);
142 exit(1);
144 pnsGetStreamHeaderSize = dlsym(handle, "PNStream_GetStreamHeaderSize");
145 if ((error = dlerror()) != NULL) {
146 fprintf (stderr, "dlsym(pnsGetStreamHeaderSize): %s\n", error);
147 exit(1);
149 pnsGetStreamHeader = dlsym(handle, "PNStream_GetStreamHeader");
150 if ((error = dlerror()) != NULL) {
151 fprintf (stderr, "dlsym(pnsGetStreamHeader): %s\n", error);
152 exit(1);
154 pnsInput = dlsym(handle, "PNStream_Input");
155 if ((error = dlerror()) != NULL) {
156 fprintf (stderr, "dlsym(pnsInput): %s\n", error);
157 exit(1);
159 pnsSetOutputPacketSize = dlsym(handle, "PNStream_SetOutputPacketSize");
160 if ((error = dlerror()) != NULL) {
161 fprintf (stderr, "dlsym(pnsSetOutputPacketSize): %s\n", error);
162 exit(1);
164 pnsGetInputBufferSize = dlsym(handle, "PNStream_GetInputBufferSize");
165 if ((error = dlerror()) != NULL) {
166 fprintf (stderr, "dlsym(pnsGetInputBufferSize): %s\n", error);
167 exit(1);
169 setDLLAccessPath = dlsym(handle, "SetDLLAccessPath");
170 if ((error = dlerror()) != NULL) {
171 fprintf (stderr, "dlsym(SetDLLAccessPath): %s\n", error);
172 exit(1);
174 b_dlOpened=1;
178 void closeDll(void) {
179 if (handle) {
180 b_dlOpened=0;
181 dlclose(handle);
182 handle=NULL;
186 void _init(void) {
187 loadSyms();
190 struct timezone tz;
191 struct timeval tv1, tv2;
193 void tic(void) {
194 gettimeofday(&tv1, &tz);
197 void toc(void) {
198 long secs, usecs;
199 gettimeofday(&tv2, &tz);
200 secs=tv2.tv_sec-tv1.tv_sec;
201 usecs=tv2.tv_usec-tv1.tv_usec;
202 if (usecs<0) {
203 usecs+=1000000;
204 --secs;
206 fprintf(stderr, "Duration: %ld.%.6lds\n", secs, usecs);
210 void hexdump(void *pos, int len) {
211 unsigned char *cpos=pos, *cpos1;
212 int lines=(len+15)>>4;
213 while(lines--) {
214 int len1=len, i;
215 fprintf(stderr, "%0x ", cpos);
216 cpos1=cpos;
217 for (i=0;i<16;i++) {
218 if (len1>0) {
219 fprintf(stderr, "%02x ", *(cpos++));
220 } else {
221 fprintf(stderr, " ");
223 len1--;
225 fputs(" ", stderr);
226 cpos=cpos1;
227 for (i=0;i<16;i++) {
228 if (len>0) {
229 unsigned char ch=(*(cpos++));
230 if ((ch<32)||(ch>127)) ch='.';
231 fputc(ch, stderr);
233 len--;
235 fputs("\n", stderr);
237 fputc('\n', stderr);
241 ulong PNCodec_Open(ulong p1,ulong p2) {
242 ulong result;
243 fprintf(stderr, "PNCodec_Open(ulong fourcc=0x%0lx(%ld), ", p1, p1);
244 fprintf(stderr, "PNCMain **pncMain=0x%0lx(%ld))\n", p2, p2);
245 // hexdump((void*)p1, 44);
246 tic();
247 result=(*pncOpen)(p1,p2);
248 toc();
249 hexdump((void*)p2, 4);
250 // hexdump(*((void**)p2), 0x1278);
251 fprintf(stderr, "PNCodec_Open --> 0x%0lx(%ld)\n\n\n", result, result);
252 return result;
255 ulong PNCodec_Close(ulong p1) {
256 ulong result;
257 fprintf(stderr, "PNCodec_Close(PNCMain *pncMain=0x%0lx(%ld))\n", p1, p1);
258 // hexdump((void*)p1, 44);
259 tic();
260 result=(*pncClose)(p1);
261 toc();
262 // hexdump((void*)p1, 44);
263 fprintf(stderr, "PNCodec_Close --> 0x%0lx(%ld)\n\n\n", result, result);
264 return result;
267 ulong PNCodec_GetUIName(ulong p1,ulong p2) {
268 ulong result;
269 fprintf(stderr, "PNCodec_GetUIName(PNCMain *pncMain=0x%0lx(%ld), ", p1, p1);
270 fprintf(stderr, "char **appname=0x%0lx(%ld))\n", p2, p2);
271 // hexdump((void*)p1, 0x1278);
272 // hexdump((void*)p2, 128);
273 tic();
274 result=(*pncGetUIName)(p1,p2);
275 toc();
276 // hexdump((void*)p1, 0x1278);
277 // hexdump((void*)p2, 128);
278 fprintf(stderr, "PNCodec_GetUIName --> 0x%0lx(%ld)\n\n\n", result, result);
279 return result;
282 ulong PNCodec_GetVersion(ulong p1,ulong p2) {
283 ulong result;
284 fprintf(stderr, "PNCodec_GetVersion(ulong p1=0x%0lx(%ld), ", p1, p1);
285 fprintf(stderr, "ulong p2=0x%0lx(%ld))\n", p2, p2);
286 // hexdump((void*)p1, 44);
287 tic();
288 result=(*pncGetVersion)(p1,p2);
289 toc();
290 // hexdump((void*)p1, 44);
291 fprintf(stderr, "PNCodec_GetVersion --> 0x%0lx(%ld)\n\n\n", result, result);
292 return result;
295 ulong PNCodec_QueryMediaFormat(ulong p1,ulong p2,ulong p3,ulong p4) {
296 ulong result;
297 fprintf(stderr, "PNCodec_QueryMediaFormat(ulong p1=0x%0lx(%ld), ", p1, p1);
298 fprintf(stderr, "ulong p2=0x%0lx(%ld),\n\t", p2, p2);
299 fprintf(stderr, "ulong p3=0x%0lx(%ld),", p3, p3);
300 fprintf(stderr, "ulong p4=0x%0lx(%ld),\n", p4, p4);
301 // hexdump((void*)p1, 44);
302 tic();
303 result=(*pncQueryMediaFormat)(p1,p2,p3,p4);
304 toc();
305 // hexdump((void*)p1, 44);
306 fprintf(stderr, "PNCodec_QueryMediaFormat --> 0x%0lx(%ld)\n\n\n", result, result);
307 return result;
310 ulong PNCodec_PreferredMediaFormat(ulong p1,ulong p2,ulong p3,ulong p4) {
311 ulong result;
312 fprintf(stderr, "PNCodec_PreferredMediaFormat(ulong p1=0x%0lx(%ld), ", p1, p1);
313 fprintf(stderr, "ulong p2=0x%0lx(%ld),\n\t", p2, p2);
314 fprintf(stderr, "ulong p3=0x%0lx(%ld),", p3, p3);
315 fprintf(stderr, "ulong p4=0x%0lx(%ld),\n", p4, p4);
316 // hexdump((void*)p1, 44);
317 tic();
318 result=(*pncPreferredMediaFormat)(p1,p2,p3,p4);
319 toc();
320 // hexdump((void*)p1, 44);
321 fprintf(stderr, "PNCodec_PreferredMediaFormat --> 0x%0lx(%ld)\n\n\n", result, result);
322 return result;
325 ulong PNCodec_GetMediaFormats(ulong p1,ulong p2,ulong p3,ulong p4) {
326 ulong result;
327 fprintf(stderr, "PNCodec_GetMediaFormats(ulong p1=0x%0lx(%ld), ", p1, p1);
328 fprintf(stderr, "ulong p2=0x%0lx(%ld),\n\t", p2, p2);
329 fprintf(stderr, "ulong p3=0x%0lx(%ld),", p3, p3);
330 fprintf(stderr, "ulong p4=0x%0lx(%ld),\n", p4, p4);
331 // hexdump((void*)p1, 44);
332 tic();
333 result=(*pncGetMediaFormats)(p1,p2,p3,p4);
334 toc();
335 // hexdump((void*)p1, 44);
336 fprintf(stderr, "PNCodec_GetMediaFormats --> 0x%0lx(%ld)\n\n\n", result, result);
337 return result;
340 ulong PNCodec_StreamOpen(ulong p1,ulong p2,ulong p3) {
341 ulong result;
342 fprintf(stderr, "PNCodec_StreamOpen(PNCMain *pncMain=0x%0lx(%ld), ", p1, p1);
343 fprintf(stderr, "PNSMain **pnsMain=0x%0lx(%ld),\n\t", p2, p2);
344 fprintf(stderr, "ulong **p3=0x%0lx(%ld),\n", p3, p3);
345 // hexdump((void*)p1, 0x1278);
346 // hexdump((void*)p2, 128);
347 // hexdump((void*)p3, 4);
348 hexdump(*((void**)p3), 4);
349 tic();
350 result=(*pncStreamOpen)(p1,p2,p3);
351 toc();
352 // hexdump((void*)p1, 0x1278);
353 hexdump((void*)p2, 4);
354 // hexdump((void*)p3, 128);
355 hexdump(*((void**)p2), 128);
356 hexdump(**((void***)p2), 128);
357 fprintf(stderr, "PNCodec_StreamOpen --> 0x%0lx(%ld)\n\n\n", result, result);
358 return result;
361 ulong PNStream_OpenSettingsBox(ulong p1,ulong p2) {
362 ulong result;
363 fprintf(stderr, "PNStream_OpenSettingsBox(ulong p1=0x%0lx(%ld), ", p1, p1);
364 fprintf(stderr, "ulong p2=0x%0lx(%ld),\n", p2, p2);
365 // hexdump((void*)p1, 44);
366 tic();
367 result=(*pnsOpenSettingsBox)(p1,p2);
368 toc();
369 // hexdump((void*)p1, 44);
370 fprintf(stderr, "PNStream_OpenSettingsBox --> 0x%0lx(%ld)\n\n\n", result, result);
371 return result;
374 ulong PNStream_GetIPNUnknown(ulong p1) {
375 ulong result;
376 fprintf(stderr, "PNStream_GetIPNUnknown(ulong p1=0x%0lx(%ld))\n", p1, p1);
377 // hexdump((void*)p1, 44);
378 tic();
379 result=(*pnsGetIPNUnknown)(p1);
380 toc();
381 // hexdump((void*)p1, 44);
382 fprintf(stderr, "PNStream_GetIPNUnknown --> 0x%0lx(%ld)\n\n\n", result, result);
383 return result;
386 ulong PNStream_SetDataCallback(ulong p1,ulong p2,ulong p3,ulong p4) {
387 ulong result;
388 int i=0;
389 void **pp;
390 fprintf(stderr, "PNStream_SetDataCallback(ulong p1=0x%0lx(%ld), ", p1, p1);
391 fprintf(stderr, "ulong p2=0x%0lx(%ld),\n\t", p2, p2);
392 fprintf(stderr, "ulong p3=0x%0lx(%ld),", p3, p3);
393 fprintf(stderr, "ulong p4=0x%0lx(%ld))\n", p4, p4);
394 hexdump((void*)p1, 0x24);
395 hexdump((void*)p2, 32);
396 hexdump((void*)p3, 4);
397 hexdump((void*)p4, 32);
398 fprintf(stderr, "content of the callback functions:\n\n");
399 while(i<8) {
400 hexdump(*((void**)p2+i), (i==0)?32*4:16);
401 i++;
403 i=0;
404 pp=(*(void***)p2);
405 fprintf(stderr, "content of the callback functions (first entry):\n\n");
406 while(i<15) {
407 hexdump(*((void**)pp+i), 32);
408 i++;
411 tic();
412 result=(*pnsSetDataCallback)(p1,p2,p3,p4);
413 toc();
414 hexdump((void*)p1, 0x24);
415 // hexdump((void*)p2, 256);
416 // hexdump((void*)p3, 4);
417 hexdump(*((void**)p3), 256);
418 fprintf(stderr, "PNStream_SetDataCallback --> 0x%0lx(%ld)\n\n\n", result, result);
419 return result;
422 ulong PNStream_SetProperty(ulong p1,ulong p2,ulong p3) {
423 ulong result;
424 fprintf(stderr, "PNStream_SetProperty(ulong p1=0x%0lx(%ld), ", p1, p1);
425 fprintf(stderr, "ulong p2=0x%0lx(%ld),\n\t", p2, p2);
426 fprintf(stderr, "ulong p3=0x%0lx(%ld))\n", p3, p3);
427 hexdump((void*)p3, 4);
428 tic();
429 result=(*pnsSetProperty)(p1,p2,p3);
430 toc();
431 // hexdump((void*)p3, 44);
432 fprintf(stderr, "PNStream_SetProperty --> 0x%0lx(%ld)\n\n\n", result, result);
433 return result;
436 ulong PNStream_GetProperty(ulong p1,ulong p2,ulong p3) {
437 ulong result;
438 fprintf(stderr, "PNStream_GetProperty(ulong p1=0x%0lx(%ld), ", p1, p1);
439 fprintf(stderr, "ulong p2=0x%0lx(%ld),\n\t", p2, p2);
440 fprintf(stderr, "ulong p3=0x%0lx(%ld))\n", p3, p3);
441 // hexdump((void*)p3, 44);
442 tic();
443 result=(*pnsGetProperty)(p1,p2,p3);
444 toc();
445 hexdump((void*)p3, 4);
446 fprintf(stderr, "PNStream_GetProperty --> 0x%0lx(%ld)\n\n\n", result, result);
447 return result;
450 ulong PNStream_Close(ulong p1) {
451 ulong result;
452 fprintf(stderr, "PNStream_Close(ulong p1=0x%0lx(%ld))\n", p1, p1);
453 // hexdump((void*)p1, 44);
454 tic();
455 result=(*pnsClose)(p1);
456 toc();
457 // hexdump((void*)p1, 44);
458 fprintf(stderr, "PNStream_Close --> 0x%0lx(%ld)\n\n\n", result, result);
459 return result;
462 ulong streamHeaderSize=0;
464 ulong PNStream_GetStreamHeaderSize(ulong p1,ulong p2) {
465 ulong result;
466 fprintf(stderr, "PNStream_GetStreamHeaderSize(ulong p1=0x%0lx(%ld), ", p1, p1);
467 fprintf(stderr, "ulong p2=0x%0lx(%ld),\n", p2, p2);
468 // hexdump((void*)p2, 44);
469 tic();
470 result=(*pnsGetStreamHeaderSize)(p1,p2);
471 toc();
472 hexdump((void*)p2, 4);
473 streamHeaderSize=*((ulong *)p2);
474 fprintf(stderr, "PNStream_GetStreamHeaderSize --> 0x%0lx(%ld)\n\n\n", result, result);
475 return result;
478 ulong PNStream_GetStreamHeader(ulong p1,ulong p2) {
479 ulong result;
480 fprintf(stderr, "PNStream_GetStreamHeader(ulong p1=0x%0lx(%ld), ", p1, p1);
481 fprintf(stderr, "ulong p2=0x%0lx(%ld),\n", p2, p2);
482 // hexdump((void*)p2, 44);
483 tic();
484 result=(*pnsGetStreamHeader)(p1,p2);
485 toc();
486 hexdump((void*)p2, streamHeaderSize);
487 fprintf(stderr, "PNStream_GetStreamHeader --> 0x%0lx(%ld)\n\n\n", result, result);
488 return result;
491 ulong PNStream_Input(ulong p1,ulong p2,ulong p3) {
492 ulong result;
493 fprintf(stderr, "PNStream_Input(ulong p1=0x%0lx(%ld), ", p1, p1);
494 fprintf(stderr, "ulong p2=0x%0lx(%ld),\n\t", p2, p2);
495 fprintf(stderr, "ulong p3=0x%0lx(%ld))\n", p3, p3);
496 hexdump((void*)p3, 4);
497 tic();
498 result=(*pnsInput)(p1,p2,p3);
499 toc();
500 // hexdump((void*)p3, 44);
501 fprintf(stderr, "PNStream_Input --> 0x%0lx(%ld)\n\n\n", result, result);
502 return result;
505 ulong PNStream_SetOutputPacketSize(ulong p1,ulong p2,ulong p3,ulong p4) {
506 ulong result;
507 fprintf(stderr, "PNStream_SetOutputPacketSize(ulong p1=0x%0lx(%ld), ", p1, p1);
508 fprintf(stderr, "ulong p2=0x%0lx(%ld),\n\t", p2, p2);
509 fprintf(stderr, "ulong p3=0x%0lx(%ld),", p3, p3);
510 fprintf(stderr, "ulong p4=0x%0lx(%ld))\n", p4, p4);
511 // hexdump((void*)p1, 44);
512 tic();
513 result=(*pnsSetOutputPacketSize)(p1,p2,p3,p4);
514 toc();
515 // hexdump((void*)p1, 44);
516 fprintf(stderr, "PNStream_SetOutputPacketSize --> 0x%0lx(%ld)\n\n\n", result, result);
517 return result;
520 ulong PNStream_GetInputBufferSize(ulong p1,ulong p2) {
521 ulong result;
522 fprintf(stderr, "PNStream_GetInputBufferSize(ulong p1=0x%0lx(%ld), ", p1, p1);
523 fprintf(stderr, "ulong p2=0x%0lx(%ld))\n", p2, p2);
524 // hexdump((void*)p1, 44);
525 tic();
526 result=(*pnsGetInputBufferSize)(p1,p2);
527 toc();
528 // hexdump((void*)p1, 44);
529 fprintf(stderr, "PNStream_GetInputBufferSize --> 0x%0lx(%ld)\n\n\n", result, result);
530 return result;
533 void SetDLLAccessPath(ulong p1) {
534 fprintf(stderr, "SetDLLAccessPath(ulong p1=0x%0lx(%ld))\n", p1, p1);
535 // hexdump((void*)p1, 44);
536 (*setDLLAccessPath)(p1);
537 // hexdump((void*)p1, 44);
538 fprintf(stderr, "--> void\n\n\n");