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.6 by root, Tue Apr 5 03:42:21 2005 UTC vs.
Revision 1.11 by root, Wed May 17 15:46:26 2006 UTC

30package Linux::DVB; 30package Linux::DVB;
31 31
32use Fcntl (); 32use Fcntl ();
33 33
34BEGIN { 34BEGIN {
35 $VERSION = '0.2'; 35 $VERSION = '0.4';
36 @ISA = qw(Exporter); 36 @ISA = qw(Exporter);
37 37
38 require XSLoader; 38 require XSLoader;
39 XSLoader::load __PACKAGE__, $VERSION; 39 XSLoader::load __PACKAGE__, $VERSION;
40 40
134 fec_inner => 134 fec_inner =>
135 135
136QAM frontends: 136QAM frontends:
137 137
138 symbol_rate => 138 symbol_rate =>
139 fec_inner =>
140 modulation => 139 modulation =>
141 140
142QFDM frontends: 141QFDM frontends:
143 142
144 bandwidth => 143 bandwidth =>
165 164
166 { 165 {
167 frequency => 426000000, # 426 Mhz 166 frequency => 426000000, # 426 Mhz
168 inversion => 0, # INVERSION_OFF 167 inversion => 0, # INVERSION_OFF
169 symbol_rate => 6900000, # 6.9 MB/s 168 symbol_rate => 6900000, # 6.9 MB/s
170 fec_inner => 0, # FEC_NONE
171 modulation => 3, # QAM_64 169 modulation => 3, # QAM_64
172 } 170 }
173 171
174=cut 172=cut
175 173
346 344
347=cut 345=cut
348 346
349our %nibble_to_genre = ( 347our %nibble_to_genre = (
350 0x1 => { 348 0x1 => {
351 0x0 => 'Movie / Drama', 349 0x0 => 'Movie/Drama (general)',
352 0x1 => 'Movie - detective/thriller', 350 0x1 => 'Movie - detective/thriller',
353 0x2 => 'Movie - adventure/western/war', 351 0x2 => 'Movie - adventure/western/war',
354 0x3 => 'Movie - science fiction/fantasy/horror', 352 0x3 => 'Movie - science fiction/fantasy/horror',
355 0x4 => 'Movie - comedy', 353 0x4 => 'Movie - comedy',
356 0x5 => 'Movie - soap/melodrama/folkloric', 354 0x5 => 'Movie - soap/melodrama/folkloric',
357 0x6 => 'Movie - romance', 355 0x6 => 'Movie - romance',
358 0x7 => 'Movie - serious/classical/religious/historical movie/drama', 356 0x7 => 'Movie - serious/classical/religious/historical movie/drama',
359 0x8 => 'Movie - adult movie/drama', 357 0x8 => 'Movie - adult movie/drama',
360 }, 358 },
361 0x2 => { 359 0x2 => {
362 0x0 => 'News / Current Affairs', 360 0x0 => 'News/Current Affairs (general)',
363 0x1 => 'news/weather report', 361 0x1 => 'news/weather report',
364 0x2 => 'news magazine', 362 0x2 => 'news magazine',
365 0x3 => 'documentary', 363 0x3 => 'documentary',
366 0x4 => 'discussion/interview/debate', 364 0x4 => 'discussion/interview/debate',
367 }, 365 },
368 0x3 => { 366 0x3 => {
369 0x0 => 'Show / Game Show', 367 0x0 => 'Show/Game Show (general)',
370 0x1 => 'game show/quiz/contest', 368 0x1 => 'game show/quiz/contest',
371 0x2 => 'variety show', 369 0x2 => 'variety show',
372 0x3 => 'talk show', 370 0x3 => 'talk show',
373 }, 371 },
374 0x4 => { 372 0x4 => {
375 0x0 => 'Sports', 373 0x0 => 'Sports (general)',
376 0x1 => 'special events (Olympic Games, World Cup etc.)', 374 0x1 => 'special events (Olympic Games, World Cup etc.)',
377 0x2 => 'sports magazines', 375 0x2 => 'sports magazines',
378 0x3 => 'football/soccer', 376 0x3 => 'football/soccer',
379 0x4 => 'tennis/squash', 377 0x4 => 'tennis/squash',
380 0x5 => 'team sports (excluding football)', 378 0x5 => 'team sports (excluding football)',
384 0x9 => 'winter sports', 382 0x9 => 'winter sports',
385 0xA => 'equestrian', 383 0xA => 'equestrian',
386 0xB => 'martial sports', 384 0xB => 'martial sports',
387 }, 385 },
388 0x5 => { 386 0x5 => {
389 0x0 => 'Childrens / Youth', 387 0x0 => 'Childrens/Youth (general)',
390 0x1 => "pre-school children's programmes", 388 0x1 => "pre-school children's programmes",
391 0x2 => 'entertainment programmes for 6 to 14', 389 0x2 => 'entertainment programmes for 6 to 14',
392 0x3 => 'entertainment programmes for 10 to 16', 390 0x3 => 'entertainment programmes for 10 to 16',
393 0x4 => 'informational/educational/school programmes', 391 0x4 => 'informational/educational/school programmes',
394 0x5 => 'cartoons/puppets', 392 0x5 => 'cartoons/puppets',
395 }, 393 },
396 0x6 => { 394 0x6 => {
397 0x0 => 'Music / Ballet / Dance', 395 0x0 => 'Music/Ballet/Dance (general)',
398 0x1 => 'rock/pop', 396 0x1 => 'rock/pop',
399 0x2 => 'serious music/classical music', 397 0x2 => 'serious music or classical music',
400 0x3 => 'folk/traditional music', 398 0x3 => 'folk/traditional music',
401 0x4 => 'jazz', 399 0x4 => 'jazz',
402 0x5 => 'musical/opera', 400 0x5 => 'musical/opera',
403 0x6 => 'ballet', 401 0x6 => 'ballet',
404 }, 402 },
405 0x7 => { 403 0x7 => {
406 0x0 => 'Arts / Culture', 404 0x0 => 'Arts/Culture (without music, general)',
407 0x1 => 'performing arts', 405 0x1 => 'performing arts',
408 0x2 => 'fine arts', 406 0x2 => 'fine arts',
409 0x3 => 'religion', 407 0x3 => 'religion',
410 0x4 => 'popular culture/traditional arts', 408 0x4 => 'popular culture/traditional arts',
411 0x5 => 'literature', 409 0x5 => 'literature',
415 0x9 => 'new media', 413 0x9 => 'new media',
416 0xA => 'arts/culture magazines', 414 0xA => 'arts/culture magazines',
417 0xB => 'fashion', 415 0xB => 'fashion',
418 }, 416 },
419 0x8 => { 417 0x8 => {
420 0x0 => 'Social / Policical / Economics', 418 0x0 => 'Social/Policical/Economics (general)',
421 0x1 => 'magazines/reports/documentary', 419 0x1 => 'magazines/reports/documentary',
422 0x2 => 'economics/social advisory', 420 0x2 => 'economics/social advisory',
423 0x3 => 'remarkable people', 421 0x3 => 'remarkable people',
424 }, 422 },
425 0x9 => { 423 0x9 => {
426 0x0 => 'Education / Science / Factual', 424 0x0 => 'Education/Science/Factual (general)',
427 0x1 => 'nature/animals/environment', 425 0x1 => 'nature/animals/environment',
428 0x2 => 'technology/natural sciences', 426 0x2 => 'technology/natural sciences',
429 0x3 => 'medicine/physiology/psychology', 427 0x3 => 'medicine/physiology/psychology',
430 0x4 => 'foreign countries/expeditions', 428 0x4 => 'foreign countries/expeditions',
431 0x5 => 'social/spiritual sciences', 429 0x5 => 'social/spiritual sciences',
432 0x6 => 'further education', 430 0x6 => 'further education',
433 0x7 => 'languages', 431 0x7 => 'languages',
434 }, 432 },
435 0xA => { 433 0xA => {
436 0x0 => 'Leisure / Hobbies', 434 0x0 => 'Leisure/Hobbies (general)',
437 0x1 => 'tourism/travel', 435 0x1 => 'tourism/travel',
438 0x2 => 'handicraft', 436 0x2 => 'handicraft',
439 0x3 => 'motoring', 437 0x3 => 'motoring',
440 0x4 => 'fitness & health', 438 0x4 => 'fitness & health',
441 0x5 => 'cooking', 439 0x5 => 'cooking',
442 0x6 => 'advertizement/shopping', 440 0x6 => 'advertizement/shopping',
443 0x7 => 'gardening', 441 0x7 => 'gardening',
444 }, 442 },
445 0xB => { 443 0xB => {
446 0x0 => 'Original Language', 444 0x0 => '(original language)',
447 0x1 => 'black & white', 445 0x1 => '(black & white)',
448 0x2 => 'unpublished', 446 0x2 => '(unpublished)',
449 0x3 => 'live broadcast', 447 0x3 => '(live broadcast)',
450 }, 448 },
451); 449);
452 450
451=item ($sec,$min,$hour) = Linux::DVB::Decode::time $hms
452
453=item ($mday,$mon,$year) = Linux::DVB::Decode::date $mjd
454
453=item ($sec,$min,$hour,$mday,$mon,$year) = Linux::DVB::Decode::time $mjd, $time 455=item ($sec,$min,$hour,$mday,$mon,$year) = Linux::DVB::Decode::datetime $mjd, $hms
456
457=item $sec = Linux::DVB::Decode::time_linear $hms
458
459=item $sec = Linux::DVB::Decode::datetime_linear $mjd, $hms
454 460
455Break down a "DVB time" (modified julian date + bcd encoded seconds) into 461Break down a "DVB time" (modified julian date + bcd encoded seconds) into
456it's components in UTC (i.e. use Time::Local::timegm to convert to UNIX 462it's components (non-C<_linear>) or into a seconds count (C<_linear>
457time). 463variants) since the epoch (C<datetime_linear>) or the start of the day
464(C<time_linear>).
458 465
459=cut 466The format of the returns value of the date and datetime functions is
467I<not> compatible with C<Time::Local>. Use the C<_linear> functions
468instead.
460 469
470Example:
471
472 my $time = Linux::DVB::Decode::datetime_linear $mjd, $hms
473 printf "Starts at %s\n",
474 POSIX::strftime "%Y-%m-%d %H:%M:%S",
475 localtime $time;
476
477=cut
478
461sub time($$) { 479sub time($) {
462 my ($mjd, $time) = @_; 480 my ($time) = @_;
481
482 # Time is in UTC, 24 bit, every nibble one digit in BCD from right to left
483 my $hour = sprintf "%02x", ($time >> 16) & 0xFF;
484 my $minute = sprintf "%02x", ($time >> 8) & 0xFF;
485 my $second = sprintf "%02x", ($time ) & 0xFF;
486
487 ($second, $minute, $hour)
488}
489
490sub date($) {
491 my ($mjd) = @_;
463 492
464 # Date is given in Modified Julian Date 493 # Date is given in Modified Julian Date
465 # Decoding routines taken from ANNEX C, ETSI EN 300 468 (DVB SI) 494 # Decoding routines taken from ANNEX C, ETSI EN 300 468 (DVB SI)
466 my $y_ = int ($mjd - 15078.2) / 365.25; 495 my $y_ = int (($mjd - 15078.2) / 365.25);
467 my $m_ = int (($mjd - 14956.1 - int ($y_ * 365.25)) / 30.6001); 496 my $m_ = int (($mjd - 14956.1 - int ($y_ * 365.25)) / 30.6001);
468 my $day = $mjd - 14956 - int ($y_ * 365.25) - int ($m_ * 30.6001); 497 my $day = $mjd - 14956 - int ($y_ * 365.25) - int ($m_ * 30.6001);
469 my $k = $m_ == 14 or $m_ == 15 ? 1 : 0; 498 my $k = $m_ == 14 or $m_ == 15 ? 1 : 0;
470 my $year = $y_ + $k + 1900; 499 my $year = $y_ + $k + 1900;
471 my $month = $m_ - 1 - $k * 12; 500 my $month = $m_ - 1 - $k * 12;
472 501
473 # Time is in UTC, 24 bit, every nibble one digit in BCD from right to left 502 ($day, $month, $year)
474 my $hour = sprintf "%02x", ($time >> 16) & 0xFF; 503}
475 my $minute = sprintf "%02x", ($time >> 8) & 0xFF;
476 my $second = sprintf "%02x", ($time ) & 0xFF;
477 504
505sub datetime($$) {
506 (Linux::DVB::Decode::time $_[1], date $_[0])
507}
508
509sub time_linear($) {
510 my ($s, $m, $h) = Linux::DVB::Decode::time $_[0];
511
512 (($h * 60) + $m * 60) + $s
513}
514
515sub datetime_linear($$) {
478 return ($second, $minute, $hour, $day, $month, $year); 516 my ($sec, $min, $hour, $mday, $mon, $year) =
517 Linux::DVB::Decode::datetime $_[0], $_[1];
518
519 require Time::Local;
520 Time::Local::timegm ($sec, $min, $hour, $mday, $mon - 1, $year)
479} 521}
480 522
481=back 523=back
482 524
483=head1 AUTHORS 525=head1 AUTHORS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines