7779aa979526305cb509b379cb3d29682ee96be4
[audio-opusfile.git] / Opusfile.xs
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
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
19 MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile PREFIX = op_
20
21 PROTOTYPES: ENABLE
22 INCLUDE: const-xs.inc
23
24 Audio::Opusfile
25 op_open_file(path)
26 const char *path;
27 PREINIT:
28 int err;
29 C_ARGS:
30 path, &err
31 POSTCALL:
32 if(err)
33 croak("op_open_file returned error %d\n", err);
34
35 Audio::Opusfile
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;
55 OUTPUT:
56 RETVAL
57
58
59 void
60 DESTROY(of)
61 Audio::Opusfile of;
62 CODE:
63 op_free(of);
64
65 bool
66 op_seekable(of)
67 Audio::Opusfile of;
68
69 int
70 op_link_count(of)
71 Audio::Opusfile of;
72
73 int
74 op_serialno(of, li = -1)
75 Audio::Opusfile of;
76 int li;
77
78 Audio::Opusfile::Head
79 op_head(of, li = -1)
80 Audio::Opusfile of;
81 int li;
82
83 Audio::Opusfile::Tags
84 op_tags(of, li = -1)
85 Audio::Opusfile of;
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)
92 Audio::Opusfile::Tags tags;
93 const char* tag;
94
95 const char*
96 opus_tags_query(tags, tag, count = 0)
97 Audio::Opusfile::Tags tags;
98 const char* tag;
99 int count;
100
101 MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::PictureTag PREFIX = opus_picture_tag_
102
103 Audio::Opusfile::PictureTag
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)
119 Audio::Opusfile::PictureTag pic
120 CODE:
121 Safefree(pic);
122
123 int
124 type(pic)
125 Audio::Opusfile::PictureTag pic;
126 CODE:
127 RETVAL = pic->type;
128 OUTPUT:
129 RETVAL
130
131 const char*
132 mime_type(pic)
133 Audio::Opusfile::PictureTag pic;
134 CODE:
135 RETVAL = pic->mime_type;
136 OUTPUT:
137 RETVAL
138
139 const char*
140 description(pic)
141 Audio::Opusfile::PictureTag pic;
142 CODE:
143 RETVAL = pic->description;
144 OUTPUT:
145 RETVAL
146
147 int
148 width(pic)
149 Audio::Opusfile::PictureTag pic;
150 CODE:
151 RETVAL = pic->width;
152 OUTPUT:
153 RETVAL
154
155 int
156 height(pic)
157 Audio::Opusfile::PictureTag pic;
158 CODE:
159 RETVAL = pic->height;
160 OUTPUT:
161 RETVAL
162
163 int
164 depth(pic)
165 Audio::Opusfile::PictureTag pic;
166 CODE:
167 RETVAL = pic->depth;
168 OUTPUT:
169 RETVAL
170
171 int
172 colors(pic)
173 Audio::Opusfile::PictureTag pic;
174 CODE:
175 RETVAL = pic->colors;
176 OUTPUT:
177 RETVAL
178
179 int
180 data_length(pic)
181 Audio::Opusfile::PictureTag pic;
182 CODE:
183 RETVAL = pic->data_length;
184 OUTPUT:
185 RETVAL
186
187 SV*
188 data(pic)
189 Audio::Opusfile::PictureTag pic;
190 CODE:
191 RETVAL = newSVpvn(pic->data, pic->data_length);
192 OUTPUT:
193 RETVAL
194
195 int
196 format(pic)
197 Audio::Opusfile::PictureTag pic;
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)
207 Audio::Opusfile::Head head;
208 CODE:
209 RETVAL = head->version;
210 OUTPUT:
211 RETVAL
212
213 int
214 channel_count(head)
215 Audio::Opusfile::Head head;
216 CODE:
217 RETVAL = head->channel_count;
218 OUTPUT:
219 RETVAL
220
221 unsigned
222 pre_skip(head)
223 Audio::Opusfile::Head head;
224 CODE:
225 RETVAL = head->pre_skip;
226 OUTPUT:
227 RETVAL
228
229 unsigned
230 input_sample_rate(head)
231 Audio::Opusfile::Head head;
232 CODE:
233 RETVAL = head->input_sample_rate;
234 OUTPUT:
235 RETVAL
236
237 int
238 mapping_family(head)
239 Audio::Opusfile::Head head;
240 CODE:
241 RETVAL = head->mapping_family;
242 OUTPUT:
243 RETVAL
244
245 int
246 stream_count(head)
247 Audio::Opusfile::Head head;
248 CODE:
249 RETVAL = head->stream_count;
250 OUTPUT:
251 RETVAL
252
253 int
254 coupled_count(head)
255 Audio::Opusfile::Head head;
256 CODE:
257 RETVAL = head->coupled_count;
258 OUTPUT:
259 RETVAL
260
261 int
262 mapping(head, k)
263 Audio::Opusfile::Head head;
264 int k;
265 CODE:
266 RETVAL = (int) head->mapping[k];
267 OUTPUT:
268 RETVAL
This page took 0.029551 seconds and 3 git commands to generate.