commit b43d09a3ddfbb8cb409c40c855531f1544b7f71c
parent ab15f9243df870d2643b2c31f6da896fe2adcec9
Author: Oliver Lowe <o@olowe.co>
Date: Tue, 14 May 2024 18:07:47 +1000
scte35: More documentation
Needed docs on value of TimeSignal as it was unclear whether it
represented a duration or a timestamp (technically it's both but
semantically it's a timestamp). And an example function!
Diffstat:
4 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/scte35/codec_test.go b/scte35/codec_test.go
@@ -0,0 +1,35 @@
+package scte35_test
+
+import (
+ "encoding/base64"
+ "fmt"
+
+ "github.com/untangledco/streaming/scte35"
+)
+
+func Example() {
+ msg := "/DA0AAAAAAAA///wBQb+cr0AUAAeAhxDVUVJSAAAjn/PAAGlmbAICAAAAAAsoKGKNAIAmsnRfg=="
+ b, err := base64.StdEncoding.DecodeString(msg)
+ if err != nil {
+ // handle error...
+ }
+ splice, err := scte35.DecodeSpliceInfo(b)
+ if err != nil {
+ // handle error...
+ }
+
+ dur := splice.Descriptors[0].(scte35.SegmentationDescriptor).Duration
+ fmt.Println(*dur)
+ *dur += 15 * 90000 // add 15 seconds as per 90KHz clock.
+ fmt.Println(*splice.Descriptors[0].(scte35.SegmentationDescriptor).Duration)
+
+ bb, err := scte35.EncodeSpliceInfo(splice)
+ if err != nil {
+ // handle error...
+ }
+ fmt.Println(base64.StdEncoding.EncodeToString(bb))
+
+ // Output: 27630000
+ // 28980000
+ // /DA0AAAAAAAA///wBQb+cr0AUAAeAhxDVUVJSAAAjn/PAAG6MyAICAAAAAAsoKGKNAIAQO/SuQ==
+}
diff --git a/scte35/command.go b/scte35/command.go
@@ -15,7 +15,9 @@ type Command struct {
Type CommandType
Schedule []Event // SpliceSchedule
Insert *Insert
- // Number of ticks of a 90KHz clock.
+ // Number of ticks of a 90KHz clock since midnight UTC.
+ // TODO(otl): use time.Time here instead,
+ // then calculate ticks when converting to wire format?
TimeSignal *uint64
Private *PrivateCommand
}
diff --git a/scte35/scte35_test.go b/scte35/scte35_test.go
@@ -168,5 +168,3 @@ var samples = []sample{
},
},
}
-
-func newuint64(i uint64) *uint64 { p := new(uint64); p = &i; return p }
diff --git a/scte35/splice_info.go b/scte35/splice_info.go
@@ -263,3 +263,5 @@ func decodeCommand(buf []byte) (*Command, error) {
}
return &cmd, nil
}
+
+func newuint64(i uint64) *uint64 { p := new(uint64); p = &i; return p }