// Create connection client. Use DirectRTCClient if room name is an IP otherwise use the
// standard WebSocketRTCClient.
if("firebase".equals(roomId)){ Log.d(TAG,"firebase"); appRtcClient =new FirebaseRTCClient(this);}elseif(loopback ||!DirectRTCClient.IP_PATTERN.matcher(roomId).matches()){ appRtcClient =new WebSocketRTCClient(this);}else{ Log.i(TAG,"Using DirectRTCClient because room name looks like an IP."); appRtcClient =new DirectRTCClient(this);}
/**
* AppRTCClient is the interface representing an AppRTC client.
*/publicinterfaceAppRTCClient{/**
* Struct holding the connection parameters of an AppRTC room.
*/classRoomConnectionParameters{publicfinal String roomUrl;publicfinal String roomId;publicfinalboolean loopback;publicRoomConnectionParameters(String roomUrl, String roomId,boolean loopback){this.roomUrl= roomUrl;this.roomId= roomId;this.loopback= loopback;}}/**
* Asynchronously connect to an AppRTC room URL using supplied connection
* parameters. Once connection is established onConnectedToRoom()
* callback with room parameters is invoked.
*/voidconnectToRoom(RoomConnectionParameters connectionParameters);/**
* Send offer SDP to the other participant.
*/voidsendOfferSdp(final SessionDescription sdp);/**
* Send answer SDP to the other participant.
*/voidsendAnswerSdp(final SessionDescription sdp);/**
* Send Ice candidate to the other participant.
*/voidsendLocalIceCandidate(final IceCandidate candidate);/**
* Send removed ICE candidates to the other participant.
*/voidsendLocalIceCandidateRemovals(final IceCandidate[] candidates);/**
* Disconnect from room.
*/voiddisconnectFromRoom();/**
* Struct holding the signaling parameters of an AppRTC room.
*/classSignalingParameters{publicfinal List<PeerConnection.IceServer> iceServers;publicfinalboolean initiator;publicfinal String clientId;publicfinal String wssUrl;publicfinal String wssPostUrl;publicfinal SessionDescription offerSdp;publicfinal List<IceCandidate> iceCandidates;publicSignalingParameters(List<PeerConnection.IceServer> iceServers,boolean initiator, String clientId, String wssUrl, String wssPostUrl, SessionDescription offerSdp, List<IceCandidate> iceCandidates){this.iceServers= iceServers;this.initiator= initiator;this.clientId= clientId;this.wssUrl= wssUrl;this.wssPostUrl= wssPostUrl;this.offerSdp= offerSdp;this.iceCandidates= iceCandidates;}}/**
* Callback interface for messages delivered on signaling channel.
*
* <p>Methods are guaranteed to be invoked on the UI thread of |activity|.
*/interfaceSignalingEvents{/**
* Callback fired once the room's signaling parameters
* SignalingParameters are extracted.
*/voidonConnectedToRoom(final SignalingParameters params);/**
* Callback fired once remote SDP is received.
*/voidonRemoteDescription(final SessionDescription sdp);/**
* Callback fired once remote Ice candidate is received.
*/voidonRemoteIceCandidate(final IceCandidate candidate);/**
* Callback fired once remote Ice candidate removals are received.
*/voidonRemoteIceCandidatesRemoved(final IceCandidate[] candidates);/**
* Callback fired once channel is closed.
*/voidonChannelClose();/**
* Callback fired once channel error happened.
*/voidonChannelError(final String description);}}