Author: duncan
Date: Tue Jan 8 15:40:43 2008
New Revision: 10269
Log:
Fixed a bug in ivtv_record, it didn't use the VideoGroup device to record from
Corrected and changes some debug messages
Modified:
branches/rel-1/freevo/src/tv/channels.py
branches/rel-1/freevo/src/tv/ivtv.py
branches/rel-1/freevo/src/tv/plugins/ivtv_record.py
branches/rel-1/freevo/src/tv/v4l2.py
Modified: branches/rel-1/freevo/src/tv/channels.py
==============================================================================
--- branches/rel-1/freevo/src/tv/channels.py (original)
+++ branches/rel-1/freevo/src/tv/channels.py Tue Jan 8 15:40:43 2008
@@ -124,7 +124,7 @@
for pos in range(len(config.TV_CHANNELS)):
chan_cfg = config.TV_CHANNELS[pos]
- if chan_cfg[2] == chan:
+ if str(chan_cfg[2]) == str(chan):
new_chan = chan
self.chan_index = pos
Modified: branches/rel-1/freevo/src/tv/ivtv.py
==============================================================================
--- branches/rel-1/freevo/src/tv/ivtv.py (original)
+++ branches/rel-1/freevo/src/tv/ivtv.py Tue Jan 8 15:40:43 2008
@@ -116,8 +116,7 @@
10 : 3, 11 : 4, 12 : 5, 13 : 3, 14 : 3
}
try:
- if config.DEBUG >= 1:
- _debug_('streamTypeIvtvToV4l2 %s -> %s' % (stream_type,
map_ivtv_to_v4l2[stream_type]))
+ _debug_('streamTypeIvtvToV4l2 %s -> %s' % (stream_type,
map_ivtv_to_v4l2[stream_type]), 2)
return map_ivtv_to_v4l2[stream_type]
except:
print 'streamTypeIvtvToV4l2 %s failed' % (stream_type)
@@ -129,7 +128,7 @@
0 : 0, 2 : 2, 3 : 10, 4 : 11, 5 : 12,
}
try:
- _debug_('streamTypeV4l2ToIVTV %s -> %s' % (stream_type,
map_v4l2_to_ivtv[stream_type]))
+ _debug_('streamTypeV4l2ToIVTV %s -> %s' % (stream_type,
map_v4l2_to_ivtv[stream_type]), 2)
return map_v4l2_to_ivtv[stream_type]
except:
print 'streamTypeV4l2ToIVTV %s failed' % (stream_type)
Modified: branches/rel-1/freevo/src/tv/plugins/ivtv_record.py
==============================================================================
--- branches/rel-1/freevo/src/tv/plugins/ivtv_record.py (original)
+++ branches/rel-1/freevo/src/tv/plugins/ivtv_record.py Tue Jan 8 15:40:43 2008
@@ -56,6 +56,7 @@
"""
def __init__(self):
+ _debug_('PluginInterface.__init__()', 2)
plugin.Plugin.__init__(self)
plugin.register(Recorder(), plugin.RECORD)
@@ -63,6 +64,7 @@
class Recorder:
def __init__(self):
+ _debug_('Recorder.__init__()', 2)
# Disable this plugin if not loaded by record_server.
if string.find(sys.argv[0], 'recordserver') == -1:
return
@@ -76,17 +78,18 @@
def Record(self, rec_prog):
+ _debug_('Record(rec_prog=%r)' % (rec_prog), 2)
# It is safe to ignore config.TV_RECORD_FILE_SUFFIX here.
rec_prog.filename =
os.path.splitext(tv_util.getProgFilename(rec_prog))[0] + '.mpeg'
self.thread.mode = 'record'
self.thread.prog = rec_prog
self.thread.mode_flag.set()
-
_debug_('Recorder::Record: %s' % rec_prog, DINFO)
def Stop(self):
+ _debug_('Stop()', 2)
self.thread.mode = 'stop'
self.thread.mode_flag.set()
@@ -95,6 +98,7 @@
class Record_Thread(threading.Thread):
def __init__(self):
+ _debug_('Record_Thread.__init__()', 2)
threading.Thread.__init__(self)
self.mode = 'idle'
@@ -104,6 +108,7 @@
def run(self):
+ _debug_('Record_Thread.run()', 2)
while 1:
_debug_('Record_Thread::run: mode=%s' % self.mode)
if self.mode == 'idle':
@@ -111,63 +116,69 @@
self.mode_flag.clear()
elif self.mode == 'record':
- rc.post_event(Event('RECORD_START', arg=self.prog))
- _debug_('Record_Thread::run: started recording', DINFO)
-
- fc = FreevoChannels()
- _debug_('CHAN: %s' % fc.getChannel())
-
- (v_norm, v_input, v_clist, v_dev) = config.TV_SETTINGS.split()
-
- v = tv.ivtv.IVTV(v_dev)
-
- v.init_settings()
- vg = fc.getVideoGroup(self.prog.tunerid, False)
-
- _debug_('Setting Input to %s' % vg.input_type)
- v.setinputbyname(vg.input_type)
-
- cur_std = v.getstd()
try:
- new_std = V4L2.NORMS.get(vg.tuner_norm)
- if cur_std != new_std:
- v.setstd(new_std)
- except:
- _debug_("Videogroup norm value '%s' not from NORMS: %s" % \
- (vg.tuner_norm, V4L2.NORMS.keys()), DERROR)
- _debug_('Setting Channel to %s' % self.prog.tunerid)
- fc.chanSet(str(self.prog.tunerid), False)
-
- if vg.cmd != None:
- _debug_("run cmd: %s" % vg.cmd)
- retcode=os.system(vg.cmd)
- _debug_("exit code: %g" % retcode)
-
- _debug_('%s' % v.print_settings())
-
- now = time.time()
- stop = now + self.prog.rec_duration
-
- time.sleep(2)
-
- v_in = open(v_dev, 'r')
- v_out = open(self.prog.filename, 'w')
-
- while time.time() < stop:
- buf = v_in.read(CHUNKSIZE)
- v_out.write(buf)
- if self.mode == 'stop':
- break
-
- v_in.close()
- v_out.close()
- v.close()
- v = None
+ _debug_('Record_Thread::run: started recording', DINFO)
- self.mode = 'idle'
+ fc = FreevoChannels()
+ _debug_('Channel: %s' % (fc.getChannel()))
+
+ vg = fc.getVideoGroup(self.prog.tunerid, False)
- rc.post_event(Event('RECORD_STOP', arg=self.prog))
- _debug_('Record_Thread::run: finished recording', DINFO)
+ _debug_('Opening device %r' % (vg.vdev))
+ v = tv.ivtv.IVTV(vg.vdev)
+
+ v.init_settings()
+
+ _debug_('Setting input to %r' % (vg.input_type))
+ v.setinputbyname(vg.input_type)
+
+ cur_std = v.getstd()
+ try:
+ new_std = V4L2.NORMS.get(vg.tuner_norm)
+ if cur_std != new_std:
+ _debug_('Setting standard to %s' % (new_std))
+ v.setstd(new_std)
+ except:
+ _debug_("Videogroup norm value '%s' not from NORMS:
%s" % \
+ (vg.tuner_norm, V4L2.NORMS.keys()), DERROR)
+
+ _debug_('Setting channel to %r' % self.prog.tunerid)
+ fc.chanSet(str(self.prog.tunerid), False)
+
+ if vg.cmd != None:
+ _debug_("Running command %r" % vg.cmd)
+ retcode = os.system(vg.cmd)
+ _debug_("exit code: %g" % retcode)
+
+ now = time.time()
+ stop = now + self.prog.rec_duration
+
+ rc.post_event(Event('RECORD_START', arg=self.prog))
+ time.sleep(2)
+
+ v_in = open(vg.vdev, 'r')
+ v_out = open(self.prog.filename, 'w')
+
+ _debug_('Recording from %r to %r in %s byte chunks' %
(vg.vdev, self.prog.filename, CHUNKSIZE))
+ while time.time() < stop:
+ buf = v_in.read(CHUNKSIZE)
+ v_out.write(buf)
+ if self.mode == 'stop':
+ _debug_('Recording stopped', DINFO)
+ break
+
+ v_in.close()
+ v_out.close()
+ v.close()
+ v = None
+
+ self.mode = 'idle'
+
+ rc.post_event(Event('RECORD_STOP', arg=self.prog))
+ _debug_('Record_Thread::run: finished recording', DINFO)
+ except Exception, why:
+ _debug_('%s' % (why), DCRITICAL)
+ return
else:
self.mode = 'idle'
Modified: branches/rel-1/freevo/src/tv/v4l2.py
==============================================================================
--- branches/rel-1/freevo/src/tv/v4l2.py (original)
+++ branches/rel-1/freevo/src/tv/v4l2.py Tue Jan 8 15:40:43 2008
@@ -467,12 +467,11 @@
"""
v_norm = name.upper()
try:
- _debug_('setstdbyname: %s (0x%08X) set' % (name, NORMS[v_norm]))
self.setstd(NORMS[v_norm])
+ _debug_('setstdbyname: %s (0x%08X) set' % (name, NORMS[v_norm]), 3)
except KeyError, e:
_debug_('setstdbyname failed: %s' % (e), DERROR)
_debug_('possible are: %r' % (NORMS.keys()), DINFO)
- _debug_('setstdbyname: %s (0x%08X) set' % (name, NORMS[v_norm]))
def enuminput(self, num):
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog