MMX optimizations by Nils Pipenbrinck.
[xiph/unicode.git] / souffleur / oggStreams.py
blobcecb58aa29d3c71d4dfb8255a649d95c9306bce3
1 __name__="oggStreams - class of streams in OGG files"
2 __author__="Maxim Litvinov (aka DarakuTenshi) otaky<at>ukr.net"
4 import os
5 import re
7 import oggStream
9 class oggStreams:
10 """
11 Class for work with OGG.
12 """
13 def __init__(self, fileName):
14 """
15 Constructor of oggStreams class.
16 @param[IN] fileName - name of OGG file.
17 """
18 #Run ogminfo util on given file.
19 OGMINFO=os.popen("ogminfo -v \"" + fileName + "\"", "r")
20 if(OGMINFO==None): return NULL
21 STAT=OGMINFO.readlines() #Output data from ogminfo to the list of strings.
22 OGMINFO.close()
24 self.streams={}
25 for i in STAT:
26 #Stream info
27 regSTAT=re.compile("\(ogminfo.c\) [(](\w)(\d)[/](\S+) (\d)[)] (\S+)")
28 mathSTAT=regSTAT.match(i)
29 if mathSTAT!=None:
30 HASH=mathSTAT.group(1)+mathSTAT.group(2)
31 self.streams[HASH]=oggStream.oggStream(mathSTAT.group(4), mathSTAT.group(1), fileName)
32 #Stream attribute
33 regSTAT=re.compile("\(ogminfo.c\) (\S+)[:](\s+)(\S+)[=]([\S\s]+)[\n]")
34 mathSTAT=regSTAT.match(i)
35 if mathSTAT!=None:
36 OGGStream=self.streams[mathSTAT.group(1)]
37 OGGStream.addAttr(mathSTAT.group(3), mathSTAT.group(4))
38 return
39 #==============================================================================
40 def getStreams(self):
41 """
42 This function return a list of streams.
43 """
44 return self.streams.values()
45 #==============================================================================