def _handle_attach(self, request): session = self._get_session(request) attach_params_schema = Schema({ 'plugin': StrVal(max_len=64), Optional('opaque_id'): StrVal(max_len=64), AutoDel(str): object # for all other key we don't care }) params = attach_params_schema.validate(request.message) handle = session.attach_handle(**params) return create_janus_msg('success', request.session_id, request.transaction, data={'id': handle.handle_id})
class Request(object): request_schema = Schema({ "janus": StrRe(r"^\S+$"), "transaction": StrRe(r"^\S+$"), Optional("session_id"): IntVal(), Optional("handle_id"): IntVal(), Optional("apisecret"): StrVal(), DoNotCare(str): object # for all other key we don't care }) def __init__(self, transport_session, message): message = self.request_schema.validate(message) self.transport = transport_session self.message = message self.janus = message['janus'] self.transaction = message['transaction'] self.session_id = message.get('session_id', 0) self.handle_id = message.get('handle_id', 0) self.apisecret = message.get('apisecret', '')
def read_config(config_file): p2pcall_config_schema = Schema({ Optional("general"): Default({ Optional("user_db"): Default(StrVal(), default='memory'), AutoDel(str): object # for all other key we don't care }, default={}), DoNotCare(str): object # for all other key we don't care }) #print('config file:', config_file) if config_file is None or config_file == '': config = p2pcall_config_schema.validate({}) else: log.info('P2Pcall plugin loads the config file: {}'.format(os.path.abspath(config_file))) config = parse_config(config_file, p2pcall_config_schema) # check other configure option is valid or not return config
def read_config(config_file): videocall_config_schema = Schema({ Optional("general"): Default( { Optional("user_db"): Default(StrVal(), default='memory'), AutoDel(str): object # for all other key we don't care }, default={}), DoNotCare(str): object # for all other key we don't care }) #print('config file:', config_file) if config_file is None or config_file == '': config = videocall_config_schema.validate({}) else: config = parse_config(config_file, videocall_config_schema) # check other configure option is valid or not return config
config_schema = Schema({ Optional("general"): Default( { Optional("daemonize"): Default(BoolVal(), default=False), AutoDel(str): object # for all other key remove }, default={}), Optional("log"): Default( { Optional('log_to_stdout'): Default(BoolVal(), default=True), Optional('log_to_file'): Default(StrVal(), default=''), Optional('debug_level'): Default(EnumVal(['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL']), default='DEBUG'), Optional('log_file_size'): Default(IntVal(), default=104857600), Optional('log_file_rotate'): Default(IntVal(), default=10), AutoDel(str): object # for all other key remove }, default={}), Optional("janus"): Default( { Optional("server_name"):
JANUS_VIDEOCALL_API_BASE_PATH = '/plugins/videocall' INCOMMING_CALL_TIMEOUT = 10 username_schema = Schema({ 'username': StrRe('^\w{1,128}$'), DoNotCare(str): object # for all other key we don't care }) set_schema = Schema({ Optional('audio'): BoolVal(), Optional('video'): BoolVal(), Optional('bitrate'): IntVal(min=1), Optional('record'): BoolVal(), Optional('restart'): BoolVal(), Optional('filename'): StrVal(), Optional('substream'): IntVal(min=0, max=2), Optional('temporal'): IntVal(min=0, max=2), Optional('fallback'): IntVal(min=0), AutoDel(str): object # for all other key we must delete }) post_videocall_user_schema = Schema({ 'caller_username': StrRe('^\w{1, 128}$'), 'backend_server_url': StrVal(max_len=1024), 'backend_keepalive_interval': IntVal(min=1, max=86400), AutoDel(str): object # for all other key we must delete
server_update_schema = Schema({ 'name': StrRe('^\S{1,64}$'), 'url': StrRe('^(ws|wss)://\S+$'), 'status': IntVal(values=(JANUS_SERVER_STATUS_NORMAL, JANUS_SERVER_STATUS_ABNORMAL, JANUS_SERVER_STATUS_MAINTENANCE)), Optional("session_timeout"): IntVal(min=0, max=86400), Optional("session_num"): IntVal(min=0, max=10000), Optional("handle_num"): IntVal(min=0, max=100000), Optional("location"): StrVal(min_len=0, max_len=64), Optional("isp"): StrVal(min_len=0, max_len=64), Optional("expire"): IntVal(min=0, max=86400), AutoDel(str): object # for all other key we must delete }) @post_view(route_name='sentinel_callback') def post_sentinel_callback(request): params = get_params_from_request(request, server_update_schema) backend_server_manager = request.registry.backend_server_manager backend_server_manager.update_server(**params) return Response(status=200)
JANUS_VIDEOCALL_API_SYNC_VERSION JANUS_VIDEOCALL_NAME = 'JANUS VideoCall plugin' JANUS_VIDEOCALL_AUTHOR = 'opensight.cn' JANUS_VIDEOCALL_PACKAGE = 'janus.plugin.videocall' JANUS_VIDEOCALL_API_BASE_PATH = '/plugins/videocall' INCOMMING_CALL_TIMEOUT = 10 username_schema = Schema({ 'username': StrRe('^\w{1,128}$'), DoNotCare(str): object # for all other key we don't care }) set_schema = Schema({ 'request': StrVal(), Optional('audio'): BoolVal(), Optional('video'): BoolVal(), Optional('bitrate'): IntVal(min=1), Optional('record'): BoolVal(), Optional('restart'): BoolVal(), Optional('filename'): StrVal(), Optional('substream'): IntVal(min=0, max=2), Optional('temporal'): IntVal(min=0, max=2), Optional('fallback'): IntVal(min=0), DoNotCare(str): object # for all other key we we don't care }) post_videocall_user_schema = Schema({ 'caller_username': StrRe('^\w{1, 128}$'),
INCOMMING_CALL_TIMEOUT = 10 username_schema = Schema({ 'username': StrRe('^\w{1,128}$'), DoNotCare(str): object # for all other key we don't care }) exists_schema = Schema({ 'username': StrRe('^\w{1,128}$'), DoNotCare(str): object # for all other key we don't care }) set_schema = Schema({ 'request': StrVal(), Optional('audio'): BoolVal(), Optional('video'): BoolVal(), Optional('bitrate'): IntVal(min=1), Optional('record'): BoolVal(), Optional('restart'): BoolVal(), Optional('filename'): StrVal(), Optional('substream'): IntVal(min=0, max=2), Optional('temporal'): IntVal(min=0, max=2), Optional('fallback'): IntVal(min=0), DoNotCare(str): object # for all other key we we don't care }) post_videocall_user_schema = Schema({ 'caller_username': StrRe('^\w{1,128}$'), 'backend_server_url': StrVal(max_len=1024),
# -*- coding: utf-8 -*- from januscloud.common.schema import Schema, StrVal, Default, AutoDel, Optional, BoolVal, IntVal, \ StrRe, EnumVal, Or from januscloud.common.confparser import parse as parse_config from pkg_resources import Requirement, resource_filename import os config_schema = Schema({ Optional("general"): Default({ Optional("daemonize"): Default(BoolVal(), default=False), Optional("configs_folder"): Default(StrVal(), default=''), Optional("server_name"): Default(StrRe(r'^\S*$'), default=''), Optional("session_timeout"): Default(IntVal(min=0, max=86400), default=60), Optional("server_db"): Default(StrVal(), default='memory'), Optional("server_select"): Default(StrVal(), default='rr'), Optional('api_secret'): Default(StrVal(), default=''), AutoDel(str): object # for all other key we don't care }, default={}), Optional("log"): Default({ Optional('log_to_stdout'): Default(BoolVal(), default=True), Optional('log_to_file'): Default(StrVal(), default=''), Optional('debug_level'): Default(EnumVal(['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL']), default='DEBUG'), Optional('log_file_size'): Default(IntVal(), default=104857600), Optional('log_file_rotate'): Default(IntVal(), default=10), AutoDel(str): object # for all other key we don't care }, default={}), Optional("certificates"): Default({ Optional("cert_pem"): StrVal(), Optional("cert_key"): StrVal(), Optional("cert_pwd"): StrVal(),
StrRe, EnumVal, Or from januscloud.common.confparser import parse as parse_config from pkg_resources import Requirement, resource_filename import os import logging log = logging.getLogger(__name__) config_schema = Schema({ Optional("general"): Default( { Optional("daemonize"): Default(BoolVal(), default=False), Optional("configs_folder"): Default(StrVal(), default=''), Optional("server_name"): Default(StrRe(r'^\S*$'), default=''), Optional("session_timeout"): Default(IntVal(min=0, max=86400), default=60), Optional("server_db"): Default(StrVal(), default='memory'), Optional("server_select"): Default(StrVal(), default='rr'), Optional('api_secret'): Default(StrVal(), default=''), AutoDel(str): object # for all other key we don't care }, default={}), Optional("log"):