odoo17 音视频扩展

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自身带来的服务压力。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值