Author: dmeyer
Date: Mon Mar 26 18:28:04 2007
New Revision: 2599
Added:
trunk/WIP/record/src/v4l/
trunk/WIP/record/src/v4l/__init__.py
trunk/WIP/record/src/v4l/bin.py
trunk/WIP/record/src/v4l/frequencies.py
- copied, changed from r2597, /trunk/record/src/v4l_frequencies.py
trunk/WIP/record/src/v4l/tuner.py
- copied, changed from r2597, /trunk/record/src/v4l_tuner.py
Modified:
trunk/WIP/record/test/v4l.py
Log:
add v4l tuner support and create nice gst bin for it
Added: trunk/WIP/record/src/v4l/__init__.py
==============================================================================
--- (empty file)
+++ trunk/WIP/record/src/v4l/__init__.py Mon Mar 26 18:28:04 2007
@@ -0,0 +1,32 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# v4l - Gstreamer V4L modules
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------------
+# kaa-record - A recording module
+# Copyright (C) 2007 S�nke Schwardt, Dirk Meyer
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------------
+
+from bin import V4Lsrc
Added: trunk/WIP/record/src/v4l/bin.py
==============================================================================
--- (empty file)
+++ trunk/WIP/record/src/v4l/bin.py Mon Mar 26 18:28:04 2007
@@ -0,0 +1,92 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# bin - Gstreamer V4L source bin element
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------------
+# kaa-record - A recording module
+# Copyright (C) 2007 S�nke Schwardt, Dirk Meyer
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------------
+
+# gstreamer imports
+import pygst
+pygst.require('0.10')
+import gst
+
+from tuner import Tuner
+from frequencies import CHANLIST
+
+class V4Lsrc(gst.Bin):
+ def __init__(self):
+ gst.Bin.__init__(self, 'v4lsrcbin_%d')
+ self._device = '/dev/video0'
+ self._norm = 'NTSC'
+ self._tuner = Tuner(self._device, self._norm)
+ self._src = gst.element_factory_make('v4lsrc')
+ self._src.set_property('device', self._device)
+ self._queue = gst.element_factory_make('queue')
+ self.add(self._src, self._queue)
+
+ # FIXME: make this a property
+ size = 'width=%s,height=%s' % (720, 576)
+ caps = gst.structure_from_string('video/x-raw-yuv,%s' % size)
+ self._src.link_pads_filtered('src', self._queue, 'sink',
gst.Caps(caps))
+
+ pad = self._queue.get_pad('src')
+ self._ghost = gst.GhostPad(pad.get_name(), pad)
+ self.add_pad(self._ghost)
+ self._chanlist = None
+
+
+ def set_property(self, prop, value):
+ if prop == 'chanlist':
+ if not value in CHANLIST:
+ raise AttributeError('unknown chanlist %s' % value)
+ self._chanlist = value
+ return True
+ if prop == 'frequency':
+ return self._tuner.setfreq(value)
+ if prop == 'channel':
+ if not self._chanlist:
+ raise AttributeError('chanlist not set')
+ if not value in CHANLIST[self._chanlist]:
+ raise AttributeError('unknown channel %s' % value)
+ return self._tuner.setfreq(CHANLIST[self._chanlist][value])
+ if prop == 'device':
+ self._device = value
+ self._tuner = Tuner(self._device, self._norm)
+ return self._src.set_property('device', self._device)
+ if prop == 'norm':
+ if not value.upper() in ('NTSC', 'PAL'):
+ raise AttributeError('unknown norm %s' % value)
+ self._norm = value.upper()
+ self._tuner = Tuner(self._device, self._norm)
+ return self._src.set_property('device', self._device)
+ raise AttributeError
+
+
+ def get_request_pad(self, type):
+ if type == 'video':
+ return self._ghost
+ raise AttributeError
Copied: trunk/WIP/record/src/v4l/frequencies.py (from r2597,
/trunk/record/src/v4l_frequencies.py)
==============================================================================
--- /trunk/record/src/v4l_frequencies.py (original)
+++ trunk/WIP/record/src/v4l/frequencies.py Mon Mar 26 18:28:04 2007
@@ -1,31 +1,20 @@
# -*- coding: iso-8859-1 -*-
-# -----------------------------------------------------------------------
-# v4l_frequencies.py - Video Channel Frequencies
-# -----------------------------------------------------------------------
+# -----------------------------------------------------------------------------
+# frequencies - analog frequency list
+# -----------------------------------------------------------------------------
# $Id$
#
-# Notes:
-#
-# Todo:
-#
# -----------------------------------------------------------------------------
# kaa-record - A recording module
-# Copyright (C) 2005 S<F6>nke Schwardt, Dirk Meyer
+# Copyright (C) 2007 S�nke Schwardt, Dirk Meyer
#
-# First Edition: Rob Shortt <[EMAIL PROTECTED]>
-# Maintainer: Rob Shortt <[EMAIL PROTECTED]>
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
#
-# Please see the file doc/CREDITS for a complete list of authors.
+# The contents of this file are originally taken from Freevo and written by
+# Thomas Schueppel <[EMAIL PROTECTED]> and Rob Shortt <[EMAIL PROTECTED]>
#
-# -----------------------------------------------------------------------
-#
-# The contents of this file are originally taken from:
-#
-# Freevo - A Home Theater PC framework
-# Copyright (C) 2003-2005 Krister Lagerstrom, Dirk Meyer, et al.
-# Please see Freevo's doc/CREDITS for a complete list of authors.
-# src/tv/freq.py by Thomas Schueppel <[EMAIL PROTECTED]>,
-# Rob Shortt <[EMAIL PROTECTED]>
+# Please see the file AUTHORS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -41,37 +30,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# ----------------------------------------------------------------------- */
-
-import logging
-
-log = logging.getLogger('record')
-
-
-def get_frequency(tuner_id, chanlist):
- """
- Returns the frequency of a channel in MHz
- """
- freq_table = CHANLIST.get(chanlist)
-
- if freq_table:
- freq = freq_table.get(tuner_id)
- if not freq:
- log.error('unable to get frequency for %s from %s' % (tuner_id,
chanlist))
- return 0
- else:
- log.error('frequency table for "%s" unavailable' % chanlist)
- return 0
-
- return freq
-
-
-def get_frequency_khz(tuner_id, chanlist):
- """
- Returns the frequency of a channel in KHz
- """
- return float(get_frequency(tuner_id, chanlist))/1000.00
-
+# -----------------------------------------------------------------------------
NTSC_BCAST = [
("2", 55250),
Copied: trunk/WIP/record/src/v4l/tuner.py (from r2597,
/trunk/record/src/v4l_tuner.py)
==============================================================================
--- /trunk/record/src/v4l_tuner.py (original)
+++ trunk/WIP/record/src/v4l/tuner.py Mon Mar 26 18:28:04 2007
@@ -1,29 +1,20 @@
# -*- coding: iso-8859-1 -*-
-# -----------------------------------------------------------------------
-# v4l_tuner.py - V4L2 python interface.
-# -----------------------------------------------------------------------
-#
-# Notes: http://bytesex.org/v4l/spec/
-# Todo:
+# -----------------------------------------------------------------------------
+# tuner.py - v4l(2) python interface
+# -----------------------------------------------------------------------------
+# $Id$
#
# -----------------------------------------------------------------------------
# kaa-record - A recording module
-# Copyright (C) 2005 S<F6>nke Schwardt, Dirk Meyer
-#
-# First Edition: Rob Shortt <[EMAIL PROTECTED]>
-# Maintainer: Rob Shortt <[EMAIL PROTECTED]>
+# Copyright (C) 2007 S�nke Schwardt, Dirk Meyer
#
-# Please see the file doc/CREDITS for a complete list of authors.
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
#
-# -----------------------------------------------------------------------
+# The contents of this file are originally taken from Freevo and written by
+# Thomas Schueppel <[EMAIL PROTECTED]> and Rob Shortt <[EMAIL PROTECTED]>
#
-# The contents of this file are originally taken from:
-#
-# Freevo - A Home Theater PC framework
-# Copyright (C) 2003-2005 Krister Lagerstrom, Dirk Meyer, et al.
-# Please see Freevo's doc/CREDITS for a complete list of authors.
-# src/tv/v4l2.py by Thomas Schueppel <[EMAIL PROTECTED]>,
-# Rob Shortt <[EMAIL PROTECTED]>
+# Please see the file AUTHORS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -39,7 +30,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# ----------------------------------------------------------------------- */
+# -----------------------------------------------------------------------------
# python imports
import logging
@@ -50,8 +41,7 @@
from types import *
# kaa imports
-from kaa.ioctl import ioctl, IOR, IOW, IOWR
-from v4l_frequencies import get_frequency, CHANLIST
+import kaa.ioctl as ioctl
log = logging.getLogger('record')
@@ -71,53 +61,53 @@
# ioctl structs and numbers
FREQUENCY_ST = "III32x"
-GETFREQ_NO = IOWR('V', 56, FREQUENCY_ST)
-SETFREQ_NO = IOW('V', 57, FREQUENCY_ST)
+GETFREQ_NO = ioctl.IOWR('V', 56, FREQUENCY_ST)
+SETFREQ_NO = ioctl.IOW('V', 57, FREQUENCY_ST)
-SETFREQ_NO_V4L = IOW('v', 15, "L")
+SETFREQ_NO_V4L = ioctl.IOW('v', 15, "L")
QUERYCAP_ST = "16s32s32sLL16x"
-QUERYCAP_NO = IOR('V', 0, QUERYCAP_ST)
+QUERYCAP_NO = ioctl.IOR('V', 0, QUERYCAP_ST)
ENUMSTD_ST = "LQ24s2LL16x"
-ENUMSTD_NO = IOWR('V', 25, ENUMSTD_ST)
+ENUMSTD_NO = ioctl.IOWR('V', 25, ENUMSTD_ST)
STANDARD_ST = "Q"
-GETSTD_NO = IOR('V', 23, STANDARD_ST)
-SETSTD_NO = IOW('V', 24, STANDARD_ST)
+GETSTD_NO = ioctl.IOR('V', 23, STANDARD_ST)
+SETSTD_NO = ioctl.IOW('V', 24, STANDARD_ST)
ENUMINPUT_ST = "L32sLLLQL16x"
-ENUMINPUT_NO = IOWR('V', 26, ENUMINPUT_ST)
+ENUMINPUT_NO = ioctl.IOWR('V', 26, ENUMINPUT_ST)
INPUT_ST = "L";
-GETINPUT_NO = IOR('V', 38, INPUT_ST)
-SETINPUT_NO = IOWR('V', 39, INPUT_ST)
+GETINPUT_NO = ioctl.IOR('V', 38, INPUT_ST)
+SETINPUT_NO = ioctl.IOWR('V', 39, INPUT_ST)
FMT_ST = "L7L4x168x"
-GET_FMT_NO = IOWR ('V', 4, FMT_ST)
-SET_FMT_NO = IOWR ('V', 5, FMT_ST)
+GET_FMT_NO = ioctl.IOWR ('V', 4, FMT_ST)
+SET_FMT_NO = ioctl.IOWR ('V', 5, FMT_ST)
FMT_VBI_ST = "12L00x"
FMT_VBI_VARS = ('type', 'sampling_rate', 'offset', 'samples_per_line',
'sample_format',
'start0', 'start1', 'count0', 'count1', 'flags', 'reserved0',
'reserved1')
-GET_FMT_VBI_NO = IOWR ('V', 4, FMT_VBI_ST)
-SET_FMT_VBI_NO = IOWR ('V', 5, FMT_VBI_ST)
+GET_FMT_VBI_NO = ioctl.IOWR ('V', 4, FMT_VBI_ST)
+SET_FMT_VBI_NO = ioctl.IOWR ('V', 5, FMT_VBI_ST)
# struct v4l2_tuner
TUNER_ST = "L32si5L2l16x"
TUNER_VARS = ('index', 'name', 'type', 'capabilities', 'rangelow', 'rangehigh',
'rxsubchans', 'audmode', 'signal', 'afc')
-GET_TUNER_NO = IOWR ('V', 29, TUNER_ST)
-SET_TUNER_NO = IOW ('V', 30, TUNER_ST)
+GET_TUNER_NO = ioctl.IOWR ('V', 29, TUNER_ST)
+SET_TUNER_NO = ioctl.IOW ('V', 30, TUNER_ST)
AUDIO_ST = "L32sLL8x"
-GET_AUDIO_NO = IOWR ('V', 33, AUDIO_ST)
-SET_AUDIO_NO = IOW ('V', 34, AUDIO_ST)
+GET_AUDIO_NO = ioctl.IOWR ('V', 33, AUDIO_ST)
+SET_AUDIO_NO = ioctl.IOW ('V', 34, AUDIO_ST)
VIDIOC_STREAMON_ST = 'i'
VIDIOC_STREAMOFF_ST = 'i'
-VIDIOC_STREAMON = IOW('V', 18, VIDIOC_STREAMON_ST)
-VIDIOC_STREAMOFF = IOW('V', 19, VIDIOC_STREAMOFF_ST)
+VIDIOC_STREAMON = ioctl.IOW('V', 18, VIDIOC_STREAMON_ST)
+VIDIOC_STREAMOFF = ioctl.IOW('V', 19, VIDIOC_STREAMOFF_ST)
NORMS = { 'NTSC' : 0x3000,
@@ -132,66 +122,27 @@
for i, v in enumerate(var):
d[v] = r[i]
return d
-
+
def pack_dict(frm, var, d):
l = []
for v in var:
l.append(d[v])
return struct.pack(frm, *l)
-
-
-class V4L(object):
- class _V4LChannel:
- def __init__(self, tunerid, name, frequency):
- self.tunerid = tunerid
- self.name = name
- self.frequency = frequency
- def __str__(self):
- s = '%s:%s:%s' % (self.tunerid, self.name, self.frequency)
- return s
+class Tuner(object):
- def __init__(self, device, norm, chanlist=None, channels=None,
card_input=1):
+ def __init__(self, device, norm, card_input=1):
"""
"""
- self.device = device
- self.card_input = card_input
-
- if not chanlist:
- # TODO: this will be removed, we have channels.conf now
- log.error('no chanlist supplied')
- self.chanlist = 'unknown'
-
- else:
- if not chanlist in CHANLIST.keys():
- log.error('bad chanlist "%s", setting to unknown' % chanlist)
- self.chanlist = 'unknown'
- else:
- self.chanlist = chanlist
-
- # Keep a dict of the channels we care about.
- self.channels = {}
-
- if channels:
- if type(channels) == ListType:
- self.parse_channels(channels)
- elif os.path.exists(channels):
- self.load_channels(channels)
-
if not type(norm) is StringType or norm.upper() not in NORMS.keys():
log.error('bad norm "%s", using NTSC as default' % norm)
- self.norm = 'NTSC'
- else:
- self.norm = norm.upper()
-
- self.devfd = -1
- self.open()
-
- #self.devfd = os.open(self.device, os.O_RDONLY)
- #if self.devfd < 0:
- # log.error('failed to open %s, fd: %d' % (self.device, self.devfd))
+ norm = 'NTSC'
+
+ self.devfd = os.open(device, os.O_RDONLY | os.O_NONBLOCK)
+ if self.devfd < 0:
+ raise RuntimeError('failed to open %s' % device)
cardcaps = self.querycap()
self.driver = cardcaps[0][:cardcaps[0].find('\0')]
@@ -199,250 +150,117 @@
self.bus_info = cardcaps[2]
self.version = cardcaps[3]
self.capabilities = cardcaps[4]
-
- self.setstd(NORMS.get(self.norm))
- self.setinput(self.card_input)
+
+ self.setstd(NORMS.get(norm.upper()))
+ self.setinput(card_input)
# XXX TODO: make a good way of setting the capture resolution
# self.setfmt(int(width), int(height))
-
-
- def load_channels(self, channels_conf):
- channels = []
-
- try:
- cfile = open(channels_conf, 'r')
- except Exception, e:
- log.error('failed to read channels.conf (%s): %s' % (channels, e))
- return
-
- for line in cfile.readlines():
- good = line.split('#', 1)[0].rstrip('\n')
- if len(good.strip()) == 0: continue
- channels.append(good)
-
- cfile.close()
-
- self.parse_channels(channels)
-
-
- def parse_channels(self, channels):
- if type(channels) is not ListType:
- log.error('Error parsing channels: not a list')
- return False
-
- for channel in channels:
- c = channel.split(':', 2)
-
- # first field: tunerid
- tunerid = c[0]
-
- if len(c) > 1:
- # second field: name
- name = c[1]
- else:
- name = 'undefined'
-
- if len(c) > 2:
- # third field: frequency
- frequency = c[2]
- else:
- # no frequency specified, look it up
- frequency = get_frequency(tunerid, self.chanlist)
-
- if frequency == 0:
- log.error('no frequency for %s, either specify in config or
check your chanlist' % tunerid)
- continue
-
- chan = self._V4LChannel(tunerid, name, frequency)
- log.info('adding channel: %s' % chan)
- self.channels[chan.tunerid] = chan
-
-
- def get_bouquet_list(self):
- """
- Return bouquets as a list
- """
- bl = []
- for c in self.channels.values():
- bl.append([])
- bl[-1].append(c.tunerid)
-
- return bl
-
-
- def open(self):
- self.devfd = os.open(self.device, os.O_RDONLY | os.O_NONBLOCK)
- if self.devfd < 0:
- log.error('failed to open %s, fd: %d' % (self.device, self.devfd))
- return -1
-
- return self.devfd
-
-
- def close(self):
- os.close(self.devfd)
def getfreq(self):
val = struct.pack( FREQUENCY_ST, 0,0,0 )
try:
- r = ioctl(self.devfd, GETFREQ_NO, val)
+ r = ioctl.ioctl(self.devfd, GETFREQ_NO, val)
(junk,junk, freq, ) = struct.unpack(FREQUENCY_ST, r)
return freq
except IOError:
- log.warn('Failed to get frequency, not supported by device?')
+ log.warn('Failed to get frequency, not supported by device?')
return -1
- def setchannel(self, channel):
- freq = get_frequency(channel, self.chanlist)
-
- log.debug('setting channel to %s (%d)' % (channel, freq))
-
- freq *= 16
-
- # The folowing check for TUNER_LOW capabilities was not working for
- # me... needs further investigation.
- # if not (self.capabilities & V4L2_TUNER_CAP_LOW):
- # # Tune in MHz.
- # freq /= 1000
- freq /= 1000
-
+ def setfreq(self, freq):
+ freq = (freq * 16) / 1000
try:
- self.setfreq(freq)
+ val = struct.pack( FREQUENCY_ST, long(0), long(0), freq)
+ r = ioctl.ioctl(self.devfd, long(SETFREQ_NO), val)
except:
- self.setfreq_old(freq)
-
-
- def setfreq_old(self, freq):
- val = struct.pack( "L", freq)
- r = ioctl(self.devfd, long(SETFREQ_NO_V4L), val)
-
-
- def setfreq(self, freq):
- val = struct.pack( FREQUENCY_ST, long(0), long(0), freq)
- r = ioctl(self.devfd, long(SETFREQ_NO), val)
+ val = struct.pack( "L", freq)
+ r = ioctl.ioctl(self.devfd, long(SETFREQ_NO_V4L), val)
def getinput(self):
- r = ioctl(self.devfd, GETINPUT_NO, struct.pack(INPUT_ST,0))
+ r = ioctl.ioctl(self.devfd, GETINPUT_NO, struct.pack(INPUT_ST,0))
return struct.unpack(INPUT_ST,r)[0]
-
+
def setinput(self,value):
- r = ioctl(self.devfd, SETINPUT_NO, struct.pack(INPUT_ST,value))
+ r = ioctl.ioctl(self.devfd, SETINPUT_NO, struct.pack(INPUT_ST,value))
def querycap(self):
val = struct.pack( QUERYCAP_ST, "", "", "", 0, 0 )
- r = ioctl(self.devfd, QUERYCAP_NO, val)
+ r = ioctl.ioctl(self.devfd, QUERYCAP_NO, val)
return struct.unpack( QUERYCAP_ST, r )
def enumstd(self, no):
val = struct.pack( ENUMSTD_ST, no, 0, "", 0, 0, 0)
- r = ioctl(self.devfd,ENUMSTD_NO,val)
+ r = ioctl.ioctl(self.devfd,ENUMSTD_NO,val)
return struct.unpack( ENUMSTD_ST, r )
def getstd(self):
val = struct.pack( STANDARD_ST, 0 )
- r = ioctl(self.devfd,GETSTD_NO, val)
+ r = ioctl.ioctl(self.devfd,GETSTD_NO, val)
return struct.unpack( STANDARD_ST, r )[0]
def setstd(self, value):
val = struct.pack( STANDARD_ST, value )
- r = ioctl(self.devfd,SETSTD_NO, val)
+ r = ioctl.ioctl(self.devfd,SETSTD_NO, val)
def enuminput(self,index):
val = struct.pack( ENUMINPUT_ST, index, "", 0,0,0,0,0)
- r = ioctl(self.devfd,ENUMINPUT_NO,val)
+ r = ioctl.ioctl(self.devfd,ENUMINPUT_NO,val)
return struct.unpack( ENUMINPUT_ST, r )
- def getfmt(self):
+ def getfmt(self):
val = struct.pack( FMT_ST, 1L,0,0,0,0,0,0,0)
try:
- r = ioctl(self.devfd,GET_FMT_NO,val)
+ r = ioctl.ioctl(self.devfd,GET_FMT_NO,val)
return struct.unpack( FMT_ST, r )
except IOError:
- log.warn('Failed to get format, not supported by device?')
+ log.warn('Failed to get format, not supported by device?')
return (-1, -1, -1, -1, -1, -1, -1, -1)
def setfmt(self, width, height):
val = struct.pack( FMT_ST, 1L, width, height, 0L, 4L, 0L, 131072L, 0L)
- r = ioctl(self.devfd,SET_FMT_NO,val)
+ r = ioctl.ioctl(self.devfd,SET_FMT_NO,val)
- def getvbifmt(self):
+ def getvbifmt(self):
val = struct.pack( FMT_VBI_ST, 3L,0,0,0,0,0,0,0,0,0,0,0)
- r = ioctl(self.devfd,GET_FMT_NO,val)
+ r = ioctl.ioctl(self.devfd,GET_FMT_NO,val)
return unpack_dict(FMT_VBI_ST, FMT_VBI_VARS, r)
- def setvbifmt(self, d):
+ def setvbifmt(self, d):
val = pack_dict( FMT_VBI_ST, FMT_VBI_VARS, d)
- r = ioctl(self.devfd,GET_FMT_NO,val)
+ r = ioctl.ioctl(self.devfd,GET_FMT_NO,val)
return unpack_dict(FMT_VBI_ST, FMT_VBI_VARS, r)
def gettuner(self, index):
val = struct.pack( TUNER_ST, index, "", 0,0,0,0,0,0,0,0)
- return unpack_dict( TUNER_ST, TUNER_VARS,
ioctl(self.devfd,GET_TUNER_NO,val))
+ r = ioctl.ioctl(self.devfd,GET_TUNER_NO,val)
+ return unpack_dict( TUNER_ST, TUNER_VARS, r)
def settuner(self,index,audmode):
val = struct.pack( TUNER_ST, index, "", 0,0,0,0,0,audmode,0,0)
- r = ioctl(self.devfd,SET_TUNER_NO,val)
+ r = ioctl.ioctl(self.devfd,SET_TUNER_NO,val)
def getaudio(self,index):
val = struct.pack( AUDIO_ST, index, "", 0,0)
- r = ioctl(self.devfd,GET_AUDIO_NO,val)
+ r = ioctl.ioctl(self.devfd,GET_AUDIO_NO,val)
return struct.unpack( AUDIO_ST, r )
def setaudio(self,index,mode):
val = struct.pack( AUDIO_ST, index, "", mode, 0)
- r = ioctl(self.devfd,SET_AUDIO_NO,val)
-
-
- def settings_as_string(self):
- s = 'Driver: %s\n' % self.driver
- s += 'Card: %s\n' % self.card
- s += 'Version: %s\n' % self.version
- s += 'Capabilities: %s\n' % self.capabilities
-
- s += 'Enumerating supported Standards.\n'
- try:
- for i in range(0,255):
- (index,id,name,junk,junk,junk) = self.enumstd(i)
- s += ' %i: 0x%x %s\n' % (index, id, name)
- except:
- pass
- s += 'Current Standard is: 0x%x\n' % self.getstd()
-
- s += 'Enumerating supported Inputs.\n'
- try:
- for i in range(0,255):
- (index,name,type,audioset,tuner,std,status) = self.enuminput(i)
- s += ' %i: %s\n' % (index, name)
- except:
- pass
- s += 'Input: %i\n' % self.getinput()
-
- (buf_type, width, height, pixelformat, field, bytesperline,
- sizeimage, colorspace) = self.getfmt()
- s += 'Width: %i, Height: %i\n' % (width,height)
-
- freq = self.getfreq()
- s += 'Read Frequency: %d (%d)' % (freq, freq*1000/16)
- return s
-
-
- def print_settings(self):
- log.info('Settings:\n%s' %self.settings_as_string())
+ r = ioctl.ioctl(self.devfd,SET_AUDIO_NO,val)
Modified: trunk/WIP/record/test/v4l.py
==============================================================================
--- trunk/WIP/record/test/v4l.py (original)
+++ trunk/WIP/record/test/v4l.py Mon Mar 26 18:28:04 2007
@@ -17,6 +17,8 @@
import kaa.notifier
kaa.notifier.init('gtk', x11=False)
+from kaa.record2.v4l import V4Lsrc
+
def bus_event(bus, message):
t = message.type
if t == gst.MESSAGE_EOS:
@@ -26,30 +28,47 @@
err, debug = message.parse_error()
print "Error: %s" % err, debug
sys.exit(0)
+ elif t == gst.MESSAGE_STATE_CHANGED:
+ if message.src == src and message.parse_state_changed()[1] ==
gst.STATE_PLAYING:
+ print 'go'
+
print message
return True
pipeline = gst.Pipeline()
pipeline.get_bus().add_watch(bus_event)
-src = gst.element_factory_make('v4lsrc')
-video = gst.element_factory_make('queue')
+src = V4Lsrc()
+# src.set_property('frequency', 196250)
+src.set_property('norm', 'pal')
+src.set_property('chanlist', 'europe-west')
+src.set_property('channel', 'E8')
+
+deinterlace = gst.element_factory_make('deinterlace')
+
mpeg4 = gst.element_factory_make('ffenc_mpeg4')
-mpeg4.set_property('bitrate', 800)
+mpeg4.set_property('bitrate', 5000)
mpeg4.set_property('pass', 'quant')
mpeg4.set_property('quantizer', 10)
mpeg4.set_property('flags', 0x00000004 | 0x00000040 | 0x00200000)
mux = gst.element_factory_make('matroskamux')
sink = gst.element_factory_make('filesink')
-sink.set_property('location', '/local/testvideo.mkv')
+sink.set_property('location', 'testvideo.mkv')
+pipeline.add(src, deinterlace, mpeg4, mux, sink)
+gst.element_link_many(src, deinterlace, mpeg4)
-pipeline.add(src, video, mpeg4, mux, sink)
-gst.element_link_many(src, video, mpeg4)
vpad = mux.get_compatible_pad(mpeg4.get_pad('src'))
mpeg4.get_pad('src').link(vpad)
gst.element_link_many(mux, sink)
+# audio = gst.element_factory_make('alsasrc')
+# audio.set_property('device', '/dev/sound/dsp')
+# pipeline.add(audio)
+# apad = mux.get_compatible_pad(audio.get_pad('src'))
+# audio.get_pad('src').link(apad)
+
pipeline.set_state(gst.STATE_PLAYING)
+
kaa.notifier.loop()
-------------------------------------------------------------------------
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