Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / libjingle / source / talk / examples / android / src / org / appspot / apprtc / AppRTCClient.java
1 /*
2  * libjingle
3  * Copyright 2013, Google Inc.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
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.
15  *
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.
26  */
27 package org.appspot.apprtc;
28
29 import org.webrtc.IceCandidate;
30 import org.webrtc.MediaConstraints;
31 import org.webrtc.PeerConnection;
32 import org.webrtc.SessionDescription;
33
34 import java.util.List;
35
36 public interface AppRTCClient {
37   /**
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.
41    */
42   public void connectToRoom(String url);
43
44   /**
45    * Send local SDP (offer or answer, depending on role) to the
46    * other participant.
47    */
48   public void sendLocalDescription(final SessionDescription sdp);
49
50   /**
51    * Send Ice candidate to the other participant.
52    */
53   public void sendLocalIceCandidate(final IceCandidate candidate);
54
55   /**
56    * Disconnect from the channel.
57    */
58   public void disconnect();
59
60   /**
61    * Struct holding the signaling parameters of an AppRTC room.
62    */
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;
69
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;
79     }
80   }
81
82   /**
83    * Callback interface for messages delivered on signalling channel.
84    *
85    * Methods are guaranteed to be invoked on the UI thread of |activity|.
86    */
87   public static interface AppRTCSignalingEvents {
88     /**
89      * Callback fired once the room's signaling parameters
90      * AppRTCSignalingParameters are extracted.
91      */
92     public void onConnectedToRoom(final AppRTCSignalingParameters params);
93
94     /**
95      * Callback fired once channel for signaling messages is opened and
96      * ready to receive messages.
97      */
98     public void onChannelOpen();
99
100     /**
101      * Callback fired once remote SDP is received.
102      */
103     public void onRemoteDescription(final SessionDescription sdp);
104
105     /**
106      * Callback fired once remote Ice candidate is received.
107      */
108     public void onRemoteIceCandidate(final IceCandidate candidate);
109
110     /**
111      * Callback fired once channel is closed.
112      */
113     public void onChannelClose();
114
115     /**
116      * Callback fired once channel error happened.
117      */
118     public void onChannelError(int code, String description);
119   }
120 }