Tizen WASM Player
Tizen TV WebAssembly Media Player extension allowing for a low-level elementary media stream playback.
|
Main class of WASM Player. ElementaryMediaStreamSource
acts as a data source for html::HTMLMediaElement
.
More...
#include <elementary_media_stream_source.h>
Friends | |
class | html::HTMLMediaElement |
Main class of WASM Player. ElementaryMediaStreamSource
acts as a data source for html::HTMLMediaElement
.
ElementaryMediaStreamSource
manages a set of ElementaryMediaTrack
objects. ElementaryMediaPacket
s that media consists of are sent to WASM Player via individual tracks added to the source.
html::HTMLMediaElement
and attach an object implementing the html::HTMLMediaElementListener
interface.ElementaryMediaStreamSource
and attach an object implementing the ElementaryMediaStreamSourceListener
interface.html::HTMLMediaElement::SetSrc()
. This triggers source transition from ReadyState::kDetached
to ReadyState::kClosed
.ElementaryMediaTrack
s that will provide data for the media stream using ElementaryMediaStreamSource::AddTrack()
.ElementaryMediaTrackListener
interface implementation to each track.ElementaryMediaStreamSource::SetDuration()
. This step is skipped if low latency mode is used.ElementaryMediaStreamSource::Open()
to conclude setup. Setup is complete once source changes state from ReadyState::kClosed
to ReadyState::kOpen
.ElementaryMediaStreamSource
is a data source. It provides elementary media data for Media Player to play. html::MediaElement
is a playback control element: it controls when media is to be played, paused, seeked, and so on.
Changing configuration of the source and sending data will cause HTMLMediaElement::ReadyState
to change. Similarly, interacting with html::MediaElement
will impact ElementaryMediaStreamSource
. Application should listen to ElementaryMediaStreamSourceListener
and all ElementaryMediaTrackListener
s and react accordingly.
Most notably, changes in both source and track states will inform application when it should send elementary media data to Media Player for playback:
ReadyState::kOpen
(and each track receives ElementaryMediaTrackListener::OnTrackOpen()
) Media Player is ready to accept data,ReadyState::kOpen
(and each track receives ElementaryMediaTrackListener::OnTrackClosed()
) Media Player won't accept any more data.ElementaryMediaTrackListener
to track when data should be sent to Media Player.A single ElementaryMediaPacket
is sent to Media Player using the ElementaryMediaTrack::AppendPacket()
method.
When Mode::kNormal
is used, App should track current playback position using ElementaryMediaStreamSourceListener::OnPlaybackPositionChanged()
. Media Player uses buffering in this mode to ensure playback is smooth and App can use current playback position information to ensure packet buffer underrun doesn't happen:
When Mode::kLowLatency
is used, Media Player will render packets immediately after they are sent. No internal buffering happens in Media Player. Since this mode is intended for live sources, usually it's a good idea to hand packets to the source right after they are received by App.
Definition at line 143 of file elementary_media_stream_source.h.
Defines modes in which ElementaryMediaStreamSource
can operate. The mode is set in ElementaryMediaStreamSource
's constructor and cannot be changed during its lifetime.
Enumerator | |
---|---|
kNormal | This is a default mode, appropriate for most playback scenarios (most notably on-demand video playback). Pipeline clock is controlled by the Platform when WASM Player works in normal latency mode. Platform guarantees smooth media playback when working in this mode, provided packets are delivered to the Source on time (i.e. internal buffer overrun doesn't happen). |
kLow | This mode is appropriate for low latency playback scenarios (live streaming). Pipeline clock is controlled by the application when the player works in low latency mode. Source will render appended packets as soon as possible and won't perform any internal buffering. Pipeline clock is set according to the pts values of appended packets.
|
kUltraLow | This mode is appropriate for ultra low latency playback scenarios (live streaming games). It works in the same way as low-latency mode with following features:
|
Definition at line 211 of file elementary_media_stream_source.h.
|
strong |
Defines modes in which ElementaryMediaStreamSource
can operate. The mode is set in ElementaryMediaStreamSource
's constructor and cannot be changed during its lifetime.
ElementaryMediaStreamSource::Mode
is deprecated, use ElementaryMediaStreamSource::LatencyMode
and ElementaryMediaStreamSource::RenderingMode
(and associated functions) instead. Enumerator | |
---|---|
kNormal | This is a default mode, appropriate for most playback scenarios (most notably on-demand video playback). Pipeline clock is controlled by the Platform when WASM Player works in normal latency mode. Platform guarantees smooth media playback when working in this mode, provided packets are delivered to the Source on time (i.e. internal buffer overrun doesn't happen). |
kLowLatency | This mode is appropriate for low latency playback scenarios (live streaming). Pipeline clock is controlled by the application when the player works in low latency mode. Source will render appended packets as soon as possible and won't perform any internal buffering. Pipeline clock is set according to the pts values of appended packets.
|
kVideoTexture | This mode makes WASM Player decode video packets into GL textures so that they can be rendered by App using OpenGL. Video is not displayed on the associated Source will buffer packets until they can be rendered according to their pts values. Buffered packets will be decoded and put into GL textures. Application should constantly request for new pictures by calling When this mode is set, Player behaves as in the
|
Definition at line 154 of file elementary_media_stream_source.h.
Enumerates all possible states of ElementaryMediaStreamSource
. Current ready state of EMSS can be retrieved with GetReadyState()
method and its change is signaled by ElementaryMediaStreamSourceListener
.
ElementaryMediaStreamSource
and html::HTMLMediaElement
states should not be confused. ElementaryMediaStreamSource
represents a state of the source of data, while html::HTMLMediaElement
represents a state of the multimedia player. As such, ElementaryMediaStreamSource
will signal App whether or not multimedia pipeline needs data and can accept ElementaryMediaPacket
s. This is not in sync with the multimedia player state.For example, a Source that is in the ReadyState::kEnded
state can be associated with a still-playing Media Element. This will occur in Normal Latency mode when App signals end of all tracks but multimedia pipeline has buffered ElementaryMediaPacket
s that were not displayed yet.
Enumerator | |
---|---|
kDetached | Not attached to |
kClosed | Tracks are not configured and player is not initialized. Can't play in this state. This state will be entered when:
|
kOpenPending |
This state can be entered both from the |
kOpen | Player is fully initialized and When App finishes configuring tracks, it can request entering this state by calling When |
kEnded | Stream has ended but multimedia pipeline remains initialized. Playback can still be restarted, for example by seek. This state is entered when App marks active |
Definition at line 294 of file elementary_media_stream_source.h.
Defines modes in which ElementaryMediaStreamSource
can operate. The mode is set in ElementaryMediaStreamSource
's constructor and cannot be changed during its lifetime.
Enumerator | |
---|---|
kMediaElement | This mode is appropriate for decoding video into HTMLMediaElement. |
kVideoTexture | This mode makes WASM Player decode video packets into GL textures so that they can be rendered by App using OpenGL. Video is not displayed on the associated Application should constantly request for new pictures by calling
|
Definition at line 256 of file elementary_media_stream_source.h.
|
explicit |
Creates a source with the given mode. Mode cannot be changed during lifetime of the object.
[in] | mode | Create a source that uses specified playback mode. |
samsung::wasm::ElementaryMediaStreamSource::ElementaryMediaStreamSource | ( | LatencyMode | latency_mode, |
RenderingMode | rendering_mode | ||
) |
Creates a source with the given mode. Mode cannot be changed during lifetime of the object.
[in] | latencyMode | Latency mode the player should use. |
[in] | renderingMode | Specify render target of the player. |
|
delete |
samsung::wasm::ElementaryMediaStreamSource::ElementaryMediaStreamSource | ( | ElementaryMediaStreamSource && | ) |
samsung::wasm::ElementaryMediaStreamSource::~ElementaryMediaStreamSource | ( | ) |
Result<ElementaryMediaTrack> samsung::wasm::ElementaryMediaStreamSource::AddTrack | ( | const ElementaryAudioTrackConfig & | ) |
Adds an audio track to the source.
[in] | config | A config describing track. |
Result<ElementaryMediaTrack>
with operation_result
field set to OperationResult::kSuccess
and a valid ElementaryMediaTrack
object on success, otherwise a code describing the error.kClosed
state.Result<void> samsung::wasm::ElementaryMediaStreamSource::AddTrack | ( | const ElementaryAudioTrackConfig & | , |
std::function< void(OperationResult, ElementaryMediaTrack)> | on_finished_callback | ||
) |
Asynchronously adds an audio track to the source.
[in] | config | A config describing track. |
[in] | on_finished_callback | A callback notifying end of AddTrack() . The callback receives OperationResult informing of the result of the operation and ElementaryMediaTrack object - invalid in case of operation failure. |
Result<void>
with operation_result
field set to OperationResult::kSuccess
on success, otherwise a code describing the error.kClosed
state.Result<ElementaryMediaTrack> samsung::wasm::ElementaryMediaStreamSource::AddTrack | ( | const ElementaryVideoTrackConfig & | ) |
Adds a video track to the source.
[in] | config | A config describing track. |
Result<ElementaryMediaTrack>
with operation_result
field set to OperationResult::kSuccess
and a valid ElementaryMediaTrack
object on success, otherwise a code describing the error.kClosed
state.Result<void> samsung::wasm::ElementaryMediaStreamSource::AddTrack | ( | const ElementaryVideoTrackConfig & | , |
std::function< void(OperationResult, ElementaryMediaTrack)> | on_finished_callback | ||
) |
Asynchronously adds a video track to the source.
[in] | config | A config describing track. |
[in] | on_finished_callback | A callback notifying end of AddTrack() . The callback receives OperationResult informing of the result of the operation and ElementaryMediaTrack object - invalid in case of operation failure. |
Result<void>
with operation_result
field set to OperationResult::kSuccess
on success, otherwise a code describing the error.kClosed
state.Result<void> samsung::wasm::ElementaryMediaStreamSource::Close | ( | std::function< void(OperationResult)> | on_finished_callback | ) |
Closes the source asynchronously. When the operation is done, the source will be in ReadyState::kClosed
state and a callback passed as the argument will be called. During that time it's impossible to request another ready state change.
[in] | on_finished_callback | A callback notifying end of Close() . The callback receives OperationResult informing of the result of the operation. |
Result<void>
with operation_result
field set to OperationResult::kSuccess
on success, otherwise a code describing the error. Result<void> samsung::wasm::ElementaryMediaStreamSource::Flush | ( | ) |
Flushes internal packets' buffers, causing ElementaryMediaTrack
s belonging to this Source to drop all packets appended so far.
Result<void>
with operation_result
field set to OperationResult::kSuccess
on success, otherwise a code describing the error. Returns the duration of the source.
Result<Seconds>
with operation_result
field set to OperationResult::kSuccess
and a valid Seconds
object representing duration of the source on success, otherwise a code describing the error. Result<LatencyMode> samsung::wasm::ElementaryMediaStreamSource::GetLatencyMode | ( | ) | const |
Returns the latency mode of the source, as set during object construction.
Result<ElementaryMediaStreamSource::LatencyMode>
with operation_result
field set to OperationResult::kSuccess
and a valid LatencyMode
representing mode of the source on success, otherwise a code describing the error. Returns the mode of the source, as set during object construction.
Result<ElementaryMediaStreamSource::Mode>
with operation_result
field set to OperationResult::kSuccess
and a valid Mode
representing mode of the source on success, otherwise a code describing the error.GetLatencyMode()
and GetRenderingMode()
instead Result<ReadyState> samsung::wasm::ElementaryMediaStreamSource::GetReadyState | ( | ) | const |
Returns current ReadyState
of the source.
Result<ReadyState>
with operation_result
field set to OperationResult::kSuccess
and a valid ReadyState
representing current ready state of the source on success, otherwise a code describing the error. Result<RenderingMode> samsung::wasm::ElementaryMediaStreamSource::GetRenderingMode | ( | ) | const |
Returns the rendering mode of the source, as set during object construction.
Result<ElementaryMediaStreamSource::RenderingMode>
with operation_result
field set to OperationResult::kSuccess
and a valid RenderingMode
representing mode of the source on success, otherwise a code describing the error. const char* samsung::wasm::ElementaryMediaStreamSource::GetURL | ( | ) | const |
Returns the source's URL received from URL.createObjectURL
WebAPI. The URL is bound to the source's lifetime and will be revoked automatically.
bool samsung::wasm::ElementaryMediaStreamSource::IsValid | ( | ) | const |
Returns true
if source instance is valid. This method should be called after constructor to ensure backend initialized the object properly. If source is invalid all method calls will fail.
true
if source instance is valid, otherwise false
. Result<void> samsung::wasm::ElementaryMediaStreamSource::Open | ( | std::function< void(OperationResult)> | on_finished_callback | ) |
Starts an asynchronous opening operation. When the operation is done, the source will be in ReadyState::kOpen
state and a callback passed as the argument will be called. During that time it's impossible to request another ready state change.
[in] | on_finished_callback | A callback notifying end of Open() . The callback receives OperationResult informing of the result of the operation. |
Result<void>
with operation_result
field set to OperationResult::kSuccess
on success, otherwise a code describing the error.
|
delete |
ElementaryMediaStreamSource& samsung::wasm::ElementaryMediaStreamSource::operator= | ( | ElementaryMediaStreamSource && | ) |
Result<void> samsung::wasm::ElementaryMediaStreamSource::RemoveTrack | ( | const ElementaryMediaTrack & | ) |
Removes a track from the source. After the operation removed track is still valid and can be re-added to the source again.
[in] | track | Track to remove. |
Result<void>
with operation_result
field set to OperationResult::kSuccess
on success, otherwise a code describing the error.kClosed
state. Sets the duration of the source. Note that this operation is unavailable in Mode::kLowLatency
mode.
[in] | new_duration | Duration to be set. |
Result<void>
with operation_result
field set to OperationResult::kSuccess
on success, otherwise a code describing the error. Result<void> samsung::wasm::ElementaryMediaStreamSource::SetListener | ( | ElementaryMediaStreamSourceListener * | listener | ) |
Sets a listener to receive updates about EMSS's state changes. Only one listener can be set: setting another clears the previous one. Pass nullptr
to reset the listener
[in] | listener | Listener to be set or nullptr to unset the listener. |
Result<void>
with operation_result
field set to OperationResult::kSuccess
on success, otherwise a code describing the error.
|
friend |
Definition at line 604 of file elementary_media_stream_source.h.