]>
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 | ||
dc986a40 MG |
78 | # op_channel_count is not exported; it can be obtained via op_head |
79 | ||
80 | long | |
81 | op_raw_total(of, li = -1) | |
82 | Audio::Opusfile of; | |
83 | int li; | |
84 | ||
85 | long | |
86 | op_pcm_total(of, li = -1) | |
87 | Audio::Opusfile of; | |
88 | int li; | |
89 | ||
eed4cab1 | 90 | Audio::Opusfile::Head |
a3f1cbda | 91 | op_head(of, li = -1) |
eed4cab1 | 92 | Audio::Opusfile of; |
a3f1cbda MG |
93 | int li; |
94 | ||
eed4cab1 | 95 | Audio::Opusfile::Tags |
a3f1cbda | 96 | op_tags(of, li = -1) |
eed4cab1 | 97 | Audio::Opusfile of; |
a3f1cbda MG |
98 | int li; |
99 | ||
dc986a40 MG |
100 | # op_current_link not exported until we export the decoding API |
101 | ||
102 | int | |
103 | op_bitrate(of, li = -1) | |
104 | Audio::Opusfile of; | |
105 | int li; | |
106 | ||
107 | # op_bitrate_instant, op_raw_tell, op_pcm_tell not exported until we | |
108 | # export the decoding API | |
109 | ||
a3f1cbda MG |
110 | MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Tags PREFIX = opus_tags_ |
111 | ||
112 | int | |
113 | opus_tags_query_count(tags, tag) | |
eed4cab1 | 114 | Audio::Opusfile::Tags tags; |
a3f1cbda MG |
115 | const char* tag; |
116 | ||
117 | const char* | |
118 | opus_tags_query(tags, tag, count = 0) | |
eed4cab1 | 119 | Audio::Opusfile::Tags tags; |
a3f1cbda MG |
120 | const char* tag; |
121 | int count; | |
2f4b5b1b MG |
122 | |
123 | MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::PictureTag PREFIX = opus_picture_tag_ | |
124 | ||
eed4cab1 | 125 | Audio::Opusfile::PictureTag |
2f4b5b1b MG |
126 | opus_picture_tag_parse(tag) |
127 | const char *tag; | |
128 | PREINIT: | |
129 | OpusPictureTag *pic; | |
130 | int err; | |
131 | CODE: | |
132 | Newx(pic, 1, OpusPictureTag); | |
133 | if(err = opus_picture_tag_parse(pic, tag)) | |
134 | croak("opus_picture_tag_parse returned error %d\n", err); | |
135 | RETVAL = pic; | |
136 | OUTPUT: | |
137 | RETVAL | |
138 | ||
139 | void | |
140 | DESTROY(pic) | |
eed4cab1 | 141 | Audio::Opusfile::PictureTag pic |
2f4b5b1b MG |
142 | CODE: |
143 | Safefree(pic); | |
144 | ||
145 | int | |
146 | type(pic) | |
eed4cab1 | 147 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
148 | CODE: |
149 | RETVAL = pic->type; | |
150 | OUTPUT: | |
151 | RETVAL | |
152 | ||
153 | const char* | |
154 | mime_type(pic) | |
eed4cab1 | 155 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
156 | CODE: |
157 | RETVAL = pic->mime_type; | |
158 | OUTPUT: | |
159 | RETVAL | |
160 | ||
161 | const char* | |
162 | description(pic) | |
eed4cab1 | 163 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
164 | CODE: |
165 | RETVAL = pic->description; | |
166 | OUTPUT: | |
167 | RETVAL | |
168 | ||
169 | int | |
170 | width(pic) | |
eed4cab1 | 171 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
172 | CODE: |
173 | RETVAL = pic->width; | |
174 | OUTPUT: | |
175 | RETVAL | |
176 | ||
177 | int | |
178 | height(pic) | |
eed4cab1 | 179 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
180 | CODE: |
181 | RETVAL = pic->height; | |
182 | OUTPUT: | |
183 | RETVAL | |
184 | ||
185 | int | |
186 | depth(pic) | |
eed4cab1 | 187 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
188 | CODE: |
189 | RETVAL = pic->depth; | |
190 | OUTPUT: | |
191 | RETVAL | |
192 | ||
193 | int | |
194 | colors(pic) | |
eed4cab1 | 195 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
196 | CODE: |
197 | RETVAL = pic->colors; | |
198 | OUTPUT: | |
199 | RETVAL | |
200 | ||
201 | int | |
202 | data_length(pic) | |
eed4cab1 | 203 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
204 | CODE: |
205 | RETVAL = pic->data_length; | |
206 | OUTPUT: | |
207 | RETVAL | |
208 | ||
209 | SV* | |
210 | data(pic) | |
eed4cab1 | 211 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
212 | CODE: |
213 | RETVAL = newSVpvn(pic->data, pic->data_length); | |
214 | OUTPUT: | |
215 | RETVAL | |
216 | ||
217 | int | |
218 | format(pic) | |
eed4cab1 | 219 | Audio::Opusfile::PictureTag pic; |
2f4b5b1b MG |
220 | CODE: |
221 | RETVAL = pic->format; | |
222 | OUTPUT: | |
223 | RETVAL | |
224 | ||
225 | MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Head | |
226 | ||
227 | int | |
228 | version(head) | |
eed4cab1 | 229 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
230 | CODE: |
231 | RETVAL = head->version; | |
232 | OUTPUT: | |
233 | RETVAL | |
234 | ||
235 | int | |
236 | channel_count(head) | |
eed4cab1 | 237 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
238 | CODE: |
239 | RETVAL = head->channel_count; | |
240 | OUTPUT: | |
241 | RETVAL | |
242 | ||
243 | unsigned | |
244 | pre_skip(head) | |
eed4cab1 | 245 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
246 | CODE: |
247 | RETVAL = head->pre_skip; | |
248 | OUTPUT: | |
249 | RETVAL | |
250 | ||
251 | unsigned | |
252 | input_sample_rate(head) | |
eed4cab1 | 253 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
254 | CODE: |
255 | RETVAL = head->input_sample_rate; | |
256 | OUTPUT: | |
257 | RETVAL | |
258 | ||
aca25728 MG |
259 | int |
260 | output_gain(head) | |
261 | Audio::Opusfile::Head head; | |
262 | CODE: | |
263 | RETVAL = head->output_gain; | |
264 | OUTPUT: | |
265 | RETVAL | |
266 | ||
2f4b5b1b MG |
267 | int |
268 | mapping_family(head) | |
eed4cab1 | 269 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
270 | CODE: |
271 | RETVAL = head->mapping_family; | |
272 | OUTPUT: | |
273 | RETVAL | |
274 | ||
275 | int | |
276 | stream_count(head) | |
eed4cab1 | 277 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
278 | CODE: |
279 | RETVAL = head->stream_count; | |
280 | OUTPUT: | |
281 | RETVAL | |
282 | ||
283 | int | |
284 | coupled_count(head) | |
eed4cab1 | 285 | Audio::Opusfile::Head head; |
2f4b5b1b MG |
286 | CODE: |
287 | RETVAL = head->coupled_count; | |
288 | OUTPUT: | |
289 | RETVAL | |
290 | ||
291 | int | |
292 | mapping(head, k) | |
eed4cab1 | 293 | Audio::Opusfile::Head head; |
b6589960 | 294 | unsigned k; |
2f4b5b1b | 295 | CODE: |
b6589960 MG |
296 | if(k >= OPUS_CHANNEL_COUNT_MAX) |
297 | croak("k must be less than %d\n", (int)OPUS_CHANNEL_COUNT_MAX); | |
2f4b5b1b MG |
298 | RETVAL = (int) head->mapping[k]; |
299 | OUTPUT: | |
300 | RETVAL |