btchannels
index
/usr/local/share/apps/kbtv/btchannels.py

TV/composite channels, list management, channelset constants

 
Modules
       
bt848
btcopyright
btdriver
buildprefs
cPickle
os
saa
time

 
Classes
       
BTChannel
BTChannelList
BTComposite

 
class BTChannel
    This class describes a TV channel.
 
  Methods defined here:
__init__(self, frequency=0, name='', finetune=True)
-> BTChannel
 
The constructor takes an integer frequency and a string name, 
and assigns them to the atributes frequency and name.Unless 
finetune is set to False, the method fineTune() is called. 
 
Frequency and name are cut off if needed to match this:
- bt848.MINFREQ (0) <= frequency <= bt848.MAXFREQ (900)
  or saa.MINFREQ <= frequency <= saa.MAXFREQ if applicable
- len(name) <= CHANNEL_NAME_MAXLEN (64)
 
If frequency and name are not passed, they become MINFREQ and "" and
can be set with the set methods. Also tunes to the frequency.
fineTune(self)
-> void
 
Attempts simple fine-tuning using AFC (bt848 module).
 
AFC has a maximum "float" of AFC_STEP (5 MHz). If one sets the 
tuner frequency to f with AFC, the optimum of f to f+4 inclusive 
is picked (that doesn't mean an actual TV signal is there, it 
may also be the "loudest" noise).
 
There's a need to distribute the AFC_STEP evenly around f: First 
the tuner is told to tune to f-2 (SCAN_STEP). Then AFC kicks in 
and sets the actual frequency to f-2, f-1, f, f+1 or f+2.
 
If this method is used, it should probably be when the BTChannel
object has just been created. Also tunes to the AFC'd frequency.
 
If the saa driver is being used, no AFC and only tunes to freq.
setFrequency(self, frequency, finetune=True)
-> void
 
Sets the BTChannel object's frequency attribute to the integer
value specified by the argument frequency (MHz). Unless finetune is 
set to False, the method fineTune() is called (does nothing with saa).
Also tunes to the frequency.
setName(self, name)
-> void
 
Sets the BTChannel object's name attribute to the string
specified by the argument name. Delimited to 
CHANNEL_NAME_MAXLEN (64) characters.

 
class BTChannelList
    This class describes a channel list and ways to manage it.
 
  Methods defined here:
__init__(self)
-> BTChannelList
 
Creates a BTChannelList object. It has an attribute channels,
which is an ordered list of arbitrary size holding BTChannel 
and BTComposite objects. It also has a convenience attribute
tuner, so that bt848.tuner_tunerdev need only be called once.
If the saa driver is used the tuner device is always 1.
It has methods to append, delete, move channel objects, as 
well as for reading and writing a representation of the data
as a plain text file. It also has a few tuning methods for 
getting and setting the channel. The channels attribute is 
initialized to an empty list.
 
BTChannelLists cycle around when moving members, so that 
moving one below index 0 will put it on the highest index 
again and vice versa.
append(self, obj, replace=False)
-> void
    
Appends a BTChannel/BTComposite object at the "end" of the
channel list (or at "position -1"). Does nothing if obj is an
object of another type.
 
The boolean replace indicates if adding the new channel should 
lead to the removal of any already present channel with the same
frequency or composite id, or the other way around (if already 
present, don't append). If omitted, replace is False.
clear(self)
-> void
 
Clears channel list, e.g. the attribute channels is set to [].
currentChannel(self)
-> BTChannel or BTComposite
 
Returns the BTChannel/BTComposite object currently tuned to. If 
the frequency or composite device currently tuned to is not in
the channel list, it returns None.
currentChannelIndex(self)
-> int
 
As currentChannel() but returns the list index, -1 if not in it.
delete(self, obj)
-> void
 
Deletes obj from the channel list if obj is in it.
deleteIndex(self, index)
-> void
 
Deletes the object at position index from the channel list.
index(self, obj)
-> int
 
Returns the channel list index of obj, or -1 if not in it.
isBTChannel(self, obj)
-> bool
 
Returns True if obj is a BTChannel object.
isBTComposite(self, obj)
-> bool
 
Returns True if obj is a BTComposite object.
len(self)
-> int
 
Returns the current length of the channel list.
moveDown(self, obj)
-> void
 
Moves obj one place down in the channel list if obj is in it.
Cycles to the end of the list if at index 0.
moveDownIndex(self, index)
-> void
 
As moveDown but by index. Does nothing if index < 0 or too large.
moveUp(self, obj)
-> void
 
Moves obj one place up in the channel list if obj is in it.
Cycles to index 0 if at the end of the list.
moveUpIndex(self, index)
-> void
 
As moveUp() but by index. Does nothing if index < 0 or too large.
readPickle(self, path)
-> bool
 
Attempts to read and unpickle the BTChannelList object stored
in path. Returns True if successfully read, unpickled, and
having set the channels attribute to its. Returns False if 
path is not a file or can't be read from, or if unpickling
fails or the cPickle doesn't contain a BTChannelList object.
repr(self)
-> void
 
Returns an unicode string representation of the channel list.
tuneDown(self)
-> void
 
Tune to the channel that is one lower in the channel list.
If the current channel is the lowest it tunes to the highest.
If the currently tuned is not in the list it tunes to index 0.
tuneTo(self, obj)
-> void
 
Tunes to the channel described by obj if obj is a BTChannel or
BTComposite object and is in the list. If not it does nothing.
tuneToIndex(self, index)
-> void
 
As tuneTo() but by index. Does nothing if index < 0 or too large.
tuneUp(self)
-> void
 
Tune to the channel that is one higher in the channel list.
If the current channel is the highest one it tunes to index 0.
If the currently tuned is not in the list it tunes to index 0.
writePickle(self, path)
-> bool
 
Attempts to write a cPickle of the BTChannelList object to path. 
Returns True on success, False if path is not a file or can't 
be written to, or if pickling fails.
writeText(self, path)
-> bool
 
Attempts to write the repr() text of the channel list to path. 
Returns True on success, False if path is not a file or can't 
be written to.

 
class BTComposite
    This class describes a composite input (or SVideo).
 
  Methods defined here:
__init__(self, device=0, name='')
-> BTComposite
 
The constructor takes an integer device for the input device 
(0 to 4 = DEV0 to 3 and SVIDEO) and a string name to give it a 
name. Name is assigned to the attribute name and the attribute id 
has the form "EXT0" or "SVID" and has the same identifying role 
as the frequency has in a BTChannel object. The device argument 
corresponds with the index of device in COMPOSITE_NAMES.
 
Dev and name are cut off if needed to match this:
- 0 <= dev <= 4
- len(name) <= CHANNEL_NAME_MAXLEN (64)
 
If dev is the tuner/TV, it will return a None object. If dev and
name are not passed, they become 0 and "" and can be set with the 
set methods. It's up to the programmer to exclude the TV input 
(often DEV1). See BTChannelList.tuner. Also tunes to the device.
setDevice(self, device)
-> void
 
Sets the BTComposite object's id attribute to the ustring
COMPOSITE_NAMES[device] if device is an integer in [0..4].
Sets nothing if < 0 or > 4. Also tunes to the device.
setName(self, name)
    -> void
    
Sets the BTComposite object's name attribute to the string 
specified by the argument name. Delimited to CHANNEL_NAME_MAXLEN
(64) characters.

 
Data
        AFC_STEP = 5
CHANNEL_NAME_MAXLEN = 64
CHANSETS_NTSC_NAMES = [('Japan Broadcast', [91, 97, 103, 171, 177, 183, 189, 193, 199, 205, 211, 217, 471, 477, 483, 489, 495, 501, 507, 513, ...]), ('Japan Cable', [109, 115, 121, 127, 133, 139, 145, 151, 157, 165, 223, 231, 237, 243, 249, 253, 259, 265, 271, 277, ...]), ('US Broadcast', [55, 61, 67, 77, 83, 175, 181, 187, 193, 199, 205, 211, 471, 477, 483, 489, 495, 501, 507, 513, ...]), ('US Cable', [8, 14, 20, 26, 32, 38, 44, 50, 55, 61, 67, 73, 77, 83, 91, 97, 103, 109, 115, 121, ...]), ('US Cable HRC', [7, 13, 19, 25, 31, 37, 43, 49, 54, 60, 66, 72, 78, 84, 102, 108, 114, 120, 126, 132, ...])]
CHANSETS_PAL_NAMES = [('Argentina', [56, 62, 68, 78, 84, 122, 128, 134, 140, 146, 152, 158, 164, 170, 176, 182, 188, 194, 200, 206, ...]), ('Australia', [46, 57, 64, 86, 95, 102, 138, 175, 182, 189, 196, 209, 216, 527, 534, 541, 548, 555, 562, 569, ...]), ('China Broadcast', [50, 58, 66, 77, 85, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, ...]), ('Europe East', [48, 50, 55, 59, 62, 69, 76, 77, 83, 85, 93, 105, 111, 112, 119, 126, 127, 133, 135, 140, ...]), ('Europe West', [48, 55, 62, 69, 76, 83, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 182, 189, 196, ...]), ('Ireland', [46, 54, 62, 175, 183, 191, 199, 207, 215, 471, 479, 487, 495, 503, 511, 519, 527, 535, 543, 551, ...]), ('Italy', [54, 62, 82, 175, 183, 192, 201, 210, 217, 224, 471, 479, 487, 495, 503, 511, 519, 527, 535, 543, ...]), ('New Zealand', [45, 55, 62, 175, 182, 189, 196, 203, 210, 217, 224, 471, 479, 487, 495, 503, 511, 519, 527, 535, ...]), ('South Africa Broadcast', [175, 183, 191, 199, 207, 215, 223, 231, 471, 479, 487, 495, 503, 511, 519, 527, 535, 543, 551, 559, ...])]
CHANSETS_SECAM_NAMES = [('France', [48, 56, 61, 64, 117, 129, 141, 160, 165, 176, 177, 184, 189, 192, 200, 201, 208, 213, 216, 225, ...]), ('Russia', [50, 59, 77, 85, 93, 111, 119, 127, 135, 143, 151, 159, 167, 175, 183, 191, 199, 207, 215, 223, ...])]
CHANSET_NTSC_JP_BCAST = [91, 97, 103, 171, 177, 183, 189, 193, 199, 205, 211, 217, 471, 477, 483, 489, 495, 501, 507, 513, ...]
CHANSET_NTSC_JP_CABLE = [109, 115, 121, 127, 133, 139, 145, 151, 157, 165, 223, 231, 237, 243, 249, 253, 259, 265, 271, 277, ...]
CHANSET_NTSC_US_BCAST = [55, 61, 67, 77, 83, 175, 181, 187, 193, 199, 205, 211, 471, 477, 483, 489, 495, 501, 507, 513, ...]
CHANSET_NTSC_US_CABLE = [8, 14, 20, 26, 32, 38, 44, 50, 55, 61, 67, 73, 77, 83, 91, 97, 103, 109, 115, 121, ...]
CHANSET_NTSC_US_HRC = [7, 13, 19, 25, 31, 37, 43, 49, 54, 60, 66, 72, 78, 84, 102, 108, 114, 120, 126, 132, ...]
CHANSET_PAL_ARGENTINA = [56, 62, 68, 78, 84, 122, 128, 134, 140, 146, 152, 158, 164, 170, 176, 182, 188, 194, 200, 206, ...]
CHANSET_PAL_AUSTRALIA = [46, 57, 64, 86, 95, 102, 138, 175, 182, 189, 196, 209, 216, 527, 534, 541, 548, 555, 562, 569, ...]
CHANSET_PAL_CN_BCAST = [50, 58, 66, 77, 85, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, ...]
CHANSET_PAL_EUR_EAST = [48, 50, 55, 59, 62, 69, 76, 77, 83, 85, 93, 105, 111, 112, 119, 126, 127, 133, 135, 140, ...]
CHANSET_PAL_EUR_WEST = [48, 55, 62, 69, 76, 83, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 182, 189, 196, ...]
CHANSET_PAL_IRELAND = [46, 54, 62, 175, 183, 191, 199, 207, 215, 471, 479, 487, 495, 503, 511, 519, 527, 535, 543, 551, ...]
CHANSET_PAL_ITALY = [54, 62, 82, 175, 183, 192, 201, 210, 217, 224, 471, 479, 487, 495, 503, 511, 519, 527, 535, 543, ...]
CHANSET_PAL_NZEALAND = [45, 55, 62, 175, 182, 189, 196, 203, 210, 217, 224, 471, 479, 487, 495, 503, 511, 519, 527, 535, ...]
CHANSET_PAL_ZA_BCAST = [175, 183, 191, 199, 207, 215, 223, 231, 471, 479, 487, 495, 503, 511, 519, 527, 535, 543, 551, 559, ...]
CHANSET_SECAM_FRANCE = [48, 56, 61, 64, 117, 129, 141, 160, 165, 176, 177, 184, 189, 192, 200, 201, 208, 213, 216, 225, ...]
CHANSET_SECAM_RUSSIA = [50, 59, 77, 85, 93, 111, 119, 127, 135, 143, 151, 159, 167, 175, 183, 191, 199, 207, 215, 223, ...]
COMPOSITE_NAMES = ['EXT0', 'EXT1', 'EXT2', 'EXT3', 'SVID']
MODULE_AUTHOR = 'Danny Pansters'
MODULE_AUTHOR_EMAIL = 'danny@ricin.com'
MODULE_COPYRIGHT = '(c) 2005-2007, Danny Pansters <danny@ricin.com>'
MODULE_LICENSE = 'BSD'
MODULE_LICENSE_TEXT = '(c) 2005-2007, Danny Pansters <danny@ricin.com>\n...EN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n'
SCAN_STEP = 2