TSDuck Version 3.32-2769 (TSDuck - The MPEG Transport Stream Toolkit)
ts::TSScrambling Class Reference

Transport stream scrambling using multiple algorithms. More...

Inheritance diagram for ts::TSScrambling:
Collaboration diagram for ts::TSScrambling:

Public Member Functions

 TSScrambling (const TSScrambling &other)
 Copy constructor. More...
 
 TSScrambling (Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))), uint8_t scrambling=SCRAMBLING_DVB_CSA2)
 Default constructor. More...
 
 TSScrambling (TSScrambling &&other)
 Move constructor. More...
 
UString algoName () const
 Get the scrambling algorithm name. More...
 
size_t cwSize () const
 Get the required control word size in bytes. More...
 
bool decrypt (TSPacket &pkt)
 Decrypt a TS packet with the CW corresponding to the parity in the packet. More...
 
virtual void defineArgs (Args &args) override
 Add command line option definitions in an Args. More...
 
bool encrypt (TSPacket &pkt)
 Encrypt a TS packet with the current parity and corresponding CW. More...
 
bool explicitScramblingType () const
 Check if a scrambling algorithm was specified on the command line. More...
 
size_t fixedCWCount () const
 Get the number of fixed control words from the command line. More...
 
bool hasFixedCW () const
 Check if fixed control words were loaded from the command line. More...
 
virtual bool loadArgs (DuckContext &duck, Args &args) override
 Load arguments from command line. More...
 
void rewindFixedCW ()
 Restart the list of fixed control words from the beginning. More...
 
uint8_t scramblingType ()
 Get the current scrambling algorithm. More...
 
bool setCW (const ByteBlock &cw, int parity)
 Set the control word for encrypt and decrypt. More...
 
bool setEncryptParity (int parity)
 Set the parity of all subsequent encryptions. More...
 
void setEntropyMode (DVBCSA2::EntropyMode mode)
 Force the entropy mode of DVB-CSA2. More...
 
bool setScramblingType (uint8_t scrambling, bool overrideExplicit=true)
 Force the usage of a given algorithm. More...
 
bool start ()
 Start the scrambling session. More...
 
bool stop ()
 Stop the scrambling session. More...
 

Detailed Description

Transport stream scrambling using multiple algorithms.

Include command line arguments processing.

The scrambling type is indicated by a constant as present in a scrambling_descriptor. Currently, SCRAMBLING_DVB_CSA2, SCRAMBLING_DVB_CISSA1 and SCRAMBLING_ATIS_IIF_IDSA are supported as standard scrambling algorithms. Additionally, the non-standard algorithms are also supported: SCRAMBLING_DUCK_AES_CBC, SCRAMBLING_DUCK_AES_CTR.

With fixed control words from the command line:

  • For encryption, the next key is used each time setEncryptParity() is called with a new parity.
  • For decryption, the next key is used each time a new scrambling_control value is found in a TS header.

Constructor & Destructor Documentation

◆ TSScrambling() [1/3]

ts::TSScrambling::TSScrambling ( Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))),
uint8_t  scrambling = SCRAMBLING_DVB_CSA2 
)

Default constructor.

Parameters
[in,out]reportWhere to report error and information.
[in]scramblingScrambling type.

◆ TSScrambling() [2/3]

ts::TSScrambling::TSScrambling ( const TSScrambling other)

Copy constructor.

Parameters
[in]otherOther instance to copy. Only the configuration parameters, typically from the command line, are copied. The state of other is not copied.

◆ TSScrambling() [3/3]

ts::TSScrambling::TSScrambling ( TSScrambling &&  other)

Move constructor.

Parameters
[in,out]otherOther instance to copy. Unmodified. Only the configuration parameters, typically from the command line, are copied. The state of other is not copied.

Member Function Documentation

◆ defineArgs()

virtual void ts::TSScrambling::defineArgs ( Args args)
overridevirtual

Add command line option definitions in an Args.

Parameters
[in,out]argsCommand line arguments to update.

Implements ts::ArgsSupplierInterface.

◆ loadArgs()

virtual bool ts::TSScrambling::loadArgs ( DuckContext duck,
Args args 
)
overridevirtual

Load arguments from command line.

Args error indicator is set in case of incorrect arguments.

Parameters
[in,out]duckTSDuck execution context.
[in,out]argsCommand line arguments.
Returns
True on success, false on error in argument line.

Implements ts::ArgsSupplierInterface.

◆ hasFixedCW()

bool ts::TSScrambling::hasFixedCW ( ) const
inline

Check if fixed control words were loaded from the command line.

Returns
True if this object uses fixed control words.

◆ fixedCWCount()

size_t ts::TSScrambling::fixedCWCount ( ) const
inline

Get the number of fixed control words from the command line.

Returns
Number of fixed control words from the command line.

◆ rewindFixedCW()

void ts::TSScrambling::rewindFixedCW ( )

Restart the list of fixed control words from the beginning.

Ignored if no control words were loaded from the command line.

◆ algoName()

UString ts::TSScrambling::algoName ( ) const
inline

Get the scrambling algorithm name.

Returns
The scrambling algorithm name.

◆ cwSize()

size_t ts::TSScrambling::cwSize ( ) const
inline

Get the required control word size in bytes.

Returns
The required control word size in bytes.

◆ setScramblingType()

bool ts::TSScrambling::setScramblingType ( uint8_t  scrambling,
bool  overrideExplicit = true 
)

Force the usage of a given algorithm.

Parameters
[in]scramblingScrambling type.
[in]overrideExplicitIf true, always set the scrambling type. If false, ignore it if an explicit type was set on the command line.
Returns
True on success, false on unsupported type.

◆ scramblingType()

uint8_t ts::TSScrambling::scramblingType ( )
inline

Get the current scrambling algorithm.

Returns
The scrambling type.

◆ explicitScramblingType()

bool ts::TSScrambling::explicitScramblingType ( ) const
inline

Check if a scrambling algorithm was specified on the command line.

Returns
Tue if a scrambling algorithm was specified on the command line.

◆ setEntropyMode()

void ts::TSScrambling::setEntropyMode ( DVBCSA2::EntropyMode  mode)

Force the entropy mode of DVB-CSA2.

By default, use settings from the command line.

Parameters
[in]modeDVB-CSA2 entropy mode.

◆ start()

bool ts::TSScrambling::start ( )

Start the scrambling session.

Reinitialize list of CW's, open files, etc.

Returns
True on success, false on error.

◆ stop()

bool ts::TSScrambling::stop ( )

Stop the scrambling session.

Close files, etc.

Returns
True on success, false on error.

◆ setCW()

bool ts::TSScrambling::setCW ( const ByteBlock cw,
int  parity 
)

Set the control word for encrypt and decrypt.

Parameters
[in]cwThe control word to use.
[in]parityUse the parity of this integer value (odd or even).
Returns
True on success, false on error.

◆ setEncryptParity()

bool ts::TSScrambling::setEncryptParity ( int  parity)

Set the parity of all subsequent encryptions.

Parameters
[in]parityUse the parity of this integer value (odd or even).
Returns
True on success, false on error (error setting next fixed CW, if any).

◆ encrypt()

bool ts::TSScrambling::encrypt ( TSPacket pkt)

Encrypt a TS packet with the current parity and corresponding CW.

Parameters
[in,out]pktThe packet to encrypt.
Returns
True on success, false on error. An already encrypted packet is an error.

◆ decrypt()

bool ts::TSScrambling::decrypt ( TSPacket pkt)

Decrypt a TS packet with the CW corresponding to the parity in the packet.

Parameters
[in,out]pktThe packet to decrypt.
Returns
True on success, false on error. A clear packet is not an error.

The documentation for this class was generated from the following file: