2005-08-28 03:20:00 +02:00
/*
2015-03-07 21:32:58 +01:00
* tools . c : Frontend Status Monitor plugin for the Video Disk Recorder
2005-08-28 03:20:00 +02:00
*
* See the README file for copyright information and how to reach the author .
*
*/
2009-09-16 11:05:15 +02:00
# ifndef __STDC_FORMAT_MACROS
# define __STDC_FORMAT_MACROS
# endif
2014-03-08 12:28:31 +01:00
# include <ctype.h>
2009-09-16 11:05:15 +02:00
# include <stdint.h>
2005-08-28 03:20:00 +02:00
# include <stdlib.h>
# include <unistd.h>
# include <sys/ioctl.h>
# include <linux/dvb/frontend.h>
2015-03-07 21:32:58 +01:00
# include "osd.h"
# include "receiver.h"
# include "tools.h"
2005-08-28 03:20:00 +02:00
2015-03-07 17:22:02 +01:00
static cString getCA ( int valueP )
2008-12-16 11:26:46 +01:00
{
// http://www.dvb.org/index.php?id=174
// http://en.wikipedia.org/wiki/Conditional_access_system
2015-03-07 17:22:02 +01:00
switch ( valueP ) {
case 0x0000 : return cString : : sprintf ( " %s (%X) " , trVDR ( " Free To Air " ) , valueP ) ; // Reserved
2008-12-16 11:26:46 +01:00
case 0x0001 . . . 0x009F :
2015-03-07 17:22:02 +01:00
case 0x00A2 . . . 0x00FF : return cString : : sprintf ( " %s (%X) " , tr ( " Fixed " ) , valueP ) ; // Standardized systems
case 0x00A0 . . . 0x00A1 : return cString : : sprintf ( " %s (%X) " , tr ( " Analog " ) , valueP ) ; // Analog signals
case 0x0100 . . . 0x01FF : return cString : : sprintf ( " SECA Mediaguard (%X) " , valueP ) ; // Canal Plus
case 0x0464 : return cString : : sprintf ( " EuroDec (%X) " , valueP ) ; // EuroDec
case 0x0500 . . . 0x05FF : return cString : : sprintf ( " Viaccess (%X) " , valueP ) ; // France Telecom
case 0x0600 . . . 0x06FF : return cString : : sprintf ( " Irdeto (%X) " , valueP ) ; // Irdeto
case 0x0700 . . . 0x07FF : return cString : : sprintf ( " DigiCipher 2 (%X) " , valueP ) ; // Jerrold/GI/Motorola 4DTV
case 0x0900 . . . 0x09FF : return cString : : sprintf ( " NDS Videoguard (%X) " , valueP ) ; // NDS
case 0x0B00 . . . 0x0BFF : return cString : : sprintf ( " Conax (%X) " , valueP ) ; // Norwegian Telekom
case 0x0D00 . . . 0x0DFF : return cString : : sprintf ( " CryptoWorks (%X) " , valueP ) ; // Philips CryptoTec
case 0x0E00 . . . 0x0EFF : return cString : : sprintf ( " PowerVu (%X) " , valueP ) ; // Scientific Atlanta
case 0x1000 : return cString : : sprintf ( " RAS (%X) " , valueP ) ; // Tandberg Television
case 0x1200 . . . 0x12FF : return cString : : sprintf ( " NagraVision (%X) " , valueP ) ; // BellVu Express
case 0x1700 . . . 0x17FF : return cString : : sprintf ( " VCAS (%X) " , valueP ) ; // Verimatrix Inc. former BetaTechnik
case 0x1800 . . . 0x18FF : return cString : : sprintf ( " NagraVision (%X) " , valueP ) ; // Kudelski SA
case 0x22F0 : return cString : : sprintf ( " Codicrypt (%X) " , valueP ) ; // Scopus Network Technologies
case 0x2600 : return cString : : sprintf ( " BISS (%X) " , valueP ) ; // European Broadcasting Union
case 0x2719 : return cString : : sprintf ( " VanyaCas (%X) " , valueP ) ; // S-Curious Research & Technology Pvt. Ltd.
case 0x4347 : return cString : : sprintf ( " CryptOn (%X) " , valueP ) ; // CryptOn
case 0x4800 : return cString : : sprintf ( " Accessgate (%X) " , valueP ) ; // Telemann
case 0x4900 : return cString : : sprintf ( " China Crypt (%X) " , valueP ) ; // CryptoWorks
case 0x4A02 : return cString : : sprintf ( " Tongfang (%X) " , valueP ) ; // Tsinghua Tongfang Company
case 0x4A10 : return cString : : sprintf ( " EasyCas (%X) " , valueP ) ; // EasyCas
case 0x4A20 : return cString : : sprintf ( " AlphaCrypt (%X) " , valueP ) ; // AlphaCrypt
case 0x4A60 : return cString : : sprintf ( " SkyCrypt (%X) " , valueP ) ; // @Sky
case 0x4A61 : return cString : : sprintf ( " Neotioncrypt (%X) " , valueP ) ; // Neotion
case 0x4A62 : return cString : : sprintf ( " SkyCrypt (%X) " , valueP ) ; // @Sky
case 0x4A63 : return cString : : sprintf ( " Neotion SHL (%X) " , valueP ) ; // Neotion
case 0x4A64 . . . 0x4A6F : return cString : : sprintf ( " SkyCrypt (%X) " , valueP ) ; // @Sky
case 0x4A70 : return cString : : sprintf ( " DreamCrypt (%X) " , valueP ) ; // Dream Multimedia
case 0x4A80 : return cString : : sprintf ( " ThalesCrypt (%X) " , valueP ) ; // Thales Broadcast & Multimedia
case 0x4AA1 : return cString : : sprintf ( " KeyFly (%X) " , valueP ) ; // SIDSA
case 0x4ABF : return cString : : sprintf ( " CTI-CAS (%X) " , valueP ) ; // Beijing Compunicate Technology Inc.
case 0x4AC1 : return cString : : sprintf ( " Latens (%X) " , valueP ) ; // Latens Systems
case 0x4AD0 . . . 0x4AD1 : return cString : : sprintf ( " X-Crypt (%X) " , valueP ) ; // XCrypt Inc.
case 0x4AD4 : return cString : : sprintf ( " OmniCrypt (%X) " , valueP ) ; // Widevine Technologies, Inc.
case 0x4AE0 . . . 0x4AE1 : return cString : : sprintf ( " Z-Crypt (%X) " , valueP ) ; // Digi Raum Electronics Co. Ltd.
case 0x4AE4 : return cString : : sprintf ( " CoreCrypt (%X) " , valueP ) ; // CoreTrust
case 0x4AE5 : return cString : : sprintf ( " PRO-Crypt (%X) " , valueP ) ; // IK SATPROF
case 0x4AEA : return cString : : sprintf ( " Cryptoguard (%X) " , valueP ) ; // Gryptoguard AB
case 0x4AEB : return cString : : sprintf ( " Abel Quintic (%X) " , valueP ) ; // Abel DRM Systems
case 0x4AF0 : return cString : : sprintf ( " ABV (%X) " , valueP ) ; // Alliance Broadcast Vision
case 0x5500 : return cString : : sprintf ( " Z-Crypt (%X) " , valueP ) ; // Digi Raum Electronics Co. Ltd.
case 0x5501 : return cString : : sprintf ( " Griffin (%X) " , valueP ) ; // Nucleus Systems Ltd.
case 0x5581 : return cString : : sprintf ( " Bulcrypt (%X) " , valueP ) ; // Bulcrypt
case 0x7BE1 : return cString : : sprintf ( " DRE-Crypt (%X) " , valueP ) ; // DRE-Crypt
case 0xA101 : return cString : : sprintf ( " RosCrypt-M (%X) " , valueP ) ; // NIIR
case 0xEAD0 : return cString : : sprintf ( " VanyaCas (%X) " , valueP ) ; // S-Curious Research & Technology Pvt. Ltd.
2009-03-24 11:51:51 +01:00
default : break ;
2008-12-16 11:26:46 +01:00
}
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %X " , valueP ) ;
2008-12-16 11:26:46 +01:00
}
2015-03-07 17:22:02 +01:00
static const char * getUserString ( int valueP , const tDvbParameterMap * mapP )
2008-12-16 11:26:46 +01:00
{
2015-03-07 17:22:02 +01:00
const tDvbParameterMap * map = mapP ;
2008-12-16 11:26:46 +01:00
while ( map & & map - > userValue ! = - 1 ) {
2015-03-07 17:22:02 +01:00
if ( map - > driverValue = = valueP )
2009-08-29 20:01:20 +02:00
return map - > userString ? trVDR ( map - > userString ) : " --- " ;
2008-12-16 11:26:46 +01:00
map + + ;
}
return " --- " ;
}
2015-03-07 17:22:02 +01:00
cDvbDevice * getDvbDevice ( cDevice * deviceP )
2012-03-29 20:48:52 +02:00
{
2015-03-07 17:22:02 +01:00
cDvbDevice * dev = dynamic_cast < cDvbDevice * > ( deviceP ) ;
2012-03-29 20:48:52 +02:00
# ifdef __DYNAMIC_DEVICE_PROBE
2015-03-07 17:22:02 +01:00
if ( ! dev & & deviceP & & deviceP - > HasSubDevice ( ) )
dev = dynamic_cast < cDvbDevice * > ( deviceP - > SubDevice ( ) ) ;
2012-03-29 20:48:52 +02:00
# endif
return dev ;
}
2015-03-07 17:22:02 +01:00
cString getFrontendInfo ( cDvbDevice * deviceP )
2006-09-17 03:20:00 +02:00
{
struct dvb_frontend_info value ;
fe_status_t status ;
2013-01-03 22:30:44 +01:00
cString info = " " ;
2006-09-17 03:20:00 +02:00
uint16_t signal = 0 ;
uint16_t snr = 0 ;
uint32_t ber = 0 ;
uint32_t unc = 0 ;
2015-09-19 16:01:01 +02:00
LOCK_CHANNELS_READ ;
const cChannel * channel = Channels - > GetByNumber ( cDevice : : CurrentChannel ( ) ) ;
2006-09-17 03:20:00 +02:00
2015-03-07 17:22:02 +01:00
if ( ! deviceP )
2012-01-15 22:07:53 +01:00
return info ;
2015-03-07 17:22:02 +01:00
int fe = open ( * cString : : sprintf ( FRONTEND_DEVICE , deviceP - > Adapter ( ) , deviceP - > Frontend ( ) ) , O_RDONLY | O_NONBLOCK ) ;
2006-09-17 03:20:00 +02:00
if ( fe < 0 )
2012-01-15 22:07:53 +01:00
return info ;
2006-09-17 03:20:00 +02:00
2015-03-07 17:22:02 +01:00
info = cString : : sprintf ( " CARD:%d \n STRG:%d \n QUAL:%d " , deviceP - > CardIndex ( ) , deviceP - > SignalStrength ( ) , deviceP - > SignalQuality ( ) ) ;
2009-09-16 08:37:51 +02:00
if ( ioctl ( fe , FE_GET_INFO , & value ) > = 0 )
2015-03-07 17:22:02 +01:00
info = cString : : sprintf ( " %s \n TYPE:%d \n NAME:%s " , * info , value . type , * deviceP - > DeviceName ( ) ) ;
2009-09-16 08:37:51 +02:00
if ( ioctl ( fe , FE_READ_STATUS , & status ) > = 0 )
info = cString : : sprintf ( " %s \n STAT:%02X " , * info , status ) ;
if ( ioctl ( fe , FE_READ_SIGNAL_STRENGTH , & signal ) > = 0 )
2009-09-22 07:44:30 +02:00
info = cString : : sprintf ( " %s \n SGNL:%04X " , * info , signal ) ;
2009-09-16 08:37:51 +02:00
if ( ioctl ( fe , FE_READ_SNR , & snr ) > = 0 )
2009-09-22 07:44:30 +02:00
info = cString : : sprintf ( " %s \n SNRA:%04X " , * info , snr ) ;
2009-09-16 08:37:51 +02:00
if ( ioctl ( fe , FE_READ_BER , & ber ) > = 0 )
2009-09-22 07:44:30 +02:00
info = cString : : sprintf ( " %s \n BERA:%08X " , * info , ber ) ;
2009-09-16 08:37:51 +02:00
if ( ioctl ( fe , FE_READ_UNCORRECTED_BLOCKS , & unc ) > = 0 )
2009-09-22 07:44:30 +02:00
info = cString : : sprintf ( " %s \n UNCB:%08X " , * info , unc ) ;
2009-09-16 08:37:51 +02:00
close ( fe ) ;
2006-09-17 03:20:00 +02:00
if ( cFemonOsd : : Instance ( ) )
info = cString : : sprintf ( " %s \n VIBR:%.0f \n AUBR:%.0f \n DDBR:%.0f " , * info , cFemonOsd : : Instance ( ) - > GetVideoBitrate ( ) , cFemonOsd : : Instance ( ) - > GetAudioBitrate ( ) , cFemonOsd : : Instance ( ) - > GetDolbyBitrate ( ) ) ;
if ( channel )
2008-12-13 21:25:26 +01:00
info = cString : : sprintf ( " %s \n CHAN:%s " , * info , * channel - > ToText ( ) ) ;
2006-09-17 03:20:00 +02:00
return info ;
}
2015-03-07 17:22:02 +01:00
cString getFrontendName ( cDvbDevice * deviceP )
2005-08-28 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
if ( ! deviceP )
2012-01-15 22:07:53 +01:00
return NULL ;
2015-03-07 17:22:02 +01:00
return ( cString : : sprintf ( " %s on deviceP #%d " , * deviceP - > DeviceName ( ) , deviceP - > CardIndex ( ) ) ) ;
2005-08-28 03:20:00 +02:00
}
2015-03-07 17:22:02 +01:00
cString getFrontendStatus ( cDvbDevice * deviceP )
2005-08-28 03:20:00 +02:00
{
fe_status_t value ;
2015-03-07 17:22:02 +01:00
if ( ! deviceP )
2012-01-15 22:07:53 +01:00
return NULL ;
2015-03-07 17:22:02 +01:00
int fe = open ( * cString : : sprintf ( FRONTEND_DEVICE , deviceP - > Adapter ( ) , deviceP - > Frontend ( ) ) , O_RDONLY | O_NONBLOCK ) ;
2005-08-28 03:20:00 +02:00
if ( fe < 0 )
return NULL ;
2009-09-16 11:05:15 +02:00
memset ( & value , 0 , sizeof ( value ) ) ;
ioctl ( fe , FE_READ_STATUS , & value ) ;
2005-08-28 03:20:00 +02:00
close ( fe ) ;
2015-03-07 17:22:02 +01:00
return ( cString : : sprintf ( " Status %s:%s:%s:%s:%s on deviceP #%d " , ( value & FE_HAS_LOCK ) ? " LOCKED " : " - " , ( value & FE_HAS_SIGNAL ) ? " SIGNAL " : " - " , ( value & FE_HAS_CARRIER ) ? " CARRIER " : " - " , ( value & FE_HAS_VITERBI ) ? " VITERBI " : " - " , ( value & FE_HAS_SYNC ) ? " SYNC " : " - " , deviceP - > CardIndex ( ) ) ) ;
2005-08-28 03:20:00 +02:00
}
2015-03-07 17:22:02 +01:00
uint16_t getSignal ( cDvbDevice * deviceP )
2005-08-28 03:20:00 +02:00
{
uint16_t value = 0 ;
2015-03-07 17:22:02 +01:00
if ( ! deviceP )
2012-01-15 22:07:53 +01:00
return ( value ) ;
2015-03-07 17:22:02 +01:00
int fe = open ( * cString : : sprintf ( FRONTEND_DEVICE , deviceP - > Adapter ( ) , deviceP - > Frontend ( ) ) , O_RDONLY | O_NONBLOCK ) ;
2005-08-28 03:20:00 +02:00
if ( fe < 0 )
return ( value ) ;
2009-09-16 11:05:15 +02:00
ioctl ( fe , FE_READ_SIGNAL_STRENGTH , & value ) ;
2005-08-28 03:20:00 +02:00
close ( fe ) ;
return ( value ) ;
}
2015-03-07 17:22:02 +01:00
uint16_t getSNR ( cDvbDevice * deviceP )
2005-08-28 03:20:00 +02:00
{
uint16_t value = 0 ;
2015-03-07 17:22:02 +01:00
if ( ! deviceP )
2012-01-15 22:07:53 +01:00
return ( value ) ;
2015-03-07 17:22:02 +01:00
int fe = open ( * cString : : sprintf ( FRONTEND_DEVICE , deviceP - > Adapter ( ) , deviceP - > Frontend ( ) ) , O_RDONLY | O_NONBLOCK ) ;
2005-08-28 03:20:00 +02:00
if ( fe < 0 )
return ( value ) ;
2009-09-16 11:05:15 +02:00
ioctl ( fe , FE_READ_SNR , & value ) ;
2005-08-28 03:20:00 +02:00
close ( fe ) ;
return ( value ) ;
}
2015-03-07 17:22:02 +01:00
uint32_t getBER ( cDvbDevice * deviceP )
2005-08-28 03:20:00 +02:00
{
uint32_t value = 0 ;
2015-03-07 17:22:02 +01:00
if ( ! deviceP )
2012-01-15 22:07:53 +01:00
return ( value ) ;
2015-03-07 17:22:02 +01:00
int fe = open ( * cString : : sprintf ( FRONTEND_DEVICE , deviceP - > Adapter ( ) , deviceP - > Frontend ( ) ) , O_RDONLY | O_NONBLOCK ) ;
2005-08-28 03:20:00 +02:00
if ( fe < 0 )
return ( value ) ;
2009-09-16 11:05:15 +02:00
ioctl ( fe , FE_READ_BER , & value ) ;
2005-08-28 03:20:00 +02:00
close ( fe ) ;
return ( value ) ;
}
2015-03-07 17:22:02 +01:00
uint32_t getUNC ( cDvbDevice * deviceP )
2005-08-28 03:20:00 +02:00
{
uint32_t value = 0 ;
2015-03-07 17:22:02 +01:00
if ( ! deviceP )
2012-01-15 22:07:53 +01:00
return ( value ) ;
2015-03-07 17:22:02 +01:00
int fe = open ( * cString : : sprintf ( FRONTEND_DEVICE , deviceP - > Adapter ( ) , deviceP - > Frontend ( ) ) , O_RDONLY | O_NONBLOCK ) ;
2005-08-28 03:20:00 +02:00
if ( fe < 0 )
return ( value ) ;
2009-09-16 11:05:15 +02:00
ioctl ( fe , FE_READ_UNCORRECTED_BLOCKS , & value ) ;
2005-08-28 03:20:00 +02:00
close ( fe ) ;
return ( value ) ;
}
2015-03-07 17:22:02 +01:00
cString getApids ( const cChannel * channelP )
2006-09-17 03:20:00 +02:00
{
int value = 0 ;
2015-03-07 17:22:02 +01:00
cString apids = cString : : sprintf ( " %d " , channelP - > Apid ( value ) ) ;
while ( channelP - > Apid ( + + value ) & & ( value < MAXAPIDS ) )
apids = cString : : sprintf ( " %s, %d " , * apids , channelP - > Apid ( value ) ) ;
2006-09-17 03:20:00 +02:00
return apids ;
}
2015-03-07 17:22:02 +01:00
cString getDpids ( const cChannel * channelP )
2006-09-17 03:20:00 +02:00
{
int value = 0 ;
2015-03-07 17:22:02 +01:00
cString dpids = cString : : sprintf ( " %d " , channelP - > Dpid ( value ) ) ;
while ( channelP - > Dpid ( + + value ) & & ( value < MAXDPIDS ) )
dpids = cString : : sprintf ( " %s, %d " , * dpids , channelP - > Dpid ( value ) ) ;
2006-09-17 03:20:00 +02:00
return dpids ;
}
2015-03-07 17:22:02 +01:00
cString getSpids ( const cChannel * channelP )
2007-10-14 03:20:00 +02:00
{
int value = 0 ;
2015-03-07 17:22:02 +01:00
cString spids = cString : : sprintf ( " %d " , channelP - > Spid ( value ) ) ;
while ( channelP - > Spid ( + + value ) & & ( value < MAXSPIDS ) )
spids = cString : : sprintf ( " %s, %d " , * spids , channelP - > Spid ( value ) ) ;
2007-10-14 03:20:00 +02:00
return spids ;
}
2015-03-07 17:22:02 +01:00
cString getCAids ( const cChannel * channelP )
2006-09-17 03:20:00 +02:00
{
int value = 0 ;
2015-03-07 17:22:02 +01:00
cString caids = cString : : sprintf ( " %s " , * getCA ( channelP - > Ca ( value ) ) ) ;
while ( channelP - > Ca ( + + value ) & & ( value < MAXCAIDS ) )
caids = cString : : sprintf ( " %s, %s " , * caids , * getCA ( channelP - > Ca ( value ) ) ) ;
2006-09-17 03:20:00 +02:00
return caids ;
}
2008-11-10 23:30:00 +01:00
cString getVideoStream ( int value )
{
if ( value ! = 0 )
return cString : : sprintf ( " #%d " , value ) ;
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getAudioStream ( int valueP , const cChannel * channelP )
2008-11-10 23:30:00 +01:00
{
int pid = 0 ;
2015-03-07 17:22:02 +01:00
if ( IS_AUDIO_TRACK ( valueP ) )
pid = int ( valueP - ttAudioFirst ) ;
if ( channelP & & channelP - > Apid ( pid ) ) {
if ( channelP - > Alang ( pid ) )
return cString : : sprintf ( " #%d (%s) " , channelP - > Apid ( pid ) , channelP - > Alang ( pid ) ) ;
2008-11-10 23:30:00 +01:00
else
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " #%d " , channelP - > Apid ( pid ) ) ;
2008-11-22 22:12:39 +01:00
}
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getAC3Stream ( int valueP , const cChannel * channelP )
2008-11-22 22:12:39 +01:00
{
int pid = 0 ;
2015-03-07 17:22:02 +01:00
if ( IS_DOLBY_TRACK ( valueP ) )
pid = int ( valueP - ttDolbyFirst ) ;
if ( channelP & & channelP - > Dpid ( pid ) ) {
if ( channelP - > Dlang ( pid ) )
return cString : : sprintf ( " #%d (%s) " , channelP - > Dpid ( pid ) , channelP - > Dlang ( pid ) ) ;
2008-11-22 22:12:39 +01:00
else
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " #%d " , channelP - > Dpid ( pid ) ) ;
2008-11-10 23:30:00 +01:00
}
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getVideoCodec ( int valueP )
2008-11-09 12:43:27 +01:00
{
2015-03-07 17:22:02 +01:00
switch ( valueP ) {
2008-11-09 12:43:27 +01:00
case VIDEO_CODEC_MPEG2 : return cString : : sprintf ( " %s " , tr ( " MPEG-2 " ) ) ;
case VIDEO_CODEC_H264 : return cString : : sprintf ( " %s " , tr ( " H.264 " ) ) ;
2017-02-27 20:51:59 +01:00
case VIDEO_CODEC_H265 : return cString : : sprintf ( " %s " , tr ( " H.265 " ) ) ;
2009-03-24 11:51:51 +01:00
default : break ;
2008-11-09 12:43:27 +01:00
}
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getAudioCodec ( int valueP )
2008-11-09 12:43:27 +01:00
{
2015-03-07 17:22:02 +01:00
switch ( valueP ) {
2008-11-09 12:43:27 +01:00
case AUDIO_CODEC_MPEG1_I : return cString : : sprintf ( " %s " , tr ( " MPEG-1 Layer I " ) ) ;
case AUDIO_CODEC_MPEG1_II : return cString : : sprintf ( " %s " , tr ( " MPEG-1 Layer II " ) ) ;
case AUDIO_CODEC_MPEG1_III : return cString : : sprintf ( " %s " , tr ( " MPEG-1 Layer III " ) ) ;
case AUDIO_CODEC_MPEG2_I : return cString : : sprintf ( " %s " , tr ( " MPEG-2 Layer I " ) ) ;
case AUDIO_CODEC_MPEG2_II : return cString : : sprintf ( " %s " , tr ( " MPEG-2 Layer II " ) ) ;
case AUDIO_CODEC_MPEG2_III : return cString : : sprintf ( " %s " , tr ( " MPEG-2 Layer III " ) ) ;
case AUDIO_CODEC_HEAAC : return cString : : sprintf ( " %s " , tr ( " HE-AAC " ) ) ;
2010-06-23 11:16:17 +02:00
case AUDIO_CODEC_LATM : return cString : : sprintf ( " %s " , tr ( " LATM " ) ) ;
2009-03-24 11:51:51 +01:00
default : break ;
2008-11-09 12:43:27 +01:00
}
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getAudioChannelMode ( int valueP )
2008-11-09 12:43:27 +01:00
{
2015-03-07 17:22:02 +01:00
switch ( valueP ) {
2008-11-09 12:43:27 +01:00
case AUDIO_CHANNEL_MODE_STEREO : return cString : : sprintf ( " %s " , tr ( " stereo " ) ) ;
case AUDIO_CHANNEL_MODE_JOINT_STEREO : return cString : : sprintf ( " %s " , tr ( " joint Stereo " ) ) ;
case AUDIO_CHANNEL_MODE_DUAL : return cString : : sprintf ( " %s " , tr ( " dual " ) ) ;
case AUDIO_CHANNEL_MODE_SINGLE : return cString : : sprintf ( " %s " , tr ( " mono " ) ) ;
2009-03-24 11:51:51 +01:00
default : break ;
2008-11-09 12:43:27 +01:00
}
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getCoderate ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %s " , getUserString ( valueP , CoderateValues ) ) ;
2006-09-17 03:20:00 +02:00
}
2015-03-07 17:22:02 +01:00
cString getTransmission ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %s " , getUserString ( valueP , TransmissionValues ) ) ;
2006-09-17 03:20:00 +02:00
}
2009-08-25 19:22:06 +02:00
2015-03-07 17:22:02 +01:00
cString getBandwidth ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %s " , getUserString ( valueP , BandwidthValues ) ) ;
2006-09-17 03:20:00 +02:00
}
2015-03-07 17:22:02 +01:00
cString getInversion ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %s " , getUserString ( valueP , InversionValues ) ) ;
2006-09-17 03:20:00 +02:00
}
2015-03-07 17:22:02 +01:00
cString getHierarchy ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %s " , getUserString ( valueP , HierarchyValues ) ) ;
2006-09-17 03:20:00 +02:00
}
2015-03-07 17:22:02 +01:00
cString getGuard ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %s " , getUserString ( valueP , GuardValues ) ) ;
2006-09-17 03:20:00 +02:00
}
2015-03-07 17:22:02 +01:00
cString getModulation ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %s " , getUserString ( valueP , ModulationValues ) ) ;
2008-11-09 12:43:27 +01:00
}
2015-03-07 17:22:02 +01:00
cString getTerrestrialSystem ( int valueP )
2012-01-15 22:07:53 +01:00
{
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %s " , getUserString ( valueP , SystemValuesTerr ) ) ;
2012-01-15 22:07:53 +01:00
}
2015-03-07 17:22:02 +01:00
cString getSatelliteSystem ( int valueP )
2008-11-09 12:43:27 +01:00
{
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %s " , getUserString ( valueP , SystemValuesSat ) ) ;
2008-11-09 12:43:27 +01:00
}
2015-03-07 17:22:02 +01:00
cString getRollOff ( int valueP )
2008-11-09 12:43:27 +01:00
{
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %s " , getUserString ( valueP , RollOffValues ) ) ;
2008-11-09 12:43:27 +01:00
}
2015-03-07 17:22:02 +01:00
cString getPilot ( int valueP )
2014-03-16 16:04:28 +01:00
{
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %s " , getUserString ( valueP , PilotValues ) ) ;
2014-03-16 16:04:28 +01:00
}
2015-03-07 17:22:02 +01:00
cString getResolution ( int widthP , int heightP , int scanP )
2008-11-09 12:43:27 +01:00
{
2015-03-07 17:22:02 +01:00
if ( ( widthP > 0 ) & & ( heightP > 0 ) ) {
switch ( scanP ) {
case VIDEO_SCAN_INTERLACED : return cString : : sprintf ( " %dx%d %s " , widthP , heightP , tr ( " interlaced " ) ) ;
case VIDEO_SCAN_PROGRESSIVE : return cString : : sprintf ( " %dx%d %s " , widthP , heightP , tr ( " progressive " ) ) ;
default : return cString : : sprintf ( " %dx%d " , widthP , heightP ) ;
2008-11-09 12:43:27 +01:00
}
}
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getAspectRatio ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
switch ( valueP ) {
2008-11-09 12:43:27 +01:00
case VIDEO_ASPECT_RATIO_RESERVED : return cString : : sprintf ( " %s " , tr ( " reserved " ) ) ;
case VIDEO_ASPECT_RATIO_EXTENDED : return cString : : sprintf ( " %s " , tr ( " extended " ) ) ;
case VIDEO_ASPECT_RATIO_1_1 : return cString : : sprintf ( " 1:1 " ) ;
case VIDEO_ASPECT_RATIO_4_3 : return cString : : sprintf ( " 4:3 " ) ;
case VIDEO_ASPECT_RATIO_16_9 : return cString : : sprintf ( " 16:9 " ) ;
case VIDEO_ASPECT_RATIO_2_21_1 : return cString : : sprintf ( " 2.21:1 " ) ;
case VIDEO_ASPECT_RATIO_12_11 : return cString : : sprintf ( " 12:11 " ) ;
case VIDEO_ASPECT_RATIO_10_11 : return cString : : sprintf ( " 10:11 " ) ;
case VIDEO_ASPECT_RATIO_16_11 : return cString : : sprintf ( " 16:11 " ) ;
case VIDEO_ASPECT_RATIO_40_33 : return cString : : sprintf ( " 40:33 " ) ;
case VIDEO_ASPECT_RATIO_24_11 : return cString : : sprintf ( " 24:11 " ) ;
case VIDEO_ASPECT_RATIO_20_11 : return cString : : sprintf ( " 20:11 " ) ;
case VIDEO_ASPECT_RATIO_32_11 : return cString : : sprintf ( " 32:11 " ) ;
case VIDEO_ASPECT_RATIO_80_33 : return cString : : sprintf ( " 80:33 " ) ;
case VIDEO_ASPECT_RATIO_18_11 : return cString : : sprintf ( " 18:11 " ) ;
case VIDEO_ASPECT_RATIO_15_11 : return cString : : sprintf ( " 15:11 " ) ;
case VIDEO_ASPECT_RATIO_64_33 : return cString : : sprintf ( " 64:33 " ) ;
case VIDEO_ASPECT_RATIO_160_99 : return cString : : sprintf ( " 160:99 " ) ;
case VIDEO_ASPECT_RATIO_3_2 : return cString : : sprintf ( " 3:2 " ) ;
case VIDEO_ASPECT_RATIO_2_1 : return cString : : sprintf ( " 2:1 " ) ;
2009-03-24 11:51:51 +01:00
default : break ;
2006-09-17 03:20:00 +02:00
}
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getVideoFormat ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
switch ( valueP ) {
2008-11-09 12:43:27 +01:00
case VIDEO_FORMAT_UNKNOWN : return cString : : sprintf ( " %s " , tr ( " unknown " ) ) ;
case VIDEO_FORMAT_RESERVED : return cString : : sprintf ( " %s " , tr ( " reserved " ) ) ;
case VIDEO_FORMAT_COMPONENT : return cString : : sprintf ( " %s " , tr ( " component " ) ) ;
case VIDEO_FORMAT_PAL : return cString : : sprintf ( " %s " , tr ( " PAL " ) ) ;
case VIDEO_FORMAT_NTSC : return cString : : sprintf ( " %s " , tr ( " NTSC " ) ) ;
case VIDEO_FORMAT_SECAM : return cString : : sprintf ( " %s " , tr ( " SECAM " ) ) ;
case VIDEO_FORMAT_MAC : return cString : : sprintf ( " %s " , tr ( " MAC " ) ) ;
2009-03-24 11:51:51 +01:00
default : break ;
2006-09-17 03:20:00 +02:00
}
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getFrameRate ( double valueP )
2008-11-09 12:43:27 +01:00
{
2015-03-07 17:22:02 +01:00
if ( valueP > 0 )
return cString : : sprintf ( " %.2f %s " , valueP , tr ( " Hz " ) ) ;
2008-11-09 12:43:27 +01:00
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getAC3BitStreamMode ( int valueP , int codingP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
switch ( valueP ) {
2008-11-09 12:43:27 +01:00
case AUDIO_BITSTREAM_MODE_CM : return cString : : sprintf ( " %s " , tr ( " Complete Main (CM) " ) ) ;
case AUDIO_BITSTREAM_MODE_ME : return cString : : sprintf ( " %s " , tr ( " Music and Effects (ME) " ) ) ;
case AUDIO_BITSTREAM_MODE_VI : return cString : : sprintf ( " %s " , tr ( " Visually Impaired (VI) " ) ) ;
case AUDIO_BITSTREAM_MODE_HI : return cString : : sprintf ( " %s " , tr ( " Hearing Impaired (HI) " ) ) ;
case AUDIO_BITSTREAM_MODE_D : return cString : : sprintf ( " %s " , tr ( " Dialogue (D) " ) ) ;
case AUDIO_BITSTREAM_MODE_C : return cString : : sprintf ( " %s " , tr ( " Commentary (C) " ) ) ;
case AUDIO_BITSTREAM_MODE_E : return cString : : sprintf ( " %s " , tr ( " Emergency (E) " ) ) ;
2015-03-07 17:22:02 +01:00
case AUDIO_BITSTREAM_MODE_VO_KAR : return cString : : sprintf ( " %s " , ( codingP = = 1 ) ? tr ( " Voice Over (VO) " ) : tr ( " Karaoke " ) ) ;
2009-03-24 11:51:51 +01:00
default : break ;
2006-09-17 03:20:00 +02:00
}
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getAC3AudioCodingMode ( int valueP , int streamP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
if ( streamP ! = 7 ) {
switch ( valueP ) {
2008-11-09 12:43:27 +01:00
case AUDIO_CODING_MODE_1_1 : return cString : : sprintf ( " 1+1 - %s, %s " , tr ( " Ch1 " ) , tr ( " Ch2 " ) ) ;
case AUDIO_CODING_MODE_1_0 : return cString : : sprintf ( " 1/0 - %s " , tr ( " C " ) ) ;
case AUDIO_CODING_MODE_2_0 : return cString : : sprintf ( " 2/0 - %s, %s " , tr ( " L " ) , tr ( " R " ) ) ;
case AUDIO_CODING_MODE_3_0 : return cString : : sprintf ( " 3/0 - %s, %s, %s " , tr ( " L " ) , tr ( " C " ) , tr ( " R " ) ) ;
case AUDIO_CODING_MODE_2_1 : return cString : : sprintf ( " 2/1 - %s, %s, %s " , tr ( " L " ) , tr ( " R " ) , tr ( " S " ) ) ;
case AUDIO_CODING_MODE_3_1 : return cString : : sprintf ( " 3/1 - %s, %s, %s, %s " , tr ( " L " ) , tr ( " C " ) , tr ( " R " ) , tr ( " S " ) ) ;
case AUDIO_CODING_MODE_2_2 : return cString : : sprintf ( " 2/2 - %s, %s, %s, %s " , tr ( " L " ) , tr ( " R " ) , tr ( " SL " ) , tr ( " SR " ) ) ;
case AUDIO_CODING_MODE_3_2 : return cString : : sprintf ( " 3/2 - %s, %s, %s, %s, %s " , tr ( " L " ) , tr ( " C " ) , tr ( " R " ) , tr ( " SL " ) , tr ( " SR " ) ) ;
2009-03-24 11:51:51 +01:00
default : break ;
2006-09-17 03:20:00 +02:00
}
}
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getAC3CenterMixLevel ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
switch ( valueP ) {
2008-11-09 12:43:27 +01:00
case AUDIO_CENTER_MIX_LEVEL_MINUS_3dB : return cString : : sprintf ( " -3.0 %s " , tr ( " dB " ) ) ;
case AUDIO_CENTER_MIX_LEVEL_MINUS_4_5dB : return cString : : sprintf ( " -4.5 %s " , tr ( " dB " ) ) ;
case AUDIO_CENTER_MIX_LEVEL_MINUS_6dB : return cString : : sprintf ( " -6.0 %s " , tr ( " dB " ) ) ;
case AUDIO_CENTER_MIX_LEVEL_RESERVED : return cString : : sprintf ( " %s " , tr ( " reserved " ) ) ;
2009-03-24 11:51:51 +01:00
default : break ;
2006-09-17 03:20:00 +02:00
}
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getAC3SurroundMixLevel ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
switch ( valueP ) {
2008-11-09 12:43:27 +01:00
case AUDIO_SURROUND_MIX_LEVEL_MINUS_3dB : return cString : : sprintf ( " -3 %s " , tr ( " dB " ) ) ;
case AUDIO_SURROUND_MIX_LEVEL_MINUS_6dB : return cString : : sprintf ( " -6 %s " , tr ( " dB " ) ) ;
case AUDIO_SURROUND_MIX_LEVEL_0_dB : return cString : : sprintf ( " 0 %s " , tr ( " dB " ) ) ;
case AUDIO_SURROUND_MIX_LEVEL_RESERVED : return cString : : sprintf ( " %s " , tr ( " reserved " ) ) ;
2009-03-24 11:51:51 +01:00
default : break ;
2006-09-17 03:20:00 +02:00
}
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getAC3DolbySurroundMode ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
switch ( valueP ) {
2008-11-09 12:43:27 +01:00
case AUDIO_DOLBY_SURROUND_MODE_NOT_INDICATED : return cString : : sprintf ( " %s " , tr ( " not indicated " ) ) ;
case AUDIO_DOLBY_SURROUND_MODE_NOT_DOLBYSURROUND : return cString : : sprintf ( " %s " , trVDR ( " no " ) ) ;
case AUDIO_DOLBY_SURROUND_MODE_DOLBYSURROUND : return cString : : sprintf ( " %s " , trVDR ( " yes " ) ) ;
case AUDIO_DOLBY_SURROUND_MODE_RESERVED : return cString : : sprintf ( " %s " , tr ( " reserved " ) ) ;
2009-03-24 11:51:51 +01:00
default : break ;
2006-09-17 03:20:00 +02:00
}
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getAC3DialogLevel ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
if ( valueP > 0 )
return cString : : sprintf ( " -%d %s " , valueP , tr ( " dB " ) ) ;
2006-09-17 03:20:00 +02:00
return cString : : sprintf ( " --- " ) ;
}
2015-03-07 17:22:02 +01:00
cString getFrequencyMHz ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
double freq = valueP ;
2014-04-12 22:01:46 +02:00
while ( freq > 20000.0 ) freq / = 1000.0 ;
return cString : : sprintf ( " %s %s " , * dtoa ( freq , " %lg " ) , tr ( " MHz " ) ) ;
2006-09-17 03:20:00 +02:00
}
2015-03-07 17:22:02 +01:00
cString getAudioSamplingFreq ( int valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
switch ( valueP ) {
2008-11-09 12:43:27 +01:00
case AUDIO_SAMPLING_FREQUENCY_INVALID : return cString : : sprintf ( " --- " ) ;
case AUDIO_SAMPLING_FREQUENCY_RESERVED : return cString : : sprintf ( " %s " , tr ( " reserved " ) ) ;
2009-03-24 11:51:51 +01:00
default : break ;
2006-09-17 03:20:00 +02:00
}
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %d %s " , valueP , tr ( " Hz " ) ) ;
2006-09-17 03:20:00 +02:00
}
2015-03-07 17:22:02 +01:00
cString getAudioBitrate ( double valueP , double streamP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
switch ( ( int ) streamP ) {
2008-11-09 12:43:27 +01:00
case AUDIO_BITRATE_INVALID : return cString : : sprintf ( " --- " ) ;
2015-03-07 17:22:02 +01:00
case AUDIO_BITRATE_RESERVED : return cString : : sprintf ( " %s (%s) " , tr ( " reserved " ) , * getBitrateKbits ( valueP ) ) ;
case AUDIO_BITRATE_FREE : return cString : : sprintf ( " %s (%s) " , tr ( " free " ) , * getBitrateKbits ( valueP ) ) ;
2009-03-24 11:51:51 +01:00
default : break ;
2006-09-17 03:20:00 +02:00
}
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %s (%s) " , * getBitrateKbits ( streamP ) , * getBitrateKbits ( valueP ) ) ;
2006-09-17 03:20:00 +02:00
}
2015-03-07 17:22:02 +01:00
cString getVideoBitrate ( double valueP , double streamP )
2008-11-09 12:43:27 +01:00
{
2015-03-07 17:22:02 +01:00
return cString : : sprintf ( " %s (%s) " , * getBitrateMbits ( streamP ) , * getBitrateMbits ( valueP ) ) ;
2008-11-09 12:43:27 +01:00
}
2015-03-07 17:22:02 +01:00
cString getBitrateMbits ( double valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
if ( valueP > 0 )
return cString : : sprintf ( " %.2f %s " , valueP / 1000000.0 , tr ( " Mbit/s " ) ) ;
2008-11-09 12:43:27 +01:00
return cString : : sprintf ( " --- " ) ;
2006-09-17 03:20:00 +02:00
}
2015-03-07 17:22:02 +01:00
cString getBitrateKbits ( double valueP )
2006-09-17 03:20:00 +02:00
{
2015-03-07 17:22:02 +01:00
if ( valueP > 0 )
return cString : : sprintf ( " %.0f %s " , valueP / 1000.0 , tr ( " kbit/s " ) ) ;
2008-11-09 12:43:27 +01:00
return cString : : sprintf ( " --- " ) ;
2006-09-17 03:20:00 +02:00
}
2009-08-25 19:22:06 +02:00
2011-11-19 15:02:16 +01:00
// --- cFemonBitStream -------------------------------------------------------
2009-08-25 19:22:06 +02:00
2011-11-19 15:02:16 +01:00
uint32_t cFemonBitStream : : GetUeGolomb ( )
2009-08-25 19:22:06 +02:00
{
int n = 0 ;
2011-11-19 15:02:16 +01:00
while ( ! GetBit ( ) & & ( n < 32 ) )
2009-08-25 19:22:06 +02:00
n + + ;
2011-11-19 15:02:16 +01:00
return ( n ? ( ( 1 < < n ) - 1 ) + GetBits ( n ) : 0 ) ;
2009-08-25 19:22:06 +02:00
}
2011-11-19 15:02:16 +01:00
int32_t cFemonBitStream : : GetSeGolomb ( )
2009-08-25 19:22:06 +02:00
{
2011-11-19 15:02:16 +01:00
uint32_t r = GetUeGolomb ( ) + 1 ;
2009-08-25 19:22:06 +02:00
2011-11-19 15:02:16 +01:00
return ( ( r & 1 ) ? - ( r > > 1 ) : ( r > > 1 ) ) ;
2009-08-25 19:22:06 +02:00
}
2011-11-19 15:02:16 +01:00
void cFemonBitStream : : SkipGolomb ( )
2009-08-25 19:22:06 +02:00
{
2011-11-19 15:02:16 +01:00
int n = 0 ;
2009-08-25 19:22:06 +02:00
2011-11-19 15:02:16 +01:00
while ( ! GetBit ( ) & & ( n < 32 ) )
n + + ;
SkipBits ( n ) ;
2009-08-25 19:22:06 +02:00
}