diff options
-rwxr-xr-x | src/flufigut.py | 97 | ||||
-rw-r--r-- | src/test.json | 28 | ||||
-rw-r--r-- | templates/example/http-stream.xml | 12 |
3 files changed, 76 insertions, 61 deletions
diff --git a/src/flufigut.py b/src/flufigut.py index 966a935..04216ea 100755 --- a/src/flufigut.py +++ b/src/flufigut.py @@ -3,8 +3,8 @@ # flufigut # # flufigut, the flumotion configuration utility, is a simple tool -# that generates flumotion configuration files using pyhton jinja2 -# template engine and simplejson. flufigut generates planet.xml +# that generates flumotion configuration files using pyhton jinja2 +# template engine and simplejson. flufigut generates planet.xml # and worker.xml files from configuration templates and an easy to # understand representation of the flow structure written in json. # @@ -60,6 +60,7 @@ flow = {} ### sanity checks ############################################### +machines = {} # TODO: # - worker<->machine only 1:1 # - list of workers (mark usage later) @@ -92,7 +93,7 @@ for format in transcode.keys(): if samplerate not in samplerates: if input['samplerate'] != samplerate: samplerates.append(samplerate) - for profile in transcode[format]: + for profile in transcode[format]: resolution = globals['profiles'][profile]['video'] if resolution not in resolutions: if input['resolution'] != resolution: @@ -174,7 +175,7 @@ for format in transcode.keys(): } muxer = globals['formats'][format]['muxer'] - flow['muxer']['muxer-%s-%s' % (muxer, profile)] = { + flow['muxer']['muxer-%s-%s' % (format, profile)] = { 'type': '%s-mux' % muxer, 'desc': "%s muxer profile %s" % (format, profile), 'worker': 'muxer-%s' % muxer, @@ -182,51 +183,57 @@ for format in transcode.keys(): 'feeder_video': video_encoder, 'properties': {}, } - + ### generate streamer components ################################ flow['streamer'] = {} -# TODO -### generate porter for all streamer/machines ################### -# -# idx = 0 -# for streamer in stream: -# worker = 'streamer%i'%(idx) -# port = streamer['config']['port'] -# found = False -# for machine in globals['machines'].keys(): -# if worker in globals['machines'][machine]: -# if machine in machines: -# if 'porter' in machines[machine]: -# if port in machines[machine]['porter']: -# raise SystemExit("Porter: machine %s already uses port %i" % (machine, port)) -# else: -# machines[machine]['porter'] = {} -# else: -# machines[machine] = { 'porter': {} } - -# found = True -# machines[machine]['porter'][port] = { -# 'socket-path': "porter%i-%s"%(idx, rand_string()), -# 'username': rand_string(size=12), -# 'password': rand_string(size=12), -# } - -# atmosphere['porter-%s-%i'%(machine, port)] = { -# 'type': "porter", -# 'desc': "Porter for %s on port %i"%(machine, port), -# 'worker': worker, -# 'properties': { -# 'port': port, -# 'socket-path': machines[machine]['porter'][port]['socket-path'], -# 'username': machines[machine]['porter'][port]['username'], -# 'password': machines[machine]['porter'][port]['password'], -# }, -# } -# if not found: -# raise SystemExit("Streamer %i has no machine assigned" % (idx)) -# idx+=1 +for cluster in stream.keys(): + streamer_cnt = stream[cluster]['count'] + port = stream[cluster]['port'] + for idx in range(streamer_cnt): + worker = '%s%i'%(cluster, idx+1) + for machine in globals['machines'].keys(): + if worker in globals['machines'][machine]: + if machine in machines: + if 'porter' in machines[machine]: + if port in machines[machine]['porter']: + raise SystemExit("Porter: machine %s already uses port %i" % (machine, port)) + else: + machines[machine]['porter'] = {} + else: + machines[machine] = { 'porter': {} } + + machines[machine]['porter'][port] = { + 'socket-path': "porter-%s"%(rand_string()), + 'username': rand_string(size=12), + 'password': rand_string(size=12), + } + + atmosphere['porter-%s-%i'%(machine, port)] = { + 'type': "porter", + 'desc': "Porter for %s on port %i"%(machine, port), + 'worker': worker, + 'properties': { + 'port': port, + 'socket-path': machines[machine]['porter'][port]['socket-path'], + 'username': machines[machine]['porter'][port]['username'], + 'password': machines[machine]['porter'][port]['password'], + }, + } + + for format in stream[cluster]['formats']: + for profile in transcode[format]: + feeder = 'muxer-%s-%s' % (format, profile) + name = '%s-%s%i-%s-%s' % (stream[cluster]['type'], cluster, idx+1, format, profile) + flow['streamer'][name] = { + 'type': "%s-stream" % stream[cluster]['type'], + 'desc': "%s streamer for %s-%s (part %i of %s)" % (stream[cluster]['type'], format, profile, idx+1, cluster), + 'worker': worker, + 'feeder': feeder, + 'properties': { + } + } ### initialize and render templates ############################# diff --git a/src/test.json b/src/test.json index 0a2c7c9..d03845e 100644 --- a/src/test.json +++ b/src/test.json @@ -25,12 +25,12 @@ "vp8": { "720p25": 2048, "480p25": 1024, "360p25": 600 } }, "machines": { - "titan": [ "input", "encoder-vorbis", "encoder-aac", "muxer-flv", "muxer-webm", "muxer-ogg", "streamer0" ], + "titan": [ "input", "encoder-vorbis", "encoder-aac", "muxer-flv", "muxer-webm", "muxer-ogg", "streamer-local1" ], "calypso": [ "encoder-h264" ], "telesto": [ "encoder-vp8" ], - "elevate1": [ "streamer1" ], - "elevate2": [ "streamer2" ], - "elevate3": [ "streamer3" ] + "elevate1": [ "streamer-pub1" ], + "elevate2": [ "streamer-pub2" ], + "elevate3": [ "streamer-pub3" ] } }, "input": { @@ -43,18 +43,14 @@ "webm": [ "high", "medium", "low" ], "ogg-audio": [ "high" ] }, - "stream": [ - { "flash": [ "high", "medium", "low" ], "webm": [ "high", "medium", "low" ], "ogg-audio": [ "high" ], - "config": { "port": 8000, "max-con": 5 } + "stream": { + "streamer-local": { + "formats": [ "flash", "webm", "ogg-audio" ], + "type": "http", "count": 1, "port": 8000, "max-con": 5 }, - { "flash": [ "high", "medium", "low" ], "webm": [ "high", "medium", "low" ], - "config": { "port": 8000, "max-bw": 290000, "next": 2 } - }, - { "flash": [ "high", "medium", "low" ], "webm": [ "high", "medium", "low" ], - "config": { "port": 8000, "max-bw": 290000, "next": 3 } - }, - { "flash": [ "high", "medium", "low" ], "webm": [ "high", "medium", "low" ], - "config": { "port": 8000, "max-bw": 290000, "next": 1 } + "streamer-pub": { + "formats": [ "flash", "webm" ], + "type": "http", "count": 3, "port": 8000, "max-bw": 290000 } - ] + } } diff --git a/templates/example/http-stream.xml b/templates/example/http-stream.xml new file mode 100644 index 0000000..5896651 --- /dev/null +++ b/templates/example/http-stream.xml @@ -0,0 +1,12 @@ + <component name="{{ name }}" + type="http-streamer" + label="{{ component.desc }}" + worker="{{ component.worker }}" + project="flumotion" + version="{{ globals.version }}"> + <eater name="default"> + <feed alias="default">{{ component.feeder }}</feed> + </eater> + <!-- TODO: add properties here --> + <clock-master>false</clock-master> + </component> |