--- a/src/pyams_media/include.py Sun Feb 18 12:47:42 2018 +0100
+++ b/src/pyams_media/include.py Mon Mar 05 12:51:54 2018 +0100
@@ -22,7 +22,8 @@
import sys
# import interfaces
-from pyams_media.interfaces import CONVERTER_HANDLER_KEY, CONVERTER_STARTER_KEY, CONVERTER_NAME
+from pyams_media.interfaces import CONVERTER_NAME, CONVERTER_HANDLER_KEY, CONVERTER_STARTER_KEY, CONVERTER_AUTH_KEY, \
+ CONVERTER_CLIENTS_KEY
from pyams_utils.interfaces import PYAMS_APPLICATION_SETTINGS_KEY, PYAMS_APPLICATION_DEFAULT_NAME
from pyramid.interfaces import IApplicationCreated
@@ -78,7 +79,10 @@
if conversion_util is not None:
# create medias converter process
process = MediaConversionProcess(settings.get(CONVERTER_HANDLER_KEY, '127.0.0.1:5556'),
- MediaConversionMessageHandler, registry)
+ MediaConversionMessageHandler,
+ settings.get(CONVERTER_AUTH_KEY),
+ settings.get(CONVERTER_CLIENTS_KEY),
+ registry)
logger.info('Starting medias converter {0!r}...'.format(process))
process.start()
if process.is_alive():
--- a/src/pyams_media/interfaces/__init__.py Sun Feb 18 12:47:42 2018 +0100
+++ b/src/pyams_media/interfaces/__init__.py Mon Mar 05 12:51:54 2018 +0100
@@ -33,6 +33,8 @@
CONVERTER_NAME = 'Medias converter'
CONVERTER_STARTER_KEY = 'pyams_media.start_handler'
CONVERTER_HANDLER_KEY = 'pyams_media.tcp_handler'
+CONVERTER_AUTH_KEY = 'pyams_media.allow_auth'
+CONVERTER_CLIENTS_KEY = 'pyams_media.allow_clients'
CUSTOM_AUDIO_TYPES = (b'application/ogg',)
CUSTOM_VIDEO_TYPES = ()
@@ -224,6 +226,9 @@
description=_("In kilo-bytes per second. Leave empty to keep original value."),
required=False)
+ def get_socket(self):
+ """Get 0MQ socket matching utility settings"""
+
def check_media_conversion(self, media):
"""Check if conversion is needed for given media"""
--- a/src/pyams_media/process.py Sun Feb 18 12:47:42 2018 +0100
+++ b/src/pyams_media/process.py Mon Mar 05 12:51:54 2018 +0100
@@ -155,6 +155,6 @@
class MediaConversionProcess(ZMQProcess):
"""Media conversion ZMQ process"""
- def __init__(self, zmq_address, handler, registry):
- ZMQProcess.__init__(self, zmq_address, handler)
+ def __init__(self, zmq_address, handler, auth, clients, registry):
+ ZMQProcess.__init__(self, zmq_address, handler, auth, clients)
self.registry = registry
--- a/src/pyams_media/utility.py Sun Feb 18 12:47:42 2018 +0100
+++ b/src/pyams_media/utility.py Mon Mar 05 12:51:54 2018 +0100
@@ -17,7 +17,7 @@
# import interfaces
from pyams_media.interfaces import IMediaConversionUtility, CONVERTER_HANDLER_KEY, CUSTOM_AUDIO_TYPES, \
- CUSTOM_VIDEO_TYPES
+ CUSTOM_VIDEO_TYPES, CONVERTER_AUTH_KEY
from zope.intid.interfaces import IIntIds
# import packages
@@ -63,15 +63,15 @@
for format in requested_formats:
self.convert(media, format)
- def _get_socket(self):
+ def get_socket(self):
registry = get_current_registry()
handler = registry.settings.get(CONVERTER_HANDLER_KEY, False)
if handler:
- return zmq_socket(handler)
+ return zmq_socket(handler, auth=registry.settings.get(CONVERTER_AUTH_KEY))
def convert(self, media, format):
"""Send conversion request for given media"""
- socket = self._get_socket()
+ socket = self.get_socket()
if socket is None:
return [501, "No socket handler defined in configuration file"]
intids = get_utility(IIntIds)
@@ -83,7 +83,7 @@
def test_process(self):
"""Send test request to conversion process"""
- socket = self._get_socket()
+ socket = self.get_socket()
if socket is None:
return [501, "No socket handler defined in configuration file"]
socket.send_json(['test', {}])