comparison TOOLS/realcodecs/rv30.c @ 7110:86c478bea7ce

realplayer codecs wrappers, originaly written by Florian Schneider, extended by A'rpi
author arpi
date Wed, 28 Aug 2002 14:17:06 +0000
parents
children 42376fcd704b
comparison
equal deleted inserted replaced
7109:4c51b2ae28c7 7110:86c478bea7ce
1 /*
2 GPL v2 blah blah
3
4 This is a small dll that works as a wrapper for the actual cook.so.6.0
5 dll from real player 8.0.
6 */
7
8 /*
9 Assuming that RACloseCodec is the last call.
10 */
11
12 #include <stddef.h>
13 #include <stdio.h>
14 #include <dlfcn.h>
15 #include <sys/time.h>
16
17 typedef unsigned long ulong;
18
19 ulong (*pncOpen)(ulong,ulong);
20 ulong (*pncClose)(ulong);
21 ulong (*pncGetUIName)(ulong,ulong);
22 ulong (*pncGetVersion)(ulong,ulong);
23 ulong (*pncQueryMediaFormat)(ulong,ulong,ulong,ulong);
24 ulong (*pncPreferredMediaFormat)(ulong,ulong,ulong,ulong);
25 ulong (*pncGetMediaFormats)(ulong,ulong,ulong,ulong);
26 ulong (*pncStreamOpen)(ulong,ulong,ulong);
27
28 ulong (*pnsOpenSettingsBox)(ulong,ulong);
29 ulong (*pnsGetIPNUnknown)(ulong);
30 ulong (*pnsSetDataCallback)(ulong,ulong,ulong,ulong);
31 ulong (*pnsSetProperty)(ulong,ulong,ulong);
32 ulong (*pnsGetProperty)(ulong,ulong,ulong);
33 ulong (*pnsClose)(ulong);
34 ulong (*pnsGetStreamHeaderSize)(ulong,ulong);
35 ulong (*pnsGetStreamHeader)(ulong,ulong);
36 ulong (*pnsInput)(ulong,ulong,ulong);
37 ulong (*pnsSetOutputPacketSize)(ulong,ulong,ulong,ulong);
38 ulong (*pnsGetInputBufferSize)(ulong,ulong);
39
40 void (*setDLLAccessPath)(ulong);
41
42 int b_dlOpened=0;
43 void *handle=NULL;
44
45 /* exits program when failure */
46 void loadSyms() {
47 fputs("loadSyms()\n", stderr);
48 if (!b_dlOpened) {
49 char *error;
50
51 fputs("opening dll...\n");
52 handle = dlopen ("/usr/local/RealPlayer8/Codecs/realrv30.so.6.0", RTLD_LAZY);
53 if (!handle) {
54 fputs (dlerror(), stderr);
55 exit(1);
56 }
57
58 pncOpen = dlsym(handle, "PNCodec_Open");
59 if ((error = dlerror()) != NULL) {
60 fprintf (stderr, "dlsym(pncOpen): %s\n", error);
61 exit(1);
62 }
63 pncClose = dlsym(handle, "PNCodec_Close");
64 if ((error = dlerror()) != NULL) {
65 fprintf (stderr, "dlsym(pncClose): %s\n", error);
66 exit(1);
67 }
68 pncGetUIName = dlsym(handle, "PNCodec_GetUIName");
69 if ((error = dlerror()) != NULL) {
70 fprintf (stderr, "dlsym(pncGetUIName): %s\n", error);
71 exit(1);
72 }
73 pncGetVersion = dlsym(handle, "PNCodec_GetVersion");
74 if ((error = dlerror()) != NULL) {
75 fprintf (stderr, "dlsym(pncGetVersion): %s\n", error);
76 exit(1);
77 }
78 pncQueryMediaFormat = dlsym(handle, "PNCodec_QueryMediaFormat");
79 if ((error = dlerror()) != NULL) {
80 fprintf (stderr, "dlsym(pncQueryMediaFormat): %s\n", error);
81 exit(1);
82 }
83 pncPreferredMediaFormat = dlsym(handle, "PNCodec_PreferredMediaFormat");
84 if ((error = dlerror()) != NULL) {
85 fprintf (stderr, "dlsym(pncPreferredMediaFormat): %s\n", error);
86 exit(1);
87 }
88 pncGetMediaFormats = dlsym(handle, "PNCodec_GetMediaFormats");
89 if ((error = dlerror()) != NULL) {
90 fprintf (stderr, "dlsym(pncGetMediaFormats): %s\n", error);
91 exit(1);
92 }
93 pncStreamOpen = dlsym(handle, "PNCodec_StreamOpen");
94 if ((error = dlerror()) != NULL) {
95 fprintf (stderr, "dlsym(pncStreamOpen): %s\n", error);
96 exit(1);
97 }
98
99 pnsOpenSettingsBox = dlsym(handle, "PNStream_OpenSettingsBox");
100 if ((error = dlerror()) != NULL) {
101 fprintf (stderr, "dlsym(pnsOpenSettingsBox): %s\n", error);
102 exit(1);
103 }
104 pnsGetIPNUnknown = dlsym(handle, "PNStream_GetIPNUnknown");
105 if ((error = dlerror()) != NULL) {
106 fprintf (stderr, "dlsym(pnsGetIPNUnknown): %s\n", error);
107 exit(1);
108 }
109 pnsSetDataCallback = dlsym(handle, "PNStream_SetDataCallback");
110 if ((error = dlerror()) != NULL) {
111 fprintf (stderr, "dlsym(pnsSetDataCallback): %s\n", error);
112 exit(1);
113 }
114 pnsSetProperty = dlsym(handle, "PNStream_SetProperty");
115 if ((error = dlerror()) != NULL) {
116 fprintf (stderr, "dlsym(pnsSetProperty): %s\n", error);
117 exit(1);
118 }
119 pnsGetProperty = dlsym(handle, "PNStream_GetProperty");
120 if ((error = dlerror()) != NULL) {
121 fprintf (stderr, "dlsym(pnsGetProperty): %s\n", error);
122 exit(1);
123 }
124 pnsClose = dlsym(handle, "PNStream_Close");
125 if ((error = dlerror()) != NULL) {
126 fprintf (stderr, "dlsym(pnsClose): %s\n", error);
127 exit(1);
128 }
129 pnsGetStreamHeaderSize = dlsym(handle, "PNStream_GetStreamHeaderSize");
130 if ((error = dlerror()) != NULL) {
131 fprintf (stderr, "dlsym(pnsGetStreamHeaderSize): %s\n", error);
132 exit(1);
133 }
134 pnsGetStreamHeader = dlsym(handle, "PNStream_GetStreamHeader");
135 if ((error = dlerror()) != NULL) {
136 fprintf (stderr, "dlsym(pnsGetStreamHeader): %s\n", error);
137 exit(1);
138 }
139 pnsInput = dlsym(handle, "PNStream_Input");
140 if ((error = dlerror()) != NULL) {
141 fprintf (stderr, "dlsym(pnsInput): %s\n", error);
142 exit(1);
143 }
144 pnsSetOutputPacketSize = dlsym(handle, "PNStream_SetOutputPacketSize");
145 if ((error = dlerror()) != NULL) {
146 fprintf (stderr, "dlsym(pnsSetOutputPacketSize): %s\n", error);
147 exit(1);
148 }
149 pnsGetInputBufferSize = dlsym(handle, "PNStream_GetInputBufferSize");
150 if ((error = dlerror()) != NULL) {
151 fprintf (stderr, "dlsym(pnsGetInputBufferSize): %s\n", error);
152 exit(1);
153 }
154 setDLLAccessPath = dlsym(handle, "SetDLLAccessPath");
155 if ((error = dlerror()) != NULL) {
156 fprintf (stderr, "dlsym(SetDLLAccessPath): %s\n", error);
157 exit(1);
158 }
159 b_dlOpened=1;
160 }
161 }
162
163 void closeDll() {
164 if (handle) {
165 b_dlOpened=0;
166 dlclose(handle);
167 handle=NULL;
168 }
169 }
170
171 void _init(void) {
172 loadSyms();
173 }
174
175 struct timezone tz;
176 struct timeval tv1, tv2;
177
178 void tic() {
179 gettimeofday(&tv1, &tz);
180 }
181
182 void toc() {
183 long secs, usecs;
184 gettimeofday(&tv2, &tz);
185 secs=tv2.tv_sec-tv1.tv_sec;
186 usecs=tv2.tv_usec-tv1.tv_usec;
187 if (usecs<0) {
188 usecs+=1000000;
189 --secs;
190 }
191 fprintf(stderr, "Duration: %d.%0.6ds\n", secs, usecs);
192 }
193
194
195 void hexdump(void *pos, int len) {
196 unsigned char *cpos=pos, *cpos1;
197 int lines=(len+15)>>4;
198 while(lines--) {
199 int len1=len, i;
200 fprintf(stderr, "%0x ", cpos);
201 cpos1=cpos;
202 for (i=0;i<16;i++) {
203 if (len1>0) {
204 fprintf(stderr, "%02x ", *(cpos++));
205 } else {
206 fprintf(stderr, " ");
207 }
208 len1--;
209 }
210 fputs(" ", stderr);
211 cpos=cpos1;
212 for (i=0;i<16;i++) {
213 if (len>0) {
214 unsigned char ch=(*(cpos++));
215 if ((ch<32)||(ch>127)) ch='.';
216 fputc(ch, stderr);
217 }
218 len--;
219 }
220 fputs("\n", stderr);
221 }
222 fputc('\n', stderr);
223 }
224
225
226 ulong PNCodec_Open(ulong p1,ulong p2) {
227 ulong result;
228 fprintf(stderr, "PNCodec_Open(ulong fourcc=0x%0x(%d), ", p1, p1);
229 fprintf(stderr, "PNCMain **pncMain=0x%0x(%d))\n", p2, p2);
230 // hexdump((void*)p1, 44);
231 tic();
232 result=(*pncOpen)(p1,p2);
233 toc();
234 hexdump((void*)p2, 4);
235 // hexdump(*((void**)p2), 0x1278);
236 fprintf(stderr, "PNCodec_Open --> 0x%0x(%d)\n\n\n", result, result);
237 return result;
238 }
239
240 ulong PNCodec_Close(ulong p1) {
241 ulong result;
242 fprintf(stderr, "PNCodec_Close(PNCMain *pncMain=0x%0x(%d))\n", p1, p1);
243 // hexdump((void*)p1, 44);
244 tic();
245 result=(*pncClose)(p1);
246 toc();
247 // hexdump((void*)p1, 44);
248 fprintf(stderr, "PNCodec_Close --> 0x%0x(%d)\n\n\n", result, result);
249 return result;
250 }
251
252 ulong PNCodec_GetUIName(ulong p1,ulong p2) {
253 ulong result;
254 fprintf(stderr, "PNCodec_GetUIName(PNCMain *pncMain=0x%0x(%d), ", p1, p1);
255 fprintf(stderr, "char **appname=0x%0x(%d))\n", p2, p2);
256 // hexdump((void*)p1, 0x1278);
257 // hexdump((void*)p2, 128);
258 tic();
259 result=(*pncGetUIName)(p1,p2);
260 toc();
261 // hexdump((void*)p1, 0x1278);
262 // hexdump((void*)p2, 128);
263 fprintf(stderr, "PNCodec_GetUIName --> 0x%0x(%d)\n\n\n", result, result);
264 return result;
265 }
266
267 ulong PNCodec_GetVersion(ulong p1,ulong p2) {
268 ulong result;
269 fprintf(stderr, "PNCodec_GetVersion(ulong p1=0x%0x(%d), ", p1, p1);
270 fprintf(stderr, "ulong p2=0x%0x(%d))\n", p2, p2);
271 // hexdump((void*)p1, 44);
272 tic();
273 result=(*pncGetVersion)(p1,p2);
274 toc();
275 // hexdump((void*)p1, 44);
276 fprintf(stderr, "PNCodec_GetVersion --> 0x%0x(%d)\n\n\n", result, result);
277 return result;
278 }
279
280 ulong PNCodec_QueryMediaFormat(ulong p1,ulong p2,ulong p3,ulong p4) {
281 ulong result;
282 fprintf(stderr, "PNCodec_QueryMediaFormat(ulong p1=0x%0x(%d), ", p1, p1);
283 fprintf(stderr, "ulong p2=0x%0x(%d),\n\t", p2, p2);
284 fprintf(stderr, "ulong p3=0x%0x(%d),", p3, p3);
285 fprintf(stderr, "ulong p4=0x%0x(%d),\n", p4, p4);
286 // hexdump((void*)p1, 44);
287 tic();
288 result=(*pncQueryMediaFormat)(p1,p2,p3,p4);
289 toc();
290 // hexdump((void*)p1, 44);
291 fprintf(stderr, "PNCodec_QueryMediaFormat --> 0x%0x(%d)\n\n\n", result, result);
292 return result;
293 }
294
295 ulong PNCodec_PreferredMediaFormat(ulong p1,ulong p2,ulong p3,ulong p4) {
296 ulong result;
297 fprintf(stderr, "PNCodec_PreferredMediaFormat(ulong p1=0x%0x(%d), ", p1, p1);
298 fprintf(stderr, "ulong p2=0x%0x(%d),\n\t", p2, p2);
299 fprintf(stderr, "ulong p3=0x%0x(%d),", p3, p3);
300 fprintf(stderr, "ulong p4=0x%0x(%d),\n", p4, p4);
301 // hexdump((void*)p1, 44);
302 tic();
303 result=(*pncPreferredMediaFormat)(p1,p2,p3,p4);
304 toc();
305 // hexdump((void*)p1, 44);
306 fprintf(stderr, "PNCodec_PreferredMediaFormat --> 0x%0x(%d)\n\n\n", result, result);
307 return result;
308 }
309
310 ulong PNCodec_GetMediaFormats(ulong p1,ulong p2,ulong p3,ulong p4) {
311 ulong result;
312 fprintf(stderr, "PNCodec_GetMediaFormats(ulong p1=0x%0x(%d), ", p1, p1);
313 fprintf(stderr, "ulong p2=0x%0x(%d),\n\t", p2, p2);
314 fprintf(stderr, "ulong p3=0x%0x(%d),", p3, p3);
315 fprintf(stderr, "ulong p4=0x%0x(%d),\n", p4, p4);
316 // hexdump((void*)p1, 44);
317 tic();
318 result=(*pncGetMediaFormats)(p1,p2,p3,p4);
319 toc();
320 // hexdump((void*)p1, 44);
321 fprintf(stderr, "PNCodec_GetMediaFormats --> 0x%0x(%d)\n\n\n", result, result);
322 return result;
323 }
324
325 ulong PNCodec_StreamOpen(ulong p1,ulong p2,ulong p3) {
326 ulong result;
327 fprintf(stderr, "PNCodec_StreamOpen(PNCMain *pncMain=0x%0x(%d), ", p1, p1);
328 fprintf(stderr, "PNSMain **pnsMain=0x%0x(%d),\n\t", p2, p2);
329 fprintf(stderr, "ulong **p3=0x%0x(%d),\n", p3, p3);
330 // hexdump((void*)p1, 0x1278);
331 // hexdump((void*)p2, 128);
332 // hexdump((void*)p3, 4);
333 hexdump(*((void**)p3), 4);
334 tic();
335 result=(*pncStreamOpen)(p1,p2,p3);
336 toc();
337 // hexdump((void*)p1, 0x1278);
338 hexdump((void*)p2, 4);
339 // hexdump((void*)p3, 128);
340 hexdump(*((void**)p2), 128);
341 hexdump(**((void***)p2), 128);
342 fprintf(stderr, "PNCodec_StreamOpen --> 0x%0x(%d)\n\n\n", result, result);
343 return result;
344 }
345
346 ulong PNStream_OpenSettingsBox(ulong p1,ulong p2) {
347 ulong result;
348 fprintf(stderr, "PNStream_OpenSettingsBox(ulong p1=0x%0x(%d), ", p1, p1);
349 fprintf(stderr, "ulong p2=0x%0x(%d),\n", p2, p2);
350 // hexdump((void*)p1, 44);
351 tic();
352 result=(*pnsOpenSettingsBox)(p1,p2);
353 toc();
354 // hexdump((void*)p1, 44);
355 fprintf(stderr, "PNStream_OpenSettingsBox --> 0x%0x(%d)\n\n\n", result, result);
356 return result;
357 }
358
359 ulong PNStream_GetIPNUnknown(ulong p1) {
360 ulong result;
361 fprintf(stderr, "PNStream_GetIPNUnknown(ulong p1=0x%0x(%d))\n", p1, p1);
362 // hexdump((void*)p1, 44);
363 tic();
364 result=(*pnsGetIPNUnknown)(p1);
365 toc();
366 // hexdump((void*)p1, 44);
367 fprintf(stderr, "PNStream_GetIPNUnknown --> 0x%0x(%d)\n\n\n", result, result);
368 return result;
369 }
370
371 ulong PNStream_SetDataCallback(ulong p1,ulong p2,ulong p3,ulong p4) {
372 ulong result;
373 int i=0;
374 void **pp;
375 fprintf(stderr, "PNStream_SetDataCallback(ulong p1=0x%0x(%d), ", p1, p1);
376 fprintf(stderr, "ulong p2=0x%0x(%d),\n\t", p2, p2);
377 fprintf(stderr, "ulong p3=0x%0x(%d),", p3, p3);
378 fprintf(stderr, "ulong p4=0x%0x(%d))\n", p4, p4);
379 hexdump((void*)p1, 0x24);
380 hexdump((void*)p2, 32);
381 hexdump((void*)p3, 4);
382 hexdump((void*)p4, 32);
383 fprintf(stderr, "content of the callback functions:\n\n");
384 while(i<8) {
385 hexdump(*((void**)p2+i), (i==0)?32*4:16);
386 i++;
387 }
388 i=0;
389 pp=(*(void***)p2);
390 fprintf(stderr, "content of the callback functions (first entry):\n\n");
391 while(i<15) {
392 hexdump(*((void**)pp+i), 32);
393 i++;
394 }
395
396 tic();
397 result=(*pnsSetDataCallback)(p1,p2,p3,p4);
398 toc();
399 hexdump((void*)p1, 0x24);
400 // hexdump((void*)p2, 256);
401 // hexdump((void*)p3, 4);
402 hexdump(*((void**)p3), 256);
403 fprintf(stderr, "PNStream_SetDataCallback --> 0x%0x(%d)\n\n\n", result, result);
404 return result;
405 }
406
407 ulong PNStream_SetProperty(ulong p1,ulong p2,ulong p3) {
408 ulong result;
409 fprintf(stderr, "PNStream_SetProperty(ulong p1=0x%0x(%d), ", p1, p1);
410 fprintf(stderr, "ulong p2=0x%0x(%d),\n\t", p2, p2);
411 fprintf(stderr, "ulong p3=0x%0x(%d))\n", p3, p3);
412 hexdump((void*)p3, 4);
413 tic();
414 result=(*pnsSetProperty)(p1,p2,p3);
415 toc();
416 // hexdump((void*)p3, 44);
417 fprintf(stderr, "PNStream_SetProperty --> 0x%0x(%d)\n\n\n", result, result);
418 return result;
419 }
420
421 ulong PNStream_GetProperty(ulong p1,ulong p2,ulong p3) {
422 ulong result;
423 fprintf(stderr, "PNStream_GetProperty(ulong p1=0x%0x(%d), ", p1, p1);
424 fprintf(stderr, "ulong p2=0x%0x(%d),\n\t", p2, p2);
425 fprintf(stderr, "ulong p3=0x%0x(%d))\n", p3, p3);
426 // hexdump((void*)p3, 44);
427 tic();
428 result=(*pnsGetProperty)(p1,p2,p3);
429 toc();
430 hexdump((void*)p3, 4);
431 fprintf(stderr, "PNStream_GetProperty --> 0x%0x(%d)\n\n\n", result, result);
432 return result;
433 }
434
435 ulong PNStream_Close(ulong p1) {
436 ulong result;
437 fprintf(stderr, "PNStream_Close(ulong p1=0x%0x(%d))\n", p1, p1);
438 // hexdump((void*)p1, 44);
439 tic();
440 result=(*pnsClose)(p1);
441 toc();
442 // hexdump((void*)p1, 44);
443 fprintf(stderr, "PNStream_Close --> 0x%0x(%d)\n\n\n", result, result);
444 return result;
445 }
446
447 ulong streamHeaderSize=0;
448
449 ulong PNStream_GetStreamHeaderSize(ulong p1,ulong p2) {
450 ulong result;
451 fprintf(stderr, "PNStream_GetStreamHeaderSize(ulong p1=0x%0x(%d), ", p1, p1);
452 fprintf(stderr, "ulong p2=0x%0x(%d),\n", p2, p2);
453 // hexdump((void*)p2, 44);
454 tic();
455 result=(*pnsGetStreamHeaderSize)(p1,p2);
456 toc();
457 hexdump((void*)p2, 4);
458 streamHeaderSize=*((ulong *)p2);
459 fprintf(stderr, "PNStream_GetStreamHeaderSize --> 0x%0x(%d)\n\n\n", result, result);
460 return result;
461 }
462
463 ulong PNStream_GetStreamHeader(ulong p1,ulong p2) {
464 ulong result;
465 fprintf(stderr, "PNStream_GetStreamHeader(ulong p1=0x%0x(%d), ", p1, p1);
466 fprintf(stderr, "ulong p2=0x%0x(%d),\n", p2, p2);
467 // hexdump((void*)p2, 44);
468 tic();
469 result=(*pnsGetStreamHeader)(p1,p2);
470 toc();
471 hexdump((void*)p2, streamHeaderSize);
472 fprintf(stderr, "PNStream_GetStreamHeader --> 0x%0x(%d)\n\n\n", result, result);
473 return result;
474 }
475
476 ulong PNStream_Input(ulong p1,ulong p2,ulong p3) {
477 ulong result;
478 fprintf(stderr, "PNStream_Input(ulong p1=0x%0x(%d), ", p1, p1);
479 fprintf(stderr, "ulong p2=0x%0x(%d),\n\t", p2, p2);
480 fprintf(stderr, "ulong p3=0x%0x(%d))\n", p3, p3);
481 hexdump((void*)p3, 4);
482 tic();
483 result=(*pnsInput)(p1,p2,p3);
484 toc();
485 // hexdump((void*)p3, 44);
486 fprintf(stderr, "PNStream_Input --> 0x%0x(%d)\n\n\n", result, result);
487 return result;
488 }
489
490 ulong PNStream_SetOutputPacketSize(ulong p1,ulong p2,ulong p3,ulong p4) {
491 ulong result;
492 fprintf(stderr, "PNStream_SetOutputPacketSize(ulong p1=0x%0x(%d), ", p1, p1);
493 fprintf(stderr, "ulong p2=0x%0x(%d),\n\t", p2, p2);
494 fprintf(stderr, "ulong p3=0x%0x(%d),", p3, p3);
495 fprintf(stderr, "ulong p4=0x%0x(%d))\n", p4, p4);
496 // hexdump((void*)p1, 44);
497 tic();
498 result=(*pnsSetOutputPacketSize)(p1,p2,p3,p4);
499 toc();
500 // hexdump((void*)p1, 44);
501 fprintf(stderr, "PNStream_SetOutputPacketSize --> 0x%0x(%d)\n\n\n", result, result);
502 return result;
503 }
504
505 ulong PNStream_GetInputBufferSize(ulong p1,ulong p2) {
506 ulong result;
507 fprintf(stderr, "PNStream_GetInputBufferSize(ulong p1=0x%0x(%d), ", p1, p1);
508 fprintf(stderr, "ulong p2=0x%0x(%d))\n", p2, p2);
509 // hexdump((void*)p1, 44);
510 tic();
511 result=(*pnsGetInputBufferSize)(p1,p2);
512 toc();
513 // hexdump((void*)p1, 44);
514 fprintf(stderr, "PNStream_GetInputBufferSize --> 0x%0x(%d)\n\n\n", result, result);
515 return result;
516 }
517
518 void SetDLLAccessPath(ulong p1) {
519 fprintf(stderr, "SetDLLAccessPath(ulong p1=0x%0x(%d))\n", p1, p1);
520 // hexdump((void*)p1, 44);
521 (*setDLLAccessPath)(p1);
522 // hexdump((void*)p1, 44);
523 fprintf(stderr, "--> void\n\n\n");
524 }
525