Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scte35 creation #94

Merged
merged 32 commits into from
Aug 15, 2018
Merged

Scte35 creation #94

merged 32 commits into from
Aug 15, 2018

Conversation

alextarasov1
Copy link
Contributor

@alextarasov1 alextarasov1 commented Jul 26, 2018

Added functionality that allows for the creation and modification of SCTE35. Exposed some private fields from SCTE35 related interfaces, such as mid. Segmentation Descriptors, Splice Commands, and SCTE35 are able to decode all of the fields instead of just skipping over them. Added Interfaces and structures that were necessary to achieve this. Every field that can be decoded into a struct can now also be encoded back into bytes.

PSI interface was removed because nothing implemented it. It was replaced by a TableHeader struct.

Tests were added for both the new SCTE35 functions and the TableHeader functions.

Example of how to use the new SCTE35 functions:

scte := scte35.CreateSCTE35()
scte.SetTier(0xFFF)
cmd := scte35.CreateTimeSignalCommand()
scte.SetCommandInfo(cmd)
cmd.SetHasPTS(true)
scte.SetPTS(0x86DF7550)

descriptor := scte35.CreateSegmentationDescriptor()
descriptor.SetEventID(0x41424344)
descriptor.SetIsEventCanceled(false)
descriptor.SetHasProgramSegmentation(true)
descriptor.SetHasDuration(false)
descriptor.SetIsDeliveryNotRestricted(false)
descriptor.SetIsWebDeliveryAllowed(false)
descriptor.SetHasNoRegionalBlackout(true)
descriptor.SetIsArchiveAllowed(true)
descriptor.SetDeviceRestrictions(scte35.RestrictNone)
descriptor.SetUPIDType(scte35.SegUPIDNotUsed)

descriptor.SetTypeID(0x10)
descriptor.SetSegmentNumber(1)
descriptor.SetSegmentsExpected(1)

scte.SetDescriptors([]scte35.SegmentationDescriptor{descriptor})

fmt.Printf("%X\n", scte.UpdateData())

Copy link
Collaborator

@WillGunther WillGunther left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main concern about this PR is the exploding interfaces that are being created. If we really do want to support the next SCTE spec these are useful, but if not a lot of this code can go away. All the accessors can go away, and we can export the fields of the struct. I'm curious if other's have guidance on this.

psi/psi.go Outdated
@@ -60,3 +60,50 @@ func sectionSyntaxIndicator(psi []byte) bool {
func sectionLength(psi []byte) uint16 {
return uint16(psi[1]&3)<<8 | uint16(psi[2])
}

func NewPointerField(size int) []byte {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick go doc style comment would be good here.

SegUPADSINFO: "SegUPADSINFO",
SegUPIDURN: "SegUPIDURN",
}

// SCTE35 represent operations available on a SCTE35 message.
type SCTE35 interface {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface is becoming a beast. Since we are in the business of breaking api's lately do we want to consider ditching this? Do we think there is a chance we will back this interface with SCTE 2015 and SCTE 20XX?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a good idea to remove the interfaces. But this big api breaking change should be done separately from this pull request. That way this pull request does not break any backwards compatibility.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can get behind that

@@ -204,42 +357,101 @@ type SegmentationDescriptor interface {
SCTE35() SCTE35
// EventID returns the event id
EventID() uint32
// TypeID returns the segmentation type for descriptor
TypeID() SegDescType
// SetEventID sets the event id
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing with this interface.

scte35/modify.go Outdated
s.commandInfo.SetHasPTS(true)
}

// HasPTS returns true if there is a pts time.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't match the fuction


// String returns a string representation of the SCTE35 message.
// String function is for debugging and testing.
func (s *scte35) String() string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've already talked about this, but it might be worthwhile to output JSON instead of this crafted string. This could be addressed in another PR though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or have multiple methods: one for a formatted string and another for a JSON formatted string.

func (c *spliceNull) PTS() gots.PTS {
return 0
}

type component struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to follow the convention that all type definitions remain in the doc.go file.

}

// returns the bytes of this splice command.
func (c *timeSignal) Data() []byte {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the func (c *spliceInsert) Data() []byte below need function names for godoc style comments

scte35/state.go Outdated
@@ -28,19 +28,6 @@ import "github.com/Comcast/gots"

const receivedRingLen = 10

type receivedElem struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I don't agree with the pattern of moving private structs/fields to doc.go I'm not going to block the PR for it.

@WillGunther WillGunther merged commit 170a10f into Comcast:master Aug 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants