Shaka Packager SDK
Classes | Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
shaka::AdaptationSet Class Reference

#include <adaptation_set.h>

Inheritance diagram for shaka::AdaptationSet:
shaka::MockAdaptationSet

Public Types

enum  Role {
  kRoleUnknown , kRoleCaption , kRoleSubtitle , kRoleMain ,
  kRoleAlternate , kRoleSupplementary , kRoleCommentary , kRoleDub ,
  kRoleDescription , kRoleSign , kRoleMetadata , kRoleEnhancedAudioIntelligibility ,
  kRoleEmergency , kRoleForcedSubtitle , kRoleEasyreader , kRoleKaraoke
}
 

Public Member Functions

virtual RepresentationAddRepresentation (const MediaInfo &media_info)
 
virtual RepresentationCopyRepresentation (const Representation &representation)
 
virtual void AddContentProtectionElement (const ContentProtectionElement &element)
 
virtual void UpdateContentProtectionPssh (const std::string &drm_uuid, const std::string &pssh)
 
virtual void AddAccessibility (const std::string &scheme, const std::string &value)
 
virtual void AddRole (Role role)
 
std::optional< xml::XmlNodeGetXml ()
 
virtual void ForceSetSegmentAlignment (bool segment_alignment)
 
virtual void ForceSubsegmentStartswithSAP (uint32_t sap_value)
 
virtual void ForceStartwithSAP (uint32_t sap_value)
 
virtual void AddAdaptationSetSwitching (const AdaptationSet *adaptation_set)
 
bool has_id () const
 
std::optional< uint32_t > SortIndex () const
 
uint32_t id () const
 
void set_id (uint32_t id)
 
void OnNewSegmentForRepresentation (uint32_t representation_id, int64_t start_time, int64_t duration)
 
void OnSetFrameRateForRepresentation (uint32_t representation_id, int32_t frame_duration, int32_t timescale)
 
virtual void AddTrickPlayReference (const AdaptationSet *adaptation_set)
 
const std::list< Representation * > GetRepresentations () const
 
bool IsVideo () const
 
const std::string & codec () const
 
void set_codec (const std::string &codec)
 
uint32_t matrix_coefficients () const
 
void set_matrix_coefficients (const uint32_t &matrix_coefficients)
 
uint32_t color_primaries () const
 
void set_color_primaries (const uint32_t &color_primaries)
 
uint32_t transfer_characteristics () const
 
void set_transfer_characteristics (const uint32_t &transfer_characteristics)
 
const MediaInfo::ProtectedContent * protected_content () const
 Return ProtectedContent.
 
void set_protected_content (const MediaInfo &media_info)
 
bool MatchAdaptationSet (const MediaInfo &media_info, bool content_protection_in_adaptation_set)
 
bool SwitchableAdaptationSet (const AdaptationSet &adaptation_set)
 

Protected Member Functions

 AdaptationSet (const std::string &language, const MpdOptions &mpd_options, uint32_t *representation_counter)
 

Friends

class Period
 
class AdaptationSetTest
 

Detailed Description

AdaptationSet class provides methods to add Representations and <ContentProtection> elements to the AdaptationSet element.

Definition at line 33 of file adaptation_set.h.

Constructor & Destructor Documentation

◆ AdaptationSet()

shaka::AdaptationSet::AdaptationSet ( const std::string &  language,
const MpdOptions mpd_options,
uint32_t *  representation_counter 
)
protected
Parameters
languageis the language of this AdaptationSet. Mainly relevant for audio.
mpd_optionsis the options for this MPD.
mpd_typeis the type of this MPD.
representation_counteris a Counter for assigning ID numbers to Representation. It can not be NULL.

Definition at line 187 of file adaptation_set.cc.

Member Function Documentation

◆ AddAccessibility()

void shaka::AdaptationSet::AddAccessibility ( const std::string &  scheme,
const std::string &  value 
)
virtual

Set the Accessibility element for this AdaptationSet. See ISO/IEC 23009-1:2012 section 5.8.4.3.

Parameters
schemeis the schemeIdUri of the accessibility element.
valueis the value of the accessibility element.

Definition at line 309 of file adaptation_set.cc.

◆ AddAdaptationSetSwitching()

void shaka::AdaptationSet::AddAdaptationSetSwitching ( const AdaptationSet adaptation_set)
virtual

Adds the adaptation set this adaptation set can switch to.

Parameters
adaptation_setpoints to the switchable adaptation set.

Definition at line 503 of file adaptation_set.cc.

◆ AddContentProtectionElement()

void shaka::AdaptationSet::AddContentProtectionElement ( const ContentProtectionElement element)
virtual

Add a ContenProtection element to the adaptation set. AdaptationSet does not add <ContentProtection> elements automatically to itself even if media_info.protected_content is populated. This is because some MPDs should have the elements at AdaptationSet level and some at Representation level.

Parameters
elementcontains the ContentProtection element contents. If element has {value, schemeIdUri} set and has {“value”, “schemeIdUri”} as key for additional_attributes, then the former is used.

Definition at line 297 of file adaptation_set.cc.

◆ AddRepresentation()

Representation * shaka::AdaptationSet::AddRepresentation ( const MediaInfo &  media_info)
virtual

Create a Representation instance using media_info.

Parameters
media_infois a MediaInfo object used to initialize the returned Representation instance. It may contain only one of VideoInfo, AudioInfo, or TextInfo, i.e. VideoInfo XOR AudioInfo XOR TextInfo.
Returns
On success, returns a pointer to Representation. Otherwise returns NULL. The returned pointer is owned by the AdaptationSet instance.

Definition at line 260 of file adaptation_set.cc.

◆ AddRole()

void shaka::AdaptationSet::AddRole ( Role  role)
virtual

Set the Role element for this AdaptationSet. The Role element's is schemeIdUri='urn:mpeg:dash:role:2011'. See ISO/IEC 23009-1:2012 section 5.8.5.5.

Parameters
roleof this AdaptationSet.

Definition at line 314 of file adaptation_set.cc.

◆ AddTrickPlayReference()

void shaka::AdaptationSet::AddTrickPlayReference ( const AdaptationSet adaptation_set)
virtual

Add the adaptation set this trick play adaptation set belongs to.

Parameters
adaptation_setpoints to the reference (or main) adapation set.

Definition at line 539 of file adaptation_set.cc.

◆ codec()

const std::string& shaka::AdaptationSet::codec ( ) const
inline
Returns
codec.

Definition at line 200 of file adaptation_set.h.

◆ color_primaries()

uint32_t shaka::AdaptationSet::color_primaries ( ) const
inline
Returns
color_primaries.

Definition at line 216 of file adaptation_set.h.

◆ CopyRepresentation()

Representation * shaka::AdaptationSet::CopyRepresentation ( const Representation representation)
virtual

Copy a Representation instance from representation in another AdaptationSet. One use case is to duplicate Representation in different periods.

Parameters
representationis an existing Representation to be cloned from.
Returns
On success, returns a pointer to Representation. Otherwise returns NULL. The returned pointer is owned by the AdaptationSet instance.

Definition at line 282 of file adaptation_set.cc.

◆ ForceSetSegmentAlignment()

void shaka::AdaptationSet::ForceSetSegmentAlignment ( bool  segment_alignment)
virtual

Forces the (sub)segmentAlignment field to be set to segment_alignment. Use this if you are certain that the (sub)segments are alinged/unaligned for the AdaptationSet.

Parameters
segment_alignmentis the value used for (sub)segmentAlignment attribute.

Definition at line 497 of file adaptation_set.cc.

◆ ForceStartwithSAP()

void shaka::AdaptationSet::ForceStartwithSAP ( uint32_t  sap_value)
virtual

Forces the StartswithSAP field to be set to sap_value. Use this if you are certain with stream access point value of the segment.

Parameters
sap_valueis the value used for startWithSAP attribute.

Definition at line 512 of file adaptation_set.cc.

◆ ForceSubsegmentStartswithSAP()

void shaka::AdaptationSet::ForceSubsegmentStartswithSAP ( uint32_t  sap_value)
virtual

Forces the subsegmentStartswithSAP field to be set to sap_value. Use this if you are certain with stream access point value of the subsegment.

Parameters
sap_valueis the value used for subsegmentstartsWithSAP attribute.

Definition at line 508 of file adaptation_set.cc.

◆ GetXml()

std::optional< xml::XmlNode > shaka::AdaptationSet::GetXml ( )

Makes a copy of AdaptationSet xml element with its child Representation and ContentProtection elements.

Returns
On success returns a non-NULL scoped_xml_ptr. Otherwise returns a NULL scoped_xml_ptr.

Definition at line 324 of file adaptation_set.cc.

◆ has_id()

bool shaka::AdaptationSet::has_id ( ) const
inline
Returns
true if id is set, false otherwise.

Definition at line 144 of file adaptation_set.h.

◆ IsVideo()

bool shaka::AdaptationSet::IsVideo ( ) const
Returns
true if it is a video AdaptationSet.

Definition at line 551 of file adaptation_set.cc.

◆ MatchAdaptationSet()

bool shaka::AdaptationSet::MatchAdaptationSet ( const MediaInfo &  media_info,
bool  content_protection_in_adaptation_set 
)

Check if the protected content associated with this AdaptationSet matches with the one in |media_info|.

Parameters
media_infoto extract ProtectedContent from.
content_protection_in_adaptation_setto indicate if there is protected content in AdaptationSet.
Returns
true if there is a match.

Definition at line 216 of file adaptation_set.cc.

◆ matrix_coefficients()

uint32_t shaka::AdaptationSet::matrix_coefficients ( ) const
inline
Returns
matrix_coefficients.

Definition at line 207 of file adaptation_set.h.

◆ OnNewSegmentForRepresentation()

void shaka::AdaptationSet::OnNewSegmentForRepresentation ( uint32_t  representation_id,
int64_t  start_time,
int64_t  duration 
)

Notifies the AdaptationSet instance that a new (sub)segment was added to the Representation with representation_id. This must be called every time a (sub)segment is added to a Representation in this AdaptationSet. If a Representation is constructed using AddRepresentation() this is called automatically whenever Representation::AddNewSegment() is is called.

Parameters
representation_idis the id of the Representation with a new segment.
start_timeis the start time of the new segment.
durationis the duration of the new segment.

Definition at line 522 of file adaptation_set.cc.

◆ OnSetFrameRateForRepresentation()

void shaka::AdaptationSet::OnSetFrameRateForRepresentation ( uint32_t  representation_id,
int32_t  frame_duration,
int32_t  timescale 
)

Notifies the AdaptationSet instance that the sample duration for the Representation was set. The frame duration for a video Representation might not be specified when a Representation is created (by calling AddRepresentation()). This should be used to notify this instance that the frame rate for a Represenatation has been set. This method is called automatically when Represenatation::SetSampleDuration() is called if the Represenatation instance was created using AddRepresentation().

Parameters
representation_idis the id of the Representation. @frame_duration is the duration of a frame in the Representation.
timescaleis the timescale of the Representation.

Definition at line 533 of file adaptation_set.cc.

◆ set_codec()

void shaka::AdaptationSet::set_codec ( const std::string &  codec)
inline

Set AdaptationSet@codec.

Parameters
codecis the new codec to be set.

Definition at line 204 of file adaptation_set.h.

◆ set_color_primaries()

void shaka::AdaptationSet::set_color_primaries ( const uint32_t &  color_primaries)
inline

Set AdaptationSet's video colour primaries.

Parameters
color_primariesis the video colour primaries.

Definition at line 220 of file adaptation_set.h.

◆ set_id()

void shaka::AdaptationSet::set_id ( uint32_t  id)
inline

Set AdaptationSet@id.

Parameters
idis the new ID to be set.

Definition at line 156 of file adaptation_set.h.

◆ set_matrix_coefficients()

void shaka::AdaptationSet::set_matrix_coefficients ( const uint32_t &  matrix_coefficients)
inline

Set AdaptationSet's video matrix coefficients.

Parameters
matrix_coefficientsis the video matrix coefficients.

Definition at line 211 of file adaptation_set.h.

◆ set_protected_content()

void shaka::AdaptationSet::set_protected_content ( const MediaInfo &  media_info)

Set AdaptationSet@protected_content.

Parameters
media_infoto extract the ProtectedContent from.

Definition at line 201 of file adaptation_set.cc.

◆ set_transfer_characteristics()

void shaka::AdaptationSet::set_transfer_characteristics ( const uint32_t &  transfer_characteristics)
inline

Set AdaptationSet's video transfer characteristics.

Parameters
transfer_characteristicsis the video transfer characteristics.

Definition at line 231 of file adaptation_set.h.

◆ SortIndex()

std::optional<uint32_t> shaka::AdaptationSet::SortIndex ( ) const
inline
Returns
true if id is set, false otherwise.

Definition at line 147 of file adaptation_set.h.

◆ SwitchableAdaptationSet()

bool shaka::AdaptationSet::SwitchableAdaptationSet ( const AdaptationSet adaptation_set)

Check if the adaptation sets are switchable.

Parameters
adaptation_setto compare this AdaptationSet with.
Returns
true if AdaptationSets are switchable.

Definition at line 243 of file adaptation_set.cc.

◆ transfer_characteristics()

uint32_t shaka::AdaptationSet::transfer_characteristics ( ) const
inline
Returns
transfer_characteristics.

Definition at line 225 of file adaptation_set.h.

◆ UpdateContentProtectionPssh()

void shaka::AdaptationSet::UpdateContentProtectionPssh ( const std::string &  drm_uuid,
const std::string &  pssh 
)
virtual

Update the 'cenc:pssh' element for drm_uuid ContentProtection element. If the element does not exist, this will add one.

Parameters
drm_uuidis the UUID of the DRM for encryption.
psshis the content of <cenc:pssh> element. Note that DASH IF IOP mentions that this should be base64 encoded string of the whole pssh box.
Attention
This might get removed once DASH IF IOP specification makes a a clear guideline on how to handle key rotation. Also to get this working with shaka-player, this method DOES NOT update the PSSH element. Instead, it removes the element regardless of the content of pssh.

Definition at line 303 of file adaptation_set.cc.


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