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