]> iEval git - audio-opusfile.git/blame_incremental - Opusfile.xs
Croak if OpusHead->mapping gets a nonsensical argument
[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
78Audio::Opusfile::Head
79op_head(of, li = -1)
80 Audio::Opusfile of;
81 int li;
82
83Audio::Opusfile::Tags
84op_tags(of, li = -1)
85 Audio::Opusfile of;
86 int li;
87
88MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Tags PREFIX = opus_tags_
89
90int
91opus_tags_query_count(tags, tag)
92 Audio::Opusfile::Tags tags;
93 const char* tag;
94
95const char*
96opus_tags_query(tags, tag, count = 0)
97 Audio::Opusfile::Tags tags;
98 const char* tag;
99 int count;
100
101MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::PictureTag PREFIX = opus_picture_tag_
102
103Audio::Opusfile::PictureTag
104opus_picture_tag_parse(tag)
105 const char *tag;
106PREINIT:
107 OpusPictureTag *pic;
108 int err;
109CODE:
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;
114OUTPUT:
115 RETVAL
116
117void
118DESTROY(pic)
119 Audio::Opusfile::PictureTag pic
120CODE:
121 Safefree(pic);
122
123int
124type(pic)
125 Audio::Opusfile::PictureTag pic;
126CODE:
127 RETVAL = pic->type;
128OUTPUT:
129 RETVAL
130
131const char*
132mime_type(pic)
133 Audio::Opusfile::PictureTag pic;
134CODE:
135 RETVAL = pic->mime_type;
136OUTPUT:
137 RETVAL
138
139const char*
140description(pic)
141 Audio::Opusfile::PictureTag pic;
142CODE:
143 RETVAL = pic->description;
144OUTPUT:
145 RETVAL
146
147int
148width(pic)
149 Audio::Opusfile::PictureTag pic;
150CODE:
151 RETVAL = pic->width;
152OUTPUT:
153 RETVAL
154
155int
156height(pic)
157 Audio::Opusfile::PictureTag pic;
158CODE:
159 RETVAL = pic->height;
160OUTPUT:
161 RETVAL
162
163int
164depth(pic)
165 Audio::Opusfile::PictureTag pic;
166CODE:
167 RETVAL = pic->depth;
168OUTPUT:
169 RETVAL
170
171int
172colors(pic)
173 Audio::Opusfile::PictureTag pic;
174CODE:
175 RETVAL = pic->colors;
176OUTPUT:
177 RETVAL
178
179int
180data_length(pic)
181 Audio::Opusfile::PictureTag pic;
182CODE:
183 RETVAL = pic->data_length;
184OUTPUT:
185 RETVAL
186
187SV*
188data(pic)
189 Audio::Opusfile::PictureTag pic;
190CODE:
191 RETVAL = newSVpvn(pic->data, pic->data_length);
192OUTPUT:
193 RETVAL
194
195int
196format(pic)
197 Audio::Opusfile::PictureTag pic;
198CODE:
199 RETVAL = pic->format;
200OUTPUT:
201 RETVAL
202
203MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Head
204
205int
206version(head)
207 Audio::Opusfile::Head head;
208CODE:
209 RETVAL = head->version;
210OUTPUT:
211 RETVAL
212
213int
214channel_count(head)
215 Audio::Opusfile::Head head;
216CODE:
217 RETVAL = head->channel_count;
218OUTPUT:
219 RETVAL
220
221unsigned
222pre_skip(head)
223 Audio::Opusfile::Head head;
224CODE:
225 RETVAL = head->pre_skip;
226OUTPUT:
227 RETVAL
228
229unsigned
230input_sample_rate(head)
231 Audio::Opusfile::Head head;
232CODE:
233 RETVAL = head->input_sample_rate;
234OUTPUT:
235 RETVAL
236
237int
238output_gain(head)
239 Audio::Opusfile::Head head;
240CODE:
241 RETVAL = head->output_gain;
242OUTPUT:
243 RETVAL
244
245int
246mapping_family(head)
247 Audio::Opusfile::Head head;
248CODE:
249 RETVAL = head->mapping_family;
250OUTPUT:
251 RETVAL
252
253int
254stream_count(head)
255 Audio::Opusfile::Head head;
256CODE:
257 RETVAL = head->stream_count;
258OUTPUT:
259 RETVAL
260
261int
262coupled_count(head)
263 Audio::Opusfile::Head head;
264CODE:
265 RETVAL = head->coupled_count;
266OUTPUT:
267 RETVAL
268
269int
270mapping(head, k)
271 Audio::Opusfile::Head head;
272 unsigned k;
273CODE:
274 if(k >= OPUS_CHANNEL_COUNT_MAX)
275 croak("k must be less than %d\n", (int)OPUS_CHANNEL_COUNT_MAX);
276 RETVAL = (int) head->mapping[k];
277OUTPUT:
278 RETVAL
This page took 0.016409 seconds and 4 git commands to generate.