This section provides an overview of WASM Player, a Tizen TV WebAssembly extension allowing for low-level elementary media stream playback. Essential information & guidelines on WASM Player APIs for WebAssembly are included.
Tizen WASM Player is a Samsung TV extension API which grants a WebAssembly application low level access to a Platform's media player. WASM Player operates on Elementary Media Stream Packet level, accepting encoded packets (audio/video frames) that are decoded and rendered by the TV multimedia pipeline. Depending on operation mode, WASM Player is fit to be used as a video on-demand player (normal Latency Mode, suitable for adaptive streaming scenarios), as a streaming player (low Latency Mode) or as a game streaming player (ultra low Latency Mode).
Tizen WASM Player is a low level API that accepts Encoded Audio/Video Frames (or Elementary Media Packets) to render media.
When used in this documentation Audio/Video Frames are defined as raw, encoded audio or video data that can be rendered after decoding in WASM Player. The complementary term, often used interchangeably, is Elementary Media Packet: defined as an Audio/Video Frame with added metadata.
Tizen WASM Player is labelled as a low level media API, because it works at Elementary Media Packet level: Tizen WASM Player responsibility is decoding and rendering media content. Acquiring media content and splitting it into Audio/Video Frames (Elementary Media Packets) is entirely dependent on App.
Rendering of Audio/Video Frames is configurable in Tizen WASM Player:
This allows for a great flexibility: the application has full control over downloading and demuxing data, implementation of either low latency or adaptive streaming protocol, etc. When WASM Player is used major part of multimedia pipeline can be implemented as a WebAssembly module and is platform-independent, allowing for a wide variety of multimedia applications.
This article describes both modes in detail and describes all API components required to use WASM Player in a WebAssembly App.
Flexible configuration options allow for Tizen WASM Player usage in a wide range of applications. However, two typical usage scenarios can be highlighted:
Those two typical scenarios are described in detail below.
Please note that WASM Player's Latency Mode is orthogonal to the scenarios listed above. Latency Mode is decoupled from app's media data processing method (container- or streaming-based playback) and display mode (WASM Player renders content, app renders content using OpenGL). While low Latency Modes will usually be used with streaming protocols, they can be also used with container-based apps (and vice versa).
In this approach:
Tizen WASM Player is a more low level alternative to MSE:
Please refer to the following table for Tizen WASM Player/MSE key difference highlights.
WASM Player in normal latency mode can be used to playback typical on-demand media. In this mode Platform maintains both multimedia pipeline clock and synchronization of all running streams (audio and/or video), whereas the WebAssembly application is required to fill WASM Player packet buffer with ES packets to be decoded and rendered by Platform. Normal latency mode supports all playback operations defined by WASM Player components, as well as DRM-protected content playback (see table comparing modes below).
Normal latency mode is the best choice when playback is not optimized for latency.
When Normal Latency mode is used, Platform runs the multimedia pipeline according to a steady, monotonic internal clock. Rendering of packets sent to WASM Player is synchronized with the clock according to their timestamps. Pipeline time advances only when player's internal buffer allows continuous playback of all streams; if buffer underflow is detected, pipeline pauses.
WASM Player set to Low Latency mode can be used to playback streams which require low latency, such as media originating from online streams (e.g. football match). In this mode both pipeline clock and synchronization of multimedia pipeline is controlled entirely by the WebAssembly application. Platform renders ES Packets immediately after they are passed to WASM Player. Low latency mode allows playback with low latency, however access to some operations and DRMs is limited (see table comparing modes below). Due to a nature of low latency playback, B-frames cannot be used.
Low latency mode is the best choice for playing media from online streams, that should benefit from picture enhancements functionality of Smart TV, with only little overhead on latency.
When Low Latency mode is used, Platform advances multimedia pipeline running time according to timestamps of packets passed to EMSS: whenever a packet is sent the pipeline clock is updated immediately based on it's timestamp.
Since Platform renders incoming Elementary Media Packets as they are sent and updates of the pipeline clock are directly dependent on App's actions, track synchronization is App's responsibility.
WASM Player set to Ultra Low Latency mode can be used to playback streams which require minimal latency, such as game streaming applications. In comparison to Low Latency mode, picture enhancements are disabled, providing further latency reduction.
Ultra low latency mode is the best choice for playing media from live sources that require lowest possible latency.
Pipeline clock and stream synchronization of WASM Player set to Ultra Low Latency mode is the same as in Low Latency mode.
* - FPS rate doesn't apply in low latency mode, as rendering rate is dependent entirely on packet sending frequency (therefore fps is freely and entirely controlled by App).
** - Seek operation doesn't apply in low latency mode, as it implies working with a live, non-seekable source.
*** - DRM support is available only in conjunction with Media Element rendering mode.
WASM Player set to Media Element rendering mode presents decoded video frames directly on the attached HTMLMediaElement.
This is the default rendering mode that provides support for both normal and encrypted playback.
WASM Player set to Video Texture rendering mode fills a provided texture with pictures decoded from the video stream. That WebGL texture can be rendered on a screen on canvas element.
Encrypted playback is not supported in this mode.
* - DRM support is available only in conjunction with Normal Latency Mode.
WASM Player is meant to be used in Tizen TV widget applications that employ WebAssembly modules. Tizen TV widget applications work in HTML5 environment: WASM Player provides an ElementaryMediaStreamSource component that is designed to be used as a source object of HTMLMediaElement.
In order to use Media Player with WASM Player, App should use classes it provides (which act as a source of data for playback) and the HTMLMediaElement class (to control Media Player). Class responsibilities and functions are as follow:
Please note that ElementaryMediaStreamSource and HTMLMediaElement serve different purpose in Media Player. As shown above, Elementary Media Stream Source objects act as a mean to deliver media data to HTMLMediaElement for playback. Controlling playback (e.g. issuing Play, Pause, Seeking, etc.) on Media Player is done via HTMLMediaElement API. Elementary Media Stream Source allows to deliver media data in form of Elementary Media Packets.
When operating Media Player, App should rely on HTMLMediaElement events and methods. For example, ElementaryMediaStreamSource signals when Media Player requires media data. However, the moment Media Player starts reading media data is not always the very same moment a playback can be started. Readiness for playback is signalized by HTMLMediaElement by the means of HTMLMediaElementListener::OnCanPlay() event.
ElementaryMediaStreamSource's and HTMLMediaElement's states should not be confused. ElementaryMediaStreamSource represents state of a source of data, while HTMLMediaElement represents state of a multimedia player. As such, ElementaryMediaStreamSource signals App whether or not multimedia pipeline needs data and can accept Elementary Media Packets. This is not in sync with multimedia player's state.
For example, the kEnded state can be associated with a still-playing Media Element. This occurs in Normal Latency mode when App signals end of all tracks but multimedia pipeline has buffered Elementary Media Packets remaining to play.
Depending on the Latency Mode the ElementaryMediaStreamSource's preconditions for entering the kOpen state are slightly different.
There is a number of reasons for EMSS to switch between states. Usage Guide provides detailed information on when such a change happens.
ElementaryMediaTrack state reflects that of an associated ElementaryMediaStreamSource, however in a simplified manner. Track can be either open or closed, represented by a single boolean attribute.
When track closes, an event is generated carrying a reason why close occurred. Possible close reasons can be checked here.
C++ HTMLMediaElement class supplied with Elementary Media Stream Source is a wrapper for a HTML5's HTMLMediaElement. Please refer to HTML Media Element Specification for information on HTMLMediaElement's states.
App that targets Tizen Smart TV work in a multitasking environment and must respond to multitasking appropriately. For a multimedia application this often means it have to suspend media playback when the application becomes invisible (e.g. goes into background when user launches another application) and resume playback when the application becomes visible (e.g. goes into foreground when user resumes App).
WASM Player tracks an application's multitasking state and generates appropriate events for App to react to. Specifics of event sequence depends on a selected EMSS mode of operation.
Please refer to SmartTV Media Specifications for information on supported codecs and configurations.