streaming

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

commit bf20623811837382195b3c2fb8dca039caf0478a
parent b42f3743957c915b7d3f33a3d80f94f95fe1bedf
Author: Oliver Lowe <o@olowe.co>
Date:   Tue, 14 May 2024 13:54:03 +1000

internal/scte35: implement DTMFDescriptor decoding

Diffstat:
Minternal/scte35/splice_descriptor.go | 21++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/internal/scte35/splice_descriptor.go b/internal/scte35/splice_descriptor.go @@ -76,6 +76,14 @@ func (d DTMFDescriptor) Data() []byte { return b } +func unmarshalDTMF(buf []byte) DTMFDescriptor { + // skip buf[1]; contains the length which we don't care about when using slices. + return DTMFDescriptor{ + Preroll: uint8(buf[0]), + Chars: buf[2:], + } +} + type DeliveryRestrictions uint8 const ( @@ -142,8 +150,11 @@ func (d SegmentationDescriptor) Data() []byte { switch d.Type { // TODO(otl): use named constants from section 10.3.3.1 Table 23 - segmentation_type_id case 0x34, 0x30, 0x32, 0x36, 0x38, 0x3a, 0x44, 0x46: - if d.Expected > 0 { - buf = append(buf, d.SubNumber, d.SubExpected) + if d.SubNumber > 0 { + buf = append(buf, d.SubNumber) + } + if d.SubExpected > 0 { + buf = append(buf, d.SubExpected) } } } @@ -193,8 +204,10 @@ func unmarshalSegDescriptor(buf []byte) SegmentationDescriptor { switch desc.Type { // TODO(otl): use named constants from section 10.3.3.1 Table 23 - segmentation_type_id case 0x34, 0x30, 0x32, 0x36, 0x38, 0x3a, 0x44, 0x46: - if desc.Expected > 0 { + if len(buf[2:]) > 1 { desc.SubNumber = uint8(buf[3]) + } + if len(buf[2:]) > 2 { desc.SubExpected = uint8(buf[4]) } } @@ -336,6 +349,8 @@ func UnmarshalSpliceDescriptor(buf []byte) (SpliceDescriptor, error) { return AvailDescriptor(binary.BigEndian.Uint32(buf)), nil case TagSegmentation: return unmarshalSegDescriptor(buf), nil + case TagDTMF: + return unmarshalDTMF(buf), nil } return nil, fmt.Errorf("unmarshal %d unsupported", tag) }