streaming

Media streaming and broadcast systems in Go
Log | Files | Refs | README | LICENSE

commit 56d4eb83f43bc68a7e15eb6505d26ee870457933
parent d3eae7cf0fe96700836a1211241e76d7c25b1ee4
Author: Oliver Lowe <o@olowe.co>
Date:   Sat, 11 May 2024 19:45:19 +1000

internal/scte35: rename EncryptionAlgorithm to Cipher

Lots of verbiage for no more detail or clarity!

Diffstat:
Minternal/scte35/encrypted_packet.go | 2+-
Minternal/scte35/encrypted_packet_test.go | 6+++---
Minternal/scte35/splice_info.go | 14+++++++-------
Minternal/scte35/splice_info_test.go | 4++--
4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/internal/scte35/encrypted_packet.go b/internal/scte35/encrypted_packet.go @@ -3,7 +3,7 @@ package scte35 -// cipher is a 6-bit field specifying the algorithm used to encrypt +// Cipher is a 6-bit field specifying the algorithm used to encrypt // payloads as defined in SCTE 35 section 11.3. type Cipher uint8 diff --git a/internal/scte35/encrypted_packet_test.go b/internal/scte35/encrypted_packet_test.go @@ -9,11 +9,11 @@ func TestPackEncryption(t *testing.T) { } var tests = []ptest{ { - sis: SpliceInfo{Encrypted: true, EncryptionAlgorithm: DES_CBC}, + sis: SpliceInfo{Encrypted: true, Cipher: DES_CBC}, want: 0b10000100, }, { - sis: SpliceInfo{Encrypted: true, EncryptionAlgorithm: TripleDES}, + sis: SpliceInfo{Encrypted: true, Cipher: TripleDES}, want: 0b10000110, }, } @@ -22,7 +22,7 @@ func TestPackEncryption(t *testing.T) { if tt.sis.Encrypted { b |= (1 << 7) } - b |= byte(tt.sis.EncryptionAlgorithm) << 1 + b |= byte(tt.sis.Cipher) << 1 if b != tt.want { t.Errorf("pack encryption info %v: got %08b, want %08b", tt.sis, b, tt.want) } diff --git a/internal/scte35/splice_info.go b/internal/scte35/splice_info.go @@ -32,9 +32,9 @@ func (t SAPType) String() string { } type SpliceInfo struct { - SAPType SAPType - Encrypted bool - EncryptionAlgorithm Cipher + SAPType SAPType + Encrypted bool + Cipher Cipher // Holds a 33-bit unsigned integer representing the number of ticks of a 90KHz clock. PTSAdjustment uint64 CWIndex uint8 @@ -81,11 +81,11 @@ func encodeSpliceInfo(sis *SpliceInfo) ([]byte, error) { if sis.Encrypted { buf[4] |= (1 << 7) } - if sis.EncryptionAlgorithm > maxCipher { - return nil, fmt.Errorf("encryption algorithm %d larger than max value %d", sis.EncryptionAlgorithm, maxCipher) + if sis.Cipher > maxCipher { + return nil, fmt.Errorf("encryption algorithm %d larger than max value %d", sis.Cipher, maxCipher) } // pack 6-bit cipher into next 6. Keep 1 bit for PTSAdjustment. - buf[4] |= byte(sis.EncryptionAlgorithm) << 1 + buf[4] |= byte(sis.Cipher) << 1 pts := toPTS(sis.PTSAdjustment) buf[4] |= pts[0] buf = append(buf, pts[1:]...) @@ -151,7 +151,7 @@ func decodeSpliceInfo(buf []byte) (*SpliceInfo, error) { if buf[1]&0b10000000 == 1 { info.Encrypted = true // right-most bit is used by PTSAdjustment. - info.EncryptionAlgorithm = Cipher(buf[1] & 0b01111110) + info.Cipher = Cipher(buf[1] & 0b01111110) } pts := make([]byte, 8) diff --git a/internal/scte35/splice_info_test.go b/internal/scte35/splice_info_test.go @@ -22,8 +22,8 @@ func diffInfo(a, b SpliceInfo) string { if a.SAPType != b.SAPType { fmt.Fprintf(buf, "SAP type = %s, %s\n", a.SAPType, b.SAPType) } - if a.EncryptionAlgorithm != b.EncryptionAlgorithm { - fmt.Fprintln(buf, "cipher = ", a.EncryptionAlgorithm, b.EncryptionAlgorithm) + if a.Cipher != b.Cipher { + fmt.Fprintln(buf, "cipher = ", a.Cipher, b.Cipher) } if a.PTSAdjustment != b.PTSAdjustment { fmt.Fprintln(buf, "pts adjustment = ", a.PTSAdjustment, b.PTSAdjustment)