ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Video-Capture-V4l/examples/vbi-info
Revision: 1.1
Committed: Fri May 5 20:21:53 2000 UTC (26 years, 6 months ago) by pcg
Branch: MAIN
CVS Tags: rel-0_9, rel-0_902, HEAD
Log Message:
Initial check-in

File Contents

# User Rev Content
1 pcg 1.1 #!/usr/bin/perl
2    
3     # dumps "interesting" data about tv channels
4    
5     use Video::Capture::V4l;
6     use Video::Capture::VBI qw/:DEFAULT %VPS_CNI %VT_NI/;
7    
8     $vbi = new Video::Capture::V4l::VBI or die;
9    
10     # the next line is optional (it enables buffering)
11     $vbi->backlog(25); # max. 1 second backlog (~900kB)
12    
13     $inp_fd = fileno STDIN;
14     $vbi_fd = $vbi->fileno;
15    
16     print "VBI capturing started.\n\n";
17     print <<EOF;
18     You can enter the following commands, ended by <return>
19    
20     q quit
21     c clear
22    
23     EOF
24    
25     sub init {
26     %fea = ();
27     print "\n";
28     }
29    
30     sub fea {
31     $fea{$_[0]} = $_[1];
32     }
33    
34     my($last_cni, $last_ni);
35    
36     for(;;) {
37     my $r="";
38     vec($r,$inp_fd,1)=1;
39     #vec($r,$vbi_fd,1)=1;
40     select $r,undef,undef,0.2;
41     while ($vbi->queued) {
42     $fields++;
43     my $vbi_alloc;
44     for (decode_field $vbi->field, VBI_VT|VBI_VPS|VBI_OTHER|VBI_EMPTY) {
45     if ($_->[0] == VBI_VPS) {
46     init if $last_cni != $_->[3]; $last_cni = $_->[3];
47     if (ord($_->[1]) > 127 or length $name_ >= 12) {
48     $name = $name_; $name_ = "";
49     }
50     $name_ .= $_->[1] & "\x7f";
51     fea('VPS',sprintf "%04x=%s|$name",$_->[3],$VPS_CNI{$_->[3] & 0x0fff});
52     $vps++;
53     $vbi_alloc .= "V";
54     } elsif ($_->[0] == VBI_VT) {
55     if ($_->[2] == 0) {
56     if ($_->[4] == 0x1df) {
57     fea('EPG');
58     } else {
59     fea('VT');
60     }
61     } elsif ($_->[2] == 30) {
62     if (($_->[3]>>1) == 0) {
63     init if $last_ni != $_->[6]; $last_ni = $_->[6];
64     fea("NI30/1",sprintf "%04x=%s", $_->[6], $VT_NI{$_->[6]}[0]);
65     } elsif (($_->[3]>>1) == 8) {
66     fea('PDC');
67     } else {
68     fea("30","$_->[3]");
69     }
70     } elsif ($_->[2] == 31) {
71     if ($_->[4] == 0x500) {
72     fea("$_->[1]/IC");
73     } else {
74     fea(sprintf "$_->[1]/31[%x]",$_->[4]);
75     }
76     }
77     $vt++;
78     $vbi_alloc .= "T";
79     } elsif ($_->[0] == VBI_OTHER) {
80     $vbi_alloc .= $_->[1] == 1 ? "c" : "O";
81     } elsif ($_->[0] == VBI_EMPTY) {
82     $vbi_alloc .= ".";
83     } else {
84     $others++;
85     }
86     }
87     fea("alloc","$vbi_alloc");
88     }
89     if (vec($r,$inp_fd,1)) {
90     $_ = <STDIN>;
91     if (/^q/) {
92     last;
93     } elsif (/^c/) {
94     init;
95     }
96     }
97     printf "%5d|F %5d|VPS %6d|VT %5d|O", $fields, $vps,$vt,$others;
98     while (my($k, $v) = each(%fea)) {
99     print " $k";
100     print "[$v]" if $v;
101     }
102     $|=1;
103     print " < \r";
104     $|=0;
105     }
106