widevine

package module
v0.0.0-...-b4496f3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2021 License: MIT Imports: 15 Imported by: 0

README

Widevine

Golang Client API for Widevine Cloud.

https://godoc.org/github.com/alfg/widevine

Unittest GoDoc

Install

go get github.com/alfg/widevine

Usage

Generating license keys
// Set Widevine options and create instance.
options := widevine.Options{
    Key:      []byte{key},     // Your Widevine Key as a byte array.
    IV:       []byte{iv},      // Your Widevine IV as a byte array.
    Provider: "widevine_test", // Your Widevine Provider/Portal.
}

// Create the Widevine instance.
wv := widevine.New(options)

// Your video content ID, usually a GUID.
contentID := "testing"

// Set policy options.
policy := widevine.Policy{
    ContentID: contentID,
    Tracks:    []string{"SD", "HD", "AUDIO"},
    DRMTypes:  []string{"WIDEVINE"},
    Policy:    "default",
}

// Make the request to generate or get a content key.
resp := wv.GetContentKey(contentID, policy)

// Response data from Widevine Cloud.
fmt.Println("status: ", resp.Status)
fmt.Println("drm: ", resp.DRM)
for _, v := range resp.Tracks {
    fmt.Println("key_id: ", v.KeyID)
    fmt.Println("type: ", v.Type)
    fmt.Println("drm_type: ", v.PSSH[0].DRMType)
    fmt.Println("data: ", v.PSSH[0].Data)
}
fmt.Println("already_used: ", resp.AlreadyUsed)
License Proxy

You can also use this package to create a license proxy.

See: examples/proxy

Examples

See: examples

Develop

TODO

protoc.exe --go_out=. *.proto

TODO

  • External Keys
  • Custom PSSH API
  • Tests
  • More error handling
  • Implement more Widevine features

Resources

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crypto

type Crypto struct {
	Key []byte
	IV  []byte
}

Crypto struct.

func NewCrypto

func NewCrypto(key []byte, iv []byte) *Crypto

NewCrypto creates a Crypto instance with key and iv.

type GetContentKeyResponse

type GetContentKeyResponse struct {
	Status      string   `json:"status"`
	DRM         []drm    `json:"drm"`
	Tracks      []tracks `json:"tracks"`
	AlreadyUsed bool     `json:"already_used"`
}

GetContentKeyResponse JSON response from Widevine Cloud. /cenc/getcontentkey/<provider>

type GetLicenseResponse

type GetLicenseResponse struct {
	Status                     string            `json:"status"`
	License                    string            `json:"license"`
	Make                       string            `json:"make"`
	Model                      string            `json:"model"`
	SecurityLevel              int               `json:"security_level"`
	InternalStatus             int               `json:"internal_status"`
	DRMCertSerialNumber        string            `json:"drm_cert_serial_number"`
	DeviceWhitelistState       string            `json:"device_whitelist_state"`
	MessageType                string            `json:"message_type"`
	Platform                   string            `json:"platform"`
	DeviceState                string            `json:"device_state"`
	ClientMaxHDCPVersion       string            `json:"client_max_hdcp_version"`
	PlatformVerificationStatus string            `json:"platform_verification_status"`
	ContentOwner               string            `json:"content_owner"`
	ContentPRovider            string            `json:"content_provider"`
	SessionState               sessionState      `json:"session_state"`
	LicenseMetadata            licenseMetadata   `json:"license_metadata"`
	SupportedTracks            []supportedTracks `json:"supported_tracks"`
	PSSHData                   psshData          `json:"pssh_data"`
	ClientInfo                 []clientInfo      `json:"client_info"`
}

GetLicenseResponse decoded JSON response from Widevine Cloud. /cenc/getlicense

type HTTPClient

type HTTPClient struct {
	*http.Client
}

HTTPClient defines an HTTP client.

func NewClient

func NewClient() (*HTTPClient, error)

NewClient creates an HTTPClient instance.

type Options

type Options struct {
	Key      []byte
	IV       []byte
	Provider string
	URL      string
}

Options provided to Widevine{} instance.

type Policy

type Policy struct {
	ContentID string
	Tracks    []string
	DRMTypes  []string
	Policy    string
}

Policy struct to set policy options for a ContentKey request.

type Widevine

type Widevine struct {
	Key      []byte
	IV       []byte
	Provider string
	URL      string
}

Widevine structure.

func New

func New(opts Options) *Widevine

New returns a Widevine instance with options.

func (*Widevine) GetContentKey

func (wp *Widevine) GetContentKey(contentID string, policy Policy) GetContentKeyResponse

GetContentKey creates a content key giving a contentID.

func (*Widevine) GetLicense

func (wp *Widevine) GetLicense(contentID string, body string) GetLicenseResponse

GetLicense creates a license request used with a proxy server.

Directories

Path Synopsis
examples
Package proto is a generated protocol buffer package.
Package proto is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL