WebRTC (iOS)技術篇一(編譯)
1 編譯
- 基本上參照官網的方法是能編譯通過的,建議購買一臺國外的 AES 服務器,否則翻牆會出現無數的坑。
- WebRTC iOS 官網編譯地址
- 在 gclient sync 下載的過程中有時候會出現某些類庫無法的情況,這個時候可以使用 git clone 的方法,將相關類庫下載到 third_party 相關目錄中
- 有的時候會出現亞馬遜證書的問題,這個時候請將下面這個方法放到 depot_tools 中,然後
- 下載 download_from_google_storage 這個文件,然後替換掉 depot_tools 中的文件,重新 gclient sync,到此下載完結
- 編譯和使用 AppRTCMobile 的方法網上很多,可以直接使用。
import urllib2
import os
httpsPrefix = "https://storage.googleapis.com/"
gsPrefix = "gs://"
def download_gs_to_file(url, fileName):
download_http_to_file(url.replace(gsPrefix, httpsPrefix), fileName)
def download_http_to_file(url, fileName):
path=os.path.dirname(fileName)
if not os.path.exists(path):
os.makedirs(path)
response = urllib2.urlopen(url)
CHUNK = 16 * 1024
with open(fileName, 'wb') as f:
while True:
chunk = response.read(CHUNK)
if not chunk:
break
f.write(chunk)
print ('download ......ok')
if __name__ == "__main__":
print ('This is main of module "hello.py"')
download_gs_to_file('gs://chromium-android-tools/play-services/10.2.0/31843001b7ce94fbdf71f2a9db76b28548a795fa', '/tmp/tmpl1RB43/LICENSE')
簡單使用(P2P)
WebRTC 默認直接支持 P2P 音視頻聊天,效果也是很好的
- coturn NAT 相關服務搭建,這個是 WebRTC 使用的前提,視頻或者音頻流通過該服務來進行傳輸,分爲 stun 和 turn 兩種。
- 信令服務器,不用完全根據網上的方法去搭建信令服務器,WebRTC 主要是用信令服務器來傳輸 sdp 信息,如果你能夠通過 IM 傳遞 sdp 也是可以的,還簡單,常見的比如 socketio。(需要相關 demo 的可以回覆聯繫我)
音視頻會議室
- WebRTC 默認不支持會議室功能,因爲多路數據收發是很豪客戶端性能的,這是時候需要 server 來做數據中轉,常見 server 有 MCU 和 SFU
- 本文後續文章會介紹 SFU 的環境大家和使用(以 janus-gateway 舉例)
- 大家可以先看看我搭建的 demo 試玩一下,正常配置的 server 使用 janus-gateway 性能是很高的
- janus-gateway github 地址
後面會發文章繼續介紹