ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-DVB/eg/extract-si
Revision: 1.4
Committed: Sun Apr 3 02:16:05 2005 UTC (19 years, 2 months ago) by root
Branch: MAIN
Changes since 1.3: +13 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/opt/bin/perl
2    
3 root 1.2 # extract whatever data available in the currently tuned transponder
4    
5     # this program is slightly overdesigned as it is was the base for a
6     # larger program, it still shows how to react to channel changes
7     # and scan pids and decode si info.
8    
9     my $PID = 18; # epg data and more
10    
11 root 1.1 use Event;
12     use Linux::DVB;
13    
14     use Data::Dumper;
15    
16 root 1.4 my $sniff_only = 1; # set to zero to actively tune to a channel
17    
18     my $fe = new Linux::DVB::Frontend "/dev/dvb/adapter0/frontend0", $sniff_only ? &O_RDONLY : &O_RDWR;
19    
20     unless ($sniff_only) {
21     $fe->set (
22     frequency => 426000000,
23     symbol_rate => 6900000,
24     modulation => QAM_64,
25     fec_inner => FEC_AUTO,
26     inversion => INVERSION_AUTO,
27     ) or die "frontend->set: $!";
28     }
29 root 1.1
30     sub new_demux {
31     new Linux::DVB::Demux "/dev/dvb/adapter0/demux0";
32     }
33    
34     package scanner;
35    
36     sub new {
37     print "new scanner\n";
38     my $self = bless { };
39    
40 root 1.2 $self->{dmx} = ::new_demux;
41     $self->{dmx}->sct_filter ($PID, "", "");
42 root 1.3 $self->{dmx}->buffer (0x10000);
43 root 1.2 $self->{dmx}->start;
44    
45     $self->{w} = Event->io (fd => $self->{dmx}->fh, poll => 'r', cb => sub {
46 root 1.3 sysread $self->{dmx}->fh, my $data, 4096;
47 root 1.2 print Data::Dumper::Dumper Linux::DVB::Decode::si $data;
48 root 1.1 });
49     }
50    
51     sub DESTROY {
52     my $self = shift;
53     $self->{w}->cancel;
54     }
55    
56     package main;
57    
58     my $frequency = -1;
59    
60     sub status_changed {
61     if ($fe->parameters->{frequency} != $frequency) {
62     $frequency = $fe->parameters->{frequency};
63     undef $scanner;
64     }
65     if ($fe->status & FE_HAS_LOCK) {
66     $scanner ||= new scanner;
67     } else {
68     undef $scanner;
69     }
70     }
71    
72     Event->io (fd => $fe->{fd}, poll => 'e', cb => sub {
73     my $event = $fe->event;
74     # tuning event, status changes not reported
75     status_changed;
76     });
77    
78     Event->timer (interval => 1, cb => sub {
79     #print $fe->status & FE_HAS_LOCK, "\n";
80     });
81    
82     status_changed;
83    
84     Event::loop;