Exemplo n.º 1
0
def main():
    create_loggers()
    log.info('Dummy XML Encoder')

    tt = bindings.tt(sequenceIdentifier='testSequence001',
                     sequenceNumber='1',
                     timeBase='smpte',
                     lang='en-GB',
                     head=bindings.head_type(
                         metadata.headMetadata_type(
                             metadata.documentMetadata()),
                         bindings.styling(bindings.style(id='ID001')),
                         bindings.layout()),
                     body=BIND(
                         bindings.div_type(
                             bindings.p_type(
                                 bindings.span_type('Some example text...'),
                                 bindings.br_type(),
                                 bindings.span_type('And another line'),
                                 id='ID005',
                                 begin='00:00:00:50',
                                 end='00:00:03:24',
                             ))))

    print(
        tt.toDOM(bds=BindingDOMSupport(
            default_namespace=bindings.Namespace)).toprettyxml(indent='  '))
    log.info('XML output printed')
Exemplo n.º 2
0
    def _create_test_document(self):
        doc = EBUTT3Document(time_base='clock',
                             clock_mode='local',
                             lang='en-GB',
                             sequence_identifier='testSequenceEncoder01',
                             sequence_number='1')

        head_elem = bindings.head_type(
            metadata.headMetadata_type(metadata.documentMetadata()),
            bindings.styling(
                bindings.style_type(id='style1', fontSize='12px'),
                bindings.style_type(id='style2', fontSize='15px'),
                bindings.style_type(id='style3', color='red', fontSize='12px'),
                bindings.style_type(id='style4', backgroundColor='blue')),
            bindings.layout(
                bindings.region_type(id='region1',
                                     origin='200px 450px',
                                     extent='300px 150px',
                                     style=['style3'])))

        body_elem = bindings.body_type(bindings.div_type(bindings.p_type(
            bindings.span_type('Some example text...',
                               begin=datatypes.LimitedClockTimingType(
                                   timedelta(hours=11, minutes=32, seconds=1)),
                               end=datatypes.LimitedClockTimingType(
                                   timedelta(hours=11, minutes=32, seconds=2)),
                               style=['style4'],
                               id='span1'),
            bindings.br_type(),
            bindings.span_type('And another line',
                               begin=datatypes.LimitedClockTimingType(
                                   timedelta(hours=11, minutes=32, seconds=3)),
                               end=datatypes.LimitedClockTimingType(
                                   timedelta(hours=11, minutes=32, seconds=4)),
                               id='span2'),
            id='ID005',
        ),
                                                         style=['style1'],
                                                         region='region1'),
                                       begin=datatypes.LimitedClockTimingType(
                                           timedelta(hours=11,
                                                     minutes=32,
                                                     seconds=.5)),
                                       dur=datatypes.LimitedClockTimingType(
                                           timedelta(hours=11,
                                                     minutes=32,
                                                     seconds=5)),
                                       style=['style2'])

        doc.binding.head = head_elem
        doc.binding.body = body_elem
        doc.binding.extent = '800px 600px'
        doc.validate()
        raw_xml = doc.get_xml()
        doc = EBUTT3Document.create_from_xml(raw_xml)
        return doc
Exemplo n.º 3
0
    def process_document(self, document, **kwargs):
        if self.is_document(document):

            if document.sequence_identifier == self._document_sequence:
                raise UnexpectedSequenceIdentifierError()

            if self.check_if_document_seen(document=document):

                self.limit_sequence_to_one(document)

                # change the sequence identifier
                document.sequence_identifier = self._document_sequence

                if document.binding.head.metadata is None:
                    document.binding.head.metadata = metadata.headMetadata_type(
                        metadata.documentMetadata())

                if document.binding.head.metadata.documentMetadata is None:
                    document.binding.head.metadata.documentMetadata = metadata.documentMetadata(
                    )

                ap_metadata = metadata.appliedProcessing_type(
                    process='retimed by ' + str(self._fixed_delay) + 's',
                    generatedBy='retiming_delay_node_v1.0',
                    sourceId=self.node_id,
                    appliedDateTime=datetime.now())

                document.binding.head.metadata.documentMetadata.appliedProcessing.append(
                    ap_metadata)

                if has_a_leaf_with_no_timing_path(document.binding.body):
                    update_body_timing(document.binding.body,
                                       document.time_base, self._fixed_delay)

                else:
                    update_children_timing(document.binding,
                                           document.time_base,
                                           self._fixed_delay)

                document.validate()
                self.producer_carriage.emit_data(data=document, **kwargs)
            else:
                log.warning('Ignoring duplicate document: {}__{}'.format(
                    document.sequence_identifier, document.sequence_number))
        else:
            self.producer_carriage.emit_data(data=document, **kwargs)
def main():
    create_loggers()
    log.info('Dummy XML Encoder')

    tt = bindings.tt(
        sequenceIdentifier='testSequence001',
        sequenceNumber='1',
        timeBase='smpte',
        lang='en-GB',
        head=bindings.head_type(
            metadata.headMetadata_type(
                metadata.documentMetadata()
            ),
            bindings.styling(
                bindings.style(
                    id='ID001'
                )
            ),
            bindings.layout()
        ),
        body=BIND(
            bindings.div_type(
                bindings.p_type(
                    bindings.span_type(
                        'Some example text...'
                    ),
                    bindings.br_type(),
                    bindings.span_type(
                        'And another line'
                    ),
                    id='ID005',
                    begin='00:00:00:50',
                    end='00:00:03:24',
                )
            )
        )
    )

    print(
        tt.toDOM(
            bds=BindingDOMSupport(default_namespace=bindings.Namespace)
        ).toprettyxml(
            indent='  '
        )
    )
    log.info('XML output printed')
Exemplo n.º 5
0
def main():
    create_loggers()
    log.info('Dummy XML Encoder')

    tt = bindings.tt(
        sequenceIdentifier='testSequence001',
        sequenceNumber='1',
        timeBase='clock',
        clockMode='local',
        lang='en-GB',
        head=bindings.head_type(
            metadata.headMetadata_type(
                metadata.documentMetadata()
            ),
            bindings.styling(
                bindings.style(
                    id='ID001'
                )
            ),
            bindings.layout()
        ),
        body=BIND(
            bindings.div_type(
                bindings.p_type(
                    bindings.span_type(
                        'Some example text...'
                    ),
                    bindings.br_type(),
                    bindings.span_type(
                        'And another line'
                    ),
                    id='ID005',
                    begin=timedelta(seconds=.5),
                    end=timedelta(seconds=3.42),
                )
            ),
            begin=timedelta(seconds=.5),
            dur=timedelta(seconds=5)
        )
    )

    print(
        tt.toxml()
    )

    log.info('XML output printed')
Exemplo n.º 6
0
    def __init__(self, time_base, sequence_number, sequence_identifier, lang, clock_mode=None):
        if not clock_mode and time_base is TimeBase.CLOCK:
            clock_mode = 'local'
        self._ebutt3_content = bindings.tt(
            timeBase=time_base,
            clockMode=clock_mode,
            sequenceIdentifier=sequence_identifier,
            sequenceNumber=sequence_number,
            lang=lang,
            head=BIND(
                metadata.headMetadata_type(
                    metadata.documentMetadata()
                )
            ),
            body=BIND()
        )

        self.validate()
Exemplo n.º 7
0
    def __init__(self, time_base, sequence_number, sequence_identifier, lang, clock_mode=None):
        if not clock_mode and time_base is TimeBase.CLOCK:
            clock_mode = 'local'
        self._ebutt3_content = bindings.tt(
            timeBase=time_base,
            clockMode=clock_mode,
            sequenceIdentifier=sequence_identifier,
            sequenceNumber=sequence_number,
            lang=lang,
            head=BIND(
                metadata.headMetadata_type(
                    metadata.documentMetadata()
                )
            ),
            body=BIND()
        )

        self.validate()
Exemplo n.º 8
0
    def __init__(self,
                 time_base,
                 sequence_number,
                 sequence_identifier,
                 lang,
                 clock_mode=None,
                 availability_time=None,
                 authors_group_identifier=None):
        if not clock_mode and time_base is TimeBase.CLOCK:
            clock_mode = 'local'
        self._ebutt3_content = bindings.tt(
            timeBase=time_base,
            clockMode=clock_mode,
            sequenceIdentifier=sequence_identifier,
            authorsGroupIdentifier=authors_group_identifier,
            sequenceNumber=sequence_number,
            lang=lang,
            head=BIND(metadata.headMetadata_type(metadata.documentMetadata())),
            body=BIND())
        if availability_time is not None:
            self._availability_time = availability_time

        self.validate()
Exemplo n.º 9
0
def main():
    create_loggers(logging.INFO)
    log.info("Dummy XML Encoder")

    tt = bindings.tt(
        sequenceIdentifier="testSequence001",
        sequenceNumber="1",
        timeBase="clock",
        extent="800px 600px",
        clockMode="local",
        lang="en-GB",
    )

    head_elem = bindings.head_type(
        metadata.headMetadata_type(metadata.documentMetadata()),
        bindings.styling(
            bindings.style_type(id="style1", fontSize="12px"),
            bindings.style_type(id="style2", fontSize="15px"),
            bindings.style_type(id="style3", color="red", fontSize="12px"),
            bindings.style_type(id="style4", backgroundColor="blue"),
        ),
        bindings.layout(
            bindings.region_type(id="region1", origin="200px 450px", extent="300px 150px", style=["style3"])
        ),
    )

    body_elem = bindings.body_type(
        bindings.div_type(
            bindings.p_type(
                bindings.span_type(
                    "Some example text...",
                    begin=datatypes.LimitedClockTimingType(timedelta(seconds=1)),
                    end=datatypes.LimitedClockTimingType(timedelta(seconds=2)),
                    style=["style4"],
                    id="span1",
                ),
                bindings.br_type(),
                bindings.span_type(
                    "And another line",
                    begin=datatypes.LimitedClockTimingType(timedelta(seconds=3)),
                    end=datatypes.LimitedClockTimingType(timedelta(seconds=4)),
                    id="span2",
                ),
                id="ID005",
            ),
            style=["style1"],
            region="region1",
        ),
        begin=datatypes.LimitedClockTimingType(timedelta(seconds=0.5)),
        dur=datatypes.LimitedClockTimingType(timedelta(seconds=5)),
        style=["style2"],
    )

    tt.head = head_elem
    tt.body = body_elem

    document = EBUTT3Document.create_from_raw_binding(tt)

    document.validate()

    print(document.get_xml())

    log.info("XML output printed")
def main():
    create_loggers(logging.INFO)
    log.info('Dummy XML Encoder')

    tt = bindings.tt(sequenceIdentifier='testSequence001',
                     sequenceNumber='1',
                     timeBase='clock',
                     extent='800px 600px',
                     clockMode='local',
                     lang='en-GB')

    head_elem = bindings.head_type(
        metadata.headMetadata_type(metadata.documentMetadata()),
        bindings.styling(
            bindings.style_type(id='style1', fontSize='12px'),
            bindings.style_type(id='style2', fontSize='15px'),
            bindings.style_type(id='style3', color='red', fontSize='12px'),
            bindings.style_type(id='style4', backgroundColor='blue')),
        bindings.layout(
            bindings.region_type(id='region1',
                                 origin='200px 450px',
                                 extent='300px 150px',
                                 style=['style3'])))

    body_elem = bindings.body_type(
        bindings.div_type(bindings.p_type(
            bindings.span_type(
                'Some example text...',
                begin=datatypes.LimitedClockTimingType(timedelta(seconds=1)),
                end=datatypes.LimitedClockTimingType(timedelta(seconds=2)),
                style=['style4'],
                id='span1'),
            bindings.br_type(),
            bindings.span_type(
                'And another line',
                begin=datatypes.LimitedClockTimingType(timedelta(seconds=3)),
                end=datatypes.LimitedClockTimingType(timedelta(seconds=4)),
                id='span2'),
            id='ID005',
        ),
                          style=['style1'],
                          region='region1'),
        begin=datatypes.LimitedClockTimingType(timedelta(seconds=.5)),
        dur=datatypes.LimitedClockTimingType(timedelta(seconds=5)),
        style=['style2'])

    applied_proc1 = metadata.appliedProcessing_type(
        process='Creation',
        generatedBy='ebu_dummy_encoder',
        appliedDateTime=datetime.now())

    applied_proc2 = metadata.appliedProcessing_type(
        process='Validation',
        generatedBy='ebu_dummy_encoder',
        appliedDateTime=datetime.now())

    head_elem.metadata.documentMetadata.appliedProcessing.append(applied_proc1)
    head_elem.metadata.documentMetadata.appliedProcessing.append(applied_proc2)
    tt.head = head_elem
    tt.body = body_elem

    document = EBUTT3Document.create_from_raw_binding(tt)

    document.validate()

    print(document.get_xml())

    log.info('XML output printed')