-
Notifications
You must be signed in to change notification settings - Fork 1
/
codecID.c.m4
73 lines (59 loc) · 1.94 KB
/
codecID.c.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
include(`defines.m4')
define(<!doCase!>, <!ifelse($1, lastCase, , <!ifdef(<!lastCase!>, <! codecID = lastCase;
break;
!>)!>)<! case $2:!>
define(<!lastCase!>, <!$1!>)!>)dnl
define(<!printCaseStatement!>, <!ifelse(len($1), 0, <!!>, <!foreach(<!X!>, <!doCase($1, X)!>, shift($@))!>)!>)dnl
define(<!Codec!>, <!printCaseStatement($2, shift(shift(shift(shift($@)))))!>)dnl
dnl
define(<!EntryPoint!>, <!!>)dnl
define(<!ResourceOnly!>, <!!>)dnl
#include "avcodec.h"
#include "CodecIDs.h"
#include <QuickTime/QuickTime.h>
#include "PerianResourceIDs.h"
int getCodecID(OSType componentType)
{
enum CodecID codecID = CODEC_ID_NONE;
switch(componentType)
{
include(<!codecList.m4!>)
codecID = lastCase;
break;
default:
break;
}
return codecID;
}
undefine(<!lastCase!>)dnl
define(<!doCase!>, <!ifelse($1, lastCase, , <!ifdef(<!lastCase!>, <! err = GetComponentResource((Component)self, codecInfoResourceType, lastCase, (Handle *)&tempCodecInfo);
break;
!>)!>)<! case $2:!>
define(<!lastCase!>, <!$1!>)!>)dnl
define(<!Codec!>, <!printCaseStatement($1, shift(shift(shift(shift($@)))))!>)dnl
pascal ComponentResult getPerianCodecInfo(ComponentInstance self, OSType componentType, void *info)
{
OSErr err = noErr;
if (info == NULL)
{
err = paramErr;
}
else
{
CodecInfo **tempCodecInfo;
switch (componentType)
{
include(<!codecList.m4!>)
err = GetComponentResource((Component)self, codecInfoResourceType, lastCase, (Handle *)&tempCodecInfo);
break;
default: // should never happen but we have to handle the case
err = GetComponentResource((Component)self, codecInfoResourceType, kDivX4CodecInfoResID, (Handle *)&tempCodecInfo);
}
if (err == noErr)
{
*((CodecInfo *)info) = **tempCodecInfo;
DisposeHandle((Handle)tempCodecInfo);
}
}
return err;
}