More functions
[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
14MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile PREFIX = op_
15
16PROTOTYPES: ENABLE
17INCLUDE: const-xs.inc
18
19OggOpusFile*
20op_open_file(path)
21 const char *path;
22PREINIT:
23 int err;
5fbea9a2
MG
24C_ARGS:
25 path, &err
26POSTCALL:
a3f1cbda
MG
27 if(err)
28 croak("op_open_file returned error %d\n", err);
5fbea9a2
MG
29
30OggOpusFile*
31op_open_memory(const char *data, size_t length(data))
32PREINIT:
33 int err;
34C_ARGS:
35 data, XSauto_length_of_data, &err
36POSTCALL:
37 if(err)
38 croak("op_open_memory returned error %d\n", err);
39
40bool
41op_test(const char *data, size_t length(data))
42PROTOTYPE: $
43PREINIT:
44 int ret;
45CODE:
46 ret = op_test (NULL, data, XSauto_length_of_data);
47 if(ret < 0 && ret != OP_ENOTFORMAT && ret != OP_EBADHEADER)
48 croak("op_test returned error %d\n", RETVAL);
49 RETVAL = !ret;
a3f1cbda
MG
50OUTPUT:
51 RETVAL
52
5fbea9a2 53
a3f1cbda
MG
54void
55DESTROY(of)
56 OggOpusFile *of;
57CODE:
58 op_free(of);
59
5fbea9a2
MG
60bool
61op_seekable(of)
62 OggOpusFile* of;
63
64int
65op_link_count(of)
66 OggOpusFile* of;
67
68int
69op_serialno(of, li = -1)
70 OggOpusFile* of;
71 int li;
72
a3f1cbda
MG
73const OpusHead*
74op_head(of, li = -1)
75 OggOpusFile *of;
76 int li;
77
78const OpusTags*
79op_tags(of, li = -1)
80 OggOpusFile *of;
81 int li;
82
83MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Tags PREFIX = opus_tags_
84
85int
86opus_tags_query_count(tags, tag)
87 const OpusTags* tags;
88 const char* tag;
89
90const char*
91opus_tags_query(tags, tag, count = 0)
92 const OpusTags* tags;
93 const char* tag;
94 int count;
2f4b5b1b
MG
95
96MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::PictureTag PREFIX = opus_picture_tag_
97
98const OpusPictureTag*
99opus_picture_tag_parse(tag)
100 const char *tag;
101PREINIT:
102 OpusPictureTag *pic;
103 int err;
104CODE:
105 Newx(pic, 1, OpusPictureTag);
106 if(err = opus_picture_tag_parse(pic, tag))
107 croak("opus_picture_tag_parse returned error %d\n", err);
108 RETVAL = pic;
109OUTPUT:
110 RETVAL
111
112void
113DESTROY(pic)
114 const OpusPictureTag* pic
115CODE:
116 Safefree(pic);
117
118int
119type(pic)
120 const OpusPictureTag *pic;
121CODE:
122 RETVAL = pic->type;
123OUTPUT:
124 RETVAL
125
126const char*
127mime_type(pic)
128 const OpusPictureTag *pic;
129CODE:
130 RETVAL = pic->mime_type;
131OUTPUT:
132 RETVAL
133
134const char*
135description(pic)
136 const OpusPictureTag *pic;
137CODE:
138 RETVAL = pic->description;
139OUTPUT:
140 RETVAL
141
142int
143width(pic)
144 const OpusPictureTag *pic;
145CODE:
146 RETVAL = pic->width;
147OUTPUT:
148 RETVAL
149
150int
151height(pic)
152 const OpusPictureTag *pic;
153CODE:
154 RETVAL = pic->height;
155OUTPUT:
156 RETVAL
157
158int
159depth(pic)
160 const OpusPictureTag *pic;
161CODE:
162 RETVAL = pic->depth;
163OUTPUT:
164 RETVAL
165
166int
167colors(pic)
168 const OpusPictureTag *pic;
169CODE:
170 RETVAL = pic->colors;
171OUTPUT:
172 RETVAL
173
174int
175data_length(pic)
176 const OpusPictureTag *pic;
177CODE:
178 RETVAL = pic->data_length;
179OUTPUT:
180 RETVAL
181
182SV*
183data(pic)
184 const OpusPictureTag *pic;
185CODE:
186 RETVAL = newSVpvn(pic->data, pic->data_length);
187OUTPUT:
188 RETVAL
189
190int
191format(pic)
192 const OpusPictureTag *pic;
193CODE:
194 RETVAL = pic->format;
195OUTPUT:
196 RETVAL
197
198MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Head
199
200int
201version(head)
202 const OpusHead* head;
203CODE:
204 RETVAL = head->version;
205OUTPUT:
206 RETVAL
207
208int
209channel_count(head)
210 const OpusHead* head;
211CODE:
212 RETVAL = head->channel_count;
213OUTPUT:
214 RETVAL
215
216unsigned
217pre_skip(head)
218 const OpusHead* head;
219CODE:
220 RETVAL = head->pre_skip;
221OUTPUT:
222 RETVAL
223
224unsigned
225input_sample_rate(head)
226 const OpusHead* head;
227CODE:
228 RETVAL = head->input_sample_rate;
229OUTPUT:
230 RETVAL
231
232int
233mapping_family(head)
234 const OpusHead* head;
235CODE:
236 RETVAL = head->mapping_family;
237OUTPUT:
238 RETVAL
239
240int
241stream_count(head)
242 const OpusHead* head;
243CODE:
244 RETVAL = head->stream_count;
245OUTPUT:
246 RETVAL
247
248int
249coupled_count(head)
250 const OpusHead* head;
251CODE:
252 RETVAL = head->coupled_count;
253OUTPUT:
254 RETVAL
255
256int
257mapping(head, k)
258 const OpusHead* head;
259 int k;
260CODE:
261 RETVAL = (int) head->mapping[k];
262OUTPUT:
263 RETVAL
This page took 0.023398 seconds and 4 git commands to generate.