DVB(3pm) | User Contributed Perl Documentation | DVB(3pm) |
Linux::DVB - interface to (some parts of) the Linux DVB API
use Linux::DVB;
This module provides an interface to the Linux DVB API. It is a straightforward translation of the C API. You should read the Linux DVB API description to make any sense of this module. It can be found here:
http://www.linuxtv.org/docs/dvbapi/dvbapi.html
All constants from frontend.h and demux.h are exported by their C name and by default.
Noteworthy differences to the C API: unions and sub-structs are usually translated into flat perl hashes, i.e "struct.u.qam.symbol_rate" becomes "$struct->{symbol_rate}".
Noteworthy limitations of this module include: No interface to the video, audio and net devices. If you need this functionality bug the author.
my $fe = new Linux::DVB::Frontend $path, $writable; my $fe = new Linux::DVB::Frontend "/dev/dvb/adapter0/frontend0", 1; $fe->fh; # filehandle $fe->fd; # fileno $fe->blocking (0); # or 1 $fe->{name} $fe->{type} $fe->frontend_info->{name} $fe->status & FE_HAS_LOCK print $fe->ber, $fe->snr, $fe->signal_strength, $fe->uncorrected; my $tune = $fe->parameters; $tune->{frequency}; $tune->{symbol_rate};
Returns true on success.
All modes:
frequency => inversion =>
QPSK frontends:
symbol_rate => fec_inner =>
QAM frontends:
symbol_rate => modulation =>
QFDM frontends:
bandwidth => code_rate_HP => code_rate_LP => constellation => transmission_mode =>
Example:
Data::Dumper::Dumper $fe->get { frequency => 426000000, # 426 Mhz inversion => 0, # INVERSION_OFF symbol_rate => 6900000, # 6.9 MB/s modulation => 3, # QAM_64 }
my $dmx = new Linux::DVB::Demux "/dev/dvb/adapter0/demux0"; $fe->fh; # filehandle $fe->fd; # fileno $fe->blocking (1); # non-blocking is default $dmx->buffer (16384); $dmx->sct_filter ($pid, "filter", "mask", $timeout=0, $flags=DMX_CHECK_CRC); $dmx->pes_filter ($pid, $input, $output, $type, $flags=0); $dmx->start; $dmx->stop;
$si_decoded_hashref = Linux::DVB::Decode::si $section_data;
The way to use this function is to append new data to your $section_data and then call "Linux::DVB::Decode::si" in a loop until it returns "undef". Please ntoe, however, that the Linux DVB API will return only one table at a time from sysread, so you can safely assume that every sysread will return exactly one (or zero in case of errors) SI table.
Here is an example of what to expect:
{ 'segment_last_section_number' => 112, 'table_id' => 81, 'service_id' => 28129, 'original_network_id' => 1, 'section_syntax_indicator' => 1, 'current_next_indicator' => 1, 'events' => [ { 'running_status' => 0, 'start_time_hms' => 2097152, 'event_id' => 39505, 'free_CA_mode' => 0, 'start_time_mjd' => 53470, 'descriptors' => [ { 'event_name' => 'Nachrichten', 'text' => '', 'ISO_639_language_code' => 'deu', 'type' => 77 }, { 'programme_identification_label' => 337280, 'type' => 105 }, { 'raw_data' => '22:0010.04#00', 'type' => 130 } ], 'duration' => 1280 }, { 'running_status' => 0, 'start_time_hms' => 2098432, 'event_id' => 39506, 'free_CA_mode' => 0, 'start_time_mjd' => 53470, 'descriptors' => [ { 'event_name' => 'SR 1 - Nachtwerk', 'text' => '', 'ISO_639_language_code' => 'deu', 'type' => 77 }, { 'programme_identification_label' => 337285, 'type' => 105 }, { 'raw_data' => '22:0510.04#00', 'type' => 130 } ], 'duration' => 87296 } ], 'last_table_id' => 81, 'section_number' => 112, 'last_section_number' => 176, 'version_number' => 31, 'transport_stream_id' => 1101 }
$Linux::DVB::Decode::nibble_to_genre{7}{6} => 'film/cinema'
The format of the returns value of the date and datetime functions is not compatible with "Time::Local". Use the "_linear" functions instead.
Example:
my $time = Linux::DVB::Decode::datetime_linear $mjd, $hms printf "Starts at %s\n", POSIX::strftime "%Y-%m-%d %H:%M:%S", localtime $time;
Marc Lehmann <schmorp@schmorp.de>, http://home.schmorp.de/ Magnus Schmidt, eMail at http://www.27b-6.de/email.php
2022-10-20 | perl v5.36.0 |