.. java:import:: at.jumpch.utils JCAudioManager .. java:import:: at.jumpch.utils Log .. java:import:: io.socket SocketIO .. java:import:: io.socket IOCallback .. java:import:: io.socket IOAcknowledge .. java:import:: io.socket SocketIOException .. java:import:: org.apache.http.client HttpClient .. java:import:: org.apache.http.client ResponseHandler .. java:import:: org.apache.http.client.methods HttpGet .. java:import:: org.apache.http.impl.client BasicResponseHandler .. java:import:: org.apache.http.impl.client DefaultHttpClient .. java:import:: org.json JSONArray .. java:import:: org.json JSONException .. java:import:: org.json JSONObject .. java:import:: org.webrtc AudioSource .. java:import:: org.webrtc AudioTrack .. java:import:: org.webrtc DataChannel .. java:import:: org.webrtc IceCandidate .. java:import:: org.webrtc MediaConstraints .. java:import:: org.webrtc MediaStream .. java:import:: org.webrtc MediaStreamTrack .. java:import:: org.webrtc PeerConnection .. java:import:: org.webrtc PeerConnectionFactory .. java:import:: org.webrtc SdpObserver .. java:import:: org.webrtc SessionDescription .. java:import:: org.webrtc VideoCapturer .. java:import:: org.webrtc VideoCapturerAndroid .. java:import:: org.webrtc VideoSource .. java:import:: org.webrtc VideoTrack .. java:import:: android.app Activity .. java:import:: android.content Context .. java:import:: android.content Intent .. java:import:: android.graphics Bitmap .. java:import:: android.graphics BitmapFactory .. java:import:: android.graphics PixelFormat .. java:import:: android.graphics Point .. java:import:: android.hardware.display DisplayManager .. java:import:: android.hardware.display VirtualDisplay .. java:import:: android.media Image .. java:import:: android.media ImageReader .. java:import:: android.media.projection MediaProjection .. java:import:: android.media.projection MediaProjectionManager .. java:import:: android.os Build .. java:import:: android.os Handler .. java:import:: android.os SystemClock .. java:import:: android.util Base64 .. java:import:: android.util DisplayMetrics .. java:import:: android.view Display .. java:import:: android.view WindowManager .. java:import:: java.io ByteArrayOutputStream .. java:import:: java.io UnsupportedEncodingException .. java:import:: java.net URL .. java:import:: java.nio ByteBuffer .. java:import:: java.nio.charset Charset .. java:import:: java.util ArrayList .. java:import:: java.util HashMap .. java:import:: java.util List .. java:import:: java.util Map .. java:import:: java.util Random .. java:import:: java.util UUID .. java:import:: java.util.regex Matcher .. java:import:: java.util.regex Pattern .. java:import:: javax.net.ssl SSLContext JCClient ======== .. java:package:: at.jumpch.sdk :noindex: .. java:type:: public class JCClient JumpChat client class. Create this object to use JumpChat services. Fields ------ CAMERA_BACK ^^^^^^^^^^^ .. java:field:: public static final int CAMERA_BACK :outertype: JCClient Specify the back camera. **See also:** :java:ref:`JCVideoCaptureInterface.selectCamera(int)` CAMERA_FRONT ^^^^^^^^^^^^ .. java:field:: public static final int CAMERA_FRONT :outertype: JCClient Specify the front camera. **See also:** :java:ref:`JCVideoCaptureInterface.selectCamera(int)` FOURCC_ABGR ^^^^^^^^^^^ .. java:field:: public static final int FOURCC_ABGR :outertype: JCClient Specify image format \ `ABGR `_\ . **See also:** :java:ref:`JCVideoCaptureCallback.provideFrame(byte[],int,int,int)`, :java:ref:`JCVideoCaptureCallback.provideFrame(byte[],int,int,int,long,int)` FOURCC_ARGB ^^^^^^^^^^^ .. java:field:: public static final int FOURCC_ARGB :outertype: JCClient Specify image format \ `ARGB `_\ . **See also:** :java:ref:`JCVideoCaptureCallback.provideFrame(byte[],int,int,int)`, :java:ref:`JCVideoCaptureCallback.provideFrame(byte[],int,int,int,long,int)` FOURCC_NV21 ^^^^^^^^^^^ .. java:field:: public static final int FOURCC_NV21 :outertype: JCClient Specify image format \ `NV12 `_\ . **See also:** :java:ref:`JCVideoCaptureCallback.provideFrame(byte[],int,int,int)`, :java:ref:`JCVideoCaptureCallback.provideFrame(byte[],int,int,int,long,int)` FOURCC_YV12 ^^^^^^^^^^^ .. java:field:: public static final int FOURCC_YV12 :outertype: JCClient Specify image format \ `YV12 `_\ . **See also:** :java:ref:`JCVideoCaptureCallback.provideFrame(byte[],int,int,int)`, :java:ref:`JCVideoCaptureCallback.provideFrame(byte[],int,int,int,long,int)` ROOM_TYPE_CUSTOM ^^^^^^^^^^^^^^^^ .. java:field:: public static final String ROOM_TYPE_CUSTOM :outertype: JCClient Custom room type. This is a string representing the room. ROOM_TYPE_DEFAULT ^^^^^^^^^^^^^^^^^ .. java:field:: public static final String ROOM_TYPE_DEFAULT :outertype: JCClient Default room type is \ :java:ref:`JCClient.ROOM_TYPE_RANDOM`\ . ROOM_TYPE_RANDOM ^^^^^^^^^^^^^^^^ .. java:field:: public static final String ROOM_TYPE_RANDOM :outertype: JCClient Random room type. This is a 10 digit number. SETTING_API_KEY ^^^^^^^^^^^^^^^ .. java:field:: public static final String SETTING_API_KEY :outertype: JCClient Specify the API key that should be used by the JumpChat web API. **See also:** :java:ref:`JCClient.JCClient(Callback,Context,Map)` SETTING_CREATE_VIDEO ^^^^^^^^^^^^^^^^^^^^ .. java:field:: public static final String SETTING_CREATE_VIDEO :outertype: JCClient Settings to disable creating \ :java:ref:`JCVideoView`\ objects. This is mainly used when JCClient is only a broadcaster. **See also:** :java:ref:`JCClient.JCClient(Callback,Context,Map)` SETTING_SERVER_NAME ^^^^^^^^^^^^^^^^^^^ .. java:field:: public static final String SETTING_SERVER_NAME :outertype: JCClient Settings to specify the serverName to connect to. Use this if running a standalone JumpChat server. **See also:** :java:ref:`JCClient.JCClient(Callback,Context,Map)` SETTING_USER_AVATAR ^^^^^^^^^^^^^^^^^^^ .. java:field:: public static final String SETTING_USER_AVATAR :outertype: JCClient Specify the current user's avatar. The string is a Base64 encoded JPEG. **See also:** :java:ref:`JCClient.JCClient(Callback,Context,Map)` SETTING_USER_ID ^^^^^^^^^^^^^^^ .. java:field:: public static final String SETTING_USER_ID :outertype: JCClient Specify the user id of the current user. Any unique string can be used to specify the user id. **See also:** :java:ref:`JCClient.JCClient(Callback,Context,Map)` SETTING_USER_NAME ^^^^^^^^^^^^^^^^^ .. java:field:: public static final String SETTING_USER_NAME :outertype: JCClient Specify the current user's name. **See also:** :java:ref:`JCClient.JCClient(Callback,Context,Map)` SETTING_VIDEO_CAPTURE_CLASS ^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:field:: public static final String SETTING_VIDEO_CAPTURE_CLASS :outertype: JCClient Specify the class to be used when override the video capturer. This is used when the developer wants to implement a custom video capturer. **See also:** :java:ref:`JCClient.JCClient(Callback,Context,Map)` Constructors ------------ JCClient ^^^^^^^^ .. java:constructor:: public JCClient(Callback callback, Context context) :outertype: JCClient JCClient constructor. You should generally not create more than one within the application. \ **Example:**\ .. code-block:: java JCClient mJC = new JCClient(callback, getApplicationContext(), activity); :param callback: \ :java:ref:`JCClient.Callback`\ implementation :param context: \ :java:ref:`Context`\ object from Android application JCClient ^^^^^^^^ .. java:constructor:: public JCClient(Callback callback, Context context, Map settings) :outertype: JCClient JCClient constructor. You should generally not create more than one within the application. Settings map should use \ `JCClient constants `_\ \ **Example:**\ .. code-block:: java Bitmap avatar = BitmapFactory.decodeResource(activity.getResources(), R.drawable.avatar) Map settings = new Map settings() {{ put(JCClient.SETTING_USER_ID, "userid-123456790"); put(JCClient.SETTING_USER_NAME, "JumpChat Android SDK Example"); put(JCClient.SETTING_USER_AVATAR, JCClient.encodeBitmap(avatar)); }}; JCClient jc = new JCClient(callback, getApplicationContext(), activity); :param callback: \ :java:ref:`JCClient.Callback`\ implementation :param context: \ :java:ref:`Context`\ object from Android application :param settings: Provide custom settings for JumpChat client Methods ------- checkVersion ^^^^^^^^^^^^ .. java:method:: public void checkVersion(String clientName) :outertype: JCClient Request a version check for a given client name. If the application is not registered, an empty string will be returned in \ :java:ref:`JCClient.Callback.onVersionCheck(String)`\ :param clientName: String of the client name. **See also:** :java:ref:`JCClient.Callback.onVersionCheck(String)` createRoom ^^^^^^^^^^ .. java:method:: public void createRoom() :outertype: JCClient Request the server to create a new room. The result is ready, \ :java:ref:`JCClient.Callback.onRoomCreated(String)`\ is called. **See also:** :java:ref:`JCClient.Callback.onRoomCreated(String)` dispose ^^^^^^^ .. java:method:: public void dispose() :outertype: JCClient Dispose the JCClient object. Cleans up allocated resources. enableAudio ^^^^^^^^^^^ .. java:method:: public boolean enableAudio(boolean enabled) :outertype: JCClient Mute/Unmute the recording microphone. Returns the new state. :param enabled: \ ``true``\ if audio is enable, \ ``false otherwise``\ :return: \ ``true``\ if audio is enable, \ ``false otherwise``\ enableHD ^^^^^^^^ .. java:method:: public boolean enableHD(boolean enable) :outertype: JCClient Enable/Disable capturing video in HD. HD resolutions is 1280x720. SD resolution is 640x480. :param enable: \ ``true``\ if HD is enable, \ ``false otherwise``\ :return: \ ``true``\ if HD is enable, \ ``false otherwise``\ enableVideo ^^^^^^^^^^^ .. java:method:: public boolean enableVideo(boolean enabled) :outertype: JCClient Enable/Disable the camera. Return the new state. :param enabled: \ ``true``\ if video is enable, \ ``false otherwise``\ :return: \ ``true``\ if video is enable, \ ``false otherwise``\ encodeBitmap ^^^^^^^^^^^^ .. java:method:: public static String encodeBitmap(Bitmap img) :outertype: JCClient Encode a bitmap into Base64 encoded JPEG. :param img: \ :java:ref:`Bitmap`\ to be encoded to Base64 JPEG :return: String representing the img getAudioBandwidth ^^^^^^^^^^^^^^^^^ .. java:method:: public int getAudioBandwidth() :outertype: JCClient Get the audio bandwidth limit in kilo bits per second for audio. Zero means unlimited. :return: Bandwidth limit value in kbps getAvatar ^^^^^^^^^ .. java:method:: public Bitmap getAvatar(String userid) :outertype: JCClient Retrieve the \ :java:ref:`Bitmap`\ avatar for a specific user. \ **Example:**\ .. code-block:: java Bitmap avatar = mJC.getAvatar(userid); ImageView view = (ImageView)findViewById(R.id.image_view); view.setImageBitmap(avatar); :param userid: User id of the avatar. Can be \ ``me``\ for current user’s avatar. :return: \ :java:ref:`Bitmap`\ avatar of the user, \ ``null``\ otherwise. getInstance ^^^^^^^^^^^ .. java:method:: public static JCClient getInstance() :outertype: JCClient Get the last instantiated instance of JCClient. Useful when JCClient is not readily available. \ **Example:**\ .. parsed-literal:: JCClient mJC = JCClient.getInstance(); :return: last JCClient instance getJoinUrl ^^^^^^^^^^ .. java:method:: public String getJoinUrl() :outertype: JCClient Retrieve the URL to join room. Used to invite others to room. \ **Example:**\ .. code-block:: java String url = mJC.getJoinUrl(); if (!url.isEmpty()) { // Send message to friend to click on URL } :return: URL string of the room getName ^^^^^^^ .. java:method:: public String getName(String userid) :outertype: JCClient Get the name of a specific user. \ **Example:**\ .. code-block:: java String name = mJC.getName(userid); :param userid: User id string. Can be \ ``me``\ for current user’s avatar :return: Name of the user getPassword ^^^^^^^^^^^ .. java:method:: public String getPassword() :outertype: JCClient Get the password for the current room. \ **Example:**\ .. code-block:: java String password = mJC.getPassword(); if (password.isEmpty()) { // unlocked } else { // locked } :return: Password for the room getRoomName ^^^^^^^^^^^ .. java:method:: public String getRoomName() :outertype: JCClient Retrieve the room name. Can be used for display. :return: String of the room name getScreenShare ^^^^^^^^^^^^^^ .. java:method:: public boolean getScreenShare() :outertype: JCClient Find out if screen share is enabled or not. :return: \ ``true``\ if sharing screen, \ ``false``\ otherwise getSessId ^^^^^^^^^ .. java:method:: public String getSessId() :outertype: JCClient Retrieve the session id. Session ids represent the connection to the server. :return: String representing session id. getUsers ^^^^^^^^ .. java:method:: public Map getUsers() :outertype: JCClient Get a map of userid to \ :java:ref:`JSONObject`\ representing the user information. \ **Example:**\ .. code-block:: java Map users = mJC.getUsers(); for (Map.Entry entry : users.entrySet()) { System.out.println(entry.getKey() + "/" + entry.getValue().toString()); } :return: Map of the users getVideoBandwidth ^^^^^^^^^^^^^^^^^ .. java:method:: public int getVideoBandwidth() :outertype: JCClient Get the video bandwidth limit in kilo bits per second for audio. Zero means unlimited. :return: Bandwidth limit value in kbps isAdmin ^^^^^^^ .. java:method:: public boolean isAdmin() :outertype: JCClient Check if current user is admin. Shortcut for \ ``isAdmin("me")``\ . :return: \ ``true``\ if user id admin, \ ``false``\ otherwise isAdmin ^^^^^^^ .. java:method:: public boolean isAdmin(String userid) :outertype: JCClient Check if user id is admin. :param userid: User id to look up if admin :return: \ ``true``\ if user id admin, \ ``false``\ otherwise isScreenShareAvailable ^^^^^^^^^^^^^^^^^^^^^^ .. java:method:: public static boolean isScreenShareAvailable() :outertype: JCClient Return if screen share feature is available. :return: \ ``true``\ if screenshare is available, \ ``false``\ otherwise join ^^^^ .. java:method:: public void join(String roomName) :outertype: JCClient Join a room, given a room name. :param roomName: String with the name of the room. join ^^^^ .. java:method:: public void join(String roomName, String roomType) :outertype: JCClient Join a room, given a room name and room type. :param roomName: String with the name of the room. :param roomType: \ :java:ref:`JCClient.ROOM_TYPE_RANDOM`\ or \ :java:ref:`JCClient.ROOM_TYPE_CUSTOM`\ joinUrl ^^^^^^^ .. java:method:: public void joinUrl(String url) :outertype: JCClient Join a room, with a URL. This is used for federated JumpChat rooms. :param url: URL that represents the JumpChat room leave ^^^^^ .. java:method:: public void leave() :outertype: JCClient Leave the joined room. **See also:** :java:ref:`JCClient.join(String)`, :java:ref:`JCClient.join(String,String)`, :java:ref:`JCClient.joinUrl(String)` muteAudioStream ^^^^^^^^^^^^^^^ .. java:method:: public void muteAudioStream(boolean mute) :outertype: JCClient Mute/Unmute all incoming audio streams :param mute: \ ``true``\ to mute audio, \ ``false``\ otherwise onActivityResult ^^^^^^^^^^^^^^^^ .. java:method:: public void onActivityResult(int requestCode, int resultCode, Intent data) :outertype: JCClient Called from activity to process the screen share request. :param requestCode: Should be \ :java:ref:`JCClient.CUSTOM_REQUEST_START_PROJECTION`\ :param resultCode: Result of the screen share request :param data: Data for the screen share request onPause ^^^^^^^ .. java:method:: public void onPause() :outertype: JCClient Call from \ :java:ref:`Activity.onPause()`\ to release camera. onResume ^^^^^^^^ .. java:method:: public void onResume() :outertype: JCClient Call from \ :java:ref:`Activity.onResume()`\ to acquire camera. selectCamera ^^^^^^^^^^^^ .. java:method:: public void selectCamera(int cameraId) :outertype: JCClient Select camera to receive video from. Use \ :java:ref:`JCClient.CAMERA_FRONT`\ or \ :java:ref:`CAMERA_BACK`\ . :param cameraId: Camera id to select to. sendDataMessage ^^^^^^^^^^^^^^^ .. java:method:: public void sendDataMessage(JSONObject dataMsg) :outertype: JCClient Send data message to everyone in the room. :param dataMsg: \ :java:ref:`JSONObject`\ representing the data sendDataMessage ^^^^^^^^^^^^^^^ .. java:method:: public void sendDataMessage(String userid, JSONObject dataMsg) :outertype: JCClient Send data message to everyone a user in the room. :param userid: Specific user id string to send data to. :param dataMsg: \ :java:ref:`JSONObject`\ representing the data sendKick ^^^^^^^^ .. java:method:: public void sendKick(String userid) :outertype: JCClient Request a user be kicked. Only the admin can kick a user. :param userid: User id string. sendKnockAnswer ^^^^^^^^^^^^^^^ .. java:method:: public void sendKnockAnswer(String sessid, Boolean answer) :outertype: JCClient Return the answer for a knock request. The session id is given in the onKnocking callback. :param sessid: Session id of the user knocking. :param answer: \ ``true``\ if user is allowed in, \ ``false``\ otherwise sendLock ^^^^^^^^ .. java:method:: public void sendLock(Boolean lock) :outertype: JCClient Request room to be locked. Only the admin can lock the room. :param lock: \ ``true``\ if locking, \ ``false``\ otherwise **See also:** :java:ref:`Callback.onRoomInfoUpdated()` sendTextMessage ^^^^^^^^^^^^^^^ .. java:method:: public void sendTextMessage(String textMessage) :outertype: JCClient Send text message to everyone in the room. :param textMessage: Message to send sendTextMessage ^^^^^^^^^^^^^^^ .. java:method:: public void sendTextMessage(String userid, String textMessage) :outertype: JCClient Send text message to a user in the room. :param userid: User id string to send message to :param textMessage: Message to send setAudioBandwidth ^^^^^^^^^^^^^^^^^ .. java:method:: public void setAudioBandwidth(int bw) :outertype: JCClient Set the audio bandwidth limit in kilo bits per second for audio. Zero means unlimited. :param bw: Bandwidth limit value in kbps setScreenShare ^^^^^^^^^^^^^^ .. java:method:: public void setScreenShare(boolean screenShare, Activity activity) :outertype: JCClient Find out if screen share is enabled or not. :return: \ ``true``\ if sharing screen, \ ``false``\ otherwise setServerName ^^^^^^^^^^^^^ .. java:method:: public void setServerName(String serverName) :outertype: JCClient Set the server name if using a federated server or running your own server. :param serverName: Name of the server **See also:** :java:ref:`JCClient.SETTING_SERVER_NAME` setVideoBandwidth ^^^^^^^^^^^^^^^^^ .. java:method:: public void setVideoBandwidth(int bw) :outertype: JCClient Set the audio bandwidth limit in kilo bits per second for audio. Zero means unlimited. :param bw: Bandwidth limit value in kbps toggleCamera ^^^^^^^^^^^^ .. java:method:: public int toggleCamera() :outertype: JCClient Toggle between front and back camera. :return: \ :java:ref:`JCClient.CAMERA_FRONT`\ or \ :java:ref:`CAMERA_BACK`\ updateAvatar ^^^^^^^^^^^^ .. java:method:: public void updateAvatar(String encodedAvatar) :outertype: JCClient Send an updated avatar to everyone in the room. encodedAvatar is a base64 encoded string. :param encodedAvatar: base64 encoded JPEG image updateName ^^^^^^^^^^ .. java:method:: public void updateName(String name) :outertype: JCClient Send an updated name to everyone in the room. :param name: Name to update