Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
228 lines (209 sloc) 13.2 KB

AppRTCDemo - A WebRTC for iOS Client Demo


##About AppRTCDemo# This is a WebRTC4iOS client demo. This demo show how 2 ios clients have a real-time audio&video communication. If you have the STUN/TURN server, they can communicate in different LAN.


##Requirements#

  • Xcode 5 or higher
  • iOS 6.0 or higher
  • ARC

##About WebRTC# WebRTC is a free, open project that enables web browsers with Real-Time Communications (RTC) capabilities via simple JavaScript APIs. The WebRTC components have been optimized to best serve this purpose.


##About WebRTC Native APIs and libjingle# To implement real time communication, web developer can use WebRTC API, but we, as native developer, can use what? Thsese are: WebRTC Native APIs and libjingle, they can enable Native APP to implement RTC(Real-time communication) function.

In fact, the official has provided us some Native Example Applications. Here is the official iOS example, but it's not good. This is a better iOS example based the official one.


##About Signaling Service# Signaling protocols and mechanisms are not defined by WebRTC standards, so you need to build it by yourself.

The demo uses XMPP to build the signaling service.It implements that with XMPPFramework.

PS: The official iOS example uses the Google App Engine Channel API to build the service.


##The Basic P2P Communication Process#

Caller Callee

1. build the signaling service and listen to the signaling message

1. build the signaling service and listen to the signaling message
... to bulid RTC connection...
2. create peerConnection

3.1 create and send offer sdp(sessionDescription);

if got new ICE Candidate, then send it to Callee

2. listen to the signaling message. Cache the remote offer sdp and ICE Candidate

3.2 create peerConnection and deal with the offer sdp and ICE Candidate
4.2 listen to the signaling message. Deal with the remote answer sdp and ICE Candidate

4.1 create and send answer sdp(sessionDescription);

if got new ICE Candidate, then send it to Caller

..successfully building RTC connection, then can start audio and video communication...
5.1 send BYE signaling message and close peerConnection 5.2 when get the BYE signaling message, then close peerConnection


中文版

Caller Callee
1. 建立信令通讯(XMPPWorker)以及监听信令
1. 建立信令通讯(XMPPWorker)以及监听信令
... 建立RTC 链接...
2. 创建 peerConnection

3.1 创建并发送 offer

若发现新的ICE Candidate,则发送给Callee

2. 监听信令。把收到的 offer 以及 ICE Candidate缓存起来

3.2 创建 peerConnection,处理缓存的 offer 以及ICE Candidate
4.2 监听信令。直接处理收到的 answer 以及 ICE Candidate

4.1 创建并发送 answer

若发现新的ICE Candidate,则发送给Caller

..RTC 链接建立完毕,开始进行音视频通讯...
5.1 发送 BYE 信令,关闭 peerConnection 5.2 收到 BYE 信令后,关闭 peerConnection



##100% Attention#

  • In this demo, I custom-make a signaling type XMPPMessage to transfer the signallings. Before run this demo, Please Check whether your jabber server can support this custom XMPPMessage. If your jabber server cann't support it, you should modify the custom XMPPMessage's type that your jabber server can support in the XMPPMessage+Signaling file, for example in the file, change TYPE_SIGNALING macro value signaling to chat.

  • 在该Demo中,我使用的是自定义的、类型为 signaling 的 XMPPMessage 来传递信令。**运行该Demo前,请务必检测你的jabber服务器是否支持这种自定义类型的 XMPPMessage 。**如果不支持,请把该类型的 XMPPMessage 修改为你的jabber服务器支持的类型,如 chat 类型(在XMPPMessage+Signaling文件中修改TYPE_SIGNALING的宏定义值即可)。


##Change Log#

1.0 - 2014/03/11

  • Initial release. Now 2 iOS client can have a real-time audio&video communication repeatedly, and if you have the STUN/TURN server, they can communicate each other in different LAN.