| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Audio::File::Type; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 5 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 27 |  | 
| 4 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 375 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | our $VERSION = '0.02'; | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | =head1 NAME | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | Audio::File::Type - represents an audio filetype | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | An instance of an object inherited from Audio::File::Type is returned by the | 
| 15 |  |  |  |  |  |  | constructor of Audio::File. This object currently provides access to the audio | 
| 16 |  |  |  |  |  |  | files information like its audio properties (bitrate, sample rate, number of | 
| 17 |  |  |  |  |  |  | channels, ...) and the data stored in the files tag, but also providing access | 
| 18 |  |  |  |  |  |  | to the raw audio data and other information should be easy to be implemented. | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | =head1 METHODS | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | =head2 new | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | Constructor. In fact you don't need to use it. Please use Audio::File which will | 
| 25 |  |  |  |  |  |  | call the appropriate constructor corresponding to the files type. | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | =cut | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | sub new { | 
| 30 | 3 |  |  | 3 | 1 | 9 | my($class, $filename) = @_; | 
| 31 | 3 |  | 33 |  |  | 26 | $class = ref $class || $class; | 
| 32 | 3 |  |  |  |  | 16 | my $self = { | 
| 33 |  |  |  |  |  |  | name		=> $filename, | 
| 34 |  |  |  |  |  |  | readonly 	=> 1 | 
| 35 |  |  |  |  |  |  | }; | 
| 36 | 3 |  |  |  |  | 11 | bless $self, $class; | 
| 37 | 3 | 50 |  |  |  | 25 | return unless $self->is_readable(); | 
| 38 | 3 | 50 |  |  |  | 16 | $self->init(@_) or return; | 
| 39 | 3 |  |  |  |  | 31 | return $self; | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =head2 init | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | This method will be called by the constructor. It's empty by default and should | 
| 45 |  |  |  |  |  |  | be overwritten by inheriting subclasses to initialize themselfes. | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | =cut | 
| 48 |  |  |  |  |  |  |  | 
| 49 | 0 |  |  | 0 | 1 | 0 | sub init { | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | } | 
| 52 |  |  |  |  |  |  |  | 
| 53 | 0 |  |  | 0 |  | 0 | sub _create_tag { } | 
| 54 |  |  |  |  |  |  |  | 
| 55 | 0 |  |  | 0 |  | 0 | sub _create_audio_properties { } | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | =head2 name | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | Returns the name of the audio file. | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | =cut | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | sub name { | 
| 64 | 6 |  |  | 6 | 1 | 79 | return shift->{name}; | 
| 65 |  |  |  |  |  |  | } | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | =head2 is_readable | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | Checks whether the file is readable or not. At the moment it's only used by the | 
| 70 |  |  |  |  |  |  | constructor, but it will be more usefull with later versions of Audio::File. | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =cut | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | sub is_readable { | 
| 75 | 3 |  |  | 3 | 1 | 102 | return -r shift->{name}; | 
| 76 |  |  |  |  |  |  | } | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | =head2 is_writeable | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | Checks whether the file is writeable or not. At the moment you'll probably don't | 
| 81 |  |  |  |  |  |  | need to call this method, but it'll be more usefull as soon as changing the | 
| 82 |  |  |  |  |  |  | audio file is implemented. | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | =cut | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | sub is_writeable { | 
| 87 | 0 |  |  | 0 | 1 | 0 | return -w shift->{name}; | 
| 88 |  |  |  |  |  |  | } | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | =head2 tag | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | Returns a reference to the files tag object. See the documentation of | 
| 93 |  |  |  |  |  |  | L to learn about what the tag object does. | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | =cut | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | sub tag { | 
| 98 | 27 |  |  | 27 | 1 | 9841 | my $self = shift; | 
| 99 | 27 | 100 |  |  |  | 84 | unless( $self->{tag} ) { | 
| 100 | 3 | 50 |  |  |  | 11 | $self->_create_tag() or return; | 
| 101 |  |  |  |  |  |  | } | 
| 102 |  |  |  |  |  |  |  | 
| 103 | 27 |  |  |  |  | 132 | return $self->{tag}; | 
| 104 |  |  |  |  |  |  | } | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | =head2 audio_properties | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | Returns a reference to the files audio properties object. See the documentation | 
| 109 |  |  |  |  |  |  | of L to get information about what the audio | 
| 110 |  |  |  |  |  |  | properties object does. | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | =cut | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | sub audio_properties { | 
| 115 | 15 |  |  | 15 | 1 | 7370 | my $self = shift; | 
| 116 | 15 | 100 |  |  |  | 53 | unless( $self->{audio_properties} ) { | 
| 117 | 3 | 50 |  |  |  | 13 | $self->_create_audio_properties() or return; | 
| 118 |  |  |  |  |  |  | } | 
| 119 |  |  |  |  |  |  |  | 
| 120 | 15 |  |  |  |  | 81 | return $self->{audio_properties}; | 
| 121 |  |  |  |  |  |  | } | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | =head2 save | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | Saves the audio file. This is not yet implemented but it should remember me to | 
| 126 |  |  |  |  |  |  | do it at some time.. :-) | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | =cut | 
| 129 |  |  |  |  |  |  |  | 
| 130 | 0 |  |  | 0 | 1 | 0 | sub save { | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | } | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | =head2 type | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | Returns the files type. | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | =cut | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | sub type { | 
| 141 | 3 |  |  | 3 | 1 | 2474 | (my $type = ref shift) =~ s/.*:://; | 
| 142 | 3 |  |  |  |  | 18 | return lc $type; | 
| 143 |  |  |  |  |  |  | } | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | =head1 TODO | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | =over 4 | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | =item implement changing the file | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | =back | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 154 |  |  |  |  |  |  |  | 
| 155 |  |  |  |  |  |  | L, L, L | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  | =head1 AUTHOR | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  | Florian Ragwitz | 
| 160 |  |  |  |  |  |  |  | 
| 161 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 162 |  |  |  |  |  |  |  | 
| 163 |  |  |  |  |  |  | Copyright (C) 2004 Florian Ragwitz | 
| 164 |  |  |  |  |  |  |  | 
| 165 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify | 
| 166 |  |  |  |  |  |  | it under the terms of the GNU General Public License as published by | 
| 167 |  |  |  |  |  |  | the Free Software Foundation; either version 2 of the License, or | 
| 168 |  |  |  |  |  |  | (at your option) any later version. | 
| 169 |  |  |  |  |  |  |  | 
| 170 |  |  |  |  |  |  | This program is distributed in the hope that it will be useful, | 
| 171 |  |  |  |  |  |  | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 172 |  |  |  |  |  |  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 173 |  |  |  |  |  |  | GNU Library General Public License for more details. | 
| 174 |  |  |  |  |  |  |  | 
| 175 |  |  |  |  |  |  | You should have received a copy of the GNU General Public License | 
| 176 |  |  |  |  |  |  | along with this program; if not, write to the Free Software | 
| 177 |  |  |  |  |  |  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 
| 178 |  |  |  |  |  |  |  | 
| 179 |  |  |  |  |  |  | =cut |