剛嘗試了怎麼樣在區域網路中使用 WebRTC 來進行 VOIP,意外發現其實滿簡單的。分享一下我的步驟
git clone https://github.com/andyet/signalmaster
cd signalmaster
npm install| var stringify = function(obj, prop) { | |
| var placeholder = '____PLACEHOLDER____'; | |
| var fns = []; | |
| var json = JSON.stringify(obj, function(key, value) { | |
| if (typeof value === 'function') { | |
| fns.push(value); | |
| return placeholder; | |
| } | |
| return value; | |
| }, 2); |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet"> | |
| <script src="http://code.jquery.com/jquery.js"></script> | |
| <script src="https://rawgithub.com/caolan/async/master/lib/async.js"></script> | |
| <script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script> | |
| <script> | |
| window.URL = window.URL || window.webkitURL; | |
| #! /bin/sh | |
| #### NOT CONFIRMED WORKING YET #### | |
| # on fresh ubuntu 14.04 | |
| sudo apt-get install build-essential | |
| sudo apt-get install gcc-arm-linux-gnueabihf g++-4.8-multilib-arm-linux-gnueabihf | |
| apt-get install pkgconfig | |
| sudo apt-get install git # do we need this? |
| sudo apt-get install libatk1.0-0 libc6 libasound2 libcairo2 libcups2 libexpat1 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0 libgtk2.0-0 libpam0g libpango1.0-0 libpci3 libpcre3 libpixman-1-0 libpng12-0 libspeechd2 libstdc++6 libsqlite3-0 libx11-6 libxau6 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1 libxtst6 zlib1g apache2.2-bin bison curl elfutils fakeroot flex g++ gperf libapache2-mod-php5 libasound2-dev libbz2-dev libcairo2-dev libcups2-dev libcurl4-gnutls-dev libelf-dev libgconf2-dev libgl1-mesa-dev libglib2.0-dev libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev libkrb5-dev libnspr4-dev libnss3-dev libpam0g-dev libpci-dev libpulse-dev libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev libudev-dev libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev mesa-common-dev metacity patch perl php5-cgi pkg-config python python-cherrypy3 python-dev python-psutil rpm ruby subversion ttf-dejavu-core ttf-indic-fonts ttf-koc |
| cd ~ | |
| mkdir .gyp | |
| nano .gyp/include.gypi | |
| paste the following | |
| { | |
| 'variables': { | |
| 'linux_use_gold_binary' : 0, | |
| 'linux_use_gold_flags' : 0, | |
| 'target_arch': 'arm', | |
| 'disable_nacl': 1, # NaCL does not build for ARM. |
| === Relevant links | |
| https://help.ubuntu.com/community/MultiArch | |
| http://unix.stackexchange.com/questions/60282/can-one-install-an-armel-ubuntu-package-on-armhf-ubuntu-system | |
| === Setup multiarch for armel | |
| Create | |
| '/etc/dpkg/dpkg.cfg.d/multiarch' | |
| containing | |
| 'foreign-architecture armel'. |
| #!/usr/bin/env node | |
| /* | |
| * Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js | |
| * Modified from https://gist.github.com/paolorossi/1993068 | |
| */ | |
| var http = require('http') | |
| , fs = require('fs') | |
| , util = require('util') |
| /* | |
| * Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js | |
| */ | |
| var http = require('http'), | |
| fs = require('fs'), | |
| util = require('util'); | |
| http.createServer(function (req, res) { | |
| var path = 'video.mp4'; |
| var app = require('express')(); | |
| var GridStore = require('mongodb').GridStore; | |
| var ObjectID = require('mongodb').ObjectID; | |
| var MongoClient = require('mongodb').MongoClient; | |
| var Server = require('mongodb').Server; | |
| var dbConnection; | |
| MongoClient.connect("mongodb://localhost:27017/ersatz?auto_reconnect", {journal: true}, function(err, db) { | |
| dbConnection = db; | |
| app.listen(3000); |