Shaka Player Embedded
Classes | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
shaka::media::StreamBase Class Reference

#include <streams.h>

Inheritance diagram for shaka::media::StreamBase:
shaka::media::Stream< T, OrderByDts > shaka::media::Stream< DecodedFrame, false >

Classes

class  Impl
 

Public Member Functions

 StreamBase (bool order_by_dts)
 
 ~StreamBase ()
 
 StreamBase (const StreamBase &)=delete
 
StreamBaseoperator= (const StreamBase &)=delete
 
 StreamBase (StreamBase &&)=delete
 
StreamBaseoperator= (StreamBase &&)=delete
 
size_t CountFramesBetween (double start, double end) const
 
std::vector< BufferedRangeGetBufferedRanges () const
 
size_t EstimateSize () const
 
void Remove (double start, double end)
 
void Clear ()
 
void DebugPrint (bool all_frames) const
 

Static Public Attributes

static constexpr const double kMaxGapSize = 0.15
 

Protected Member Functions

std::shared_ptr< BaseFrameGetFrameInternal (double time, FrameLocation kind) const
 
void AddFrameInternal (std::shared_ptr< BaseFrame > frame)
 

Detailed Description

Defines a base class for a stream containing frames. This represents a stream of frames of a single type (i.e. video-only or audio-only); but this may contain frames from different source streams (i.e. from adaptation). Frames are all within a single timeline and have been reordered/moved according to MSE.

This type is internally thread-safe.

Definition at line 69 of file streams.h.

Constructor & Destructor Documentation

§ StreamBase() [1/3]

shaka::media::StreamBase::StreamBase ( bool  order_by_dts)
explicit

Creates a new StreamBase that stores frames based on the given ordering. This will order and query frames based on PTS or DTS. So when you ask for a time of N seconds, this will either use PTS or DTS to determine the correct frame. Some methods always use PTS to match requirements of MSE; this means there may be differences between the times used in some methods.

Definition at line 147 of file streams.cc.

§ ~StreamBase()

shaka::media::StreamBase::~StreamBase ( )

Definition at line 149 of file streams.cc.

§ StreamBase() [2/3]

shaka::media::StreamBase::StreamBase ( const StreamBase )
delete

§ StreamBase() [3/3]

shaka::media::StreamBase::StreamBase ( StreamBase &&  )
delete

Member Function Documentation

§ AddFrameInternal()

void shaka::media::StreamBase::AddFrameInternal ( std::shared_ptr< BaseFrame frame)
protected

Adds a new frame to the stream. This won't check for compatible streams or for keyframe requirements; it is assumed the caller will only append frames that can be played. For example, the caller may need to discard demuxed frames until they find a keyframe.

If adding a frame with the same start time, this will replace the existing frame; otherwise this will insert based on the start time, even if they overlap.

Definition at line 162 of file streams.cc.

§ Clear()

void shaka::media::StreamBase::Clear ( )

Removes all frames in the stream.

Definition at line 326 of file streams.cc.

§ CountFramesBetween()

size_t shaka::media::StreamBase::CountFramesBetween ( double  start,
double  end 
) const
Parameters
startThe exclusive time to start from.
endThe exclusive time to end at.
Returns
The number of frames that start within the given range.

Definition at line 237 of file streams.cc.

§ DebugPrint()

void shaka::media::StreamBase::DebugPrint ( bool  all_frames) const

Prints debug info about the stream to stderr.

Parameters
all_framesTrue to print times of all frames; false to only print a summary.

Definition at line 331 of file streams.cc.

§ EstimateSize()

size_t shaka::media::StreamBase::EstimateSize ( ) const

Estimates the size of the stream by adding up all the stored frames.

Returns
The estimated size of the stream, in bytes.

Definition at line 151 of file streams.cc.

§ GetBufferedRanges()

std::vector< BufferedRange > shaka::media::StreamBase::GetBufferedRanges ( ) const

Returns the time ranges of the contiguously buffered ranges. Each element contains a start and end time of a range that has contiguous frames in it. Each range should start with a keyframe and will be sorted. This always uses PTS to report the ranges.

Returns
The time ranges of the buffered regions.

Definition at line 225 of file streams.cc.

§ GetFrameInternal()

std::shared_ptr< BaseFrame > shaka::media::StreamBase::GetFrameInternal ( double  time,
FrameLocation  kind 
) const
protected

Gets the frame that is associated with the given time. How this searches for frames depends on the second argument. This may return nullptr if there is no such frame.

Parameters
timeThe time (in seconds) to search for.
kindHow to search for the frame.
Returns
The located frame, or nullptr if not found.

Definition at line 356 of file streams.cc.

§ operator=() [1/2]

StreamBase& shaka::media::StreamBase::operator= ( StreamBase &&  )
delete

§ operator=() [2/2]

StreamBase& shaka::media::StreamBase::operator= ( const StreamBase )
delete

§ Remove()

void shaka::media::StreamBase::Remove ( double  start,
double  end 
)

Removes any frames that start in the given range. Since this type returns a shared_ptr to the frames, they will not be destroyed until they are no longer being used by the renderers or the app.

This always uses PTS to determine what frames to remove. This will keep removing past the end until the next keyframe; all DemuxedFrame objects are considered keyframes.

Parameters
startThe inclusive time to start removing.
endThe exclusive time to end removing.

Definition at line 270 of file streams.cc.

Member Data Documentation

§ kMaxGapSize

constexpr const double shaka::media::StreamBase::kMaxGapSize = 0.15
static

The gap, in seconds, between frames that will still be considered part of the same buffered range. If two frames are further than this apart, then they will be part of different buffered ranges.

Definition at line 76 of file streams.h.


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