We're no longer very incomplete
[audio-opusfile.git] / Opusfile.xs
CommitLineData
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
14typedef OggOpusFile* Audio__Opusfile;
15typedef const OpusHead* Audio__Opusfile__Head;
16typedef const OpusTags* Audio__Opusfile__Tags;
17typedef const OpusPictureTag* Audio__Opusfile__PictureTag;
18
a3f1cbda
MG
19MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile PREFIX = op_
20
21PROTOTYPES: ENABLE
22INCLUDE: const-xs.inc
23
eed4cab1 24Audio::Opusfile
a3f1cbda
MG
25op_open_file(path)
26 const char *path;
27PREINIT:
28 int err;
5fbea9a2
MG
29C_ARGS:
30 path, &err
31POSTCALL:
a3f1cbda
MG
32 if(err)
33 croak("op_open_file returned error %d\n", err);
5fbea9a2 34
eed4cab1 35Audio::Opusfile
5fbea9a2
MG
36op_open_memory(const char *data, size_t length(data))
37PREINIT:
38 int err;
39C_ARGS:
40 data, XSauto_length_of_data, &err
41POSTCALL:
42 if(err)
43 croak("op_open_memory returned error %d\n", err);
44
45bool
46op_test(const char *data, size_t length(data))
47PROTOTYPE: $
48PREINIT:
49 int ret;
50CODE:
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
55OUTPUT:
56 RETVAL
57
5fbea9a2 58
a3f1cbda
MG
59void
60DESTROY(of)
eed4cab1 61 Audio::Opusfile of;
a3f1cbda
MG
62CODE:
63 op_free(of);
64
5fbea9a2
MG
65bool
66op_seekable(of)
eed4cab1 67 Audio::Opusfile of;
5fbea9a2
MG
68
69int
70op_link_count(of)
eed4cab1 71 Audio::Opusfile of;
5fbea9a2
MG
72
73int
74op_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
80long
81op_raw_total(of, li = -1)
82 Audio::Opusfile of;
83 int li;
84
85long
86op_pcm_total(of, li = -1)
87 Audio::Opusfile of;
88 int li;
89
eed4cab1 90Audio::Opusfile::Head
a3f1cbda 91op_head(of, li = -1)
eed4cab1 92 Audio::Opusfile of;
a3f1cbda
MG
93 int li;
94
eed4cab1 95Audio::Opusfile::Tags
a3f1cbda 96op_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
102int
103op_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
110MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Tags PREFIX = opus_tags_
111
112int
113opus_tags_query_count(tags, tag)
eed4cab1 114 Audio::Opusfile::Tags tags;
a3f1cbda
MG
115 const char* tag;
116
117const char*
118opus_tags_query(tags, tag, count = 0)
eed4cab1 119 Audio::Opusfile::Tags tags;
a3f1cbda
MG
120 const char* tag;
121 int count;
2f4b5b1b
MG
122
123MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::PictureTag PREFIX = opus_picture_tag_
124
eed4cab1 125Audio::Opusfile::PictureTag
2f4b5b1b
MG
126opus_picture_tag_parse(tag)
127 const char *tag;
128PREINIT:
129 OpusPictureTag *pic;
130 int err;
131CODE:
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;
136OUTPUT:
137 RETVAL
138
139void
140DESTROY(pic)
eed4cab1 141 Audio::Opusfile::PictureTag pic
2f4b5b1b
MG
142CODE:
143 Safefree(pic);
144
145int
146type(pic)
eed4cab1 147 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
148CODE:
149 RETVAL = pic->type;
150OUTPUT:
151 RETVAL
152
153const char*
154mime_type(pic)
eed4cab1 155 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
156CODE:
157 RETVAL = pic->mime_type;
158OUTPUT:
159 RETVAL
160
161const char*
162description(pic)
eed4cab1 163 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
164CODE:
165 RETVAL = pic->description;
166OUTPUT:
167 RETVAL
168
169int
170width(pic)
eed4cab1 171 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
172CODE:
173 RETVAL = pic->width;
174OUTPUT:
175 RETVAL
176
177int
178height(pic)
eed4cab1 179 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
180CODE:
181 RETVAL = pic->height;
182OUTPUT:
183 RETVAL
184
185int
186depth(pic)
eed4cab1 187 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
188CODE:
189 RETVAL = pic->depth;
190OUTPUT:
191 RETVAL
192
193int
194colors(pic)
eed4cab1 195 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
196CODE:
197 RETVAL = pic->colors;
198OUTPUT:
199 RETVAL
200
201int
202data_length(pic)
eed4cab1 203 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
204CODE:
205 RETVAL = pic->data_length;
206OUTPUT:
207 RETVAL
208
209SV*
210data(pic)
eed4cab1 211 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
212CODE:
213 RETVAL = newSVpvn(pic->data, pic->data_length);
214OUTPUT:
215 RETVAL
216
217int
218format(pic)
eed4cab1 219 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
220CODE:
221 RETVAL = pic->format;
222OUTPUT:
223 RETVAL
224
225MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Head
226
227int
228version(head)
eed4cab1 229 Audio::Opusfile::Head head;
2f4b5b1b
MG
230CODE:
231 RETVAL = head->version;
232OUTPUT:
233 RETVAL
234
235int
236channel_count(head)
eed4cab1 237 Audio::Opusfile::Head head;
2f4b5b1b
MG
238CODE:
239 RETVAL = head->channel_count;
240OUTPUT:
241 RETVAL
242
243unsigned
244pre_skip(head)
eed4cab1 245 Audio::Opusfile::Head head;
2f4b5b1b
MG
246CODE:
247 RETVAL = head->pre_skip;
248OUTPUT:
249 RETVAL
250
251unsigned
252input_sample_rate(head)
eed4cab1 253 Audio::Opusfile::Head head;
2f4b5b1b
MG
254CODE:
255 RETVAL = head->input_sample_rate;
256OUTPUT:
257 RETVAL
258
aca25728
MG
259int
260output_gain(head)
261 Audio::Opusfile::Head head;
262CODE:
263 RETVAL = head->output_gain;
264OUTPUT:
265 RETVAL
266
2f4b5b1b
MG
267int
268mapping_family(head)
eed4cab1 269 Audio::Opusfile::Head head;
2f4b5b1b
MG
270CODE:
271 RETVAL = head->mapping_family;
272OUTPUT:
273 RETVAL
274
275int
276stream_count(head)
eed4cab1 277 Audio::Opusfile::Head head;
2f4b5b1b
MG
278CODE:
279 RETVAL = head->stream_count;
280OUTPUT:
281 RETVAL
282
283int
284coupled_count(head)
eed4cab1 285 Audio::Opusfile::Head head;
2f4b5b1b
MG
286CODE:
287 RETVAL = head->coupled_count;
288OUTPUT:
289 RETVAL
290
291int
292mapping(head, k)
eed4cab1 293 Audio::Opusfile::Head head;
b6589960 294 unsigned k;
2f4b5b1b 295CODE:
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];
299OUTPUT:
300 RETVAL
This page took 0.029238 seconds and 4 git commands to generate.