TSDuck v3.40-3963
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::TSScrambling Class Reference

Transport stream scrambling using multiple algorithms. More...

#include <tsTSScrambling.h>

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

Public Member Functions

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

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 = (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()

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

Add command line option definitions in an Args.

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

◆ loadArgs()

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

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.

◆ 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.

◆ entropyMode()

DVBCSA2::EntropyMode ts::TSScrambling::entropyMode ( ) const

Get the entropy mode of DVB-CSA2.

Returns
DVB-CSA2 entropy mode. Always return FULL_CW if the current scrambling is not DVB-CSA.

◆ 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: