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.10 by root, Tue Apr 12 01:22:04 2005 UTC

30package Linux::DVB; 30package Linux::DVB;
31 31
32use Fcntl (); 32use Fcntl ();
33 33
34BEGIN { 34BEGIN {
35 $VERSION = '0.3'; 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
346 346
347=cut 347=cut
348 348
349our %nibble_to_genre = ( 349our %nibble_to_genre = (
350 0x1 => { 350 0x1 => {
351 0x0 => 'Movie / Drama', 351 0x0 => 'Movie/Drama (general)',
352 0x1 => 'Movie - detective/thriller', 352 0x1 => 'Movie - detective/thriller',
353 0x2 => 'Movie - adventure/western/war', 353 0x2 => 'Movie - adventure/western/war',
354 0x3 => 'Movie - science fiction/fantasy/horror', 354 0x3 => 'Movie - science fiction/fantasy/horror',
355 0x4 => 'Movie - comedy', 355 0x4 => 'Movie - comedy',
356 0x5 => 'Movie - soap/melodrama/folkloric', 356 0x5 => 'Movie - soap/melodrama/folkloric',
357 0x6 => 'Movie - romance', 357 0x6 => 'Movie - romance',
358 0x7 => 'Movie - serious/classical/religious/historical movie/drama', 358 0x7 => 'Movie - serious/classical/religious/historical movie/drama',
359 0x8 => 'Movie - adult movie/drama', 359 0x8 => 'Movie - adult movie/drama',
360 }, 360 },
361 0x2 => { 361 0x2 => {
362 0x0 => 'News / Current Affairs', 362 0x0 => 'News/Current Affairs (general)',
363 0x1 => 'news/weather report', 363 0x1 => 'news/weather report',
364 0x2 => 'news magazine', 364 0x2 => 'news magazine',
365 0x3 => 'documentary', 365 0x3 => 'documentary',
366 0x4 => 'discussion/interview/debate', 366 0x4 => 'discussion/interview/debate',
367 }, 367 },
368 0x3 => { 368 0x3 => {
369 0x0 => 'Show / Game Show', 369 0x0 => 'Show/Game Show (general)',
370 0x1 => 'game show/quiz/contest', 370 0x1 => 'game show/quiz/contest',
371 0x2 => 'variety show', 371 0x2 => 'variety show',
372 0x3 => 'talk show', 372 0x3 => 'talk show',
373 }, 373 },
374 0x4 => { 374 0x4 => {
375 0x0 => 'Sports', 375 0x0 => 'Sports (general)',
376 0x1 => 'special events (Olympic Games, World Cup etc.)', 376 0x1 => 'special events (Olympic Games, World Cup etc.)',
377 0x2 => 'sports magazines', 377 0x2 => 'sports magazines',
378 0x3 => 'football/soccer', 378 0x3 => 'football/soccer',
379 0x4 => 'tennis/squash', 379 0x4 => 'tennis/squash',
380 0x5 => 'team sports (excluding football)', 380 0x5 => 'team sports (excluding football)',
384 0x9 => 'winter sports', 384 0x9 => 'winter sports',
385 0xA => 'equestrian', 385 0xA => 'equestrian',
386 0xB => 'martial sports', 386 0xB => 'martial sports',
387 }, 387 },
388 0x5 => { 388 0x5 => {
389 0x0 => 'Childrens / Youth', 389 0x0 => 'Childrens/Youth (general)',
390 0x1 => "pre-school children's programmes", 390 0x1 => "pre-school children's programmes",
391 0x2 => 'entertainment programmes for 6 to 14', 391 0x2 => 'entertainment programmes for 6 to 14',
392 0x3 => 'entertainment programmes for 10 to 16', 392 0x3 => 'entertainment programmes for 10 to 16',
393 0x4 => 'informational/educational/school programmes', 393 0x4 => 'informational/educational/school programmes',
394 0x5 => 'cartoons/puppets', 394 0x5 => 'cartoons/puppets',
395 }, 395 },
396 0x6 => { 396 0x6 => {
397 0x0 => 'Music / Ballet / Dance', 397 0x0 => 'Music/Ballet/Dance (general)',
398 0x1 => 'rock/pop', 398 0x1 => 'rock/pop',
399 0x2 => 'serious music/classical music', 399 0x2 => 'serious music or classical music',
400 0x3 => 'folk/traditional music', 400 0x3 => 'folk/traditional music',
401 0x4 => 'jazz', 401 0x4 => 'jazz',
402 0x5 => 'musical/opera', 402 0x5 => 'musical/opera',
403 0x6 => 'ballet', 403 0x6 => 'ballet',
404 }, 404 },
405 0x7 => { 405 0x7 => {
406 0x0 => 'Arts / Culture', 406 0x0 => 'Arts/Culture (without music, general)',
407 0x1 => 'performing arts', 407 0x1 => 'performing arts',
408 0x2 => 'fine arts', 408 0x2 => 'fine arts',
409 0x3 => 'religion', 409 0x3 => 'religion',
410 0x4 => 'popular culture/traditional arts', 410 0x4 => 'popular culture/traditional arts',
411 0x5 => 'literature', 411 0x5 => 'literature',
415 0x9 => 'new media', 415 0x9 => 'new media',
416 0xA => 'arts/culture magazines', 416 0xA => 'arts/culture magazines',
417 0xB => 'fashion', 417 0xB => 'fashion',
418 }, 418 },
419 0x8 => { 419 0x8 => {
420 0x0 => 'Social / Policical / Economics', 420 0x0 => 'Social/Policical/Economics (general)',
421 0x1 => 'magazines/reports/documentary', 421 0x1 => 'magazines/reports/documentary',
422 0x2 => 'economics/social advisory', 422 0x2 => 'economics/social advisory',
423 0x3 => 'remarkable people', 423 0x3 => 'remarkable people',
424 }, 424 },
425 0x9 => { 425 0x9 => {
426 0x0 => 'Education / Science / Factual', 426 0x0 => 'Education/Science/Factual (general)',
427 0x1 => 'nature/animals/environment', 427 0x1 => 'nature/animals/environment',
428 0x2 => 'technology/natural sciences', 428 0x2 => 'technology/natural sciences',
429 0x3 => 'medicine/physiology/psychology', 429 0x3 => 'medicine/physiology/psychology',
430 0x4 => 'foreign countries/expeditions', 430 0x4 => 'foreign countries/expeditions',
431 0x5 => 'social/spiritual sciences', 431 0x5 => 'social/spiritual sciences',
432 0x6 => 'further education', 432 0x6 => 'further education',
433 0x7 => 'languages', 433 0x7 => 'languages',
434 }, 434 },
435 0xA => { 435 0xA => {
436 0x0 => 'Leisure / Hobbies', 436 0x0 => 'Leisure/Hobbies (general)',
437 0x1 => 'tourism/travel', 437 0x1 => 'tourism/travel',
438 0x2 => 'handicraft', 438 0x2 => 'handicraft',
439 0x3 => 'motoring', 439 0x3 => 'motoring',
440 0x4 => 'fitness & health', 440 0x4 => 'fitness & health',
441 0x5 => 'cooking', 441 0x5 => 'cooking',
442 0x6 => 'advertizement/shopping', 442 0x6 => 'advertizement/shopping',
443 0x7 => 'gardening', 443 0x7 => 'gardening',
444 }, 444 },
445 0xB => { 445 0xB => {
446 0x0 => 'Original Language', 446 0x0 => '(original language)',
447 0x1 => 'black & white', 447 0x1 => '(black & white)',
448 0x2 => 'unpublished', 448 0x2 => '(unpublished)',
449 0x3 => 'live broadcast', 449 0x3 => '(live broadcast)',
450 }, 450 },
451); 451);
452 452
453=item ($sec,$min,$hour) = Linux::DVB::Decode::time $hms 453=item ($sec,$min,$hour) = Linux::DVB::Decode::time $hms
454 454
463Break down a "DVB time" (modified julian date + bcd encoded seconds) into 463Break down a "DVB time" (modified julian date + bcd encoded seconds) into
464it's components (non-C<_linear>) or into a seconds count (C<_linear> 464it'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 465variants) since the epoch (C<datetime_linear>) or the start of the day
466(C<time_linear>). 466(C<time_linear>).
467 467
468The format of the returns value of the date and datetime functions is
469I<not> compatible with C<Time::Local>. Use the C<_linear> functions
470instead.
471
468Example: 472Example:
469 473
470 my $time = Linux::DVB::Decode::datetime_linear $mjd, $hms 474 my $time = Linux::DVB::Decode::datetime_linear $mjd, $hms
471 printf "Starts at %s\n", 475 printf "Starts at %s\n",
472 POSIX::strftime "%Y-%m-%d %H:%M:%S", 476 POSIX::strftime "%Y-%m-%d %H:%M:%S",
488sub date($) { 492sub date($) {
489 my ($mjd) = @_; 493 my ($mjd) = @_;
490 494
491 # Date is given in Modified Julian Date 495 # Date is given in Modified Julian Date
492 # Decoding routines taken from ANNEX C, ETSI EN 300 468 (DVB SI) 496 # Decoding routines taken from ANNEX C, ETSI EN 300 468 (DVB SI)
493 my $y_ = int ($mjd - 15078.2) / 365.25; 497 my $y_ = int (($mjd - 15078.2) / 365.25);
494 my $m_ = int (($mjd - 14956.1 - int ($y_ * 365.25)) / 30.6001); 498 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); 499 my $day = $mjd - 14956 - int ($y_ * 365.25) - int ($m_ * 30.6001);
496 my $k = $m_ == 14 or $m_ == 15 ? 1 : 0; 500 my $k = $m_ == 14 or $m_ == 15 ? 1 : 0;
497 my $year = $y_ + $k + 1900; 501 my $year = $y_ + $k + 1900;
498 my $month = $m_ - 1 - $k * 12; 502 my $month = $m_ - 1 - $k * 12;
509 513
510 (($h * 60) + $m * 60) + $s 514 (($h * 60) + $m * 60) + $s
511} 515}
512 516
513sub datetime_linear($$) { 517sub datetime_linear($$) {
518 my ($sec, $min, $hour, $mday, $mon, $year) =
519 Linux::DVB::Decode::datetime $_[0], $_[1];
520
514 require Time::Local; 521 require Time::Local;
515 Time::Local::timegm (Linux::DVB::Decode::datetime $_[0], $_[1]) 522 Time::Local::timegm ($sec, $min, $hour, $mday, $mon - 1, $year)
516} 523}
517 524
518=back 525=back
519 526
520=head1 AUTHORS 527=head1 AUTHORS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines