Class: PsshBox::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/pssh_box/builder.rb

Class Method Summary collapse

Class Method Details

.build_pssh_box(pssh_version, system_id, pssh_data, key_ids = []) ⇒ Object

Build a PSSH box using the given parameters. The logic in this method is based on the PSSH implementation at: github.com/google/shaka-packager/tree/master/packager/tools/pssh.

Params:

  • pssh_version: 0 or 1; for version 1, the key IDs will be included in the PSSH box.

  • system_id: the DRM provider system ID

  • pssh_data: a byte array containing the DRM-specific data (e.g. an encoded protocol buffer for Widevine, or a WRMHEADER for PlayReady)

  • key_ids: the key IDs to be included in a version 1 box; ignored for version 0 boxes.



14
15
16
17
18
19
20
21
22
# File 'lib/pssh_box/builder.rb', line 14

def self.build_pssh_box(pssh_version, system_id, pssh_data, key_ids = [])
  unless pssh_version == 0 || pssh_version == 1
    raise ArgumentError, "PSSH version #{pssh_version} is not supported; allowed values are 0 and 1."
  end

  pssh_bytes = build_pssh_bytes(key_ids, pssh_data, pssh_version, system_id)

  base64_encode_bytes(pssh_bytes)
end