streaming

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

commit 25eae1eaba327961f34375c0d948debc21e1f021
parent 7641bd0d9aeb83e2e02c11d1e22b0699ba00bc49
Author: Oliver Lowe <o@olowe.co>
Date:   Wed,  1 May 2024 13:20:39 +1000

interrnal/scte35: import changes from our scte35-go

Diffstat:
Ainternal/scte35/LICENSE.ISC | 13+++++++++++++
Dinternal/scte35/README | 7-------
Ainternal/scte35/README.md | 23+++++++++++++++++++++++
Minternal/scte35/encrypted_packet.go | 72+++++++++++++++++++++++++++++++++---------------------------------------
Minternal/scte35/splice_info_section.go | 2+-
Minternal/scte35/splice_insert.go | 10++++++++++
Dinternal/scte35/splice_time.go | 27---------------------------
7 files changed, 80 insertions(+), 74 deletions(-)

diff --git a/internal/scte35/LICENSE.ISC b/internal/scte35/LICENSE.ISC @@ -0,0 +1,13 @@ +Copyright 2024 The Untangled Authors <o@olowe.co> + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/internal/scte35/README b/internal/scte35/README @@ -1,7 +0,0 @@ -This is an in-progress fork of github.com/comcast/scte35-go@v1.4.5. -The goals are: - -- remove dependencies -- improve godoc with examples, idioms -- no contributor license agreement (CLA) -- ... diff --git a/internal/scte35/README.md b/internal/scte35/README.md @@ -0,0 +1,23 @@ +# scte35-go: ANSI/SCTE 35 Decoder/Encoder + +This repository is a fork of [github.com/Comcast/scte35-go@ba13aa8](https://github.com/Comcast/scte35-go) + +Notable differences from the original works are: + +- third party dependencies removed +- refactored test code + +## License + +Unless otherwise noted, this software is +Copyright 2021 Comcast Cable Communications Management, LLC +licensed under the Apache License, Version 2.0. +See NOTICE.md. + +Derivative work by The Untangled Authors is licensed under the ISC License. +See LICENSE.ISC. + +## Code of Conduct + +Contributors to this repository agree to the +[Contributor Covenant Code of Conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct/code_of_conduct.txt) diff --git a/internal/scte35/encrypted_packet.go b/internal/scte35/encrypted_packet.go @@ -1,56 +1,50 @@ -// Copyright 2021 Comcast Cable Communications Management, LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024 The Untangled Authors. Use of this source code is +// governed by the ISC license available in the LICENSE.ISC file. package scte35 const ( - // EncryptionAlgorithmNone is the encryption_algorithm for None. - EncryptionAlgorithmNone = 0 - // EncryptionAlgorithmDESECB is the encryption_algorithm for DES - ECB Mode. - EncryptionAlgorithmDESECB = 1 - // EncryptionAlgorithmDESCBC is the encryption_algorithm for DES - CBC Mode. - EncryptionAlgorithmDESCBC = 2 - // EncryptionAlgorithmTripleDES is the encryption_algorithm for Triple DES - // EDE3 - ECB Mode. - EncryptionAlgorithmTripleDES = 3 + EncryptionAlgorithmNone uint32 = iota + EncryptionAlgorithmDESECB + EncryptionAlgorithmDESCBC + EncryptionAlgorithmTripleDES ) -// EncryptedPacket contains the encryption details if this payload has been -// encrypted. +// EncryptedPacket represents payload encryption information. type EncryptedPacket struct { + // Specifies which cipher is used. + // See SCTE 35 section 11.3. EncryptionAlgorithm uint32 `xml:"encryptionAlgorithm,attr,omitempty" json:"encryptionAlgorithm,omitempty"` CWIndex uint32 `xml:"cwIndex,attr,omitempty" json:"cwIndex,omitempty"` } -// encryptionAlgorithmName returns the user-friendly encryption algorithm name -func (p *EncryptedPacket) encryptionAlgorithmName() string { - if p == nil { - return "No encryption" - } +// cipher is a 6-bit field specifying the algorithm used to encrypt +// payloads as defined in SCTE 35 section 11.3. +type cipher uint8 - switch p.EncryptionAlgorithm { - case EncryptionAlgorithmNone: - return "No encryption" - case EncryptionAlgorithmDESECB: +const ( + cipherNone cipher = iota + des_ECB // SCTE 35 section 11.3.1 + des_CBC // SCTE 35 section 11.3.2 + tripleDES // SCTE 35 section 11.3.3 + reserved + // Values 32 through 63 are available for "User private" + // algorithms. See SCTE 35 section 11.3.4. +) + +func (c cipher) String() string { + switch c { + case cipherNone: + return "none" + case des_ECB: return "DES – ECB mode" - case EncryptionAlgorithmDESCBC: + case des_CBC: return "DES – CBC mode" - case EncryptionAlgorithmTripleDES: + case tripleDES: return "Triple DES EDE3 – ECB mode" - default: - return "User private" } + if c >= reserved && c < 32 { + return "reserved" + } + return "user private" } diff --git a/internal/scte35/splice_info_section.go b/internal/scte35/splice_info_section.go @@ -264,7 +264,7 @@ func (sis *SpliceInfoSection) Table(prefix, indent string) string { t.row(1, "section_length", sis.sectionLength()) t.row(0, "}", nil) t.row(0, "protocol_version", sis.ProtocolVersion) - t.row(0, "encryption_algorithm", fmt.Sprintf("%d (%s)", sis.EncryptedPacket.EncryptionAlgorithm, sis.EncryptedPacket.encryptionAlgorithmName())) + t.row(0, "encryption_algorithm", fmt.Sprintf("%d (%s)", sis.EncryptedPacket.EncryptionAlgorithm, cipher(sis.EncryptedPacket.EncryptionAlgorithm))) t.row(0, "pts_adjustment", sis.PTSAdjustment) t.row(0, "cw_index", sis.EncryptedPacket.CWIndex) t.row(0, "tier", sis.Tier) diff --git a/internal/scte35/splice_insert.go b/internal/scte35/splice_insert.go @@ -319,3 +319,13 @@ type SpliceInsertProgram struct { func (p *SpliceInsertProgram) TimeSpecifiedFlag() bool { return p != nil && p.SpliceTime.PTSTime != nil } + +// SpliceTime specifies the time of the splice event. +type SpliceTime struct { + PTSTime *uint64 `xml:"ptsTime,attr" json:"ptsTime,omitempty"` +} + +// TimeSpecifiedFlag returns true if PTSTime is not nil. +func (t *SpliceTime) TimeSpecifiedFlag() bool { + return t != nil && t.PTSTime != nil +} diff --git a/internal/scte35/splice_time.go b/internal/scte35/splice_time.go @@ -1,27 +0,0 @@ -// Copyright 2021 Comcast Cable Communications Management, LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// SPDX-License-Identifier: Apache-2.0 - -package scte35 - -// SpliceTime specifies the time of the splice event. -type SpliceTime struct { - PTSTime *uint64 `xml:"ptsTime,attr" json:"ptsTime,omitempty"` -} - -// TimeSpecifiedFlag returns true if PTSTime is not nil. -func (t *SpliceTime) TimeSpecifiedFlag() bool { - return t != nil && t.PTSTime != nil -}