mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Add DASH streams for VP9 transcoding (#3275)
This commit is contained in:
41
vendor/github.com/zencoder/go-dash/v3/mpd/pssh.go
generated
vendored
Normal file
41
vendor/github.com/zencoder/go-dash/v3/mpd/pssh.go
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
package mpd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func MakePSSHBox(systemID, payload []byte) ([]byte, error) {
|
||||
if len(systemID) != 16 {
|
||||
return nil, fmt.Errorf("SystemID must be 16 bytes, was: %d", len(systemID))
|
||||
}
|
||||
|
||||
psshBuf := &bytes.Buffer{}
|
||||
size := uint32(12 + 16 + 4 + len(payload)) // 3 uint32s, systemID, "pssh" string and payload
|
||||
if err := binary.Write(psshBuf, binary.BigEndian, size); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := binary.Write(psshBuf, binary.BigEndian, []byte("pssh")); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := binary.Write(psshBuf, binary.BigEndian, uint32(0)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := psshBuf.Write(systemID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := binary.Write(psshBuf, binary.BigEndian, uint32(len(payload))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := psshBuf.Write(payload); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return psshBuf.Bytes(), nil
|
||||
}
|
||||
Reference in New Issue
Block a user