layout: doc title: “Starboard Module Reference: drm.h”

Provides definitions that allow for DRM support, which are common between Player and Decoder interfaces.

Enums

SbDrmKeyStatus

Status of a particular media key. https://w3c.github.io/encrypted-media/#idl-def-MediaKeyStatus

Values

  • kSbDrmKeyStatusUsable
  • kSbDrmKeyStatusExpired
  • kSbDrmKeyStatusReleased
  • kSbDrmKeyStatusRestricted
  • kSbDrmKeyStatusDownscaled
  • kSbDrmKeyStatusPending
  • kSbDrmKeyStatusError

Structs

SbDrmKeyId

Members

SbDrmSampleInfo

All the optional information needed per sample for encrypted samples.

Members

SbDrmSubSampleMapping

A mapping of clear and encrypted bytes for a single subsample. All subsamples within a sample must be encrypted with the same encryption parameters. The clear bytes always appear first in the sample.

Members

SbDrmSystem

A handle to a DRM system which can be used with either an SbDecoder or a SbPlayer.

Functions

SbDrmCloseSession

Description

Clear any internal states/resources related to the specified session_id.

Declaration and definitions

#include "starboard/drm.h"

void SbDrmCloseSession(SbDrmSystem drm_system,
                       const void* session_id,
                       int session_id_size) {
  SB_UNREFERENCED_PARAMETER(drm_system);
  SB_UNREFERENCED_PARAMETER(session_id);
  SB_UNREFERENCED_PARAMETER(session_id_size);
}

Parameters

SbDrmCreateSystem

Declaration and definitions

#include "starboard/drm.h"

#if SB_API_VERSION >= 6

SbDrmSystem SbDrmCreateSystem(
    const char* key_system,
    void* context,
    SbDrmSessionUpdateRequestFunc update_request_callback,
    SbDrmSessionUpdatedFunc session_updated_callback,
    SbDrmSessionKeyStatusesChangedFunc key_statuses_changed_callback) {
  SB_UNREFERENCED_PARAMETER(context);
  SB_UNREFERENCED_PARAMETER(key_system);
  SB_UNREFERENCED_PARAMETER(update_request_callback);
  SB_UNREFERENCED_PARAMETER(session_updated_callback);
  SB_UNREFERENCED_PARAMETER(key_statuses_changed_callback);
  return kSbDrmSystemInvalid;
}

#else  // SB_API_VERSION >= 6

SbDrmSystem SbDrmCreateSystem(
    const char* key_system,
    void* context,
    SbDrmSessionUpdateRequestFunc update_request_callback,
    SbDrmSessionUpdatedFunc session_updated_callback) {
  SB_UNREFERENCED_PARAMETER(context);
  SB_UNREFERENCED_PARAMETER(key_system);
  SB_UNREFERENCED_PARAMETER(update_request_callback);
  SB_UNREFERENCED_PARAMETER(session_updated_callback);
  return kSbDrmSystemInvalid;
}

#endif  // SB_API_VERSION >= 6

Parameters

SbDrmDestroySystem

Description

Destroys drm_system, which implicitly removes all keys installed in it and invalidates all outstanding session update requests. A DRM system cannot be destroyed unless any associated SbPlayer or SbDecoder has first been destroyed.
All callbacks are guaranteed to be finished when this function returns. As a result, if this function is called from a callback that is passed to SbDrmCreateSystem(), a deadlock will occur.

Declaration and definitions

#include "starboard/drm.h"

void SbDrmDestroySystem(SbDrmSystem drm_system) {
  SB_UNREFERENCED_PARAMETER(drm_system);
}

Parameters

SbDrmGenerateSessionUpdateRequest

Description

Asynchronously generates a session update request payload for initialization_data, of initialization_data_size, in case sensitive type, extracted from the media stream, in drm_system's key system.
This function calls drm_system's update_request_callback function, which is defined when the DRM system is created by SbDrmCreateSystem. When calling that function, this function either sends context (also from SbDrmCreateSystem) and a populated request, or it sends NULL session_id if an error occurred.
drm_system's context may be used to route callbacks back to an object instance.
Callbacks may be called either from the current thread before this function returns or from another thread.

Declaration and definitions

#include "starboard/drm.h"

void SbDrmGenerateSessionUpdateRequest(SbDrmSystem /*drm_system*/,
                                       int /*ticket*/,
                                       const char* /*type*/,
                                       const void* /*initialization_data*/,
                                       int /*initialization_data_size*/) {
}

Parameters

SbDrmGetKeyCount

Description

Returns the number of keys installed in drm_system.

Declaration

SB_EXPORT int SbDrmGetKeyCount(SbDrmSystem drm_system);

Parameters

SbDrmGetKeyStatus

Description

Gets out_key, out_key_size, and out_status for the key with index in drm_system. Returns whether a key is installed at index. If not, the output parameters, which all must not be NULL, will not be modified.

Declaration

SB_EXPORT bool SbDrmGetKeyStatus(SbDrmSystem drm_system,
                                 const void* session_id,
                                 int session_id_size,
                                 int index,
                                 void** out_key,
                                 int* out_key_size,
                                 SbDrmKeyStatus* out_status);

Parameters

SbDrmRemoveAllKeys

Description

Removes all installed keys for drm_system. Any outstanding session update requests are also invalidated.

Declaration

SB_EXPORT void SbDrmRemoveAllKeys(SbDrmSystem drm_system);

Parameters

SbDrmSystemIsValid

Description

Indicates whether drm_system is a valid SbDrmSystem.

Declaration

static SB_C_FORCE_INLINE bool SbDrmSystemIsValid(SbDrmSystem drm) {
  return drm != kSbDrmSystemInvalid;
}

Parameters

SbDrmTicketIsValid

Description

Indicates whether ticket is a valid ticket.

Declaration

static SB_C_FORCE_INLINE bool SbDrmTicketIsValid(int ticket) {
  return ticket != kSbDrmTicketInvalid;
}

Parameters

SbDrmUpdateSession

Description

Update session with key, in drm_system's key system, from the license server response. Calls session_updated_callback with context and whether the update succeeded. context may be used to route callbacks back to an object instance.
ticket is the opaque ID that allows to distinguish callbacks from multiple concurrent calls to SbDrmUpdateSession(), which will be passed to session_updated_callback as-is. It is the responsibility of the caller to establish ticket uniqueness, issuing multiple calls with the same ticket may result in undefined behavior.
Once the session is successfully updated, an SbPlayer or SbDecoder associated with that DRM key system will be able to decrypt encrypted samples.
drm_system's session_updated_callback may called either from the current thread before this function returns or from another thread.

Declaration and definitions

#include "starboard/drm.h"

void SbDrmUpdateSession(SbDrmSystem /*drm_system*/,
                        int /*ticket*/,
                        const void* /*key*/,
                        int /*key_size*/,
                        const void* /*session_id*/,
                        int /*session_id_size*/) {
}

Parameters