diff options
-rw-r--r-- | src/examples/audio.json | 6 | ||||
-rw-r--r-- | src/examples/avminimal.json | 6 | ||||
-rw-r--r-- | src/examples/elevate2013.json | 8 | ||||
-rw-r--r-- | src/examples/lac2013.json | 12 | ||||
-rw-r--r-- | src/examples/test.json | 6 | ||||
-rw-r--r-- | src/examples/test2.json | 6 | ||||
-rwxr-xr-x | src/flufigut.py | 91 |
7 files changed, 101 insertions, 34 deletions
diff --git a/src/examples/audio.json b/src/examples/audio.json index a173fae..68baeb9 100644 --- a/src/examples/audio.json +++ b/src/examples/audio.json @@ -25,7 +25,7 @@ "muxer-audio-ogg-high", "muxer-audio-ogg-medium", "muxer-audio-ogg-low", "streamer-local1" ] } }, - "input": { + "inputs": { "alsa": { "type": "soundcard", "master": true, @@ -36,7 +36,7 @@ } } }, - "mux": { + "muxes": { "audio": { "audio": "alsa", "formats": { @@ -44,7 +44,7 @@ } } }, - "stream": { + "streams": { "streamer-local": { "muxes": [ "audio" ], "type": "http", "count": 1, "port": 8000, diff --git a/src/examples/avminimal.json b/src/examples/avminimal.json index b6c6da5..cef0ef6 100644 --- a/src/examples/avminimal.json +++ b/src/examples/avminimal.json @@ -28,7 +28,7 @@ "localhost": [ "input-video", "input-audio", "encoder-video-vp8-360p25", "encoder-audio-vorbis-96", "muxer-av-webm-low", "streamer-local1" ] } }, - "input": { + "inputs": { "audio": { "type": "audiotest", "master": true, @@ -44,7 +44,7 @@ } } }, - "mux": { + "muxes": { "av": { "video": "video", "audio": "audio", @@ -53,7 +53,7 @@ } } }, - "stream": { + "streams": { "streamer-local": { "muxes": [ "av" ], "type": "http", "count": 1, "port": 8000, diff --git a/src/examples/elevate2013.json b/src/examples/elevate2013.json index 487033a..1dedbd1 100644 --- a/src/examples/elevate2013.json +++ b/src/examples/elevate2013.json @@ -66,7 +66,7 @@ "elevate2": [ "streamer-pub2" ] } }, - "input": { + "inputs": { "sdi": { "type": "decklink", "master": true, @@ -92,7 +92,7 @@ } } }, - "mux": { + "muxes": { "av-orig": { "video": "sdi:video", "audio": "sdi:audio", @@ -131,7 +131,7 @@ } } }, - "stream": { + "streams": { "streamer-local": { "muxes": [ "av-orig", "av-en", "audio-orig", "audio-en" ], "type": "http", "count": 1, "port": 8000, @@ -145,7 +145,7 @@ "hostname": "elevate-live%i", "repeater": "repeater-pub" } }, - "record": { + "records": { "av": { "muxes": { "avr": { "format": "rec", "profile": "full" } diff --git a/src/examples/lac2013.json b/src/examples/lac2013.json index 45bc8fe..f686b6e 100644 --- a/src/examples/lac2013.json +++ b/src/examples/lac2013.json @@ -55,7 +55,7 @@ "elevate0": [ "streamer-pub2" ] } }, - "input": { + "inputs": { "sdi": { "type": "decklink", "master": true, @@ -69,7 +69,7 @@ } } }, - "mux": { + "muxes": { "av": { "video": "sdi:video", "audio": "sdi:audio", @@ -92,7 +92,7 @@ } } }, - "stream": { + "streams": { "streamer-local": { "muxes": [ "av", "audio" ], "type": "http", "count": 1, "port": 8000, @@ -106,10 +106,10 @@ "hostname": "lac-live%i", "repeater": "repeater-pub" } }, - "record": { + "records": { "av": { - "muxes": { - "avr": { "format": "rec", "profile": "full" } + "muxes": { + "avr": { "format": "rec", "profile": "full" } }, "directory": "/srv/lac2013/", "filename": "%Y-%m-%d %H-%M-%S" diff --git a/src/examples/test.json b/src/examples/test.json index 9f2d189..5a5d5b0 100644 --- a/src/examples/test.json +++ b/src/examples/test.json @@ -43,7 +43,7 @@ "streamer3": [ "streamer-pub3" ] } }, - "input": { + "inputs": { "sdi": { "type": "decklink", "master": true, @@ -57,7 +57,7 @@ } } }, - "mux": { + "muxes": { "av": { "video": "sdi:video", "audio": "sdi:audio", @@ -73,7 +73,7 @@ } } }, - "stream": { + "streams": { "streamer-local": { "muxes": [ "av", "audio" ], "type": "http", "count": 1, "port": 8000, diff --git a/src/examples/test2.json b/src/examples/test2.json index cb66d4d..6dc42f0 100644 --- a/src/examples/test2.json +++ b/src/examples/test2.json @@ -42,7 +42,7 @@ "telesto": [ "encoder-sdi-h264-720p25", "encoder-sdi-h264-480p25", "encoder-sdi-h264-360p25" ] } }, - "input": { + "inputs": { "sdi": { "type": "decklink", "master": true, @@ -65,7 +65,7 @@ } } }, - "mux": { + "muxes": { "av-orig": { "video": "sdi:video", "audio": "sdi:audio", @@ -93,7 +93,7 @@ } } }, - "stream": { + "streams": { "streamer-local": { "muxes": [ "av-orig", "av-en", "audio", "audio-en" ], "type": "http", "count": 1, "port": 8000, diff --git a/src/flufigut.py b/src/flufigut.py index 42406d3..03dd084 100755 --- a/src/flufigut.py +++ b/src/flufigut.py @@ -48,10 +48,10 @@ class Description: def __init__(self): self.globals = {} - self.input = {} - self.mux = {} - self.stream = {} - self.record = {} + self.inputs = {} + self.muxes = {} + self.streams = {} + self.records = {} def _sanity_check(self): # TODO: add more sanity checks @@ -69,11 +69,11 @@ class Description: cf.close() self.globals = config['globals'] - self.input = config['input'] - self.mux = config['mux'] - self.stream = config['stream'] - if 'record' in config: - self.record = config['record'] + self.inputs = config['inputs'] + self.muxs = config['muxes'] + self.streams = config['streams'] + if 'records' in config: + self.records = config['records'] return self._sanity_check() @@ -86,6 +86,45 @@ class Planet: def __init__(self): self.atmosphere = {} self.flow = {} + self._workers = {} + self._components = {} + + def __set_input_properties(self, name, props, globals): + for prop in props.keys(): + if prop == 'resolution': + self.flow['inputs'][name]['properties']['width'] = globals['resolutions'][props[prop]]['width'] + self.flow['inputs'][name]['properties']['height'] = globals['resolutions'][props[prop]]['height'] + self.flow['inputs'][name]['properties']['framerate'] = globals['resolutions'][props[prop]]['rate'] + else: + self.flow['inputs'][name]['properties'][prop] = props[prop] + + def _generate_inputs(self, inputs, globals): + self.flow['inputs'] = {} + master_cnt = 0 + for source, input in inputs.items(): + name = 'input-%s' % source + if name not in self._components: + self._components[name] = -1 + else: + self._components[name] = 1 + self.flow['inputs'][name] = { + 'type': input['type'], + 'desc': "capture raw data from %s" % (source), + 'worker': name, + 'master': input['master'], + 'properties': {}, + } + if input['master']: + master_cnt += 1 + self.__set_input_properties(name, input['properties'], globals) + + if master_cnt == 0: + raise exception("You have not configured any master clock device!") + elif master_cnt > 1: + raise exception("You have configured multiple master clock devices!") + + def generate(self, desc): + self._generate_inputs(desc.inputs, desc.globals) # Main ######################################################## @@ -103,12 +142,40 @@ if __name__ == '__main__': ret = 0 try: - desc = Description() - desc.parse(config_file) + d = Description() + d.parse(config_file) + + p = Planet() + p.generate(d) + + print("****************************************************") + print("** atmosphere **") + print("**") + __pp.pprint(p.atmosphere) + + print("**") + print("**************************") + print("** planet **") + print("**") + __pp.pprint(p.flow) + + print("**") + print("****************************************************") + print("** _workers **") + print("**") + __pp.pprint(p._workers) + + print("**") + print("**************************") + print("** _components **") + print("**") + __pp.pprint(p._components) + print("**") + print("****************************************************") except Exception as e: print("ERROR: while running app: %s" % e) - # print(traceback.format_exc()) + print(traceback.format_exc()) sys.exit(1) sys.exit(ret) |