… | |
… | |
30 | package Linux::DVB; |
30 | package Linux::DVB; |
31 | |
31 | |
32 | use Fcntl (); |
32 | use Fcntl (); |
33 | |
33 | |
34 | BEGIN { |
34 | BEGIN { |
35 | $VERSION = '0.3'; |
35 | $VERSION = '1.0'; |
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 | |
… | |
… | |
106 | %$self = ( %$self, %{ $self->frontend_info } ); |
106 | %$self = ( %$self, %{ $self->frontend_info } ); |
107 | |
107 | |
108 | $self; |
108 | $self; |
109 | } |
109 | } |
110 | |
110 | |
111 | sub frontend_info { _frontend_info ($_[0]{fd}) } |
|
|
112 | sub status { _read_status ($_[0]{fd}) } |
|
|
113 | sub ber { _read_ber ($_[0]{fd}) } |
|
|
114 | sub snr { _snr ($_[0]{fd}) } |
|
|
115 | sub signal_strength { _signal_strength ($_[0]{fd}) } |
|
|
116 | sub uncorrected { _uncorrected ($_[0]{fd}) } |
|
|
117 | |
|
|
118 | =item $fe->set (parameter => value, ...) |
111 | =item $fe->set (parameter => value, ...) |
119 | |
112 | |
120 | Sets frontend parameters. All values are stuffed into the |
113 | Sets frontend parameters. All values are stuffed into the |
121 | C<dvb_frontend_parameters> structure without conversion and passed to |
114 | C<dvb_frontend_parameters> structure without conversion and passed to |
122 | FE_SET_FRONTEND. |
115 | FE_SET_FRONTEND. |
… | |
… | |
134 | fec_inner => |
127 | fec_inner => |
135 | |
128 | |
136 | QAM frontends: |
129 | QAM frontends: |
137 | |
130 | |
138 | symbol_rate => |
131 | symbol_rate => |
139 | fec_inner => |
|
|
140 | modulation => |
132 | modulation => |
141 | |
133 | |
142 | QFDM frontends: |
134 | QFDM frontends: |
143 | |
135 | |
144 | bandwidth => |
136 | bandwidth => |
… | |
… | |
165 | |
157 | |
166 | { |
158 | { |
167 | frequency => 426000000, # 426 Mhz |
159 | frequency => 426000000, # 426 Mhz |
168 | inversion => 0, # INVERSION_OFF |
160 | inversion => 0, # INVERSION_OFF |
169 | symbol_rate => 6900000, # 6.9 MB/s |
161 | symbol_rate => 6900000, # 6.9 MB/s |
170 | fec_inner => 0, # FEC_NONE |
|
|
171 | modulation => 3, # QAM_64 |
162 | modulation => 3, # QAM_64 |
172 | } |
163 | } |
173 | |
164 | |
174 | =cut |
165 | =cut |
175 | |
166 | |
176 | sub parameters { _get ($_[0]{fd}, $_[0]{type}) } |
167 | sub parameters { _get ($_[0]{fd}, $_[0]{type}) } |
177 | sub get { _get ($_[0]{fd}, $_[0]{type}) } # unannounced alias |
168 | sub get { _get ($_[0]{fd}, $_[0]{type}) } # unannounced alias |
178 | sub event { _event ($_[0]{fd}, $_[0]{type}) } |
169 | sub event { _event ($_[0]{fd}, $_[0]{type}) } |
|
|
170 | |
|
|
171 | =item $ok = $fe->diseqc_reset_overload |
|
|
172 | |
|
|
173 | If the bus has been automatically powered off due to power overload, this |
|
|
174 | call restores the power to the bus. The call requires read/write access |
|
|
175 | to the device. This call has no effect if the device is manually powered |
|
|
176 | off. Not all DVB adapters support this call. |
|
|
177 | |
|
|
178 | =item $ok = $fe->diseqc_voltage (13|18) |
|
|
179 | |
|
|
180 | Set the DiSEqC voltage to either 13 or 18 volts. |
|
|
181 | |
|
|
182 | =item $ok = $fe->diseqc_tone (1|0) |
|
|
183 | |
|
|
184 | Enables (1) or disables (0) the DiSEqC continuous 22khz tone generation. |
|
|
185 | |
|
|
186 | =item $ok = $fe->diseqc_send_burst (0|1) |
|
|
187 | |
|
|
188 | Sends a 22KHz tone burst of type SEC_MINI_A (0) or SEC_MINI_B (1). |
|
|
189 | |
|
|
190 | =item $ok = $fe->diseqc_cmd ($command) |
|
|
191 | |
|
|
192 | Sends a DiSEqC command. |
|
|
193 | |
|
|
194 | =item $reply = $fe->diseqc_reply ($timeout) |
|
|
195 | |
|
|
196 | Receives a reply to a DiSEqC 2.0 command (or undef). |
|
|
197 | |
|
|
198 | =cut |
179 | |
199 | |
180 | package Linux::DVB::Demux; |
200 | package 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 | |
349 | our %nibble_to_genre = ( |
369 | our %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 | |
|
|
473 | =item ($sec,$min,$hour) = Linux::DVB::Decode::time $hms |
|
|
474 | |
|
|
475 | =item ($mday,$mon,$year) = Linux::DVB::Decode::date $mjd |
|
|
476 | |
453 | =item ($sec,$min,$hour,$mday,$mon,$year) = Linux::DVB::Decode::time $mjd, $time |
477 | =item ($sec,$min,$hour,$mday,$mon,$year) = Linux::DVB::Decode::datetime $mjd, $hms |
|
|
478 | |
|
|
479 | =item $sec = Linux::DVB::Decode::time_linear $hms |
|
|
480 | |
|
|
481 | =item $sec = Linux::DVB::Decode::datetime_linear $mjd, $hms |
454 | |
482 | |
455 | Break down a "DVB time" (modified julian date + bcd encoded seconds) into |
483 | Break down a "DVB time" (modified julian date + bcd encoded seconds) into |
456 | it's components in UTC (i.e. use Time::Local::timegm to convert to UNIX |
484 | it's components (non-C<_linear>) or into a seconds count (C<_linear> |
457 | time). |
485 | variants) since the epoch (C<datetime_linear>) or the start of the day |
|
|
486 | (C<time_linear>). |
458 | |
487 | |
459 | =cut |
488 | The format of the returns value of the date and datetime functions is |
|
|
489 | I<not> compatible with C<Time::Local>. Use the C<_linear> functions |
|
|
490 | instead. |
460 | |
491 | |
|
|
492 | Example: |
|
|
493 | |
|
|
494 | my $time = Linux::DVB::Decode::datetime_linear $mjd, $hms |
|
|
495 | printf "Starts at %s\n", |
|
|
496 | POSIX::strftime "%Y-%m-%d %H:%M:%S", |
|
|
497 | localtime $time; |
|
|
498 | |
|
|
499 | =cut |
|
|
500 | |
461 | sub time($$) { |
501 | sub time($) { |
462 | my ($mjd, $time) = @_; |
502 | my ($time) = @_; |
|
|
503 | |
|
|
504 | # Time is in UTC, 24 bit, every nibble one digit in BCD from right to left |
|
|
505 | my $hour = sprintf "%02x", ($time >> 16) & 0xFF; |
|
|
506 | my $minute = sprintf "%02x", ($time >> 8) & 0xFF; |
|
|
507 | my $second = sprintf "%02x", ($time ) & 0xFF; |
|
|
508 | |
|
|
509 | ($second, $minute, $hour) |
|
|
510 | } |
|
|
511 | |
|
|
512 | sub date($) { |
|
|
513 | my ($mjd) = @_; |
463 | |
514 | |
464 | # Date is given in Modified Julian Date |
515 | # Date is given in Modified Julian Date |
465 | # 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) |
466 | my $y_ = int ($mjd - 15078.2) / 365.25; |
517 | my $y_ = int (($mjd - 15078.2) / 365.25); |
467 | 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); |
468 | 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); |
469 | my $k = $m_ == 14 or $m_ == 15 ? 1 : 0; |
520 | my $k = $m_ == 14 or $m_ == 15 ? 1 : 0; |
470 | my $year = $y_ + $k + 1900; |
521 | my $year = $y_ + $k + 1900; |
471 | my $month = $m_ - 1 - $k * 12; |
522 | my $month = $m_ - 1 - $k * 12; |
472 | |
523 | |
473 | # Time is in UTC, 24 bit, every nibble one digit in BCD from right to left |
524 | ($day, $month, $year) |
474 | my $hour = sprintf "%02x", ($time >> 16) & 0xFF; |
525 | } |
475 | my $minute = sprintf "%02x", ($time >> 8) & 0xFF; |
|
|
476 | my $second = sprintf "%02x", ($time ) & 0xFF; |
|
|
477 | |
526 | |
|
|
527 | sub datetime($$) { |
|
|
528 | (Linux::DVB::Decode::time $_[1], date $_[0]) |
|
|
529 | } |
|
|
530 | |
|
|
531 | sub time_linear($) { |
|
|
532 | my ($s, $m, $h) = Linux::DVB::Decode::time $_[0]; |
|
|
533 | |
|
|
534 | (($h * 60) + $m * 60) + $s |
|
|
535 | } |
|
|
536 | |
|
|
537 | sub datetime_linear($$) { |
478 | return ($second, $minute, $hour, $day, $month, $year); |
538 | my ($sec, $min, $hour, $mday, $mon, $year) = |
|
|
539 | Linux::DVB::Decode::datetime $_[0], $_[1]; |
|
|
540 | |
|
|
541 | require Time::Local; |
|
|
542 | Time::Local::timegm ($sec, $min, $hour, $mday, $mon - 1, $year) |
479 | } |
543 | } |
480 | |
544 | |
481 | =back |
545 | =back |
482 | |
546 | |
483 | =head1 AUTHORS |
547 | =head1 AUTHORS |