ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-DVB/DVB.pm
(Generate patch)

Comparing Linux-DVB/DVB.pm (file contents):
Revision 1.8 by root, Tue Apr 12 00:54:57 2005 UTC vs.
Revision 1.16 by root, Sun Jun 14 09:53:26 2015 UTC

19 19
20Noteworthy differences to the C API: unions and sub-structs are usually 20Noteworthy differences to the C API: unions and sub-structs are usually
21translated into flat perl hashes, i.e C<struct.u.qam.symbol_rate> 21translated into flat perl hashes, i.e C<struct.u.qam.symbol_rate>
22becomes C<< $struct->{symbol_rate} >>. 22becomes C<< $struct->{symbol_rate} >>.
23 23
24Noteworthy limitations of this module include: no way to set the 24Noteworthy limitations of this module include: No interface to the video,
25frequency or diseqc. No interface to the video, audio and net devices.
26If you need this functionality bug the author. 25audio and net devices. If you need this functionality bug the author.
27 26
28=cut 27=cut
29 28
30package Linux::DVB; 29package Linux::DVB;
31 30
32use Fcntl (); 31use Fcntl ();
33 32
34BEGIN { 33BEGIN {
35 $VERSION = '0.3'; 34 $VERSION = '1.02';
36 @ISA = qw(Exporter); 35 @ISA = qw(Exporter);
37 36
38 require XSLoader; 37 require XSLoader;
39 XSLoader::load __PACKAGE__, $VERSION; 38 XSLoader::load __PACKAGE__, $VERSION;
40 39
106 %$self = ( %$self, %{ $self->frontend_info } ); 105 %$self = ( %$self, %{ $self->frontend_info } );
107 106
108 $self; 107 $self;
109} 108}
110 109
111sub frontend_info { _frontend_info ($_[0]{fd}) }
112sub status { _read_status ($_[0]{fd}) }
113sub ber { _read_ber ($_[0]{fd}) }
114sub snr { _snr ($_[0]{fd}) }
115sub signal_strength { _signal_strength ($_[0]{fd}) }
116sub uncorrected { _uncorrected ($_[0]{fd}) }
117
118=item $fe->set (parameter => value, ...) 110=item $fe->set (parameter => value, ...)
119 111
120Sets frontend parameters. All values are stuffed into the 112Sets frontend parameters. All values are stuffed into the
121C<dvb_frontend_parameters> structure without conversion and passed to 113C<dvb_frontend_parameters> structure without conversion and passed to
122FE_SET_FRONTEND. 114FE_SET_FRONTEND.
134 fec_inner => 126 fec_inner =>
135 127
136QAM frontends: 128QAM frontends:
137 129
138 symbol_rate => 130 symbol_rate =>
139 fec_inner =>
140 modulation => 131 modulation =>
141 132
142QFDM frontends: 133QFDM frontends:
143 134
144 bandwidth => 135 bandwidth =>
165 156
166 { 157 {
167 frequency => 426000000, # 426 Mhz 158 frequency => 426000000, # 426 Mhz
168 inversion => 0, # INVERSION_OFF 159 inversion => 0, # INVERSION_OFF
169 symbol_rate => 6900000, # 6.9 MB/s 160 symbol_rate => 6900000, # 6.9 MB/s
170 fec_inner => 0, # FEC_NONE
171 modulation => 3, # QAM_64 161 modulation => 3, # QAM_64
172 } 162 }
173 163
174=cut 164=cut
175 165
176sub parameters { _get ($_[0]{fd}, $_[0]{type}) } 166sub parameters { _get ($_[0]{fd}, $_[0]{type}) }
177sub get { _get ($_[0]{fd}, $_[0]{type}) } # unannounced alias 167sub get { _get ($_[0]{fd}, $_[0]{type}) } # unannounced alias
178sub event { _event ($_[0]{fd}, $_[0]{type}) } 168sub event { _event ($_[0]{fd}, $_[0]{type}) }
169
170=item $ok = $fe->diseqc_reset_overload
171
172If the bus has been automatically powered off due to power overload, this
173call restores the power to the bus. The call requires read/write access
174to the device. This call has no effect if the device is manually powered
175off. Not all DVB adapters support this call.
176
177=item $ok = $fe->diseqc_voltage (13|18)
178
179Set the DiSEqC voltage to either 13 or 18 volts.
180
181=item $ok = $fe->diseqc_tone (1|0)
182
183Enables (1) or disables (0) the DiSEqC continuous 22khz tone generation.
184
185=item $ok = $fe->diseqc_send_burst (0|1)
186
187Sends a 22KHz tone burst of type SEC_MINI_A (0) or SEC_MINI_B (1).
188
189=item $ok = $fe->diseqc_cmd ($command)
190
191Sends a DiSEqC command ($command is 3 to 6 bytes of binary data).
192
193=item $reply = $fe->diseqc_reply ($timeout)
194
195Receives a reply to a DiSEqC 2.0 command and returns it as a binary octet
196string 0..4 bytes in length (or C<undef> in the error case).
197
198=cut
179 199
180package Linux::DVB::Demux; 200package Linux::DVB::Demux;
181 201
182@ISA = qw(Linux::DVB); 202@ISA = qw(Linux::DVB);
183 203
346 366
347=cut 367=cut
348 368
349our %nibble_to_genre = ( 369our %nibble_to_genre = (
350 0x1 => { 370 0x1 => {
351 0x0 => 'Movie / Drama', 371 0x0 => 'Movie/Drama (general)',
352 0x1 => 'Movie - detective/thriller', 372 0x1 => 'Movie - detective/thriller',
353 0x2 => 'Movie - adventure/western/war', 373 0x2 => 'Movie - adventure/western/war',
354 0x3 => 'Movie - science fiction/fantasy/horror', 374 0x3 => 'Movie - science fiction/fantasy/horror',
355 0x4 => 'Movie - comedy', 375 0x4 => 'Movie - comedy',
356 0x5 => 'Movie - soap/melodrama/folkloric', 376 0x5 => 'Movie - soap/melodrama/folkloric',
357 0x6 => 'Movie - romance', 377 0x6 => 'Movie - romance',
358 0x7 => 'Movie - serious/classical/religious/historical movie/drama', 378 0x7 => 'Movie - serious/classical/religious/historical movie/drama',
359 0x8 => 'Movie - adult movie/drama', 379 0x8 => 'Movie - adult movie/drama',
360 }, 380 },
361 0x2 => { 381 0x2 => {
362 0x0 => 'News / Current Affairs', 382 0x0 => 'News/Current Affairs (general)',
363 0x1 => 'news/weather report', 383 0x1 => 'news/weather report',
364 0x2 => 'news magazine', 384 0x2 => 'news magazine',
365 0x3 => 'documentary', 385 0x3 => 'documentary',
366 0x4 => 'discussion/interview/debate', 386 0x4 => 'discussion/interview/debate',
367 }, 387 },
368 0x3 => { 388 0x3 => {
369 0x0 => 'Show / Game Show', 389 0x0 => 'Show/Game Show (general)',
370 0x1 => 'game show/quiz/contest', 390 0x1 => 'game show/quiz/contest',
371 0x2 => 'variety show', 391 0x2 => 'variety show',
372 0x3 => 'talk show', 392 0x3 => 'talk show',
373 }, 393 },
374 0x4 => { 394 0x4 => {
375 0x0 => 'Sports', 395 0x0 => 'Sports (general)',
376 0x1 => 'special events (Olympic Games, World Cup etc.)', 396 0x1 => 'special events (Olympic Games, World Cup etc.)',
377 0x2 => 'sports magazines', 397 0x2 => 'sports magazines',
378 0x3 => 'football/soccer', 398 0x3 => 'football/soccer',
379 0x4 => 'tennis/squash', 399 0x4 => 'tennis/squash',
380 0x5 => 'team sports (excluding football)', 400 0x5 => 'team sports (excluding football)',
384 0x9 => 'winter sports', 404 0x9 => 'winter sports',
385 0xA => 'equestrian', 405 0xA => 'equestrian',
386 0xB => 'martial sports', 406 0xB => 'martial sports',
387 }, 407 },
388 0x5 => { 408 0x5 => {
389 0x0 => 'Childrens / Youth', 409 0x0 => 'Childrens/Youth (general)',
390 0x1 => "pre-school children's programmes", 410 0x1 => "pre-school children's programmes",
391 0x2 => 'entertainment programmes for 6 to 14', 411 0x2 => 'entertainment programmes for 6 to 14',
392 0x3 => 'entertainment programmes for 10 to 16', 412 0x3 => 'entertainment programmes for 10 to 16',
393 0x4 => 'informational/educational/school programmes', 413 0x4 => 'informational/educational/school programmes',
394 0x5 => 'cartoons/puppets', 414 0x5 => 'cartoons/puppets',
395 }, 415 },
396 0x6 => { 416 0x6 => {
397 0x0 => 'Music / Ballet / Dance', 417 0x0 => 'Music/Ballet/Dance (general)',
398 0x1 => 'rock/pop', 418 0x1 => 'rock/pop',
399 0x2 => 'serious music/classical music', 419 0x2 => 'serious music or classical music',
400 0x3 => 'folk/traditional music', 420 0x3 => 'folk/traditional music',
401 0x4 => 'jazz', 421 0x4 => 'jazz',
402 0x5 => 'musical/opera', 422 0x5 => 'musical/opera',
403 0x6 => 'ballet', 423 0x6 => 'ballet',
404 }, 424 },
405 0x7 => { 425 0x7 => {
406 0x0 => 'Arts / Culture', 426 0x0 => 'Arts/Culture (without music, general)',
407 0x1 => 'performing arts', 427 0x1 => 'performing arts',
408 0x2 => 'fine arts', 428 0x2 => 'fine arts',
409 0x3 => 'religion', 429 0x3 => 'religion',
410 0x4 => 'popular culture/traditional arts', 430 0x4 => 'popular culture/traditional arts',
411 0x5 => 'literature', 431 0x5 => 'literature',
415 0x9 => 'new media', 435 0x9 => 'new media',
416 0xA => 'arts/culture magazines', 436 0xA => 'arts/culture magazines',
417 0xB => 'fashion', 437 0xB => 'fashion',
418 }, 438 },
419 0x8 => { 439 0x8 => {
420 0x0 => 'Social / Policical / Economics', 440 0x0 => 'Social/Policical/Economics (general)',
421 0x1 => 'magazines/reports/documentary', 441 0x1 => 'magazines/reports/documentary',
422 0x2 => 'economics/social advisory', 442 0x2 => 'economics/social advisory',
423 0x3 => 'remarkable people', 443 0x3 => 'remarkable people',
424 }, 444 },
425 0x9 => { 445 0x9 => {
426 0x0 => 'Education / Science / Factual', 446 0x0 => 'Education/Science/Factual (general)',
427 0x1 => 'nature/animals/environment', 447 0x1 => 'nature/animals/environment',
428 0x2 => 'technology/natural sciences', 448 0x2 => 'technology/natural sciences',
429 0x3 => 'medicine/physiology/psychology', 449 0x3 => 'medicine/physiology/psychology',
430 0x4 => 'foreign countries/expeditions', 450 0x4 => 'foreign countries/expeditions',
431 0x5 => 'social/spiritual sciences', 451 0x5 => 'social/spiritual sciences',
432 0x6 => 'further education', 452 0x6 => 'further education',
433 0x7 => 'languages', 453 0x7 => 'languages',
434 }, 454 },
435 0xA => { 455 0xA => {
436 0x0 => 'Leisure / Hobbies', 456 0x0 => 'Leisure/Hobbies (general)',
437 0x1 => 'tourism/travel', 457 0x1 => 'tourism/travel',
438 0x2 => 'handicraft', 458 0x2 => 'handicraft',
439 0x3 => 'motoring', 459 0x3 => 'motoring',
440 0x4 => 'fitness & health', 460 0x4 => 'fitness & health',
441 0x5 => 'cooking', 461 0x5 => 'cooking',
442 0x6 => 'advertizement/shopping', 462 0x6 => 'advertizement/shopping',
443 0x7 => 'gardening', 463 0x7 => 'gardening',
444 }, 464 },
445 0xB => { 465 0xB => {
446 0x0 => 'Original Language', 466 0x0 => '(original language)',
447 0x1 => 'black & white', 467 0x1 => '(black & white)',
448 0x2 => 'unpublished', 468 0x2 => '(unpublished)',
449 0x3 => 'live broadcast', 469 0x3 => '(live broadcast)',
450 }, 470 },
451); 471);
452 472
453=item ($sec,$min,$hour) = Linux::DVB::Decode::time $hms 473=item ($sec,$min,$hour) = Linux::DVB::Decode::time $hms
454 474
463Break down a "DVB time" (modified julian date + bcd encoded seconds) into 483Break down a "DVB time" (modified julian date + bcd encoded seconds) into
464it's components (non-C<_linear>) or into a seconds count (C<_linear> 484it's components (non-C<_linear>) or into a seconds count (C<_linear>
465variants) since the epoch (C<datetime_linear>) or the start of the day 485variants) since the epoch (C<datetime_linear>) or the start of the day
466(C<time_linear>). 486(C<time_linear>).
467 487
488The format of the returns value of the date and datetime functions is
489I<not> compatible with C<Time::Local>. Use the C<_linear> functions
490instead.
491
468Example: 492Example:
469 493
470 my $time = Linux::DVB::Decode::datetime_linear $mjd, $hms 494 my $time = Linux::DVB::Decode::datetime_linear $mjd, $hms
471 printf "Starts at %s\n", 495 printf "Starts at %s\n",
472 POSIX::strftime "%Y-%m-%d %H:%M:%S", 496 POSIX::strftime "%Y-%m-%d %H:%M:%S",
488sub date($) { 512sub date($) {
489 my ($mjd) = @_; 513 my ($mjd) = @_;
490 514
491 # Date is given in Modified Julian Date 515 # Date is given in Modified Julian Date
492 # Decoding routines taken from ANNEX C, ETSI EN 300 468 (DVB SI) 516 # Decoding routines taken from ANNEX C, ETSI EN 300 468 (DVB SI)
493 my $y_ = int ($mjd - 15078.2) / 365.25; 517 my $y_ = int (($mjd - 15078.2) / 365.25);
494 my $m_ = int (($mjd - 14956.1 - int ($y_ * 365.25)) / 30.6001); 518 my $m_ = int (($mjd - 14956.1 - int ($y_ * 365.25)) / 30.6001);
495 my $day = $mjd - 14956 - int ($y_ * 365.25) - int ($m_ * 30.6001); 519 my $day = $mjd - 14956 - int ($y_ * 365.25) - int ($m_ * 30.6001);
496 my $k = $m_ == 14 or $m_ == 15 ? 1 : 0; 520 my $k = $m_ == 14 or $m_ == 15 ? 1 : 0;
497 my $year = $y_ + $k + 1900; 521 my $year = $y_ + $k + 1900;
498 my $month = $m_ - 1 - $k * 12; 522 my $month = $m_ - 1 - $k * 12;
509 533
510 (($h * 60) + $m * 60) + $s 534 (($h * 60) + $m * 60) + $s
511} 535}
512 536
513sub datetime_linear($$) { 537sub datetime_linear($$) {
538 my ($sec, $min, $hour, $mday, $mon, $year) =
539 Linux::DVB::Decode::datetime $_[0], $_[1];
540
514 require Time::Local; 541 require Time::Local;
515 Time::Local::timegm (Linux::DVB::Decode::datetime $_[0], $_[1]) 542 Time::Local::timegm ($sec, $min, $hour, $mday, $mon - 1, $year)
516} 543}
517 544
518=back 545=back
519 546
520=head1 AUTHORS 547=head1 AUTHORS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines