Shaka Packager SDK
Public Types | Public Member Functions | List of all members
shaka::Representation Class Reference

#include <representation.h>

Inheritance diagram for shaka::Representation:
shaka::MockRepresentation

Public Types

enum  SuppressFlag { kSuppressWidth = 1 , kSuppressHeight = 2 , kSuppressFrameRate = 4 }
 

Public Member Functions

bool Init ()
 
virtual void AddContentProtectionElement (const ContentProtectionElement &element)
 
virtual void UpdateContentProtectionPssh (const std::string &drm_uuid, const std::string &pssh)
 
class AdaptationSet
 
class RepresentationTest
 
virtual void AddNewSegment (int64_t start_time, int64_t duration, uint64_t size, int64_t segment_number)
 
virtual void UpdateCompletedSegment (int64_t duration, uint64_t size)
 
virtual void SetSampleDuration (int32_t sample_duration)
 
virtual const MediaInfo & GetMediaInfo () const
 
std::optional< xml::XmlNodeGetXml ()
 
void SuppressOnce (SuppressFlag flag)
 
void SetPresentationTimeOffset (double presentation_time_offset)
 Set @presentationTimeOffset in SegmentBase / SegmentTemplate.
 
void SetAvailabilityTimeOffset ()
 
void SetSegmentDuration ()
 
bool GetStartAndEndTimestamps (double *start_timestamp_seconds, double *end_timestamp_seconds) const
 
uint32_t id () const
 
void set_media_info (const MediaInfo &media_info)
 
 Representation (const MediaInfo &media_info, const MpdOptions &mpd_options, uint32_t representation_id, std::unique_ptr< RepresentationStateChangeListener > state_change_listener)
 
 Representation (const Representation &representation, std::unique_ptr< RepresentationStateChangeListener > state_change_listener)
 

Detailed Description

Representation class contains references to a single media stream, as well as optional ContentProtection elements for that stream.

Definition at line 49 of file representation.h.

Constructor & Destructor Documentation

◆ Representation() [1/2]

shaka::Representation::Representation ( const MediaInfo &  media_info,
const MpdOptions mpd_options,
uint32_t  representation_id,
std::unique_ptr< RepresentationStateChangeListener state_change_listener 
)
protected
Parameters
media_infois a MediaInfo containing information on the media. media_info.bandwidth is required for 'static' profile. If media_info.bandwidth is not present in 'dynamic' profile, this tries to estimate it using the info passed to AddNewSegment().
mpd_optionsis options for the entire MPD.
representation_idis the numeric ID for the <Representation>.
state_change_listeneris an event handler for state changes to the representation. If null, no event handler registered.

Definition at line 87 of file representation.cc.

◆ Representation() [2/2]

shaka::Representation::Representation ( const Representation representation,
std::unique_ptr< RepresentationStateChangeListener state_change_listener 
)
protected
Parameters
representationpoints to the original Representation to be cloned.
state_change_listeneris an event handler for state changes to the representation. If null, no event handler registered.

Definition at line 102 of file representation.cc.

Member Function Documentation

◆ AddContentProtectionElement()

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

Add a ContenProtection element to the representation. Representation does not add <ContentProtection> elements automatically to itself even if media_info passed to AdaptationSet::AddRepresentation() has media_info.protected_content 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 159 of file representation.cc.

◆ AddNewSegment()

void shaka::Representation::AddNewSegment ( int64_t  start_time,
int64_t  duration,
uint64_t  size,
int64_t  segment_number 
)
virtual

Add a media (sub)segment to the representation. AdaptationSetsubsegmentAlignment,segmentAlignment} cannot be set if this is not called for all Representations.

Parameters
start_timeis the start time for the (sub)segment, in units of the stream's time scale.
durationis the duration of the segment, in units of the stream's time scale. In the low latency case, this duration is that of the first chunk because the full duration is not yet known.
sizeof the segment in bytes. In the low latency case, this size is that of the first chunk because the full size is not yet known.
segment_numberis the current segment number.

Definition at line 171 of file representation.cc.

◆ GetMediaInfo()

const MediaInfo & shaka::Representation::GetMediaInfo ( ) const
virtual
Returns
MediaInfo for the Representation.

Definition at line 243 of file representation.cc.

◆ GetStartAndEndTimestamps()

bool shaka::Representation::GetStartAndEndTimestamps ( double *  start_timestamp_seconds,
double *  end_timestamp_seconds 
) const

Gets the start and end timestamps in seconds.

Parameters
start_timestamp_secondscontains the returned start timestamp in seconds on success. It can be nullptr, which means that start timestamp does not need to be returned.
end_timestamp_secondscontains the returned end timestamp in seconds on success. It can be nullptr, which means that end timestamp does not need to be returned.
Returns
true if successful, false otherwise.

Definition at line 360 of file representation.cc.

◆ GetXml()

std::optional< xml::XmlNode > shaka::Representation::GetXml ( )
Returns
Copy of <Representation>.

Definition at line 253 of file representation.cc.

◆ id()

uint32_t shaka::Representation::id ( ) const
inline
Returns
ID number for <Representation>.

Definition at line 164 of file representation.h.

◆ Init()

bool shaka::Representation::Init ( )

Tries to initialize the instance. If this does not succeed, the instance should not be used.

Returns
true on success, false otherwise.

Definition at line 115 of file representation.cc.

◆ SetAvailabilityTimeOffset()

void shaka::Representation::SetAvailabilityTimeOffset ( )

Set @availabilityTimeOffset in SegmentTemplate. This is necessary for Low Latency DASH streaming.

Definition at line 343 of file representation.cc.

◆ SetSampleDuration()

void shaka::Representation::SetSampleDuration ( int32_t  sample_duration)
virtual

Set the sample duration of this Representation. Sample duration is not available right away especially for live. This allows setting the sample duration after the Representation has been initialized.

Parameters
sample_durationis the duration of a sample.

Definition at line 220 of file representation.cc.

◆ SetSegmentDuration()

void shaka::Representation::SetSegmentDuration ( )

Set @duration in SegmentTemplate. This is necessary for Low Latency DASH streaming.

Definition at line 235 of file representation.cc.

◆ SuppressOnce()

void shaka::Representation::SuppressOnce ( SuppressFlag  flag)

By calling this methods, the next time GetXml() is called, the corresponding attributes will not be set. For example, if SuppressOnce(kSuppressWidth) is called, then GetXml() will return a <Representation> element without a @width attribute. Note that it only applies to the next call to GetXml(), calling GetXml() again without calling this methods will return a <Representation> element with the attribute. This may be called multiple times to set different (or the same) flags.

Definition at line 331 of file representation.cc.

◆ UpdateCompletedSegment()

void shaka::Representation::UpdateCompletedSegment ( int64_t  duration,
uint64_t  size 
)
virtual

Update a media segment in the Representation. In the low latency case, the segment duration will not be ready until the entire segment has been processed. This allows setting the full duration after the segment has been completed and the true duratio is known.

Parameters
durationis the duration of the complete segment, in units of the stream's time scale.
sizeof the complete segment in bytes.

Definition at line 205 of file representation.cc.

◆ UpdateContentProtectionPssh()

void shaka::Representation::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 165 of file representation.cc.


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