2 * This is a small DLL that works as a wrapper for the actual realcook.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.
33 typedef unsigned long ulong
;
35 ulong (*raCloseCodec
)(ulong
);
36 ulong (*raDecode
)(ulong
,ulong
,ulong
,ulong
,ulong
,ulong
);
37 ulong (*raEncode
)(ulong
,ulong
,ulong
);
38 ulong (*raFlush
)(ulong
,ulong
,ulong
);
39 ulong (*raFreeDecoder
)(ulong
);
40 ulong (*raFreeEncoder
)(ulong
);
41 ulong (*raGetFlavorProperty
)(ulong
,ulong
,ulong
,ulong
);
42 ulong (*raGetNumberOfFlavors
)(void);
43 ulong (*raGetNumberOfFlavors2
)(void);
44 ulong (*raInitDecoder
)(ulong
,ulong
);
45 ulong (*raInitEncoder
)(ulong
,ulong
);
46 ulong (*raOpenCodec
)(ulong
);
47 ulong (*raOpenCodec2
)(ulong
);
48 ulong (*raSetFlavor
)(ulong
,ulong
);
49 void (*raSetDLLAccessPath
)(ulong
);
50 /* the following symbol will be _dlsym()ed by rarender.so,
51 but at least doesn't exist in cook.so
52 ulong (raSetPwd*)(ulong);
58 /* exits program when failure */
60 fputs("loadSyms()\n", stderr
);
64 // fputs("opening dll...\n");
65 handle
= dlopen ("/usr/local/RealPlayer8/Codecs/realcook.so.6.0", RTLD_LAZY
);
67 fputs (dlerror(), stderr
);
71 raCloseCodec
= dlsym(handle
, "RACloseCodec");
72 if ((error
= dlerror()) != NULL
) {
73 fprintf (stderr
, "dlsym(RACloseCodec): %s\n", error
);
76 raDecode
= dlsym(handle
, "RADecode");
77 if ((error
= dlerror()) != NULL
) {
78 fprintf (stderr
, "dlsym(RADecode): %s\n", error
);
81 raEncode
= dlsym(handle
, "RAEncode");
82 if ((error
= dlerror()) != NULL
) {
83 fprintf (stderr
, "dlsym(RAEncode): %s\n", error
);
86 raFlush
= dlsym(handle
, "RAFlush");
87 if ((error
= dlerror()) != NULL
) {
88 fprintf (stderr
, "dlsym(RAFlush): %s\n", error
);
91 raFreeDecoder
= dlsym(handle
, "RAFreeDecoder");
92 if ((error
= dlerror()) != NULL
) {
93 fprintf (stderr
, "dlsym(RAFreeDecoder): %s\n", error
);
96 raFreeEncoder
= dlsym(handle
, "RAFreeEncoder");
97 if ((error
= dlerror()) != NULL
) {
98 fprintf (stderr
, "dlsym(RAFreeEncoder): %s\n", error
);
101 raGetFlavorProperty
= dlsym(handle
, "RAGetFlavorProperty");
102 if ((error
= dlerror()) != NULL
) {
103 fprintf (stderr
, "dlsym(RAGetFlavorProperty): %s\n", error
);
106 raGetNumberOfFlavors
= dlsym(handle
, "RAGetNumberOfFlavors");
107 if ((error
= dlerror()) != NULL
) {
108 fprintf (stderr
, "dlsym(RAGetNumberOfFlavors): %s\n", error
);
111 raGetNumberOfFlavors2
= dlsym(handle
, "RAGetNumberOfFlavors2");
112 if ((error
= dlerror()) != NULL
) {
113 fprintf (stderr
, "dlsym(RAGetNumberOfFlavors2): %s\n", error
);
116 raInitDecoder
= dlsym(handle
, "RAInitDecoder");
117 if ((error
= dlerror()) != NULL
) {
118 fprintf (stderr
, "dlsym(RAInitDecoder): %s\n", error
);
121 raInitEncoder
= dlsym(handle
, "RAInitEncoder");
122 if ((error
= dlerror()) != NULL
) {
123 fprintf (stderr
, "dlsym(RAInitEncoder): %s\n", error
);
126 raOpenCodec
= dlsym(handle
, "RAOpenCodec");
127 if ((error
= dlerror()) != NULL
) {
128 fprintf (stderr
, "dlsym(RAOpenCodec): %s\n", error
);
131 raOpenCodec2
= dlsym(handle
, "RAOpenCodec2");
132 if ((error
= dlerror()) != NULL
) {
133 fprintf (stderr
, "dlsym(RAOpenCodec2): %s\n", error
);
136 raSetFlavor
= dlsym(handle
, "RASetFlavor");
137 if ((error
= dlerror()) != NULL
) {
138 fprintf (stderr
, "dlsym(RASetFlavor): %s\n", error
);
141 raSetDLLAccessPath
= dlsym(handle
, "SetDLLAccessPath");
142 if ((error
= dlerror()) != NULL
) {
143 fprintf (stderr
, "dlsym(SetDLLAccessPath): %s\n", error
);
150 void closeDll(void) {
163 struct timeval tv1
, tv2
;
166 gettimeofday(&tv1
, &tz
);
171 gettimeofday(&tv2
, &tz
);
172 secs
=tv2
.tv_sec
-tv1
.tv_sec
;
173 usecs
=tv2
.tv_usec
-tv1
.tv_usec
;
178 fprintf(stderr
, "Duration: %ld.%.6lds\n", secs
, usecs
);
182 void hexdump(void *pos
, int len
) {
183 unsigned char *cpos
=pos
, *cpos1
;
184 int lines
=(len
+15)>>4;
187 fprintf(stderr
, "%0x ", cpos
);
191 fprintf(stderr
, "%02x ", *(cpos
++));
193 fprintf(stderr
, " ");
201 unsigned char ch
=(*(cpos
++));
202 if ((ch
<32)||(ch
>127)) ch
='.';
213 ulong
RACloseCodec(ulong p1
) {
215 fprintf(stderr
, "RACloseCodec(ulong p1=0x%0lx(%ld))\n", p1
, p1
);
216 result
=(*raCloseCodec
)(p1
);
218 fprintf(stderr
, "--> 0x%0lx(%ld)\n\n\n", result
, result
);
224 ulong
RADecode(ulong p1
,ulong p2
,ulong p3
,ulong p4
,ulong
* p5
,ulong p6
) {
228 fprintf(stderr
, "RADecode(ulong ctx=0x%0lx, ", p1
);
229 fprintf(stderr
, "ulong src=0x%0lx,\n", p2
);
230 fprintf(stderr
, "ulong len=0x%0lx,", p3
);
231 fprintf(stderr
, "ulong dst=0x%0lx,\n", p4
);
232 fprintf(stderr
, "ulong dstcnt=0x%0lx, ",p5
);
233 fprintf(stderr
, "ulong p6=%ld)\n", p6
);
234 // hexdump((void*)p1, 44);
235 // hexdump((void*)p2, p3);
236 // hexdump((void*)p4, 80);
237 // hexdump((void*)p5, 16);
240 fprintf(stderr
,"\n#CRC[%3d]",pkno
++);
242 unsigned short crc
=0;
248 fprintf(stderr
," %04X",crc
);
250 fprintf(stderr
,"\n");
252 result
=(*raDecode
)(p1
,p2
,p3
,p4
,p5
,p6
);
254 // hexdump((void*)p1, 44);
255 // hexdump((void*)p4, 80);
256 // hexdump((void*)p5, 16);
257 fprintf(stderr
, "--> 0x%0lx(%ld) decoded: %ld \n\n\n", result
, result
, p5
[0]);
261 ulong
RAEncode(ulong p1
,ulong p2
,ulong p3
) {
263 fprintf(stderr
, "RAEncode(ulong p1=0x%0lx(%ld), ", p1
, p1
);
264 fprintf(stderr
, "ulong p2=0x%0lx(%ld),\n", p2
, p2
);
265 fprintf(stderr
, "ulong p3=0x%0lx(%ld))\n", p3
, p3
);
266 result
=(*raEncode
)(p1
,p2
,p3
);
267 fprintf(stderr
, "--> 0x%0lx(%ld)\n\n\n", result
, result
);
271 ulong
RAFlush(ulong p1
,ulong p2
,ulong p3
) {
273 fprintf(stderr
, "RAFlush(ulong p1=0x%0lx(%ld), ", p1
, p1
);
274 fprintf(stderr
, "ulong p2=0x%0lx(%ld),\n", p2
, p2
);
275 fprintf(stderr
, "ulong p3=0x%0lx(%ld))\n", p3
, p3
);
276 result
=(*raFlush
)(p1
,p2
,p3
);
277 fprintf(stderr
, "--> 0x%0lx(%ld)\n\n\n", result
, result
);
281 ulong
RAFreeDecoder(ulong p1
) {
283 fprintf(stderr
, "RAFreeDecoder(ulong p1=0x%0lx(%ld))\n", p1
, p1
);
284 hexdump((void*)p1
, 44);
285 result
=(*raFreeDecoder
)(p1
);
286 fprintf(stderr
, "--> 0x%0lx(%ld)\n\n\n", result
, result
);
290 ulong
RAFreeEncoder(ulong p1
) {
292 fprintf(stderr
, "RAFreeEncoder(ulong p1=0x%0lx(%ld))\n", p1
, p1
);
293 result
=(*raFreeEncoder
)(p1
);
294 fprintf(stderr
, "--> 0x%0lx(%ld)\n\n\n", result
, result
);
298 ulong
RAGetFlavorProperty(ulong p1
,ulong p2
,ulong p3
, ulong p4
) {
300 fprintf(stderr
, "RAGetFlavorProperty(ulong p1=0x%0lx(%ld), ", p1
, p1
);
301 fprintf(stderr
, "ulong p2=0x%0lx(%ld),\n", p2
, p2
);
302 fprintf(stderr
, "ulong p3=0x%0lx(%ld), ", p3
, p3
);
303 fprintf(stderr
, "ulong p4=0x%0lx(%ld))\n", p4
, p4
);
304 hexdump((void*)p4
/*(void*)(*((void**)p4))*/,p2
);
305 hexdump((void*)p1
, 44);
307 result
=(*raGetFlavorProperty
)(p1
,p2
,p3
,p4
);
309 fprintf(stderr
, "*p4=0x%0lx\n", *((ulong
*)p4
));
310 hexdump((void*)p4
/*(void*)(*((void**)p4))*/,p2
);
311 hexdump((void*)p1
, 44);
312 fprintf(stderr
, "--> 0x%0lx(%ld)\n\n\n", result
, result
);
316 ulong
RAGetNumberOfFlavors(void) {
318 fprintf(stderr
, "RAGetNumberOfFlavors(void)\n");
319 result
=(*raGetNumberOfFlavors
)();
320 fprintf(stderr
, "--> 0x%0lx(%ld)\n\n\n", result
, result
);
324 ulong
RAGetNumberOfFlavors2(void) {
326 fprintf(stderr
, "RAGetNumberOfFlavors2(void)\n");
327 result
=(*raGetNumberOfFlavors2
)();
328 fprintf(stderr
, "--> 0x%0lx(%ld)\n\n\n", result
, result
);
332 ulong
RAInitDecoder(ulong p1
,ulong p2
) {
335 unsigned char temp2
[256];
336 fprintf(stderr
, "RAInitDecoder(ulong p1=0x%0lx(%ld), ", p1
, p1
);
337 fprintf(stderr
, "ulong p2=0x%0lx(%ld))\n", p2
, p2
);
338 hexdump((void*)p2
, 4*7);
339 // hexdump((void*)p1, 44);
340 memset(temp
,0x77,256*4);
342 hexdump((void*)temp
[6], 32);
344 memset(temp2
,0x77,256);
345 memcpy(temp2
,temp
[6],16);
348 result
=(*raInitDecoder
)(p1
,temp
);
349 hexdump((void*)temp
[6], 32);
350 // memcpy(p2,temp,4*11);
351 // hexdump((void*)p1, 44);
352 fprintf(stderr
, "--> 0x%0lx(%ld)\n\n\n", result
, result
);
356 ulong
RAInitEncoder(ulong p1
,ulong p2
) {
358 fprintf(stderr
, "RAInitEncoder(ulong p1=0x%0lx(%ld), ", p1
, p1
);
359 fprintf(stderr
, "ulong p2=0x%0lx(%ld))\n", p2
, p2
);
360 result
=(*raInitEncoder
)(p1
,p2
);
361 fprintf(stderr
, "--> 0x%0lx(%ld)\n\n\n", result
, result
);
365 ulong
RAOpenCodec(ulong p1
) {
368 fprintf(stderr
, "RAOpenCodec(ulong p1=0x%0lx(%ld))\n", p1
, p1
);
369 result
=(*raOpenCodec
)(p1
);
370 fprintf(stderr
, "--> 0x%0lx(%ld)\n\n\n", result
, result
);
374 ulong
RAOpenCodec2(ulong p1
,ulong p2
) {
377 fprintf(stderr
, "RAOpenCodec2(ulong p1=0x%0lx(%ld), p2=%p)\n", p1
, p1
, p2
);
378 hexdump((void*)p1
, 44);
379 hexdump((void*)p2
, 44);
380 result
=(*raOpenCodec2
)(p1
);
381 hexdump((void*)p2
, 44);
382 hexdump((void*)p1
, 44);
383 fprintf(stderr
, "--> 0x%0lx(%ld)\n\n\n", result
, result
);
387 ulong
RASetFlavor(ulong p1
,ulong p2
) {
388 ulong result
, numprop
=0, result1
=0;
389 ulong numflavors
, flavor
;
390 unsigned short property
;
391 fprintf(stderr
, "RASetFlavor(ulong p1=0x%0lx(%ld), ", p1
, p1
);
392 fprintf(stderr
, "ulong p2=0x%0lx(%ld))\n", p2
, p2
);
393 hexdump((void*)p1
, 44);
394 hexdump((void*)p1
, 44);
395 result
=(*raSetFlavor
)(p1
,p2
);
396 fprintf(stderr
, "--> 0x%0lx(%ld)\n\n\n", result
, result
);
398 fputs("######################## FLAVOR PROPERTIES ###################\n\n", stderr
);
399 numflavors
=raGetNumberOfFlavors2();
401 while (flavor
<numflavors
) {
402 fprintf(stderr
, "************ Flavor %ld *************\n\n", flavor
);
405 result1
=raGetFlavorProperty(p1
, flavor
, numprop
, (ulong
)&property
);
406 fprintf(stderr
, "property %ld=%d, result=0x%0lx\n\n",
407 numprop
, property
, result1
);
408 hexdump((void*)result1
, property
);
414 fputs("######################## FLAVOR PROPERTIES ###################\n\n", stderr
);
419 void SetDLLAccessPath(ulong p1
) {
421 fprintf(stderr
, "SetDLLAccessPath(ulong p1=0x%0lx(%ld))\n", p1
, p1
);
422 hexdump((void*)p1
, 44);
423 (*raSetDLLAccessPath
)(p1
);
424 hexdump((void*)p1
, 44);
425 fprintf(stderr
, "--> void\n\n\n");