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