Author: dmeyer
Date: Fri Feb 23 18:44:01 2007
New Revision: 2518
Modified:
trunk/WIP/record/src/device.py
trunk/WIP/record/src/dvb.py
trunk/WIP/record/test/tuner.py
Log:
better status handling
Modified: trunk/WIP/record/src/device.py
==============================================================================
--- trunk/WIP/record/src/device.py (original)
+++ trunk/WIP/record/src/device.py Fri Feb 23 18:44:01 2007
@@ -46,7 +46,9 @@
log = logging.getLogger('record.gstreamer')
class Device(object):
-
+ """
+ kaa.record device.
+ """
def __init__(self, device):
# create gstreamer pipline
@@ -63,6 +65,9 @@
def _gst_event(self, bus, message):
+ """
+ Internal gstreamer debug for this pipeline.
+ """
t = message.type
if t == gst.MESSAGE_EOS:
log.info('EOS')
@@ -74,18 +79,41 @@
return True
+ def get_status(self):
+ """
+ Return status information of the device.
+ """
+ return self.device.get_property('status')
+
+
+ def has_signal(self):
+ """
+ Return True if the device has a lock on the signal and is
+ ready for recording.
+ """
+ return self.device.get_property('has_signal')
+
+
def start_recording(self, channel, output):
+ """
+ Start a recording.
+ """
element = output.element
self.pipeline.add(element)
element.set_state(gst.STATE_PLAYING)
sink = element.get_pad('sink')
- # FIXME: clean up needed
- pids = int(channel.config['vpid']), int(channel.config['apids'][0][0])
+ # tune to the channel
self.device.set_property('channel', channel)
+ # FIXME: Clean up needed. Which apid should be used? How to handle
+ # analog cards without pids.
+ pids = int(channel.config['vpid']), int(channel.config['apids'][0][0])
self.device.get_request_pad(*pids).link(sink)
def stop_recording(self, output):
+ """
+ Stop a recording.
+ """
element = output.element
pad = element.get_pad('sink')
peer = pad.get_peer()
Modified: trunk/WIP/record/src/dvb.py
==============================================================================
--- trunk/WIP/record/src/dvb.py (original)
+++ trunk/WIP/record/src/dvb.py Fri Feb 23 18:44:01 2007
@@ -97,6 +97,23 @@
raise AttributeError
+ def get_property(self, prop):
+ if prop == 'status':
+ cells = self._tuner.get_property('status').strip().split(' ')
+ status = { 'signalstrength': int(cells[-7]), 'snr:':
int(cells[-5]),
+ 'ber': int(cells[-3]), 'unc': int(cells[-1]) }
+ for s in ('HAS_SIGNAL', 'TIMEDOUT', 'HAS_LOCK', 'HAS_CARRIER',
+ 'HAS_VITERBI', 'HAS_SYNC'):
+ status[s] = False
+ if 'FE_%s' % s in cells:
+ status[s] = True
+ return status
+ if prop == 'has_signal':
+ cells = self._tuner.get_property('status').strip().split(' ')
+ return 'FE_HAS_SIGNAL' in cells and 'FE_HAS_LOCK' in cells
+ return Super(DVBsrc, self).get_property(prop)
+
+
def _on_new_pad(self, splitter, pad):
self._newpad = gst.GhostPad(pad.get_name(), pad)
self.add_pad(self._newpad)
Modified: trunk/WIP/record/test/tuner.py
==============================================================================
--- trunk/WIP/record/test/tuner.py (original)
+++ trunk/WIP/record/test/tuner.py Fri Feb 23 18:44:01 2007
@@ -30,8 +30,8 @@
print message
return True
-def tuner_debug(dvb):
- print dvb._tuner.get_property('status')
+def tuner_debug(device):
+ print device.get_status()
def gc_check():
gc.collect()
@@ -56,7 +56,7 @@
kaa.record2.Recording(time.time() + 3, time.time() + 8, device,
chan, kaa.record2.Filewriter('zdf.ts'))
-kaa.notifier.Timer(tuner_debug, device.device).start(1)
+kaa.notifier.Timer(tuner_debug, device).start(1)
# # start 3sat in 3 seconds
# kaa.notifier.OneShotTimer(create_recording, '3sat.ts', 561, 562).start(3)
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog