[go: up one dir, main page]

Skip to content

Commit

Permalink
custom pssh
Browse files Browse the repository at this point in the history
  • Loading branch information
alfg committed Jun 12, 2017
1 parent 07301d5 commit 6ef193e
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Widevine
Golang Client API and License Proxy for Widevine.

## Protobuf
`protoc.exe --go_out=. *.proto`

## Resources
* https://www.widevine.com/product_news.html
* https://storage.googleapis.com/wvdocs/Widevine_DRM_Getting_Started.pdf
Expand Down
16 changes: 15 additions & 1 deletion license.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package widevine
import (
"encoding/base64"
"encoding/json"
"fmt"

"github.com/alfg/widevine/pssh"
"github.com/golang/protobuf/proto"
)

const (
Expand Down Expand Up @@ -59,10 +63,20 @@ func New(opts Options) *Widevine {
func (wp *Widevine) GetContentKey(contentID string) GetContentKeyResponse {
msg := wp.buildMessage(contentID)
resp := wp.sendRequest(msg)

enc := wp.buildPSSH(contentID)
fmt.Println("pssh build:", enc)
return resp
}

func buildRequest() {
func (wp *Widevine) buildPSSH(contentID string) string {
wvpssh := &pssh.WidevineCencHeader{
Provider: proto.String(wp.Provider),
ContentId: []byte(contentID),
}
p, _ := proto.Marshal(wvpssh)

return base64.StdEncoding.EncodeToString(p)
}

func (wp *Widevine) buildMessage(contentID string) map[string]interface{} {
Expand Down
200 changes: 200 additions & 0 deletions pssh/WidevineCencHeader.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions pssh/WidevineCencHeader.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
syntax = "proto2";
package pssh;

message WidevineCencHeader {
enum Algorithm {
UNENCRYPTED = 0;
AESCTR = 1;
}
optional Algorithm algorithm = 1;
repeated bytes key_id = 2;

// Content provider name.
optional string provider = 3;

// A content identifier, specificed by content provider.
optional bytes content_id = 4;

// Track type. Acceptable values are SD, HD, and AUDIO. Used to
// differentiate content keys used by an asset.
optional string track_type_deprecated = 5;

// The name of a registered policy to be used for this asset.
optional string policy = 6;

// Crypto period index, for media using key rotation.
optional uint32 crypto_period_index = 7;

// Optional protected context for group content. The grouped_license is a
// serialized SignedMessage.
optional bytes grouped_license = 8;

// Protection scheme identifying the encryption algorithm.
// Represented as one of the following 4CC values:
// 'cenc' (AES­CTR), 'cbc1' (AES­CBC),
// 'cens' (AES­CTR subsample), 'cbcs' (AES­CBC subsample).
optional uint32 protection_scheme = 9;

// Optional. For media using key rotation, this represents the duration
// of each crypto period in seconds.
optional uint32 crypto_period_seconds = 10;
}

0 comments on commit 6ef193e

Please sign in to comment.