[4] | 1 | #if 0 |
---|
| 2 | # ----------------------------------------------------------------------- |
---|
| 3 | # $Id: pcminfo.py,v 1.8 2003/06/30 13:17:18 the_krow Exp $ |
---|
| 4 | # ----------------------------------------------------------------------- |
---|
| 5 | # $Log: pcminfo.py,v $ |
---|
| 6 | # Revision 1.8 2003/06/30 13:17:18 the_krow |
---|
| 7 | # o Refactored mediainfo into factory, synchronizedobject |
---|
| 8 | # o Parsers now register directly at mmpython not at mmpython.mediainfo |
---|
| 9 | # o use mmpython.Factory() instead of mmpython.mediainfo.get_singleton() |
---|
| 10 | # o Bugfix in PNG parser |
---|
| 11 | # o Renamed disc.AudioInfo into disc.AudioDiscInfo |
---|
| 12 | # o Renamed disc.DataInfo into disc.DataDiscInfo |
---|
| 13 | # |
---|
| 14 | # Revision 1.7 2003/06/20 19:17:22 dischi |
---|
| 15 | # remove filename again and use file.name |
---|
| 16 | # |
---|
| 17 | # Revision 1.6 2003/06/08 19:53:38 dischi |
---|
| 18 | # also give the filename to init for additional data tests |
---|
| 19 | # |
---|
| 20 | # Revision 1.5 2003/06/08 13:44:56 dischi |
---|
| 21 | # Changed all imports to use the complete mmpython path for mediainfo |
---|
| 22 | # |
---|
| 23 | # Revision 1.4 2003/06/08 13:11:25 dischi |
---|
| 24 | # removed print at the end and moved it into register |
---|
| 25 | # |
---|
| 26 | # Revision 1.3 2003/05/13 15:23:59 the_krow |
---|
| 27 | # IPTC |
---|
| 28 | # |
---|
| 29 | # ----------------------------------------------------------------------- |
---|
| 30 | # Revision 1.2 2003/05/13 12:31:43 the_krow |
---|
| 31 | # + Copyright Notice |
---|
| 32 | # |
---|
| 33 | # |
---|
| 34 | # ----------------------------------------------------------------------- |
---|
| 35 | # MMPython - Media Metadata for Python |
---|
| 36 | # Copyright (C) 2003 Thomas Schueppel |
---|
| 37 | # |
---|
| 38 | # This program is free software; you can redistribute it and/or modify |
---|
| 39 | # it under the terms of the GNU General Public License as published by |
---|
| 40 | # the Free Software Foundation; either version 2 of the License, or |
---|
| 41 | # (at your option) any later version. |
---|
| 42 | # |
---|
| 43 | # This program is distributed in the hope that it will be useful, but |
---|
| 44 | # WITHOUT ANY WARRANTY; without even the implied warranty of MER- |
---|
| 45 | # CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
| 46 | # Public License for more details. |
---|
| 47 | # |
---|
| 48 | # You should have received a copy of the GNU General Public License along |
---|
| 49 | # with this program; if not, write to the Free Software Foundation, Inc., |
---|
| 50 | # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 51 | # |
---|
| 52 | # ----------------------------------------------------------------------- |
---|
| 53 | #endif |
---|
| 54 | |
---|
| 55 | import sndhdr |
---|
| 56 | from mmpython import mediainfo |
---|
| 57 | import mmpython |
---|
| 58 | |
---|
| 59 | class PCMInfo(mediainfo.AudioInfo): |
---|
| 60 | def _what(self,f): |
---|
| 61 | """Recognize sound headers""" |
---|
| 62 | h = f.read(512) |
---|
| 63 | for tf in sndhdr.tests: |
---|
| 64 | res = tf(h, f) |
---|
| 65 | if res: |
---|
| 66 | return res |
---|
| 67 | return None |
---|
| 68 | |
---|
| 69 | def __init__(self,file): |
---|
| 70 | mediainfo.AudioInfo.__init__(self) |
---|
| 71 | t = self._what(file) |
---|
| 72 | if t: |
---|
| 73 | (self.type, self.samplerate, self.channels, self.bitrate, self.samplebits) = t |
---|
| 74 | self.mime = "audio/%s" % self.type |
---|
| 75 | self.valid = 1 |
---|
| 76 | else: |
---|
| 77 | self.valid = 0 |
---|
| 78 | return |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | mmpython.registertype( 'application/pcm', ('wav','aif','voc','au'), mediainfo.TYPE_AUDIO, PCMInfo ) |
---|