3 * Copyright 2013, Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 package org.appspot.apprtc;
29 import org.webrtc.IceCandidate;
30 import org.webrtc.MediaConstraints;
31 import org.webrtc.PeerConnection;
32 import org.webrtc.SessionDescription;
34 import java.util.List;
36 public interface AppRTCClient {
38 * Asynchronously connect to an AppRTC room URL, e.g.
39 * https://apprtc.appspot.com/?r=NNN. Once connection is established
40 * onConnectedToRoom() callback with room parameters is invoked.
42 public void connectToRoom(String url);
45 * Send local SDP (offer or answer, depending on role) to the
48 public void sendLocalDescription(final SessionDescription sdp);
51 * Send Ice candidate to the other participant.
53 public void sendLocalIceCandidate(final IceCandidate candidate);
56 * Disconnect from the channel.
58 public void disconnect();
61 * Struct holding the signaling parameters of an AppRTC room.
63 public class AppRTCSignalingParameters {
64 public final List<PeerConnection.IceServer> iceServers;
65 public final boolean initiator;
66 public final MediaConstraints pcConstraints;
67 public final MediaConstraints videoConstraints;
68 public final MediaConstraints audioConstraints;
70 public AppRTCSignalingParameters(
71 List<PeerConnection.IceServer> iceServers,
72 boolean initiator, MediaConstraints pcConstraints,
73 MediaConstraints videoConstraints, MediaConstraints audioConstraints) {
74 this.iceServers = iceServers;
75 this.initiator = initiator;
76 this.pcConstraints = pcConstraints;
77 this.videoConstraints = videoConstraints;
78 this.audioConstraints = audioConstraints;
83 * Callback interface for messages delivered on signalling channel.
85 * Methods are guaranteed to be invoked on the UI thread of |activity|.
87 public static interface AppRTCSignalingEvents {
89 * Callback fired once the room's signaling parameters
90 * AppRTCSignalingParameters are extracted.
92 public void onConnectedToRoom(final AppRTCSignalingParameters params);
95 * Callback fired once channel for signaling messages is opened and
96 * ready to receive messages.
98 public void onChannelOpen();
101 * Callback fired once remote SDP is received.
103 public void onRemoteDescription(final SessionDescription sdp);
106 * Callback fired once remote Ice candidate is received.
108 public void onRemoteIceCandidate(final IceCandidate candidate);
111 * Callback fired once channel is closed.
113 public void onChannelClose();
116 * Callback fired once channel error happened.
118 public void onChannelError(int code, String description);