Implement PictureTag and (partially) Head
[audio-opusfile.git] / lib / Audio / Opusfile.pm
1 package Audio::Opusfile;
2
3 use 5.014000;
4 use strict;
5 use warnings;
6 use Carp;
7
8 use parent qw/Exporter/;
9 use AutoLoader;
10
11 my @constants =
12 qw/OPUS_CHANNEL_COUNT_MAX
13 OP_ABSOLUTE_GAIN
14 OP_DEC_FORMAT_FLOAT
15 OP_DEC_FORMAT_SHORT
16 OP_DEC_USE_DEFAULT
17 OP_EBADHEADER
18 OP_EBADLINK
19 OP_EBADPACKET
20 OP_EBADTIMESTAMP
21 OP_EFAULT
22 OP_EIMPL
23 OP_EINVAL
24 OP_ENOSEEK
25 OP_ENOTAUDIO
26 OP_ENOTFORMAT
27 OP_EOF
28 OP_EREAD
29 OP_EVERSION
30 OP_FALSE
31 OP_GET_SERVER_INFO_REQUEST
32 OP_HEADER_GAIN
33 OP_HOLE
34 OP_HTTP_PROXY_HOST_REQUEST
35 OP_HTTP_PROXY_PASS_REQUEST
36 OP_HTTP_PROXY_PORT_REQUEST
37 OP_HTTP_PROXY_USER_REQUEST
38 OP_PIC_FORMAT_GIF
39 OP_PIC_FORMAT_JPEG
40 OP_PIC_FORMAT_PNG
41 OP_PIC_FORMAT_UNKNOWN
42 OP_PIC_FORMAT_URL
43 OP_SSL_SKIP_CERTIFICATE_CHECK_REQUEST
44 OP_TRACK_GAIN/;
45
46 our @EXPORT_OK = @constants;
47 our @EXPORT = @constants;
48
49 our $VERSION = '0.001';
50
51 sub AUTOLOAD {
52 # This AUTOLOAD is used to 'autoload' constants from the constant()
53 # XS function.
54
55 my $constname;
56 our $AUTOLOAD;
57 ($constname = $AUTOLOAD) =~ s/.*:://;
58 croak "&Audio::Opusfile::constant not defined" if $constname eq 'constant';
59 my ($error, $val) = constant($constname);
60 if ($error) { croak $error; }
61 {
62 no strict 'refs';
63 # Fixed between 5.005_53 and 5.005_61
64 #XXX if ($] >= 5.00561) {
65 #XXX *$AUTOLOAD = sub () { $val };
66 #XXX }
67 #XXX else {
68 *$AUTOLOAD = sub { $val };
69 #XXX }
70 }
71 goto &$AUTOLOAD;
72 }
73
74 require XSLoader;
75 XSLoader::load('Audio::Opusfile', $VERSION);
76 require Audio::Opusfile::Tags;
77 require Audio::Opusfile::PictureTag;
78
79 # Preloaded methods go here.
80
81 sub new_from_file {
82 my ($class, $file) = @_;
83 open_file($file)
84 }
85
86 1;
87 __END__
88
89 =encoding utf-8
90
91 =head1 NAME
92
93 Audio::Opusfile - Very incomplete interface to the libopusfile Ogg Opus library
94
95 =head1 SYNOPSIS
96
97 use Audio::Opusfile;
98 my $of = Audio::Opusfile->new_from_file('silence.opus');
99 my $tags = $of->tags;
100 say $tags->query('TITLE'); # Cellule
101
102 =head1 DESCRIPTION
103
104 Opus is a totally open, royalty-free, highly versatile audio codec.
105 Opus is unmatched for interactive speech and music transmission over
106 the Internet, but is also intended for storage and streaming
107 applications. It is standardized by the Internet Engineering Task
108 Force (IETF) as RFC 6716 which incorporated technology from Skype's
109 SILK codec and Xiph.Org's CELT codec.
110
111 libopusfile is a library for decoding and basic manipulation of Ogg
112 Opus files.
113
114 Audio::Opusfile is an interface to libopusfile. At the moment its only
115 function is reading metadata and tags from an Ogg Opus file. Future
116 versions will give access to a larger part of the libopusfile API.
117
118 Expect the API to change in future versions.
119
120 =head1 METHODS
121
122 =over
123
124 =item Audio::Opusfile->B<new_from_file>(I<$file>)
125
126 Creates a new Audio::Opusfile object from an Ogg Opus file.
127
128 Dies if the given file does not exist or is not a valid Ogg Opus file.
129
130 =item B<$of>->head
131
132 Returns an L<Audio::Opusfile::Head> object corresponding to the file.
133
134 =item B<$of>->tags
135
136 Returns an L<Audio::Opusfile::Tags> object corresponding to the file.
137
138 =back
139
140 =head1 EXPORT
141
142 All constants are exported by default:
143
144 OPUS_CHANNEL_COUNT_MAX
145 OP_ABSOLUTE_GAIN
146 OP_DEC_FORMAT_FLOAT
147 OP_DEC_FORMAT_SHORT
148 OP_DEC_USE_DEFAULT
149 OP_EBADHEADER
150 OP_EBADLINK
151 OP_EBADPACKET
152 OP_EBADTIMESTAMP
153 OP_EFAULT
154 OP_EIMPL
155 OP_EINVAL
156 OP_ENOSEEK
157 OP_ENOTAUDIO
158 OP_ENOTFORMAT
159 OP_EOF
160 OP_EREAD
161 OP_EVERSION
162 OP_FALSE
163 OP_GET_SERVER_INFO_REQUEST
164 OP_HEADER_GAIN
165 OP_HOLE
166 OP_HTTP_PROXY_HOST_REQUEST
167 OP_HTTP_PROXY_PASS_REQUEST
168 OP_HTTP_PROXY_PORT_REQUEST
169 OP_HTTP_PROXY_USER_REQUEST
170 OP_PIC_FORMAT_GIF
171 OP_PIC_FORMAT_JPEG
172 OP_PIC_FORMAT_PNG
173 OP_PIC_FORMAT_UNKNOWN
174 OP_PIC_FORMAT_URL
175 OP_SSL_SKIP_CERTIFICATE_CHECK_REQUEST
176 OP_TRACK_GAIN
177
178
179 =head1 SEE ALSO
180
181 L<Audio::Opusfile::Tags>,
182 L<http://opus-codec.org/>,
183 L<http://opus-codec.org/docs/opusfile_api-0.7/index.html>
184
185 =head1 AUTHOR
186
187 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
188
189 =head1 COPYRIGHT AND LICENSE
190
191 Copyright (C) 2016 by Marius Gavrilescu
192
193 This library is free software; you can redistribute it and/or modify
194 it under the same terms as Perl itself, either Perl version 5.24.0 or,
195 at your option, any later version of Perl 5 you may have available.
196
197
198 =cut
This page took 0.027321 seconds and 4 git commands to generate.