Use regular T_PTROBJ and typedefs instead of a complex typemap
[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
eed4cab1 78Audio::Opusfile::Head
a3f1cbda 79op_head(of, li = -1)
eed4cab1 80 Audio::Opusfile of;
a3f1cbda
MG
81 int li;
82
eed4cab1 83Audio::Opusfile::Tags
a3f1cbda 84op_tags(of, li = -1)
eed4cab1 85 Audio::Opusfile of;
a3f1cbda
MG
86 int li;
87
88MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Tags PREFIX = opus_tags_
89
90int
91opus_tags_query_count(tags, tag)
eed4cab1 92 Audio::Opusfile::Tags tags;
a3f1cbda
MG
93 const char* tag;
94
95const char*
96opus_tags_query(tags, tag, count = 0)
eed4cab1 97 Audio::Opusfile::Tags tags;
a3f1cbda
MG
98 const char* tag;
99 int count;
2f4b5b1b
MG
100
101MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::PictureTag PREFIX = opus_picture_tag_
102
eed4cab1 103Audio::Opusfile::PictureTag
2f4b5b1b
MG
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)
eed4cab1 119 Audio::Opusfile::PictureTag pic
2f4b5b1b
MG
120CODE:
121 Safefree(pic);
122
123int
124type(pic)
eed4cab1 125 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
126CODE:
127 RETVAL = pic->type;
128OUTPUT:
129 RETVAL
130
131const char*
132mime_type(pic)
eed4cab1 133 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
134CODE:
135 RETVAL = pic->mime_type;
136OUTPUT:
137 RETVAL
138
139const char*
140description(pic)
eed4cab1 141 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
142CODE:
143 RETVAL = pic->description;
144OUTPUT:
145 RETVAL
146
147int
148width(pic)
eed4cab1 149 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
150CODE:
151 RETVAL = pic->width;
152OUTPUT:
153 RETVAL
154
155int
156height(pic)
eed4cab1 157 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
158CODE:
159 RETVAL = pic->height;
160OUTPUT:
161 RETVAL
162
163int
164depth(pic)
eed4cab1 165 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
166CODE:
167 RETVAL = pic->depth;
168OUTPUT:
169 RETVAL
170
171int
172colors(pic)
eed4cab1 173 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
174CODE:
175 RETVAL = pic->colors;
176OUTPUT:
177 RETVAL
178
179int
180data_length(pic)
eed4cab1 181 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
182CODE:
183 RETVAL = pic->data_length;
184OUTPUT:
185 RETVAL
186
187SV*
188data(pic)
eed4cab1 189 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
190CODE:
191 RETVAL = newSVpvn(pic->data, pic->data_length);
192OUTPUT:
193 RETVAL
194
195int
196format(pic)
eed4cab1 197 Audio::Opusfile::PictureTag pic;
2f4b5b1b
MG
198CODE:
199 RETVAL = pic->format;
200OUTPUT:
201 RETVAL
202
203MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Head
204
205int
206version(head)
eed4cab1 207 Audio::Opusfile::Head head;
2f4b5b1b
MG
208CODE:
209 RETVAL = head->version;
210OUTPUT:
211 RETVAL
212
213int
214channel_count(head)
eed4cab1 215 Audio::Opusfile::Head head;
2f4b5b1b
MG
216CODE:
217 RETVAL = head->channel_count;
218OUTPUT:
219 RETVAL
220
221unsigned
222pre_skip(head)
eed4cab1 223 Audio::Opusfile::Head head;
2f4b5b1b
MG
224CODE:
225 RETVAL = head->pre_skip;
226OUTPUT:
227 RETVAL
228
229unsigned
230input_sample_rate(head)
eed4cab1 231 Audio::Opusfile::Head head;
2f4b5b1b
MG
232CODE:
233 RETVAL = head->input_sample_rate;
234OUTPUT:
235 RETVAL
236
237int
238mapping_family(head)
eed4cab1 239 Audio::Opusfile::Head head;
2f4b5b1b
MG
240CODE:
241 RETVAL = head->mapping_family;
242OUTPUT:
243 RETVAL
244
245int
246stream_count(head)
eed4cab1 247 Audio::Opusfile::Head head;
2f4b5b1b
MG
248CODE:
249 RETVAL = head->stream_count;
250OUTPUT:
251 RETVAL
252
253int
254coupled_count(head)
eed4cab1 255 Audio::Opusfile::Head head;
2f4b5b1b
MG
256CODE:
257 RETVAL = head->coupled_count;
258OUTPUT:
259 RETVAL
260
261int
262mapping(head, k)
eed4cab1 263 Audio::Opusfile::Head head;
2f4b5b1b
MG
264 int k;
265CODE:
266 RETVAL = (int) head->mapping[k];
267OUTPUT:
268 RETVAL
This page took 0.02633 seconds and 4 git commands to generate.