also enable pat scan for automatic sdt scan on channel change
[enigma2.git] / lib / python / Plugins / Extensions / DVDBurn / DVDTitle.py
1 class DVDTitle:
2         def __init__(self):
3                 self.cuesheet = [ ]
4                 self.source = None
5                 self.name = ""
6                 self.descr = ""
7                 self.filesize = 0
8                 self.estimatedDiskspace = 0
9                 self.inputfile = ""
10                 self.cutlist = [ ]
11                 self.chaptermarks = [ ]
12                 self.timeCreate = None
13
14         def addService(self, service):
15                 from os import path
16                 from enigma import eServiceCenter, iServiceInformation
17                 from ServiceReference import ServiceReference
18                 from time import localtime, time
19                 self.source = service
20                 serviceHandler = eServiceCenter.getInstance()
21                 info = serviceHandler.info(service)
22                 self.descr = info and " " + info.getInfoString(service, iServiceInformation.sDescription) or ""
23                 sTimeCreate = info.getInfo(service, iServiceInformation.sTimeCreate)
24                 if sTimeCreate > 1:
25                         self.timeCreate = localtime(sTimeCreate)
26                 serviceref = ServiceReference(info.getInfoString(service, iServiceInformation.sServiceref))
27                 self.name = info and info.getName(service) or "Title" + t.descr
28                 self.channel = serviceref.getServiceName()
29                 self.inputfile = service.getPath()
30                 self.filesize = path.getsize(self.inputfile)
31                 self.estimatedDiskspace = self.filesize
32                 self.length = info.getLength(service)
33
34         def produceFinalCuesheet(self):
35                 CUT_TYPE_IN = 0
36                 CUT_TYPE_OUT = 1
37                 CUT_TYPE_MARK = 2
38                 CUT_TYPE_LAST = 3
39
40                 accumulated_in = 0
41                 accumulated_at = 0
42                 last_in = 0
43
44                 self.cutlist = [ ]
45                 self.chaptermarks = [ ]
46
47                 # our demuxer expects *strictly* IN,OUT lists.
48                 currently_in = not any(type == CUT_TYPE_IN for pts, type in self.cuesheet)
49                 if currently_in:
50                         self.cutlist.append(0) # emulate "in" at first          
51
52                 for (pts, type) in self.cuesheet:
53                         #print "pts=", pts, "type=", type, "accumulated_in=", accumulated_in, "accumulated_at=", accumulated_at, "last_in=", last_in
54                         if type == CUT_TYPE_IN and not currently_in:
55                                 self.cutlist.append(pts)
56                                 last_in = pts
57                                 currently_in = True
58
59                         if type == CUT_TYPE_OUT and currently_in:
60                                 self.cutlist.append(pts)
61
62                                 # accumulate the segment
63                                 accumulated_in += pts - last_in 
64                                 accumulated_at = pts
65                                 currently_in = False
66
67                         if type == CUT_TYPE_MARK and currently_in:
68                                 # relocate chaptermark against "in" time. This is not 100% accurate,
69                                 # as the in/out points are not.
70                                 reloc_pts = pts - last_in + accumulated_in
71                                 self.chaptermarks.append(reloc_pts)
72                                 
73                 if len(self.cutlist) > 1:
74                         part = accumulated_in / (self.length*90000.0)
75                         usedsize = int ( part * self.filesize )
76                         self.estimatedDiskspace = usedsize
77                         self.length = accumulated_in / 90000
78
79         def produceAutoChapter(self, minutes):
80                 if len(self.chaptermarks) < 1:
81                         chapterpts = self.cutlist[0]
82                         while chapterpts < self.length*90000:
83                                 chapterpts += 90000 * 60 * minutes
84                                 self.chaptermarks.append(chapterpts)