]>
Commit | Line | Data |
---|---|---|
a3f1cbda MG |
1 | #define PERL_NO_GET_CONTEXT |
2 | #include "EXTERN.h" | |
3 | #include "perl.h" | |
4 | #include "XSUB.h" | |
5 | ||
6 | #include "ppport.h" | |
7 | ||
8 | /* op_free is both Perl_op_free and a function in opusfile */ | |
9 | #undef op_free | |
10 | #include <opus/opusfile.h> | |
11 | ||
12 | #include "const-c.inc" | |
13 | ||
eed4cab1 MG |
14 | typedef OggOpusFile* Audio__Opusfile; |
15 | typedef const OpusHead* Audio__Opusfile__Head; | |
16 | typedef const OpusTags* Audio__Opusfile__Tags; | |
17 | typedef const OpusPictureTag* Audio__Opusfile__PictureTag; | |
18 | ||
a3f1cbda MG |
19 | MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile PREFIX = op_ |
20 | ||
21 | PROTOTYPES: ENABLE | |
22 | INCLUDE: const-xs.inc | |
23 | ||
eed4cab1 | 24 | Audio::Opusfile |
a3f1cbda MG |
25 | op_open_file(path) |
26 | const char *path; | |
27 | PREINIT: | |
28 | int err; | |
5fbea9a2 MG |
29 | C_ARGS: |
30 | path, &err | |
31 | POSTCALL: | |
a3f1cbda MG |
32 | if(err) |
33 | croak("op_open_file returned error %d\n", err); | |
5fbea9a2 | 34 | |
eed4cab1 | 35 | Audio::Opusfile |
5fbea9a2 MG |
36 | op_open_memory(const char *data, size_t length(data)) |
37 | PREINIT: | |
38 | int err; | |
39 | C_ARGS: | |
40 | data, XSauto_length_of_data, &err | |
41 | POSTCALL: | |
42 | if(err) | |
43 | croak("op_open_memory returned error %d\n", err); | |
44 | ||
45 | bool | |
46 | op_test(const char *data, size_t length(data)) | |
47 | PROTOTYPE: $ | |
48 | PREINIT: | |
49 | int ret; | |
50 | CODE: | |
51 | ret = op_test (NULL, data, XSauto_length_of_data); | |
52 | if(ret < 0 && ret != OP_ENOTFORMAT && ret != OP_EBADHEADER) | |
53 | croak("op_test returned error %d\n", RETVAL); | |
54 | RETVAL = !ret; | |
a3f1cbda MG |
55 | OUTPUT: |
56 | RETVAL | |
57 | ||
5fbea9a2 | 58 | |
a3f1cbda MG |
59 | void |
60 | DESTROY(of) | |
eed4cab1 | 61 | Audio::Opusfile of; |
a3f1cbda MG |
62 | CODE: |
63 | op_free(of); | |
64 | ||
5fbea9a2 MG |
65 | bool |
66 | op_seekable(of) | |
eed4cab1 | 67 | Audio::Opusfile of; |
5fbea9a2 MG |
68 | |
69 | int | |
70 | op_link_count(of) | |
eed4cab1 | 71 | Audio::Opusfile of; |
5fbea9a2 MG |
72 | |
73 | int | |
74 | op_serialno(of, li = -1) | |
eed4cab1 | 75 | Audio::Opusfile of; |
5fbea9a2 MG |
76 | int li; |
77 | ||
eed4cab1 | 78 | Audio::Opusfile::Head |
a3f1cbda | 79 | op_head(of, li = -1) |
eed4cab1 | 80 | Audio::Opusfile of; |
a3f1cbda MG |
81 | int li; |
82 | ||
eed4cab1 | 83 | Audio::Opusfile::Tags |
a3f1cbda | 84 | op_tags(of, li = -1) |
eed4cab1 | 85 | Audio::Opusfile of; |
a3f1cbda MG |
86 | int li; |
87 | ||
88 | MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Tags PREFIX = opus_tags_ | |
89 | ||
90 | int | |
91 | opus_tags_query_count(tags, tag) | |
eed4cab1 | 92 | Audio::Opusfile::Tags tags; |
a3f1cbda MG |
93 | const char* tag; |
94 | ||
95 | const char* | |
96 | opus_tags_query(tags, tag, count = 0) | |
eed4cab1 | 97 | Audio::Opusfile::Tags tags; |
a3f1cbda MG |
98 | const char* tag; |
99 | int count; | |
2f4b5b1b MG |
100 | |
101 | MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::PictureTag PREFIX = opus_picture_tag_ | |
102 | ||
eed4cab1 | 103 | Audio::Opusfile::PictureTag |
2f4b5b1b MG |
104 | opus_picture_tag_parse(tag) |
105 | const char *tag; | |
106 | PREINIT: | |
107 | OpusPictureTag *pic; | |
108 | int err; | |
109 | CODE: | |
110 | Newx(pic, 1, OpusPictureTag); | |
111 | if(err = opus_picture_tag_parse(pic, tag)) | |
112 | croak("opus_picture_tag_parse returned error %d\n", err); | |
113 | RETVAL = pic; | |
114 | OUTPUT: | |
115 | RETVAL | |
116 | ||
117 | void | |
118 | DESTROY(pic) | |
eed4cab1 | 119 | Audio::Opusfile::PictureTag pic |
2f4b5b1b MG |
120 | CODE: |
121 | Safefree(pic); | |
122 | ||
123 | int | |
124 | type(pic) | |
eed4cab1 | 125 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
126 | CODE: |
127 | RETVAL = pic->type; | |
128 | OUTPUT: | |
129 | RETVAL | |
130 | ||
131 | const char* | |
132 | mime_type(pic) | |
eed4cab1 | 133 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
134 | CODE: |
135 | RETVAL = pic->mime_type; | |
136 | OUTPUT: | |
137 | RETVAL | |
138 | ||
139 | const char* | |
140 | description(pic) | |
eed4cab1 | 141 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
142 | CODE: |
143 | RETVAL = pic->description; | |
144 | OUTPUT: | |
145 | RETVAL | |
146 | ||
147 | int | |
148 | width(pic) | |
eed4cab1 | 149 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
150 | CODE: |
151 | RETVAL = pic->width; | |
152 | OUTPUT: | |
153 | RETVAL | |
154 | ||
155 | int | |
156 | height(pic) | |
eed4cab1 | 157 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
158 | CODE: |
159 | RETVAL = pic->height; | |
160 | OUTPUT: | |
161 | RETVAL | |
162 | ||
163 | int | |
164 | depth(pic) | |
eed4cab1 | 165 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
166 | CODE: |
167 | RETVAL = pic->depth; | |
168 | OUTPUT: | |
169 | RETVAL | |
170 | ||
171 | int | |
172 | colors(pic) | |
eed4cab1 | 173 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
174 | CODE: |
175 | RETVAL = pic->colors; | |
176 | OUTPUT: | |
177 | RETVAL | |
178 | ||
179 | int | |
180 | data_length(pic) | |
eed4cab1 | 181 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
182 | CODE: |
183 | RETVAL = pic->data_length; | |
184 | OUTPUT: | |
185 | RETVAL | |
186 | ||
187 | SV* | |
188 | data(pic) | |
eed4cab1 | 189 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
190 | CODE: |
191 | RETVAL = newSVpvn(pic->data, pic->data_length); | |
192 | OUTPUT: | |
193 | RETVAL | |
194 | ||
195 | int | |
196 | format(pic) | |
eed4cab1 | 197 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
198 | CODE: |
199 | RETVAL = pic->format; | |
200 | OUTPUT: | |
201 | RETVAL | |
202 | ||
203 | MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Head | |
204 | ||
205 | int | |
206 | version(head) | |
eed4cab1 | 207 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
208 | CODE: |
209 | RETVAL = head->version; | |
210 | OUTPUT: | |
211 | RETVAL | |
212 | ||
213 | int | |
214 | channel_count(head) | |
eed4cab1 | 215 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
216 | CODE: |
217 | RETVAL = head->channel_count; | |
218 | OUTPUT: | |
219 | RETVAL | |
220 | ||
221 | unsigned | |
222 | pre_skip(head) | |
eed4cab1 | 223 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
224 | CODE: |
225 | RETVAL = head->pre_skip; | |
226 | OUTPUT: | |
227 | RETVAL | |
228 | ||
229 | unsigned | |
230 | input_sample_rate(head) | |
eed4cab1 | 231 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
232 | CODE: |
233 | RETVAL = head->input_sample_rate; | |
234 | OUTPUT: | |
235 | RETVAL | |
236 | ||
aca25728 MG |
237 | int |
238 | output_gain(head) | |
239 | Audio::Opusfile::Head head; | |
240 | CODE: | |
241 | RETVAL = head->output_gain; | |
242 | OUTPUT: | |
243 | RETVAL | |
244 | ||
2f4b5b1b MG |
245 | int |
246 | mapping_family(head) | |
eed4cab1 | 247 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
248 | CODE: |
249 | RETVAL = head->mapping_family; | |
250 | OUTPUT: | |
251 | RETVAL | |
252 | ||
253 | int | |
254 | stream_count(head) | |
eed4cab1 | 255 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
256 | CODE: |
257 | RETVAL = head->stream_count; | |
258 | OUTPUT: | |
259 | RETVAL | |
260 | ||
261 | int | |
262 | coupled_count(head) | |
eed4cab1 | 263 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
264 | CODE: |
265 | RETVAL = head->coupled_count; | |
266 | OUTPUT: | |
267 | RETVAL | |
268 | ||
269 | int | |
270 | mapping(head, k) | |
eed4cab1 | 271 | Audio::Opusfile::Head head; |
b6589960 | 272 | unsigned k; |
2f4b5b1b | 273 | CODE: |
b6589960 MG |
274 | if(k >= OPUS_CHANNEL_COUNT_MAX) |
275 | croak("k must be less than %d\n", (int)OPUS_CHANNEL_COUNT_MAX); | |
2f4b5b1b MG |
276 | RETVAL = (int) head->mapping[k]; |
277 | OUTPUT: | |
278 | RETVAL |