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

Non-text Event child nodes not supported #23

Open
davemevans opened this issue Mar 17, 2019 · 1 comment
Open

Non-text Event child nodes not supported #23

davemevans opened this issue Mar 17, 2019 · 1 comment

Comments

@davemevans
Copy link
Collaborator

Event nodes may have child nodes that are not of type text. The 3rd edition of the DASH spec makes this clearer by adding the messageData attribute for use when the event data is a string (see #20 for implementation of this)

An example might be SCTE35 cues with schemeIdUri urn:scte:scte35:2013:xml or urn:scte:scte35:2014:xml+bin, where the child node would be <Signal>, with further children as required.

The library does not currently support this - the Event content is always considered to be text for parsing and writing - causing data to be lost when transforming a manifest.

@davemevans
Copy link
Collaborator Author

In case it helps anyone, I solved it as follows in the application code. Note this only considers the BinaryType child type ie urn:scte:scte35:2014:xml+bin for Signal, not SpliceInfoSectionType as we had no need for that.

def __init__(self):
    self.signals = None                                   # Signal
    self.message_data = None                              # xs:string
    self.presentation_time = None                         # xs:unsignedLong
    self.duration = None                                  # xs:unsignedLong
    self.id = None                                        # xs:unsignedInt

def parse(self, xmlnode):
    self.signals = parse_child_nodes(xmlnode, 'Signal', Signal)
    self.message_data = parse_attr_value(xmlnode, 'messageData', str)
    self.presentation_time = parse_attr_value(xmlnode, 'presentationTime', int)
    self.duration = parse_attr_value(xmlnode, 'duration', int)
    self.id = parse_attr_value(xmlnode, 'id', int)

def write(self, xmlnode):
    write_child_node(xmlnode, 'Signal', self.signals)
    write_attr_value(xmlnode, 'messageData', self.message_data)
    write_attr_value(xmlnode, 'presentationTime', self.presentation_time)
    write_attr_value(xmlnode, 'duration', self.duration)
    write_attr_value(xmlnode, 'id', self.id)

class Binary:
    def __init__(self):
        self.binary_value = None
        self.signal_type = None

    def parse(self, xmlnode):
        self.binary_value = parse_node_value(xmlnode, str)
        self.signal_type = parse_attr_value(xmlnode, "signalType", str)

    def write(self, xmlnode):
        write_node_value(xmlnode, self.binary_value)
        write_attr_value(xmlnode, 'signalType', self.signal_type)

class Signal:
    def __init__(self):
        self.xmlns = None
        self.binarys = None

    def parse(self, xmlnode):
        self.xmlns = parse_attr_value(xmlnode, 'xmlns', str)
        self.binarys = parse_child_nodes(xmlnode, 'Binary', XsStringElement)

    def write(self, xmlnode):
        write_attr_value(xmlnode, 'xmlns', self.xmlns)
        write_child_node(xmlnode, 'Binary', self.binarys)

Event.__init__ == __init__
Event.parse = parse
Event.write = write

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

No branches or pull requests

1 participant