�ⲿ�֣���Ҫ�Dzο����ϱ��˵�������ֻ�����м�������һЩ���������һ���дһ�¡�
���ȣ�webrtc�������ı�����Ҫ�ο���λ�����������//m.ajphoenix.com/linux/24112.html
�������õ���Ubuntu 16.04 LTS 64λ��linuxϵͳ��
������������Ҫע����ǣ�������������ʱ��Ҫ����ϵͳ��������Ϊ����ijЩ������ʱ�������Ҫ��ǽ����������г�������ʧ�ܵ����⣬���п����Ƿ�ǽ��ɵģ���Ҫ�Լ�ȥȷ�����Dz�����Ҫ��ǽ�����⣬����ϵͳ��������ȡ��������������Ҫע���²Ż������ã�����е��鷳��Ϊʲô����������Ч�ء�
һ��AppRTC���������
������밴��������������У�ֻ�����м䰲װijЩ������ʱ����Ҫ�ȵ�ʱ��Ƚϳ������ĵȾ����ˡ�
������ɣ����õĵط�˵���㲻ͬ�ģ�
1.�������õ�iceserver,�������µ�webrtc demo�õ���iceserver����ν��iceserver��ʵ��������һ��url��ַ������һ���������ַ��������ij����
ICE_SERVER_BASE_URL = 'http://192.168.123.231'
������url��http://192.168.123.231/v1alpha/iceconfig/?key=north�������url��Ҫ�Լ���һ����վ����һ�£������ϣ����ֻ�Dz��ԣ�д��һ����̬��index.html���ظ��ͻ���Ӧ��Ҳ�ǿ��Եġ�
url���ص�json�����ǣ�
{"iceServers":[{"username":"1473662094:ling","credential":"HbWuzrR0z\/Ei0wBPvHISXpdGvc4=","ttl":86400,"urls":["turn:192.168.123.231:3478?transport=udp","turn:192.168.123.231:3478?transport=tcp","turn:192.168.123.231:3479?transport=udp","turn:192.168.123.231:3479?transport=tcp"]},{"username":"1473662094:ling","credential":"HbWuzrR0z\/Ei0wBPvHISXpdGvc4=","ttl":86400,"urls":["turn:192.168.123.231:3478?transport=udp","turn:192.168.123.231:3478?transport=tcp","turn:192.168.123.231:3479?transport=udp","turn:192.168.123.231:3479?transport=tcp"]}]}
ע�������urls������������uris�����Dz�ͬ�ġ�����webrtc demo���õ�urls�����ġ�����mac�汾��demo�������json��android��ͬ����bug����Ҫ�Լ����¡�
2.npm�İ�װ����Ҫ��ǽ��
3.constants.py�������

4.apprtc.py���棬Ϊ�˲���ͨ�����Ҽ�����䣬��Ϊ�˲�ִ��if����Ĵ��롣

5.�ҵ���������dev_appserver.py --host 192.168.123.231 --port 8080 ./out/app_engine
����Collider���������
���Ҳ�ǰ�������������Ϳ����ˡ�����go�ı���Ҳ��������ʱ�䣬��Ҫ�ǵ�һ�α�������⡣
��Ҫע����ǣ�Ҫ��srcĿ¼������������������ҵ���������~/collider_root/bin/collidermain -port=8089 -room-server="192.168.123.231" -tls=false
����������
�����������ص�Դ��http://turnserver.open-sys.org/downloads/v4.5.0.4/turnserver-4.5.0.4.tar.gz�Լ����밲װ�ġ�.configure�Ժ�make��sudo make install�����ˡ�
����֮ǰ����û�������ã��õ�Ĭ�����������ģ�ǩ��֤�������ͬ������ġ��ҵ���������sudo turnserver start
������������漰��һ����������֤�����⣬��������ֻ���Լ������ã���Щ��û�����⡣�������Ҫ���ߵģ��������о�����°ɡ�
�ġ�iceserver������
���ڵ�һ�������url:http://192.168.123.231/v1alpha/iceconfig/?key=north
����������һ��phpʵ�֡�
1.��վ������������ubuntu16.04 LTS���Դ���һ������lighttpd����վ�����������Բ���Ҫ��ȥװʲôapache����nginx��վ�������ˡ�
2.php��װ�������//m.ajphoenix.com/linux/23034.html��������php��װ���֣��������õ�php5.6���ο�//m.ajphoenix.com/linux/21202.html
3.lighttp����php
�ҵ�/etc/lighttpd/conf-available/15-fastcgi-php.conf,��"bin-path" => "/usr/local/bin/php-cgi"ָ�����Լ���php-cgiλ��
Ȼ������
lighttpd-enable-mod fastcgi
lighttpd-enable-mod fastcgi-php
�⽫������������
/etc/lighttpd/conf-enabled/10-fastcgi.conf ָ��/etc/lighttpd/conf-available/10-fastcgi.conf
/etc/lighttpd/conf-enabled/15-fastcgi-php.conf ָ�� /etc/lighttpd/conf-available/15-fastcgi-php.conf
�������lighttpd�� sudo service lighttpd force-reload
4.��������������php,������һ���ģ������usernameʲô����Ϊ����ʱ���Ըĵ��ģ�������Ҫ��Ͽͻ�������Ӧ���ģ�����д�����µ�ʱ���Ҷ�webrtc�ͻ��˴��뻹û��̫���о�������Ϊ�˲���ͨ�����������ˡ�
<?php
$request_username = "";//$_GET["username"];
if(!isset($_GET["username"])) {
//echo "username == null";
//exit;
$request_username = "ling";
}
$request_key = "ling1234";//$_GET["key"];
$time_to_live = 600;
$timestamp = time() + $time_to_live;//ʧЧʱ��
$response_username = $timestamp.":".$request_username;//$_GET["username"];
$response_key = $request_key;
if(empty($response_key))
$response_key = "��Կ";//constants.py��CEOD_KEY
$response_password = getSignature($response_username, $response_key);
$iceServer = new Response();
$iceServer->username = $response_username;
$iceServer->credential = $response_password;
$iceServer->ttl = 86400;
$iceServer->urls = array("turn:192.168.123.231:3478?transport=udp","turn:192.168.123.231:3478?transport=tcp","turn:192.168.123.231:3479?transport=udp","turn:192.168.123.231:3479?transport=tcp");
$str = json_encode($iceServer);
$config = array("iceServers"=>[$iceServer,$iceServer]);//{"iceServers":"ff"};
echo json_encode($config);
/**
* ʹ��HMAC-SHA1�㷨����ǩ��ֵ
*
* @param $str Դ��
* @param $key ��Կ
*
* @return ǩ��ֵ
*/
function getSignature($str, $key) {
$signature = "";
if (function_exists('hash_hmac')) {
$signature = base64_encode(hash_hmac("sha1", $str, $key, true));
} else {
$blocksize = 64;
$hashfunc = 'sha1';
if (strlen($key) > $blocksize) {
$key = pack('H*', $hashfunc($key));
}
$key = str_pad($key, $blocksize, chr(0x00));
$ipad = str_repeat(chr(0x36), $blocksize);
$opad = str_repeat(chr(0x5c), $blocksize);
$hmac = pack(
'H*', $hashfunc(
($key ^ $opad) . pack(
'H*', $hashfunc(
($key ^ $ipad) . $str
)
)
)
);
$signature = base64_encode($hmac);
}
return $signature;
}
class Response {
public $username = "";
public $credential = "";
public $ttl = "";
public $urls = array("");
}
?>
������php���뱣��Ϊindex.php���ŵ�/var/www/html/v1alpha/iceconfig���档����������http://192.168.123.231/v1alpha/iceconfig/?key=north�����᷵������������json���ݣ�
{"iceServers":[{"username":"1473662094:ling","credential":"HbWuzrR0z\/Ei0wBPvHISXpdGvc4=","ttl":86400,"urls":["turn:192.168.123.231:3478?transport=udp","turn:192.168.123.231:3478?transport=tcp","turn:192.168.123.231:3479?transport=udp","turn:192.168.123.231:3479?transport=tcp"]},{"username":"1473662094:ling","credential":"HbWuzrR0z\/Ei0wBPvHISXpdGvc4=","ttl":86400,"urls":["turn:192.168.123.231:3478?transport=udp","turn:192.168.123.231:3478?transport=tcp","turn:192.168.123.231:3479?transport=udp","turn:192.168.123.231:3479?transport=tcp"]}]}
������webrtc�������Ĵ���̣����ڶ�webrtc�Ŀͻ��˺ͷ��������о�̫�٣�����IJ��趼��Ϊ�˲�����д�����Ҷ��Dz���ͨ���ġ�
�������ø��µ�ַ��//m.ajphoenix.com/linux/24114.html