MediaCapabilitiesProber

Overview

The MediaCapabilitiesProber is a tool probing what your browser can do, especially:

  • Which DRM system is supported

  • Check for HDCP support

  • which codecs are available

  • Check the color space support

⚠️ This tool is still in an experimental phase, meaning that its API can change at any new release. This is not because it is not stable (it is actually) or should not be used in production. This is just because we want to receive your feedbacks before locking definitely the API.

We can for example add supplementary informations of even explode the MediaCapabilitiesProber into several tools to lower the size of the import. We’re waiting for your feedbacks!

How to use it

As an experimental tool, the MediaCapabilitiesProber won’t be included in a default RxPlayer build.

Instead, it should be imported by adding the RxPlayer through a dependency trough the npm registry (e.g. by doing something like npm install rx-player) and then specifically importing this tool from "rx-player/experimental/tools":

import { mediaCapabilitiesProber } from "rx-player/experimental/tools";

mediaCapabilitiesProber.getStatusForHDCP("1.1")
  .then((hdcp11Status) => {
    if (hdcp11Status === "Supported") {
      console.log("HDCP 1.1 is supported");
    }
  });

Properties

LogLevel

type: string

default: "WARNING"

The current level of verbosity for this prober logs. Those logs all use the console.

From the less verbose to the most:

  • "NONE": no log

  • "ERROR": unexpected errors (via console.error)

  • "WARNING": The previous level + minor problems encountered (via console.warn)

  • "INFO": The previous levels + noteworthy events (via console.info)

  • "DEBUG": The previous levels + normal events of the prober (via console.log)

If the value set to this property is different than those, it will be automatically set to "NONE".

It is set to "WARNING" by default as it allows you to know if you forgot to set required informations on each APIs, if some APIs are missing in your browser, etc.

You might want to set it to "NONE" when in production.

Example

import { mediaCapabilitiesProber } from "rx-player/experimental/tools";
mediaCapabilitiesProber.LogLevel = "NONE";

Functions

isDRMSupported

arguments:

  • type (string): DRM reverse domain name, identifying the keySystem in the browser.

  • configuration (Object|undefined): MediaKeySystemConfiguration for this key system as defined in the EME w3c specification

return value: boolean

Probe for DRM support. The returned boolean is:

  • true: This DRM configuration is supported.

  • false: The DRM configuration is not supported.

Example

import { mediaCapabilitiesProber } from "rx-player/experimental/tools";

mediaCapabilitiesProber.isDRMSupported("com.widevine.alpha", {
  persistentState: "required"
}).then((hasWidevineWithPersistentState) => {
  if (hasWidevineWithPersistentState) {
    console.log("This DRM configuration is supported");
  } else {
    console.log("This DRM configuration is not supported");
  }
});

getStatusForHDCP

arguments:

  • type (string): The HDCP type (e.g. “1.0”, “1.1” or “2.0”)

return value: string

Test for an HDCP configuration.

The returned string of this function is either:

  • "Supported": This HDCP configuration is supported.

  • "NotSupported": The HDCP configuration is not supported.

  • "Unknown": The API is not available or it is but could not check if the HDCP type is supported.

⚠️ As of the 2018-july-03, this feature is very poorly supported (with only some support on the EDGE browser). We should have a real support of it in the coming months on Chrome and Firefox.

Example

import { mediaCapabilitiesProber } from "rx-player/experimental/tools";

mediaCapabilitiesProber.getStatusForHDCP("1.1")
  .then((hdcpStatus) => {
    switch (hdcpStatus) {
      case "Supported":
        console.log("This HDCP version is supported");
        break;

      case "NotSupported":
        console.log("This HDCP version is not supported");
        break;

      case "Unknown":
        console.log("We could'nt tell if this HDCP version is supported.");
        break;
    }
  });

getDecodingCapabilities

arguments:

  • config (Object): Object with type, video and audio configuration.

return value: string

Probe for audio/video decoding capabilities.

Argument

The object in argument is inspired from the concerned API configurations. All its properties are optional, here are what you can set.

  • type (string): The media is either buffered in MediaSource, or directly as a file. As such, you can specify which one you want to probe through one of the following strings:

    • “media-source”
    • “file”.
  • video (Object): The video capabilities you want to probe.

    • contentType (string): Media codec in mimeType format.
    • width (number): Video width.
    • height (number): Video Height.
    • bitrate (number): Bitrate of the video (in bits per second).
    • framerate (string): Number of frames used in one second.
    • bitsPerComponent (number): Number of bits used to encode one component par pixel.
  • audio (Object): The video capabilities you want to probe.

    • contentType (string): Media codec in mimeType format.
    • channels (string): Audio channels used by the track.
    • bitrate (number): Bitrate from stream (bits/second).
    • samplerate (number): Number of samples of audio carried per second.

Return value

The returned string of this function is either:

  • "Supported": This configuration is supported.

  • "MaybeSupported": Some set configuration could not be probed because not enough information was provided, but what has been probed is supported.

  • "NotSupported": The configuration is not supported.

Example

import { mediaCapabilitiesProber } from "rx-player/experimental/tools";

mediaCapabilitiesProber.getDecodingCapabilities({
  type: "media-source",
  video: {
    contentType: "video/webm; codecs=\"vp09.00.10.08\"",
    width: 1920,
    height: 1080,
    bitrate: 3450000,
    framerate: '25',
    bitsPerComponent: 8,
  },
  audio: {
    contentType: "audio/webm; codecs=\"opus\"",
    channels: 6,
    bitrate: 1200,
    samplerate: 44100,
  },
}).then((status) => {
  switch (status) {
    case "Supported":
      console.log("The configuration is supported");
      break;

    case "MaybeSupported":
      console.log("The configuration may be supported");
      break;

    case "NotSupported":
      console.log("The configuration is not supported");
      break;
  }
});

getDisplayCapabilities

arguments:

  • config (Object): Object with display configuration.

return value: string

Probe what can be displayed on the screen.

Argument

The object in argument is inspired from the concerned API configurations. All its properties are optional, here are what you can set.

  • colorSpace (string): Wanted color space (“srgb”, “p3”, etc).
  • width (number): Wanted display horizontal resolution.
  • height (number): Wanted display vertical resolution.
  • bitsPerComponent (number): Wanted display bpc capability.

Return Value

The returned string of this function is either:

  • "Supported": This configuration is supported.

  • "MaybeSupported": Some set configuration could not be probed because not enough information was provided, but what has been probed is supported.

  • "NotSupported": The configuration is not supported.

Example

import { mediaCapabilitiesProber } from "rx-player/experimental/tools";

mediaCapabilitiesProber.getDisplayCapabilities({
  colorSpace: "p3",
  width: 3840,
  height: 2160,
  bitsPerComponent: 10,
}).then((status) => {
  switch (status) {
    case "Supported":
      console.log("The configuration is supported");
      break;

    case "MaybeSupported":
      console.log("The configuration may be supported");
      break;

    case "NotSupported":
      console.log("The configuration is not supported");
      break;
  }
});

Exploited browser APIs

The tool probes media capabilities from browsers (Chrome, Firefox, etc.) exploiting current available media API: