ODOO内置了音视频服务,同时也提供了与第三方平台Twilio的接口,用以实现音视频的扩展:
Twilio是美国一家云通讯公司,算是云通讯领域的巨头企业,与同行业的公司以销售&营销进行投资来促进业务增长不同,Twilio则以API为基础,在数年内有机地打造了一个专业和广泛的软件开发员社区。
odoo原生代码:
def _get_ice_servers(self):
"""
:return: List of dict, each of which representing a stun or turn server,
formatted as expected by the specifications of RTCConfiguration.iceServers
"""
if self.env['ir.config_parameter'].sudo().get_param('mail.use_twilio_rtc_servers'):
(account_sid, auth_token) = get_twilio_credentials(self.env)
if account_sid and auth_token:
url = f'https://api.twilio.com/2010-04-01/Accounts/{account_sid}/Tokens.json'
response = requests.post(url, auth=(account_sid, auth_token), timeout=60)
if response.ok:
response_content = response.json()
if response_content:
return response_content['ice_servers']
return self._get_local_ice_servers()
class MailIceServer(models.Model):
_name = 'mail.ice.server'
_description = 'ICE server'
server_type = fields.Selection([('stun', 'stun:'), ('turn', 'turn:')], string='Type', required=True, default='stun')
uri = fields.Char('URI', required=True)
username = fields.Char()
credential = fields.Char()
def _get_local_ice_servers(self):
"""
:return: List of up to 5 dict, each of which representing a stun or turn server
"""
# firefox has a hard cap of 5 ice servers
ice_servers = self.sudo().search([], limit=5)
formatted_ice_servers = []
for ice_server in ice_servers:
formatted_ice_server = {
'urls': '%s:%s' % (ice_server.server_type, ice_server.uri),
}
if ice_server.username:
formatted_ice_server['username'] = ice_server.username
if ice_server.credential:
formatted_ice_server['credential'] = ice_server.credential
formatted_ice_servers.append(formatted_ice_server)
return formatted_ice_servers
可以看到ODOO通过用户名和密码及API调用Twilio的第三方服务(Twilio按账号收费的)。
ODOO也可以通过二次开发的方式与其他音视频平台对接,但要考虑其对于ODOO自身带来的服务压力。