Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,100 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ Overview of the EBU-TT live toolkit. | |
.. toctree:: | ||
nodes_and_carriage_mechanisms | ||
validation | ||
user_input_producer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
User input producer | ||
=================== | ||
|
||
The user input producer is composed of a user interface written in javascript, the user interface is defined in the file `ebu_tt_live/ui/user_input_producer/user_input_producer.html`. It works with Javascript, JQuery_ and nunjucks_. | ||
|
||
Demo | ||
---- | ||
|
||
To test the user input producer, setup the environment as indicated in the `README.md` file at the root of the project. Then launch the ``ebu-user-input-consumer`` script and open the `ui/user_input_producer/user_input_producer.html` file in your browser. Click on the ``Connect`` button on the HTML page; the default URL should work: if you changed it in the `ebu_tt_live/script/ebu-user-input-consumer.py` file, then enter your custom URL, just be careful that the carriage uses websocket. If you have not already created a sequence, then create one with the corresponding button, set its options and select it in the dropdown box that allows you to choose a sequence identifier. | ||
|
||
There are three ways of sending documents : | ||
* `Send document on click on "Send" button` will issue a new document each time you clik the "Send" button. | ||
* `Send document on scheduled time` replaces the "Send" button by an input box and a "Schedule" button. You have two options, using a "local" clock, which is the time of your computer or using a "media" clock, which is a clock starting at `00:00:00.0` when you click on "Synchronize" button. Times have to be entered using `hh:mm:ss` format in the "Scheduled time" input. When you click on "Schedule" the current document state is set to be sent at the given time. You can now change any field to schedule a new document without waiting. | ||
* `Send documents asynchronously` will send a new document every `x` seconds, taking your modifications on-the-go. | ||
|
||
You can type subtitle's text in the `Subtitles text` box. Each time a new document is being sent it should be logged by the ``ebu-user-input-consumer`` script. | ||
|
||
.. _JQuery: https://jquery.com/ | ||
.. _nunjucks: https://mozilla.github.io/nunjucks/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from .base import CombinedCarriageImpl | ||
|
||
|
||
class ForwarderCarriageImpl(CombinedCarriageImpl): | ||
|
||
_consumer_carriage = None | ||
_producer_carriage = None | ||
|
||
def __init__(self, consumer_carriage, producer_carriage): | ||
self._consumer_carriage = consumer_carriage | ||
self._producer_carriage = producer_carriage | ||
|
||
def register(self, node): | ||
self._node = node | ||
self._consumer_carriage.register(node) | ||
self._producer_carriage.register(node) | ||
|
||
def emit_document(self, document): | ||
self._producer_carriage.emit_document(document) | ||
|
||
def on_new_data(self, data): | ||
self._consumer_carriage.on_new_data(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from unittest import TestCase | ||
from mock import MagicMock | ||
from ebu_tt_live.carriage.forwarder_carriage import ForwarderCarriageImpl | ||
|
||
|
||
class TestForwarderCarriageImpl(TestCase): | ||
|
||
def setUp(self): | ||
self.consumer_impl = MagicMock() | ||
self.producer_impl = MagicMock() | ||
self.node = MagicMock() | ||
|
||
def test_register(self): | ||
forwarder_impl = ForwarderCarriageImpl(self.consumer_impl, self.producer_impl) | ||
forwarder_impl.register(self.node) | ||
self.consumer_impl.register.assert_called_with(self.node) | ||
self.producer_impl.register.assert_called_with(self.node) | ||
|
||
def test_emit_document(self): | ||
forwarder_impl = ForwarderCarriageImpl(self.consumer_impl, self.producer_impl) | ||
document = MagicMock() | ||
forwarder_impl.emit_document(document) | ||
self.producer_impl.emit_document.assert_called_with(document) | ||
|
||
def test_on_new_data(self): | ||
forwarder_impl = ForwarderCarriageImpl(self.consumer_impl, self.producer_impl) | ||
data = MagicMock() | ||
forwarder_impl.on_new_data(data) | ||
self.consumer_impl.on_new_data.assert_called_with(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from .base import Node | ||
import logging | ||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
class DistributingNode(Node): | ||
|
||
_reference_clock = None | ||
|
||
def __init__(self, node_id, carriage_impl, reference_clock): | ||
super(DistributingNode, self).__init__(node_id, carriage_impl) | ||
self._reference_clock = reference_clock | ||
|
||
def process_document(self, document): | ||
log.info(document) | ||
log.info(" " + str(document.sequence_identifier) + "_" + str(document.sequence_number)) | ||
log.info(document.get_xml()) | ||
self._carriage_impl.emit_document(document) | ||
|
||
@property | ||
def reference_clock(self): | ||
return self._reference_clock | ||
|
||
@reference_clock.setter | ||
def reference_clock(self, value): | ||
self._reference_clock = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from unittest import TestCase | ||
from mock import MagicMock | ||
from ebu_tt_live.node.distributing import DistributingNode | ||
|
||
|
||
class TestDistributingNode(TestCase): | ||
|
||
def test_process_document(self): | ||
carriage = MagicMock() | ||
reference_clock = MagicMock() | ||
node = DistributingNode('distributing_node', carriage, reference_clock) | ||
document = MagicMock() | ||
node.process_document(document) | ||
carriage.emit_document.assert_called_with(document) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import logging | ||
from argparse import ArgumentParser | ||
from .common import create_loggers | ||
|
||
from ebu_tt_live.node import SimpleConsumer | ||
from ebu_tt_live.clocks.local import LocalMachineClock | ||
from ebu_tt_live.twisted import TwistedConsumer, UserInputServerProtocol, UserInputServerFactory | ||
from ebu_tt_live.carriage.twisted import TwistedConsumerImpl | ||
from twisted.internet import reactor | ||
|
||
|
||
log = logging.getLogger('ebu_simple_consumer') | ||
|
||
|
||
parser = ArgumentParser() | ||
|
||
parser.add_argument('-c', '--config', dest='config', metavar='CONFIG') | ||
|
||
|
||
def main(): | ||
args = parser.parse_args() | ||
create_loggers() | ||
log.info('This is a Simple Consumer example') | ||
|
||
consumer_impl = None | ||
|
||
consumer_impl = TwistedConsumerImpl() | ||
|
||
reference_clock = LocalMachineClock() | ||
reference_clock.clock_mode = 'local' | ||
|
||
simple_consumer = SimpleConsumer( | ||
node_id='simple-consumer', | ||
carriage_impl=consumer_impl, | ||
reference_clock=reference_clock | ||
) | ||
|
||
factory = UserInputServerFactory( | ||
url='ws://127.0.0.1:9001', | ||
consumer=TwistedConsumer( | ||
custom_consumer=consumer_impl | ||
) | ||
) | ||
factory.protocol = UserInputServerProtocol | ||
|
||
factory.listen() | ||
|
||
reactor.run() |
Oops, something went wrong.