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 Web extension API which grants a WebAssembly application low level access to Tizen platform's media player. The WASM Player operates on Elementary Media Stream Packet level, accepting encoded packets (audio/video frames) that are decoded and rendered by the 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 the WASM Player. The complementary term (often used interchangeably) is Elementary Media Packet, which is defined as an Audio/Video Frame with added metadata.
Tizen WASM Player is labelled as a low level media API, because it works at the Elementary Media Packet level: Tizen WASM Player is responsible for decoding and rendering media content, while acquiring media content and splitting it into Audio/Video Frames (Elementary Media Packets) is entirely dependent on the application itself.
Rendering of Audio/Video Frames is configurable in Tizen WASM Player:
The configurable rendering allows for great flexibility: the application has full control over downloading and demuxing of data, and implementation of either low latency or adaptive streaming protocol. When the WASM Player is used, a major part of the multimedia pipeline can be implemented as a WebAssembly module and is therefore platform-independent, allowing for a wide variety of multimedia applications.
This document describes both latency modes in detail and covers all API components required to use the WASM Player in a WebAssembly application.
Flexible configuration options allow for Tizen WASM Player usage in a wide range of applications. However, 2 typical usage scenarios can be highlighted:
These typical scenarios are described in detail below.
In this usage scenario:
Tizen WASM Player is a more low-level alternative to Media Stream Extensions (MSE):
Refer to the following table for more key differences between Tizen WASM Player and MSE.
Table 1. Tizen WASM Player vs. MSE
Tizen WASM player has three distinct latency modes: normal latency, low latency, and ultra low latency.
In normal latency mode, the WASM Player can be used to playback typical on-demand media. In this mode the platform maintains both the multimedia pipeline clock and the synchronization of all running streams (audio and video), whereas the WebAssembly application is required to fill the WASM Player packet buffer with ES packets to be decoded and rendered by the platform. The normal latency mode supports all playback operations defined by WASM Player components, as well as DRM-protected content playback (see the Latency mode comparison table).
The normal latency mode is the best choice when playback is not optimized for latency.
Pipeline clock and stream sync: When the normal latency mode is used, the platform runs the multimedia pipeline according to a steady, monotonic internal clock. Rendering of packets sent to the WASM Player is synchronized with the clock according to their timestamps. Pipeline time advances only when the player's internal buffer allows continuous playback of all streams; if buffer underflow is detected, the pipeline pauses.
In low latency mode, the WASM Player can be used to playback streams which require low latency, such as media originating from online streams (such as a football match). In this mode, both the pipeline clock and the synchronization of the multimedia pipeline are controlled entirely by the WebAssembly application. The platform renders ES packets immediately after they are passed to the WASM Player. The low latency mode allows playback with low latency, however access to some operations and DRM is limited (see the Latency mode comparison table). Due to the nature of low latency playback, B-frames cannot be used.
The low latency mode is the best choice for playing media from online streams that can benefit from the picture enhancement functionality of device, with only little overhead on latency.
Pipeline clock and stream sync: When the low latency mode is used, the platform advances the multimedia pipeline running time according to the timestamps of packets passed to EMSS (ElementaryMediaStreamSource): whenever a packet is sent, the pipeline clock is updated immediately based on its timestamp.
Since the platform renders incoming Elementary Media Packets as they are sent and updates of the pipeline clock are directly dependent on the application's actions, the application is also responsible for stream synchronization.
Ultra low latency
The WASM Player set to the ultra low latency mode can be used to playback streams which require minimal latency, such as game streaming applications. In comparison to the low latency mode, picture enhancements are disabled, providing further latency reduction.
The ultra low latency mode is the best choice for playing media from live sources that require the lowest possible latency
Pipeline clock and stream sync: The pipeline clock and stream synchronization of the WASM Player set to the ultra low latency mode operate the same as in the low latency mode.
The following table shows how the 3 latency modes differ from each other with their handling of specific features.
Table 2. Latency Mode Comparison
Tizen WASM Player has 2 rendering modes: Media Element and Video texture.
In the Media Element mode, the WASM Player presents decoded video frames directly on an attached HTMLMediaElement.
This is the default rendering mode, and provides support for both normal and encrypted playback.
In the Video Texture mode, the WASM Player fills a provided texture with pictures decoded from the video stream. This WebGL texture can then be rendered on the screen on a canvas element.
Encrypted playback is not supported in this mode.
Table 3. Rendering Mode Comparison
The following sections contain a detailed look into the WASM Player architecture and its components.
The WASM Player is meant to be used in Tizen Web widget applications that employ WebAssembly modules. Tizen Web widget applications work in a HTML5 environment: the 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 the WASM Player, the application must use the provided WASM Player classes (which act as a source of data for playback) and the HTMLMediaElement class (to control Media Player). The following table defines the class responsibilities and functions:
Table 4. WASM Player and Media Player classes
ElementaryMediaStreamSource and HTMLMediaElement serve different purposes in Media Player. As shown above, Elementary Media Stream Source objects act as the means to deliver media data to HTMLMediaElement for playback. Controlling playback (such as issuing Play, Pause, and Seeking commands) on Media Player is done through the HTMLMediaElement API. Elementary Media Stream Source allows you to deliver media data in form of Elementary Media Packets.
When operating Media Player, the application must 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 exact moment that playback can be started. Readiness for playback is signalized by HTMLMediaElement through the HTMLMediaElementListener::OnCanPlay() event.
The following figure and table describe the ElementaryMediaStreamSource states and the transitions between them.
Table 5. ElementaryMediaStreamSource States
Depending on the latency mode, the ElementaryMediaStreamSource's preconditions for entering the kOpen state are slightly different.
The state of a ElementaryMediaTrack object reflects the state of an associated ElementaryMediaStreamSource, however in a simplified manner. A track can be either open or closed, represented by a single boolean attribute.
Table 6. ElementaryMediaTrack States
The C++ HTMLMediaElement class supplied with Elementary Media Stream Source is a wrapper for a HTML5's HTMLMediaElement. For information on HTMLMediaElement states, see HTML Media Element Specification.
Applications that target devices work in a multitasking environment and must respond to multitasking appropriately. For a multimedia application, this often means having to suspend media playback when the application becomes invisible (such as goes into background when the user launches another application) and resuming playback when the application becomes visible (such as goes into foreground when the user resumes the application).
The WASM Player tracks an application's multitasking state and generates appropriate events for the application to react to. Specifics of the event sequence depends on a selected EMSS mode of operation.
For information on supported codecs and configurations, see Samsung Media Specifications.