ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-DVB/eg/extract-si
Revision: 1.3
Committed: Wed Sep 8 19:47:30 2004 UTC (19 years, 10 months ago) by root
Branch: MAIN
Changes since 1.2: +2 -1 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/opt/bin/perl
2
3 # 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 use Event;
12 use Linux::DVB;
13
14 use Data::Dumper;
15
16 my $fe = new Linux::DVB::Frontend "/dev/dvb/adapter0/frontend0";
17
18 sub new_demux {
19 new Linux::DVB::Demux "/dev/dvb/adapter0/demux0";
20 }
21
22 package scanner;
23
24 sub new {
25 print "new scanner\n";
26 my $self = bless { };
27
28 $self->{dmx} = ::new_demux;
29 $self->{dmx}->sct_filter ($PID, "", "");
30 $self->{dmx}->buffer (0x10000);
31 $self->{dmx}->start;
32
33 $self->{w} = Event->io (fd => $self->{dmx}->fh, poll => 'r', cb => sub {
34 sysread $self->{dmx}->fh, my $data, 4096;
35 print Data::Dumper::Dumper Linux::DVB::Decode::si $data;
36 });
37 }
38
39 sub DESTROY {
40 my $self = shift;
41 $self->{w}->cancel;
42 }
43
44 package main;
45
46 my $frequency = -1;
47
48 sub status_changed {
49 if ($fe->parameters->{frequency} != $frequency) {
50 $frequency = $fe->parameters->{frequency};
51 undef $scanner;
52 }
53 if ($fe->status & FE_HAS_LOCK) {
54 $scanner ||= new scanner;
55 } else {
56 undef $scanner;
57 }
58 }
59
60 Event->io (fd => $fe->{fd}, poll => 'e', cb => sub {
61 my $event = $fe->event;
62 # tuning event, status changes not reported
63 status_changed;
64 });
65
66 Event->timer (interval => 1, cb => sub {
67 #print $fe->status & FE_HAS_LOCK, "\n";
68 });
69
70 status_changed;
71
72 Event::loop;