环境:vmware虚拟机ubuntu14.04
注意
1.上网模式要桥接哦
2.切换到root模式
sudo -i
1.更换阿里源
修改source.list
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trustymain restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
2.安装必备依赖
各种依赖
apt-get install git unzip lrzsz nodejs npm automake autoconf libtool nodejs-legacy python-webtest golang vim -y
apt-get install openssh-server openssh-client -y
安装jdk1.8
add-apt-repository ppa:openjdk-r/ppa;apt-get update;apt-get install openjdk-8-jdk -y;
3.升级npm,安装grunt
npm最新版本安装方法
1、安装npm
sudo apt-get install npm
2、升级npm为最新版本
sudo npm install npm@latest -g
此时通过npm -v可以发现npm版本号为最新版本3.10.3;
3、安装用于安装nodejs的模块n
sudo npm install -g n
4、然后通过n模块安装指定版本的nodejs,n模块更多介绍请参考官方文档
//安装官方最新版本 sudo n latest //安装官方稳定版本 sudo n stable
更新完成之后可能需要重启terminal或者系统
npm config set registry https://registry.npm.taobao.org
npm info underscore
npm -g install grunt-cli
4.搞apprtc源码
sudo -i
cd /root
git clone https://github.com/webrtc/apprtc.git
备份源码
tar czf apprtc.tar.gz apprtc/
安装依赖
npm install
有时候报权限错误,需要加sudo
编译
grunt build
遇到问题要多看看,复制错误日志谷歌即可
5.修改配置文件
constant.py
修改成如下就可以,注意替换成你自己的ip地址
# Copyright 2015 Google Inc. All Rights Reserved.
"""AppRTC Constants.
This module contains the constants used in AppRTC Python modules.
"""
import os
# Deprecated domains which we should to redirect to REDIRECT_URL.
REDIRECT_DOMAINS = [
'apprtc.appspot.com', 'apprtc.webrtc.org', 'www.appr.tc'
]
# URL which we should redirect to if matching in REDIRECT_DOMAINS.
REDIRECT_URL = 'https://appr.tc'
ROOM_MEMCACHE_EXPIRATION_SEC = 60 * 60 * 24
MEMCACHE_RETRY_LIMIT = 100
LOOPBACK_CLIENT_ID = 'LOOPBACK_CLIENT_ID'
# Turn/Stun server override. This allows AppRTC to connect to turn servers
# directly rather than retrieving them from an ICE server provider.
ICE_SERVER_OVERRIDE = None
# Enable by uncomment below and comment out above, then specify turn and stun
# ICE_SERVER_OVERRIDE = [
# {
# "urls": [
# "turn:hostname/IpToTurnServer:19305?transport=udp",
# "turn:hostname/IpToTurnServer:19305?transport=tcp"
# ],
# "username": "TurnServerUsername",
# "credential": "TurnServerCredentials"
# },
# {
# "urls": [
# "stun:hostname/IpToStunServer:19302"
# ]
# }
# ]
TURN_BASE_URL = 'http://192.168.23.114'
TURN_URL_TEMPLATE = '%s/turn?username=%s&key=%s'
CEOD_KEY = '4080218913'
ICE_SERVER_BASE_URL = 'http://192.168.23.114'
ICE_SERVER_URL_TEMPLATE = '%s/v1alpha/iceconfig?key=%s'
ICE_SERVER_API_KEY = os.environ.get('ICE_SERVER_API_KEY')
# Dictionary keys in the collider instance info constant.
WSS_INSTANCE_HOST_KEY = 'host_port_pair'
WSS_INSTANCE_NAME_KEY = 'vm_name'
WSS_INSTANCE_ZONE_KEY = 'zone'
WSS_INSTANCES = [{
WSS_INSTANCE_HOST_KEY: '192.168.23.114:8089',
WSS_INSTANCE_NAME_KEY: 'wsserver-std',
WSS_INSTANCE_ZONE_KEY: 'us-central1-a'
}, {
WSS_INSTANCE_HOST_KEY: '192.168.23.114:8089',
WSS_INSTANCE_NAME_KEY: 'wsserver-std-2',
WSS_INSTANCE_ZONE_KEY: 'us-central1-f'
}]
WSS_HOST_PORT_PAIRS = [ins[WSS_INSTANCE_HOST_KEY] for ins in WSS_INSTANCES]
# memcache key for the active collider host.
WSS_HOST_ACTIVE_HOST_KEY = 'wss_host_active_host'
# Dictionary keys in the collider probing result.
WSS_HOST_IS_UP_KEY = 'is_up'
WSS_HOST_STATUS_CODE_KEY = 'status_code'
WSS_HOST_ERROR_MESSAGE_KEY = 'error_message'
RESPONSE_ERROR = 'ERROR'
RESPONSE_ROOM_FULL = 'FULL'
RESPONSE_UNKNOWN_ROOM = 'UNKNOWN_ROOM'
RESPONSE_UNKNOWN_CLIENT = 'UNKNOWN_CLIENT'
RESPONSE_DUPLICATE_CLIENT = 'DUPLICATE_CLIENT'
RESPONSE_SUCCESS = 'SUCCESS'
RESPONSE_INVALID_REQUEST = 'INVALID_REQUEST'
IS_DEV_SERVER = os.environ.get('APPLICATION_ID', '').startswith('dev')
BIGQUERY_URL = 'https://www.googleapis.com/auth/bigquery'
# Dataset used in production.
BIGQUERY_DATASET_PROD = 'prod'
# Dataset used when running locally.
BIGQUERY_DATASET_LOCAL = 'dev'
# BigQuery table within the dataset.
BIGQUERY_TABLE = 'analytics'
apprtc.py
找到get_wss_parameters方法
def get_wss_parameters(request):
wss_host_port_pair = request.get('wshpp')
wss_tls = request.get('wstls')
if not wss_host_port_pair:
# Attempt to get a wss server from the status provided by prober,
# if that fails, use fallback value.
memcache_client = memcache.Client()
wss_active_host = memcache_client.get(constants.WSS_HOST_ACTIVE_HOST_KEY)
if wss_active_host in constants.WSS_HOST_PORT_PAIRS:
wss_host_port_pair = wss_active_host
else:
logging.warning(
'Invalid or no value returned from memcache, using fallback: '
+ json.dumps(wss_active_host))
wss_host_port_pair = constants.WSS_HOST_PORT_PAIRS[0]
if wss_tls and wss_tls == 'false':
wss_url = 'ws://' + wss_host_port_pair + '/ws'
wss_post_url = 'http://' + wss_host_port_pair
else:
wss_url = 'wss://' + wss_host_port_pair + '/ws'
wss_post_url = 'https://' + wss_host_port_pair
return (wss_url, wss_post_url)
修改成
def get_wss_parameters(request):
wss_host_port_pair = request.get('wshpp')
wss_tls = request.get('wstls')
if not wss_host_port_pair:
# Attempt to get a wss server from the status provided by prober,
# if that fails, use fallback value.
memcache_client = memcache.Client()
wss_active_host = memcache_client.get(constants.WSS_HOST_ACTIVE_HOST_KEY)
if wss_active_host in constants.WSS_HOST_PORT_PAIRS:
wss_host_port_pair = wss_active_host
else:
logging.warning(
'Invalid or no value returned from memcache, using fallback: '
+ json.dumps(wss_active_host))
wss_host_port_pair = constants.WSS_HOST_PORT_PAIRS[0]
if wss_tls and wss_tls == 'false':
wss_url = 'ws://' + wss_host_port_pair + '/ws'
wss_post_url = 'http://' + wss_host_port_pair
else:
wss_url = 'ws://' + wss_host_port_pair + '/ws'
wss_post_url = 'http://' + wss_host_port_pair
return (wss_url, wss_post_url)
index_template.html
找到如下代码块,修改并替换ip地址即可
{% if not chromeapp %}