Starboard Module Reference: media.h

Provides media definitions that are common between the Decoder and Player interfaces.

Enums

SbMediaAudioCodec

Types of audio elementary streams that can be supported.

Values

  • kSbMediaAudioCodecNone
  • kSbMediaAudioCodecAac
  • kSbMediaAudioCodecOpus
  • kSbMediaAudioCodecVorbis

SbMediaAudioCodingType

Possible audio coding types.

Values

  • kSbMediaAudioCodingTypeNone
  • kSbMediaAudioCodingTypeAac
  • kSbMediaAudioCodingTypeAc3
  • kSbMediaAudioCodingTypeAtrac
  • kSbMediaAudioCodingTypeBitstream
  • kSbMediaAudioCodingTypeDolbyDigitalPlus
  • kSbMediaAudioCodingTypeDts
  • kSbMediaAudioCodingTypeMpeg1
  • kSbMediaAudioCodingTypeMpeg2
  • kSbMediaAudioCodingTypeMpeg3
  • kSbMediaAudioCodingTypePcm

SbMediaAudioConnector

Possible audio connector types.

Values

  • kSbMediaAudioConnectorNone
  • kSbMediaAudioConnectorAnalog
  • kSbMediaAudioConnectorBluetooth
  • kSbMediaAudioConnectorHdmi
  • kSbMediaAudioConnectorNetwork
  • kSbMediaAudioConnectorSpdif
  • kSbMediaAudioConnectorUsb

SbMediaAudioFrameStorageType

Possible audio frame storage types.

Values

  • kSbMediaAudioFrameStorageTypeInterleaved - The samples of a multi-channel audio stream are stored in one continuous buffer. Samples at the same timestamp are stored one after another. For example, for a stereo stream with channels L and R that contains samples with timestamps 0, 1, 2, etc., the samples are stored in one buffer as "L0 R0 L1 R1 L2 R2 ...".
  • kSbMediaAudioFrameStorageTypePlanar - The samples of each channel are stored in their own continuous buffer.For example, for a stereo stream with channels L and R that containssamples with timestamps 0, 1, 2, etc., the samples are stored in twobuffers "L0 L1 L2 ..." and "R0 R1 R2 ...".

SbMediaAudioSampleType

Possible audio sample types.

Values

  • kSbMediaAudioSampleTypeInt16
  • kSbMediaAudioSampleTypeFloat32

SbMediaSupportType

Indicates how confident the device is that it can play media resources of the given type. The values are a direct map of the canPlayType() method specified at the following link: https://www.w3.org/TR/2011/WD-html5-20110113/video.html#dom-navigator-canplaytype

Values

  • kSbMediaSupportTypeNotSupported - The media type cannot be played.
  • kSbMediaSupportTypeMaybe - Cannot determinate if the media type is playable without playing it.
  • kSbMediaSupportTypeProbably - The media type seems to be playable.

SbMediaType

Types of media component streams.

Values

  • kSbMediaTypeAudio - Value used for audio streams.
  • kSbMediaTypeVideo - Value used for video streams.

SbMediaVideoCodec

Types of video elementary streams that could be supported.

Values

  • kSbMediaVideoCodecNone
  • kSbMediaVideoCodecH264
  • kSbMediaVideoCodecH265
  • kSbMediaVideoCodecMpeg2
  • kSbMediaVideoCodecTheora
  • kSbMediaVideoCodecVc1
  • kSbMediaVideoCodecVp10
  • kSbMediaVideoCodecVp8
  • kSbMediaVideoCodecVp9

Structs

SbMediaAudioConfiguration

A structure describing the audio configuration parameters of a single audio output.

Members

Members
int
index
The platform-defined index of the associated audio output.
SbMediaAudioConnector
connector
The type of audio connector. Will be the empty kSbMediaAudioConnectorNone if this device cannot provide this information.
SbTime
latency
The expected latency of audio over this output, in microseconds, or 0 if this device cannot provide this information.
SbMediaAudioCodingType
coding_type
The type of audio coding used over this connection.
int
number_of_channels
The number of audio channels currently supported by this device output, or 0 if this device cannot provide this information, in which case the caller can probably assume stereo output.

SbMediaAudioHeader

An audio sequence header, which is a description of a given audio stream. This, in hexadecimal string form, acts as a set of instructions to the audio decoder.
The Sequence Header consists of a little-endian hexadecimal encoded WAVEFORMATEX structure followed by an Audio-specific configuration field. The WAVEFORMATEX structure is specified at: http://msdn.microsoft.com/en-us/library/dd390970(v=vs.85).aspx

Members

Members
uint16_t
format_tag
The waveform-audio format type code.
uint16_t
number_of_channels
The number of audio channels in this format. 1 for mono, 2 for stereo.
uint32_t
samples_per_second
The sampling rate.
uint32_t
average_bytes_per_second
The number of bytes per second expected with this format.
uint16_t
block_alignment
Byte block alignment, e.g, 4.
uint16_t
bits_per_sample
The bit depth for the stream this represents, e.g. 8 or 16.
uint16_t
audio_specific_config_size
The size, in bytes, of the audio_specific_config.
int8_t
audio_specific_config[8]
The AudioSpecificConfig, as specified in ISO/IEC-14496-3, section 1.6.2.1: http://read.pudn.com/downloads98/doc/comm/401153/14496/ISO_IEC_14496-3%20Part%203%20Audio/C036083E_SUB1.PDF

SbMediaVideoSampleInfo

The set of information required by the decoder or player for each video sample.

Members

Members
bool
is_key_frame
Indicates whether the associated sample is a key frame (I-frame). Video key frames must always start with SPS and PPS NAL units.
int
frame_width
The frame width of this sample, in pixels. Also could be parsed from the Sequence Parameter Set (SPS) NAL Unit. Frame dimensions must only change on key frames, but may change on any key frame.
int
frame_height
The frame height of this sample, in pixels. Also could be parsed from the Sequence Parameter Set (SPS) NAL Unit. Frame dimensions must only change on key frames, but may change on any key frame.

Functions

SbMediaCanPlayMimeAndKeySystem

Description

Returns information about whether the playback of the specific media described by mime and encrypted using key_system can be played.
Note that neither mime nor key_system can be NULL. This function returns kSbMediaSupportNotSupported if either is NULL.

Declaration and definitions

SB_EXPORT SbMediaSupportType
SbMediaCanPlayMimeAndKeySystem(const char* mime, const char* key_system);

#include "starboard/media.h"

SbMediaSupportType SbMediaCanPlayMimeAndKeySystem(const char* mime,
                                                  const char* key_system) {
  return kSbMediaSupportTypeNotSupported;
}

Parameters

Parameters
const char*
mime
The mime information of the media in the form of video/webm or video/mp4; codecs="avc1.42001E". It may include arbitrary parameters like "codecs", "channels", etc.
const char*
key_system
A lowercase value in fhe form of "com.example.somesystem" as suggested by https://w3c.github.io/encrypted-media/#key-system that can be matched exactly with known DRM key systems of the platform. When key_system is an empty string, the return value is an indication for non-encrypted media.

SbMediaGetAudioConfiguration

Description

Retrieves the current physical audio configuration of audio output output_index on this device and places it in out_configuration, which must not be NULL.
This function returns false if nothing could be determined on this platform or if output_index does not exist on this device.

Declaration

SB_EXPORT bool SbMediaGetAudioConfiguration(
    int output_index,
    SbMediaAudioConfiguration* out_configuration);

Parameters

Parameters
int
output_index
SbMediaAudioConfiguration*
out_configuration
The variable that holds the audio configuration information.

SbMediaGetAudioOutputCount

Description

Returns the number of audio outputs currently available on this device. Even if the number of outputs or their audio configurations can't be determined, it is expected that the platform will at least return a single output that supports at least stereo.

Declaration

SB_EXPORT int SbMediaGetAudioOutputCount();

SbMediaIsAudioSupported

Description

Indicates whether this platform supports audio_codec at bitrate. If audio_codec is not supported under any condition, this function returns false.

Declaration

SB_EXPORT bool SbMediaIsAudioSupported(SbMediaVideoCodec audio_codec,
                                       int64_t bitrate);

Parameters

Parameters
SbMediaVideoCodec
audio_codec
The media's audio codec (SbMediaAudioCodec).
int64_t
bitrate
The media's bitrate.

SbMediaIsOutputProtected

Description

Indicates whether output copy protection is currently enabled on all capable outputs. If true, then non-protection-capable outputs are expected to be blanked.

Declaration and definitions

SB_EXPORT bool SbMediaIsOutputProtected();

#include "starboard/media.h"

#include "starboard/log.h"

bool SbMediaIsOutputProtected() {
  return false;
}

SbMediaIsSupported

Description

Indicates whether this platform supports decoding video_codec and audio_codec along with decrypting using key_system. If video_codec is kSbMediaVideoCodecNone or if audio_codec is kSbMediaAudioCodecNone, this function should return true as long as key_system is supported on the platform to decode any supported input formats.

Declaration and definitions

SB_EXPORT bool SbMediaIsSupported(SbMediaVideoCodec video_codec,
                                  SbMediaAudioCodec audio_codec,
                                  const char* key_system);

#include "starboard/media.h"

SB_EXPORT bool SbMediaIsSupported(SbMediaVideoCodec /*video_codec*/,
                                  SbMediaAudioCodec /*audio_codec*/,
                                  const char* /*key_system*/) {
  return false;
}

Parameters

Parameters
SbMediaVideoCodec
video_codec
The SbMediaVideoCodec being checked for platform compatibility.
SbMediaAudioCodec
audio_codec
The SbMediaAudioCodec being checked for platform compatibility.
const char*
key_system
The key system being checked for platform compatibility.

SbMediaIsVideoSupported

Description

Indicates whether a given combination of (frame_width x frame_height) frames at bitrate and fps is supported on this platform with video_codec. If video_codec is not supported under any condition, this function returns false.
Setting any of the parameters to 0 indicates that they shouldn't be considered.

Declaration

SB_EXPORT bool SbMediaIsVideoSupported(SbMediaVideoCodec video_codec,
                                       int frame_width,
                                       int frame_height,
                                       int64_t bitrate,
                                       int fps);

Parameters

Parameters
SbMediaVideoCodec
video_codec
The video codec used in the media content.
int
frame_width
The frame width of the media content.
int
frame_height
The frame height of the media content.
int64_t
bitrate
The bitrate of the media content.
int
fps
The number of frames per second in the media content.

SbMediaSetOutputProtection

Description

Enables or disables output copy protection on all capable outputs. If enabled, then non-protection-capable outputs are expected to be blanked.
The return value indicates whether the operation was successful, and the function returns a success even if the call is redundant in that it doesn't change the current value.

Declaration and definitions

SB_EXPORT bool SbMediaSetOutputProtection(bool enabled);

#include "starboard/media.h"

#include "starboard/log.h"

bool SbMediaSetOutputProtection(bool enabled) {
  return false;
}

Parameters

Parameters
bool
enabled
Indicates whether output protection is enabled (true) or disabled.