Giter VIP home page Giter VIP logo

cuei's People

Contributors

futzu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cuei's Issues

JSON-and-Encode always use "AvailDescriptor.Identifier=CUEI" value even if setter or json static string is modified.

Example app JSON-and-Encode does not use .Identifier="TEST" or .Identifier="" setter? Value is always CUEI string, if providing an empty string my thinking was field could also be skipped in a binary output?
https://github.com/futzu/cuei#load-json-and-encode

Online scte parser for debug use: https://www.middleman.tv/scte35-parser

disclaimer: I don't have a deep knowledge of .Identifer field, I have not seen it other scte35 examples.

Example output:
/DAvAAAAAAAAAAFgFAUAAABvf+/+AAHd5v4AUmXA//8BAgAKAAhDVUVJAAABTDVM1CE=

Example app:

package main

import (
	"fmt"
	"github.com/futzu/cuei"
)

func main() {

	js := `{
    "InfoSection": {
        "Name": "Splice Info Section",
        "TableID": "0xfc",
        "SectionSyntaxIndicator": false,
        "Private": false,
        "ProtocolVersion": 0,
        "EncryptedPacket": false,
        "EncryptionAlgorithm": 0,
        "PtsAdjustment": 0,
        "CwIndex": "0x00",
        "Tier": "0x16",
        "CommandType": 5
    },
    "Command": {
        "Name": "Splice Insert",
        "CommandType": 5,
        "SpliceEventID": 1,
        "OutOfNetworkIndicator": true,
        "ProgramSpliceFlag": true,
        "TimeSpecifiedFlag": true,
        "PTS": 0.0
    },
    "Descriptors": [
        {
            "Name": "Avail Descriptor"
        }
    ]
}
`
	cue :=  cuei.Json2Cue(js)	
	cue.AdjustPts(0.0)                      // 0..N seconds(float) pts adjustment
	cue.Command.PTS            = 1.359355   // 0..N seconds(float)
	cue.Command.AvailNum       = 1
	cue.Command.AvailExpected  = 2
	cue.Command.DurationFlag   = true       // write BreakDuration+AutoReturn fields
	cue.Command.BreakAutoReturn= true
	cue.Command.BreakDuration  = 60   // 0..N seconds
	cue.Command.UniqueProgramID= 65535
	cue.Command.SpliceEventID  = 111   // 111 or 222 or any 0..N value
	cue.Descriptors[0].ProviderAvailID=332
	
	fmt.Println("\nBytes:\n\t", cue.Encode())	// Bytes	
	fmt.Println("\nBase64:\n\t",cue.Encode2B64())  	// Base64	
	fmt.Println("\nHex:\n\t",cue.Encode2Hex()) 	// Hex
}

edit: edited example for more common default values for clarity.

Slice bounds out of range

When parsing certain SCTE-35 cues I get a panic:

panic: runtime error: slice bounds out of range [:408] with length 400

goroutine 1 [running]:
github.com/futzu/cuei.(*bitDecoder).chunk(0x14000118e40, 0x8)
        /Users/oleksiitorunov/go/pkg/mod/github.com/futzu/[email protected]/bitter.go:27 +0xac
github.com/futzu/cuei.(*bitDecoder).uInt64(0x10426bc20?, 0x14000120240?)
        /Users/oleksiitorunov/go/pkg/mod/github.com/futzu/[email protected]/bitter.go:55 +0x1c
github.com/futzu/cuei.(*bitDecoder).uInt8(...)
        /Users/oleksiitorunov/go/pkg/mod/github.com/futzu/[email protected]/bitter.go:34
github.com/futzu/cuei.(*Descriptor).decodeSegmentation(0x14000118d30, 0x14000118e40)
        /Users/oleksiitorunov/go/pkg/mod/github.com/futzu/[email protected]/descriptors.go:211 +0x144
github.com/futzu/cuei.(*Descriptor).segmentationDescriptor(0x14000118d30, 0x14000118e40, 0xb8?, 0x8c?)
        /Users/oleksiitorunov/go/pkg/mod/github.com/futzu/[email protected]/descriptors.go:165 +0x118
github.com/futzu/cuei.(*Descriptor).decode(0x0?, 0x2?, 0x0?, 0x0?)
        /Users/oleksiitorunov/go/pkg/mod/github.com/futzu/[email protected]/descriptors.go:91 +0x8c
github.com/futzu/cuei.(*Cue).dscptrLoop(0x1400012e040, 0x19, 0x14000118e40)
        /Users/oleksiitorunov/go/pkg/mod/github.com/futzu/[email protected]/cue.go:77 +0xc8
github.com/futzu/cuei.(*Cue).decodeBytes(0x1400012e040, {0x14000128040?, 0x14000118ea8?, 0x1?})
        /Users/oleksiitorunov/go/pkg/mod/github.com/futzu/[email protected]/cue.go:58 +0xdc
github.com/futzu/cuei.(*Cue).Decode(0x1400012e040, {0x104266f40?, 0x14000118f18?})
        /Users/oleksiitorunov/go/pkg/mod/github.com/futzu/[email protected]/cue.go:40 +0x104

The cue I'm attempting to decode: /DA0AAAAAAAAAAAABQb/UN6ZgAAZAhdDVUVJAIdqN3/TAAApMXgICNP3GiIAAL/Pk3w=

Decoding it like this:

c := cuei.NewCue()
ok := c.Decode("/DA0AAAAAAAAAAAABQb/UN6ZgAAZAhdDVUVJAIdqN3/TAAApMXgICNP3GiIAAL/Pk3w=")
if !ok {
    fmt.Println("failed to decode")
    os.Exit(1)
}

It's worth mentioning that I encoded this cue myself. So I believe it's the encoding that doesn't function properly. For example, if I decode a cue and then encode it again without changing any of its fields I get a somewhat different cue:

c := cuei.NewCue()
ok := c.Decode("/DA0AAAAAAAAAAAABQaB4zZ7tQAeAhxDVUVJAA6GjwDQAAESy7EICAAAAAAA0/cuIgAAXljZSQ==")
if !ok {
    fmt.Println("failed to decode")
    os.Exit(1)
}

fmt.Println(c.Encode2B64()) // Prints "/DA0AAAAAAAAAAAABQb/4zZ7tQAZAhdDVUVJAA6Gj3/TAAESy7EICNP3LiIAALikDmY="

And then it panics when I try to decode the resulting cue.

Can you take a look into it?

Thanks!

Segmentation Descriptors missing

When parsing the following B64:

/DByAAAAAAAAAv/wBQb+AAAAAABcAhRDVUVJUwIu0X/fAAApTwAAACIAAAIWQ1VFSSxMdth/3wAAKU8AAAA0AAAAAAIWQ1VFSRH5kzZ/3wAAKU8AAAA2AAAAAAIUQ1VFSUWu4aR/3wAAKU8AAAAwAADzsyAa

I only see segmentation_type_id 34 and 52. 54 and 48 are missing.

{ "InfoSection": { "Name": "Splice Info Section", "TableID": "0xfc", "SectionSyntaxIndicator": false, "Private": false, "Reserved": "0x3", "SectionLength": 114, "ProtocolVersion": 0, "EncryptedPacket": false, "EncryptionAlgorithm": 0, "PtsAdjustment": 0, "CwIndex": "0x2", "Tier": "0xfff", "CommandLength": 5, "CommandType": 6 }, "Command": { "Name": "Time Signal", "CommandType": 6, "TimeSpecifiedFlag": true }, "DescriptorLoopLength": 92, "Descriptors": [ { "Tag": 2, "Length": 20, "Identifier": "CUEI", "Name": "Segmentation Descriptor", "SegmentationEventID": "0x53022ed1", "ProgramSegmentationFlag": true, "SegmentationDurationFlag": true, "WebDeliveryAllowedFlag": true, "NoRegionalBlackoutFlag": true, "ArchiveAllowedFlag": true, "DeviceRestrictions": "No Restrictions", "SegmentationDuration": 30.08, "SegmentationMessage": "Break Start", "SegmentationTypeID": 34 }, { "Tag": 2, "Length": 22, "Identifier": "CUEI", "Name": "Segmentation Descriptor", "SegmentationEventID": "0x2c4c76d8", "ProgramSegmentationFlag": true, "SegmentationDurationFlag": true, "WebDeliveryAllowedFlag": true, "NoRegionalBlackoutFlag": true, "ArchiveAllowedFlag": true, "DeviceRestrictions": "No Restrictions", "SegmentationDuration": 30.08, "SegmentationMessage": "Provider Placement Opportunity Start", "SegmentationTypeID": 52 }, { "Identifier": "\u0002\u0016CU", "Name": "Avail Descriptor", "ProviderAvailID": 1162416633 }, {} ], "Crc32": 2145320960 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.