Wasabi ExpressPlay SDK for Embedded Systems  1.10
Data Structures | Macros | Typedefs | Enumerations | Functions
Ts2Streams.h File Reference
#include "Atomix.h"
#include "Ts2Packet.h"
#include "Ts2Protection.h"
#include "Ts2Marlin.h"
#include "Ts2Config.h"

Go to the source code of this file.

Data Structures

struct  TS2_MarlinRightsInfoHandler
 Handler for the Marlin rights information found in a BBTS stream. More...
 

Macros

#define TS2_INFINITE_PACKET_COUNT   -1
 
#define TS2_DEFAULT_MAX_CAT_PACKET_COUNT_FROM_KSM   100
 

Typedefs

typedef struct TS2_StreamInfo TS2_StreamInfo
 A TS2_StreamInfo object can be used to obtain information about a stream. More...
 
typedef struct TS2_BbtsParser TS2_BbtsParser
 

Enumerations

enum  TS2_CaSystem {
  TS2_UNKNOWN_CA,
  TS2_NO_CA,
  TS2_MARLIN_BBTS_CA
}
 Conditional Access (CA) system identifiers. More...
 
enum  TS2_BbtsParser_Status {
  TS2_BP_GOT_CONTENTID = (1<<0),
  TS2_BP_GOT_RIGHTSINFO = (1<<1)
}
 

Functions

TS2_EXPORT ATX_Result TS2_StreamInfo_Create (ATX_InputStream *stream, ATX_Int32 max_packet_count, TS2_StreamInfo **info)
 Creates a TS2_StreamInfo object from which stream information can be queried. More...
 
TS2_EXPORT ATX_Result TS2_StreamInfo_CreateEx (ATX_InputStream *stream, ATX_Int32 max_packet_count, ATX_UInt32 max_cat_packet_count_from_ksm, TS2_StreamInfo **info)
 Creates a TS2_StreamInfo object from which stream information can be queried. More...
 
TS2_EXPORT ATX_Result TS2_StreamInfo_UpdatePMT (TS2_StreamInfo *self, const ATX_Byte *pmt_table, ATX_Size pmt_len, ATX_UInt16 *ksmt_pid)
 Update stream info from the PMT. More...
 
TS2_EXPORT ATX_Result TS2_StreamInfo_UpdateCAT (TS2_StreamInfo *self, const ATX_Byte *cat_table, ATX_Size cat_len, ATX_UInt16 *mrt_pid)
 Update stream info from the CAT. More...
 
TS2_EXPORT ATX_Result TS2_StreamInfo_UpdateKSMT (TS2_StreamInfo *self, const ATX_Byte *ksm_table, ATX_Size ksm_len)
 Update stream info from the KSMT/ECM. More...
 
TS2_EXPORT ATX_Result TS2_StreamInfo_UpdateMRT (TS2_StreamInfo *self, const ATX_Byte *mr_table, ATX_Size mr_len)
 Update stream info from the Marlin Rights Table. More...
 
TS2_EXPORT TS2_KSMTTS2_StreamInfo_GetKSMT (TS2_StreamInfo *self)
 Return the KSMT. More...
 
TS2_EXPORT TS2_PATTS2_StreamInfo_GetPAT (TS2_StreamInfo *self)
 Return the PAT table. More...
 
TS2_EXPORT TS2_PMTTS2_StreamInfo_GetPMT (TS2_StreamInfo *self)
 Return the PMT table. More...
 
TS2_EXPORT TS2_CaSystem TS2_StreamInfo_GetCaSystem (const TS2_StreamInfo *self)
 Returns the conditional access (CA) system found in the stream. More...
 
TS2_EXPORT
TS2_TrafficProtectionSystem 
TS2_StreamInfo_GetTrafficProtectionSystem (const TS2_StreamInfo *self, ATX_UInt32 *kdf_type)
 Returns the traffic protection system found in the mpeg2ts stream. More...
 
TS2_EXPORT const char * TS2_StreamInfo_GetContentIdBase (const TS2_StreamInfo *self)
 returns the content id base found in the PMT or CAT. More...
 
TS2_EXPORT const char * TS2_StreamInfo_GetContentId (const TS2_StreamInfo *self)
 Returns the first content ID found in the stream. More...
 
TS2_EXPORT const char * TS2_StreamInfo_GetRightsIssuerUrl (const TS2_StreamInfo *self)
 Returns the first rights issuer URL found in the stream. More...
 
TS2_EXPORT const char * TS2_StreamInfo_GetSilentRightsUrl (const TS2_StreamInfo *self)
 Returns the silent rights URL found in the stream. More...
 
TS2_EXPORT const char * TS2_StreamInfo_GetPreviewRightsUrl (const TS2_StreamInfo *self)
 Returns the preview rights URL found in the stream. More...
 
TS2_EXPORT ATX_List * TS2_StreamInfo_GetElementaryStreams (const TS2_StreamInfo *self)
 Returns a list of objects representing information about the elementary streams found in the stream. More...
 
TS2_EXPORT void TS2_StreamInfo_Destroy (TS2_StreamInfo *self)
 Destroys the TS2_StreamInfo object. More...
 
TS2_EXPORT ATX_Result TS2_DecryptingStream_Create (ATX_InputStream *protected_stream, TS2_CryptoInterface crypto, TS2_MarlinRightsInfoHandler *marlin_handler, ATX_InputStream **decrypting_stream)
 Creates an ATX_InputStream object that can be used to decrypt a BBTS stream to obtain an MPEG-2 TS stream. More...
 
TS2_EXPORT ATX_Result TS2_AdaptiveAwareEncryptingStream_Create (ATX_InputStream *cleartext_stream, const char *content_id, const ATX_Byte *content_key, const ATX_Byte *common_iv, TS2_TrafficProtectionSystem protection, ATX_UInt32 crypto_period, const ATX_Byte *traffic_seed, ATX_Size seed_size, ATX_UInt32 first_segment_index, TS2_RotationPoints *rotation_points, ATX_UInt16 ksm_pid, const char *rights_issuer_url, const char *silent_rights_url, const char *preview_rights_url, const ATX_Byte *access_criteria, ATX_Size access_criteria_size, ATX_InputStream **encrypting_stream)
 Creates an ATX_InputStream object that can be used to encrypt an MPEG-2 TS stream to obtain a BBTS stream. More...
 
TS2_EXPORT ATX_Result TS2_EncryptingStream_Create (ATX_InputStream *cleartext_stream, const char *content_id, const ATX_Byte *content_key, const ATX_Byte *common_iv, TS2_TrafficProtectionSystem protection, ATX_UInt32 crypto_period, const char *rights_issuer_url, const char *silent_rights_url, const char *preview_rights_url, ATX_Boolean skip_payload_unit_start, ATX_Boolean single_key_layer, const ATX_Byte *access_criteria, ATX_Size access_criteria_size, ATX_InputStream **encrypting_stream)
 Creates an ATX_InputStream object that can be used to encrypt an MPEG-2 TS stream to obtain a BBTS stream. More...
 
TS2_EXPORT ATX_Result TS2_Stream_ResetSourceStream (ATX_InputStream *self, ATX_InputStream *source)
 
TS2_EXPORT ATX_Result TS2_Stream_ResetDrm (ATX_InputStream *self, const char *content_id, const ATX_Byte *content_key)
 
TS2_EXPORT ATX_Result TS2_Stream_ResetDrmEx (ATX_InputStream *self, const char *content_id, const ATX_Byte *content_key, const ATX_Byte *access_criteria, ATX_Size access_criteria_size)
 
ATX_Result TS2_BbtsParser_Create (TS2_BbtsParser **parser)
 Create parser. More...
 
void TS2_BbtsParser_Destroy (TS2_BbtsParser *self)
 Destroy parser. More...
 
ATX_Result TS2_BbtsParser_Update (TS2_BbtsParser *self, ATX_Byte *buffer, ATX_Size length, TS2_BbtsParser_Status *status)
 Update parser with new TS packets. More...
 
ATX_Result TS2_BbtsParser_GetInfo (TS2_BbtsParser *self, TS2_StreamInfo **info)
 Get parsed stream info. More...
 

Macro Definition Documentation

#define TS2_DEFAULT_MAX_CAT_PACKET_COUNT_FROM_KSM   100
#define TS2_INFINITE_PACKET_COUNT   -1

Typedef Documentation

A TS2_StreamInfo object can be used to obtain information about a stream.

Enumeration Type Documentation

Enumerator
TS2_BP_GOT_CONTENTID 
TS2_BP_GOT_RIGHTSINFO 

Conditional Access (CA) system identifiers.

Enumerator
TS2_UNKNOWN_CA 
TS2_NO_CA 
TS2_MARLIN_BBTS_CA 

Function Documentation

TS2_EXPORT ATX_Result TS2_AdaptiveAwareEncryptingStream_Create ( ATX_InputStream *  cleartext_stream,
const char *  content_id,
const ATX_Byte *  content_key,
const ATX_Byte *  common_iv,
TS2_TrafficProtectionSystem  protection,
ATX_UInt32  crypto_period,
const ATX_Byte *  traffic_seed,
ATX_Size  seed_size,
ATX_UInt32  first_segment_index,
TS2_RotationPoints rotation_points,
ATX_UInt16  ksm_pid,
const char *  rights_issuer_url,
const char *  silent_rights_url,
const char *  preview_rights_url,
const ATX_Byte *  access_criteria,
ATX_Size  access_criteria_size,
ATX_InputStream **  encrypting_stream 
)

Creates an ATX_InputStream object that can be used to encrypt an MPEG-2 TS stream to obtain a BBTS stream.

Use the ATX_InputStream methods to obtain information about the stream, read from it (to obtain the encrypted bytes), etc.

Parameters
cleartext_streamThe cleartext MPEG-2 TS stream.
content_idA BBTS-compatible content ID.
content_keyA 16-byte content key.
common_ivA 16-byte initialization vector. Can be NULL, in which case the IV will change for each ECM (KSM).
protectionthe traffic protection system.
crypto_periodCrypto period in seconds, between 1 and 120.
traffic_seedSeed for the traffic key and IV.
seed_sizeSize of the traffic seed, in bytes.
first_segment_indexIndex of the first segment.
rotation_pointsPointer to a TS2_RotationPoints object indicating where the ECMs (KSMs) are to be inserted.
ksm_pidPID for the KSM.
rights_issuer_urlURI template for the rights issuer.
silent_rights_urlURI template for silent rights acquisition.
preview_rights_urlURI template for preview rights acquisition.
access_criteriaBuffer containing access criteria block (Optional)
access_criteria_sizeSize of access_criteria buffer (Optional)
encrypting_streamAddress of an ATX_InputStream pointer that will be set to refer to the newly-created ATX_InputStream.
Returns
ATX_SUCCESS, or a specific error code in the case of failure.
ATX_Result TS2_BbtsParser_Create ( TS2_BbtsParser **  parser)

Create parser.

The TS2_BbtsParser_Destroy must be called to release a successfully created parser object.

Parameters
parserpointer to the pointer to parser object returned
void TS2_BbtsParser_Destroy ( TS2_BbtsParser self)

Destroy parser.

Release all resources allocated by the parser object.

Parameters
selfthe parser object
ATX_Result TS2_BbtsParser_GetInfo ( TS2_BbtsParser self,
TS2_StreamInfo **  info 
)

Get parsed stream info.

Parameters
selfthe parser object
infopointer to where the pointer to the TS2_StreamInfo object is returned on success. The returned object is owned by the parser object and caller should not release it directly.
ATX_Result TS2_BbtsParser_Update ( TS2_BbtsParser self,
ATX_Byte *  buffer,
ATX_Size  length,
TS2_BbtsParser_Status status 
)

Update parser with new TS packets.

The parser searches for the first sync byte and starts from there. If there are partial packets at the end, parser caches contents of the partial packets and concatenates them with data passed in subsequent calls.

Parameters
selfthe parser object
bufferpointer to the BBTS packets
lengthnumber of bytes in the buffer
statuspointer to the status returned, as a bitfield of TS2_BbtsParser_Status constants.
TS2_EXPORT ATX_Result TS2_DecryptingStream_Create ( ATX_InputStream *  protected_stream,
TS2_CryptoInterface  crypto,
TS2_MarlinRightsInfoHandler marlin_handler,
ATX_InputStream **  decrypting_stream 
)

Creates an ATX_InputStream object that can be used to decrypt a BBTS stream to obtain an MPEG-2 TS stream.

Use the ATX_InputStream methods to obtain information about the stream, read from it (to obtain the decrypted bytes), etc.

Parameters
protected_streamThe BBTS stream.
cryptoCrypto interface that includes a resolver.
marlin_handlerOptional (can be NULL) handler of Marlin rights information found in the protected stream.
decrypting_streamAddress of an ATX_InputStream pointer that will be set to refer to the newly-created ATX_InputStream.
Returns
ATX_SUCCESS, or a specific error code in the case of failure.
TS2_EXPORT ATX_Result TS2_EncryptingStream_Create ( ATX_InputStream *  cleartext_stream,
const char *  content_id,
const ATX_Byte *  content_key,
const ATX_Byte *  common_iv,
TS2_TrafficProtectionSystem  protection,
ATX_UInt32  crypto_period,
const char *  rights_issuer_url,
const char *  silent_rights_url,
const char *  preview_rights_url,
ATX_Boolean  skip_payload_unit_start,
ATX_Boolean  single_key_layer,
const ATX_Byte *  access_criteria,
ATX_Size  access_criteria_size,
ATX_InputStream **  encrypting_stream 
)

Creates an ATX_InputStream object that can be used to encrypt an MPEG-2 TS stream to obtain a BBTS stream.

Use the ATX_InputStream methods to obtain information about the stream, read from it (to obtain the encrypted bytes), etc.

Parameters
cleartext_streamThe cleartext MPEG-2 TS stream.
content_idA BBTS-compatible content ID.
content_keyA 16-byte content key.
common_ivA 16-byte initialization vector. Can be NULL, in which case the IV will change for each ECM (KSM). If single_key_layer has the value ATX_TRUE, then this parameter is ignored and the IV will be 16 0x00 bytes.
protectionthe traffic protection system.
crypto_periodCrypto period in seconds, between 1 and 120.
rights_issuer_urlURI template for the rights issuer.
silent_rights_urlURI template for silent rights acquisition.
preview_rights_urlURI template for preview rights acquisition.
skip_payload_unit_startIf ATX_TRUE, the encrypter will not encrypt packets that have the payload unit start indicator flag set.
single_key_layerIf ATX_TRUE, the encrypter will use the single-key-layer mode. In this case, the common_iv parameter is ignored.
access_criteriaBuffer containing access criteria block (Optional)
access_criteria_sizeSize of access_criteria buffer (Optional)
encrypting_streamAddress of an ATX_InputStream pointer that will be set to refer to the newly-created ATX_InputStream.
Returns
ATX_SUCCESS, or a specific error code in the case of failure.
TS2_EXPORT ATX_Result TS2_Stream_ResetDrm ( ATX_InputStream *  self,
const char *  content_id,
const ATX_Byte *  content_key 
)
TS2_EXPORT ATX_Result TS2_Stream_ResetDrmEx ( ATX_InputStream *  self,
const char *  content_id,
const ATX_Byte *  content_key,
const ATX_Byte *  access_criteria,
ATX_Size  access_criteria_size 
)
TS2_EXPORT ATX_Result TS2_Stream_ResetSourceStream ( ATX_InputStream *  self,
ATX_InputStream *  source 
)
TS2_EXPORT ATX_Result TS2_StreamInfo_Create ( ATX_InputStream *  stream,
ATX_Int32  max_packet_count,
TS2_StreamInfo **  info 
)

Creates a TS2_StreamInfo object from which stream information can be queried.

Parameters
streamThe MPEG-2 TS or BBTS stream containing the information to be queried. The stream will not be reset after it is internally read to fetch requested info.
max_packet_countThe maximum number of packets to read. Can be set to TS2_INFINITE_PACKET_COUNT.
infoAddress of a pointer to a TS2_StreamInfo, which this method will set to refer to the TS2_StreamInfo object it creates.
Returns
ATX_SUCCESS or a specific error code.
TS2_EXPORT ATX_Result TS2_StreamInfo_CreateEx ( ATX_InputStream *  stream,
ATX_Int32  max_packet_count,
ATX_UInt32  max_cat_packet_count_from_ksm,
TS2_StreamInfo **  info 
)

Creates a TS2_StreamInfo object from which stream information can be queried.

Parameters
streamThe MPEG-2 TS or BBTS stream containing the information to be queried. The stream will not be reset after it is internally read to fetch requested info.
max_packet_countThe maximum number of packets to read. Can be set to TS2_INFINITE_PACKET_COUNT.
max_cat_packet_count_from_ksmThe maximum number of packets which will be searched after KSMT to find the CAT. If the CAT is not found within this specified offset, then an absent CAT is assumed in the stream
infoAddress of a pointer to a TS2_StreamInfo, which this method will set to refer to the TS2_StreamInfo object it creates.
Returns
ATX_SUCCESS or a specific error code.
TS2_EXPORT void TS2_StreamInfo_Destroy ( TS2_StreamInfo self)

Destroys the TS2_StreamInfo object.

Parameters
selfThe TS2_StreamInfo object.
TS2_EXPORT TS2_CaSystem TS2_StreamInfo_GetCaSystem ( const TS2_StreamInfo self)

Returns the conditional access (CA) system found in the stream.

Parameters
selfThe TS2_StreamInfo object.
Returns
The conditional access system constant.
TS2_EXPORT const char* TS2_StreamInfo_GetContentId ( const TS2_StreamInfo self)

Returns the first content ID found in the stream.

This method is only relevant if the CA system is TS2_MARLIN_BBTS_CA.

Parameters
selfThe TS2_StreamInfo object.
Returns
The content ID string, or NULL if no content ID was found.
TS2_EXPORT const char* TS2_StreamInfo_GetContentIdBase ( const TS2_StreamInfo self)

returns the content id base found in the PMT or CAT.

This method is only relevant if the CA system is TS2_MARLIN_BBTS_CA

Parameters
selfthe TS2_StreamInfo object
Returns
the content id base string or NULL if none has been found
TS2_EXPORT ATX_List* TS2_StreamInfo_GetElementaryStreams ( const TS2_StreamInfo self)

Returns a list of objects representing information about the elementary streams found in the stream.

Parameters
selfThe TS2_StreamInfo object.
Returns
A pointer to an ATX_List containing ATX_ListItem objects, each of which has a TS2_ElementaryStream with information about the elementary stream.
TS2_EXPORT TS2_KSMT* TS2_StreamInfo_GetKSMT ( TS2_StreamInfo self)

Return the KSMT.

Parameters
selfpointer to the stream info object
TS2_EXPORT TS2_PAT* TS2_StreamInfo_GetPAT ( TS2_StreamInfo self)

Return the PAT table.

Parameters
selfpointer to the stream info object
TS2_EXPORT TS2_PMT* TS2_StreamInfo_GetPMT ( TS2_StreamInfo self)

Return the PMT table.

Parameters
selfpointer to the stream info object
TS2_EXPORT const char* TS2_StreamInfo_GetPreviewRightsUrl ( const TS2_StreamInfo self)

Returns the preview rights URL found in the stream.

This method is only relevant if the CA system is TS2_MARLIN_BBTS_CA.

Parameters
selfThe TS2_StreamInfo object.
Returns
The preview rights URL string, or NULL if none was found.
TS2_EXPORT const char* TS2_StreamInfo_GetRightsIssuerUrl ( const TS2_StreamInfo self)

Returns the first rights issuer URL found in the stream.

This method is only relevant if the CA system is TS2_MARLIN_BBTS_CA.

Parameters
selfThe TS2_StreamInfo object.
Returns
The rights issuer URL string, or NULL if none was found.
TS2_EXPORT const char* TS2_StreamInfo_GetSilentRightsUrl ( const TS2_StreamInfo self)

Returns the silent rights URL found in the stream.

This method is only relevant if the CA system is TS2_MARLIN_BBTS_CA.

Parameters
selfThe TS2_StreamInfo object.
Returns
The silent rights URL string, or NULL if none was found.
TS2_EXPORT TS2_TrafficProtectionSystem TS2_StreamInfo_GetTrafficProtectionSystem ( const TS2_StreamInfo self,
ATX_UInt32 *  kdf_type 
)

Returns the traffic protection system found in the mpeg2ts stream.

Parameters
selfthe TS2_StreamInfo object
kdf_typepointer to where the key derivation function type is returned, one of TS2_KEY_DERIVATION_FUNCTION_* values
Returns
the traffic protection system constant documented in Ts2Protection.h
TS2_EXPORT ATX_Result TS2_StreamInfo_UpdateCAT ( TS2_StreamInfo self,
const ATX_Byte *  cat_table,
ATX_Size  cat_len,
ATX_UInt16 *  mrt_pid 
)

Update stream info from the CAT.

The CAT must be a complete table. The Marlin Rights Table PID is returned in mrt_pid.

Parameters
selfpointer to the stream info object
cat_tablepointer to the CAT data
cat_lenlength of the cat_table in bytes
mrt_pidpointer to where the Marlin Rights Table PID is returned
TS2_EXPORT ATX_Result TS2_StreamInfo_UpdateKSMT ( TS2_StreamInfo self,
const ATX_Byte *  ksm_table,
ATX_Size  ksm_len 
)

Update stream info from the KSMT/ECM.

The KSM table must be complete.

Parameters
selfpointer to the stream info object
ksm_tablepointer to the KSM table data
ksm_lenlength of the ksm_table in bytes
TS2_EXPORT ATX_Result TS2_StreamInfo_UpdateMRT ( TS2_StreamInfo self,
const ATX_Byte *  mr_table,
ATX_Size  mr_len 
)

Update stream info from the Marlin Rights Table.

The MRT must be a complete table.

Parameters
selfpointer to the stream info object
mr_tablepointer to the KSM table data
mr_lenlength of the ksm_table in bytes
TS2_EXPORT ATX_Result TS2_StreamInfo_UpdatePMT ( TS2_StreamInfo self,
const ATX_Byte *  pmt_table,
ATX_Size  pmt_len,
ATX_UInt16 *  ksmt_pid 
)

Update stream info from the PMT.

The PMT must be a complete table. KSM/ECM PID is returned in ksmt_pid.

Parameters
selfpointer to the stream info object
pmt_tablepointer to the PMT data
pmt_lenlength of the pmt data in bytes
ksmt_pidpointer to where the KSM/ECM PID is returned