Shaka Player Embedded
Classes | Public Member Functions | Static Public Member Functions | List of all members
shaka::media::MediaPlayer Class Referenceabstract

#include <media_player.h>

Inheritance diagram for shaka::media::MediaPlayer:
shaka::media::ios::AvMediaPlayer shaka::media::MseMediaPlayer shaka::media::ProxyMediaPlayer shaka::media::DefaultMediaPlayer

Classes

class  Client
 
class  ClientList
 

Public Member Functions

 MediaPlayer ()
 
virtual ~ MediaPlayer ()
 
 MediaPlayer (const MediaPlayer &)=delete
 
MediaPlayeroperator= (const MediaPlayer &)=delete
 
 MediaPlayer (MediaPlayer &&)=delete
 
MediaPlayeroperator= (MediaPlayer &&)=delete
 
virtual MediaCapabilitiesInfo DecodingInfo (const MediaDecodingConfiguration &config) const =0
 
virtual VideoPlaybackQuality VideoPlaybackQuality () const =0
 
virtual void AddClient (Client *client) const =0
 
virtual void RemoveClient (Client *client) const =0
 
virtual std::vector< BufferedRangeGetBuffered () const =0
 
virtual VideoReadyState ReadyState () const =0
 
virtual VideoPlaybackState PlaybackState () const =0
 
virtual std::vector< std::shared_ptr< MediaTrack > > AudioTracks ()=0
 
virtual std::vector< std::shared_ptr< const MediaTrack > > AudioTracks () const =0
 
virtual std::vector< std::shared_ptr< MediaTrack > > VideoTracks ()=0
 
virtual std::vector< std::shared_ptr< const MediaTrack > > VideoTracks () const =0
 
virtual std::vector< std::shared_ptr< TextTrack > > TextTracks ()=0
 
virtual std::vector< std::shared_ptr< const TextTrack > > TextTracks () const =0
 
virtual std::shared_ptr< TextTrackAddTextTrack (TextTrackKind kind, const std::string &label, const std::string &language)=0
 
Rendering
virtual bool SetVideoFillMode (VideoFillMode mode)=0
 
virtual uint32_t Width () const =0
 
virtual uint32_t Height () const =0
 
virtual double Volume () const =0
 
virtual void SetVolume (double volume)=0
 
virtual bool Muted () const =0
 
virtual void SetMuted (bool muted)=0
 
Playback
virtual void Play ()=0
 
virtual void Pause ()=0
 
virtual double CurrentTime () const =0
 
virtual void SetCurrentTime (double time)=0
 
virtual double Duration () const =0
 
virtual void SetDuration (double duration)=0
 
virtual double PlaybackRate () const =0
 
virtual void SetPlaybackRate (double rate)=0
 
Internal methods

These are called by Shaka Player Embedded to setup state.

virtual bool AttachSource (const std::string &src)=0
 
virtual bool AttachMse ()=0
 
virtual bool AddMseBuffer (const std::string &mime, bool is_video, const ElementaryStream *stream)=0
 
virtual void LoadedMetaData (double duration)=0
 
virtual void MseEndOfStream ()=0
 
virtual bool SetEmeImplementation (const std::string &key_system, eme::Implementation *implementation)=0
 
virtual void Detach ()=0
 

Static Public Member Functions

static void SetMediaPlayerForSupportChecks (const MediaPlayer *player)
 
static const MediaPlayerGetMediaPlayerForSupportChecks ()
 

Detailed Description

Defines the base class for media handling. This handles decryption, decoding, playback, and rendering of media content. This can handle both MSE-based playback and raw src= playback; it is not required to support both, returning false from the respective methods will stop playback. For MSE-based playback, this is given the encoded frames after they have been demuxed by the Demuxer. This is expected to pull those frames when needed.

This acts both as the <video> element to JavaScript and as the app's API to interact with playback. It is expected that this type is internally thread-safe and can be called from multiple threads.

An object of a derived class is created by the app during startup and is given to the Player. The Client is created by Shaka Player Embedded and is given to this object. Once the manifest is loaded, playback is started by calling either AttachMse or AttachSource. Once playback is done, Detach is called.

If another manifest is loaded, we will start again for a new stream. Implementers are not required to support multiple playback sessions, but they'll need to avoid calling Player::Load a second time with the same MediaPlayer instance.

Definition at line 184 of file media_player.h.

Constructor & Destructor Documentation

§ MediaPlayer() [1/3]

shaka::media::MediaPlayer::MediaPlayer ( )

§ ~ MediaPlayer()

virtual shaka::media::MediaPlayer::~ MediaPlayer ( )
virtual

§ MediaPlayer() [2/3]

shaka::media::MediaPlayer::MediaPlayer ( const MediaPlayer )
delete

§ MediaPlayer() [3/3]

shaka::media::MediaPlayer::MediaPlayer ( MediaPlayer &&  )
delete

Member Function Documentation

§ AddClient()

virtual void shaka::media::MediaPlayer::AddClient ( Client client) const
pure virtual

Adds a new client listener. The given object will be called when events are raised. Clients are called in the order they are registered. Calling this with an already-registered client will have no effect.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ProxyMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ AddMseBuffer()

virtual bool shaka::media::MediaPlayer::AddMseBuffer ( const std::string &  mime,
bool  is_video,
const ElementaryStream stream 
)
pure virtual

Adds a new MSE buffer to pull frames from. This can be called after normal playback has started, but that doesn't have to be supported. This will be called for each SourceBuffer object created. If the source content is multiplexed, this will be called twice for the same input stream, but will be given separate audio/video buffers.

Parameters
mimeThe full MIME type given from JavaScript.
is_videoTrue if this is for a video stream, false for audio.
streamThe stream containing the encoded frames.
Returns
True on success, false on error or unsupported.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ AddTextTrack()

virtual std::shared_ptr<TextTrack> shaka::media::MediaPlayer::AddTextTrack ( TextTrackKind  kind,
const std::string &  label,
const std::string &  language 
)
pure virtual

Adds a new text track to the player. This can return nullptr if this isn't supported.

Parameters
kindThe kind of the new track.
labelA string label for the track.
languageThe language of the new track.
Returns
The new track object, or nullptr on error or if unsupported.

Implemented in shaka::media::DefaultMediaPlayer, shaka::media::MseMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ AttachMse()

virtual bool shaka::media::MediaPlayer::AttachMse ( )
pure virtual

Starts MSE-based playback. At a later time, AddMseBuffer will be called to give streams to pull from.

Returns
True on success, false if MSE playback isn't supported.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ AttachSource()

virtual bool shaka::media::MediaPlayer::AttachSource ( const std::string &  src)
pure virtual

Starts playback using the given src= URL. The player should read data from the given URL and play its content.

Parameters
srcThe URL to read from.
Returns
True on success, false on invalid URL or if src= isn't supported.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ AudioTracks() [1/2]

virtual std::vector<std::shared_ptr<MediaTrack> > shaka::media::MediaPlayer::AudioTracks ( )
pure virtual
Returns
The current audio tracks in the media.

Implemented in shaka::media::DefaultMediaPlayer, shaka::media::MseMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ AudioTracks() [2/2]

virtual std::vector<std::shared_ptr<const MediaTrack> > shaka::media::MediaPlayer::AudioTracks ( ) const
pure virtual
Returns
The current audio tracks in the media.

Implemented in shaka::media::DefaultMediaPlayer, shaka::media::MseMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ CurrentTime()

virtual double shaka::media::MediaPlayer::CurrentTime ( ) const
pure virtual
Returns
The current time of the video, or 0 if nothing is loaded.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ DecodingInfo()

virtual MediaCapabilitiesInfo shaka::media::MediaPlayer::DecodingInfo ( const MediaDecodingConfiguration config) const
pure virtual

Checks whether the given content can be played. In general, for MSE playback, this shouldn't check whether it can be demuxed, this should only check whether the streams can be decoded. The Demuxer should handle whether it can be demuxed.

The return value must be the same throughout playback and should be the same for all MediaPlayer implementations that are used. Since type support checking is done before a specific MediaPlayer is selected, it is expected that all MediaPlayer instances return the same value. If this isn't the case, it can cause runtime decoder errors since filtering is done early.

Parameters
configThe configuration to check support for.
Returns
The capabilities for the given configuration.

Implemented in shaka::media::DefaultMediaPlayer, shaka::media::MseMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ Detach()

virtual void shaka::media::MediaPlayer::Detach ( )
pure virtual

Stops playback from the current media. This should stop using the current ElementaryStream objects and halt playback.

Implemented in shaka::media::DefaultMediaPlayer, shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ Duration()

virtual double shaka::media::MediaPlayer::Duration ( ) const
pure virtual
Returns
The current duration of the media, or Infinity if unknown.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ GetBuffered()

virtual std::vector<BufferedRange> shaka::media::MediaPlayer::GetBuffered ( ) const
pure virtual

Gets the ranges of buffered content in the media. For MSE playback, this should use the ElementaryStream objects passed to this object; for src= playback, this type will internally handle buffering.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ProxyMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ GetMediaPlayerForSupportChecks()

const MediaPlayer * shaka::media::MediaPlayer::GetMediaPlayerForSupportChecks ( )
static
Returns
The last value passed to SetMediaPlayerForSupportChecks.

Definition at line 234 of file media_player.cc.

§ Height()

virtual uint32_t shaka::media::MediaPlayer::Height ( ) const
pure virtual
Returns
The current height of the video frames, in pixels.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ LoadedMetaData()

virtual void shaka::media::MediaPlayer::LoadedMetaData ( double  duration)
pure virtual

For MSE playback, this indicates that the init segments for the input streams have been received and have the given estimated duration. If there is more than one input stream, this is called once they all have been loaded.

Parameters
durationThe estimated duration of the stream based on the init segments; can be infinity if unknown.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ MseEndOfStream()

virtual void shaka::media::MediaPlayer::MseEndOfStream ( )
pure virtual

For MSE playback, this indicates that the last segment has been handled and the current buffered end represents the end of all the content.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ Muted()

virtual bool shaka::media::MediaPlayer::Muted ( ) const
pure virtual
Returns
Whether the audio is muted.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ operator=() [1/2]

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

§ operator=() [2/2]

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

§ Pause()

virtual void shaka::media::MediaPlayer::Pause ( )
pure virtual

Pauses playback of the current content. If this is called before AttachSource/AttachMse, this should not start playing when content is given.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ Play()

virtual void shaka::media::MediaPlayer::Play ( )
pure virtual

Starts playback of the current content. If this is called before AttachSource/AttachMse, this should start playing when content is given.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ PlaybackRate()

virtual double shaka::media::MediaPlayer::PlaybackRate ( ) const
pure virtual
Returns
The current playback rate of the video, or 1 if nothing is loaded.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ PlaybackState()

virtual VideoPlaybackState shaka::media::MediaPlayer::PlaybackState ( ) const
pure virtual
Returns
The current VideoPlaybackSate of the media.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ProxyMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ ReadyState()

virtual VideoReadyState shaka::media::MediaPlayer::ReadyState ( ) const
pure virtual
Returns
The current VideoReadyState of the media.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ProxyMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ RemoveClient()

virtual void shaka::media::MediaPlayer::RemoveClient ( Client client) const
pure virtual

Removes a client listener. The given client will no longer be called when events happen.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ProxyMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ SetCurrentTime()

virtual void shaka::media::MediaPlayer::SetCurrentTime ( double  time)
pure virtual

Seeks to a new position in the currently-playing stream. Does nothing if no content is loaded.

Parameters
timeThe presentation time to seek to.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ SetDuration()

virtual void shaka::media::MediaPlayer::SetDuration ( double  duration)
pure virtual

Sets the duration of the media.

Parameters
durationThe duration, in seconds, to set to.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ SetEmeImplementation()

virtual bool shaka::media::MediaPlayer::SetEmeImplementation ( const std::string &  key_system,
eme::Implementation implementation 
)
pure virtual

Sets the EME implementation instance used to decrypt media. This will be set early in playback and won't be changed while playing. This will be called with nullptr to clear the EME implementation.

Parameters
key_systemThe name of the key system this is for.
implementationThe implementation used to decrypt frames.
Returns
True on success, false on error or unsupported.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ SetMediaPlayerForSupportChecks()

Doxygen_Skip void shaka::media::MediaPlayer::SetMediaPlayerForSupportChecks ( const MediaPlayer player)
static

Sets the global MediaPlayer instance that is used to determine if content can be played. This is used by MediaSource.isTypeSupported to determine if content can be played.

This allows setting a special instance for these static support checks for when a "current" MediaPlayer cannot be determined. This can be set to nullptr to not use it anymore.

If a value isn't given here, we'll use an arbitrary MediaPlayer instance that was given to some Player instance. We'll only use alive instances, but we may use a different one than what will ultimately play the content.

Parameters
playerThe MediaPlayer instance to use; only the DecodingInfo method will be called.

Definition at line 230 of file media_player.cc.

§ SetMuted()

virtual void shaka::media::MediaPlayer::SetMuted ( bool  muted)
pure virtual

§ SetPlaybackRate()

virtual void shaka::media::MediaPlayer::SetPlaybackRate ( double  rate)
pure virtual

Sets the playback rate of the video. Does nothing if no content is loaded.

Parameters
rateThe new playback rate.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ SetVideoFillMode()

virtual bool shaka::media::MediaPlayer::SetVideoFillMode ( VideoFillMode  mode)
pure virtual

Sets how to resize video frames within the drawing region.

Parameters
modeThe new method to resize the video frames.
Returns
True on success, false on error or if the mode isn't supported.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ SetVolume()

virtual void shaka::media::MediaPlayer::SetVolume ( double  volume)
pure virtual

Sets the volume [0, 1] to render audio at.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ TextTracks() [1/2]

virtual std::vector<std::shared_ptr<TextTrack> > shaka::media::MediaPlayer::TextTracks ( )
pure virtual
Returns
The current text tracks in the media.

Implemented in shaka::media::DefaultMediaPlayer, shaka::media::MseMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ TextTracks() [2/2]

virtual std::vector<std::shared_ptr<const TextTrack> > shaka::media::MediaPlayer::TextTracks ( ) const
pure virtual
Returns
The current text tracks in the media.

Implemented in shaka::media::DefaultMediaPlayer, shaka::media::MseMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ VideoPlaybackQuality()

virtual VideoPlaybackQuality shaka::media::MediaPlayer::VideoPlaybackQuality ( ) const
pure virtual
Returns
The current video playback statistics.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ProxyMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ VideoTracks() [1/2]

virtual std::vector<std::shared_ptr<MediaTrack> > shaka::media::MediaPlayer::VideoTracks ( )
pure virtual
Returns
The current video tracks in the media.

Implemented in shaka::media::DefaultMediaPlayer, shaka::media::MseMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ VideoTracks() [2/2]

virtual std::vector<std::shared_ptr<const MediaTrack> > shaka::media::MediaPlayer::VideoTracks ( ) const
pure virtual
Returns
The current video tracks in the media.

Implemented in shaka::media::DefaultMediaPlayer, shaka::media::MseMediaPlayer, and shaka::media::ios::AvMediaPlayer.

§ Volume()

virtual double shaka::media::MediaPlayer::Volume ( ) const
pure virtual
Returns
The current volume [0, 1].

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.

§ Width()

virtual uint32_t shaka::media::MediaPlayer::Width ( ) const
pure virtual
Returns
The current width of the video frames, in pixels.

Implemented in shaka::media::MseMediaPlayer, shaka::media::ios::AvMediaPlayer, and shaka::media::ProxyMediaPlayer.


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