JCClient

public class JCClient

JumpChat client class. Create this object to use JumpChat services.

Fields

CAMERA_BACK

public static final int CAMERA_BACK

Specify the back camera.

See also: JCVideoCaptureInterface.selectCamera(int)

CAMERA_FRONT

public static final int CAMERA_FRONT

Specify the front camera.

See also: JCVideoCaptureInterface.selectCamera(int)

FOURCC_ABGR

public static final int FOURCC_ABGR

Specify image format ABGR.

See also: JCVideoCaptureCallback.provideFrame(byte[],int,int,int), JCVideoCaptureCallback.provideFrame(byte[],int,int,int,long,int)

FOURCC_ARGB

public static final int FOURCC_ARGB

Specify image format ARGB.

See also: JCVideoCaptureCallback.provideFrame(byte[],int,int,int), JCVideoCaptureCallback.provideFrame(byte[],int,int,int,long,int)

FOURCC_NV21

public static final int FOURCC_NV21

Specify image format NV12.

See also: JCVideoCaptureCallback.provideFrame(byte[],int,int,int), JCVideoCaptureCallback.provideFrame(byte[],int,int,int,long,int)

FOURCC_YV12

public static final int FOURCC_YV12

Specify image format YV12.

See also: JCVideoCaptureCallback.provideFrame(byte[],int,int,int), JCVideoCaptureCallback.provideFrame(byte[],int,int,int,long,int)

ROOM_TYPE_CUSTOM

public static final String ROOM_TYPE_CUSTOM

Custom room type. This is a string representing the room.

ROOM_TYPE_DEFAULT

public static final String ROOM_TYPE_DEFAULT

Default room type is JCClient.ROOM_TYPE_RANDOM.

ROOM_TYPE_RANDOM

public static final String ROOM_TYPE_RANDOM

Random room type. This is a 10 digit number.

SETTING_API_KEY

public static final String SETTING_API_KEY

Specify the API key that should be used by the JumpChat web API.

See also: JCClient.JCClient(Callback,Context,Map)

SETTING_CREATE_VIDEO

public static final String SETTING_CREATE_VIDEO

Settings to disable creating JCVideoView objects. This is mainly used when JCClient is only a broadcaster.

See also: JCClient.JCClient(Callback,Context,Map)

SETTING_SERVER_NAME

public static final String SETTING_SERVER_NAME

Settings to specify the serverName to connect to. Use this if running a standalone JumpChat server.

See also: JCClient.JCClient(Callback,Context,Map)

SETTING_USER_AVATAR

public static final String SETTING_USER_AVATAR

Specify the current user’s avatar. The string is a Base64 encoded JPEG.

See also: JCClient.JCClient(Callback,Context,Map)

SETTING_USER_ID

public static final String SETTING_USER_ID

Specify the user id of the current user. Any unique string can be used to specify the user id.

See also: JCClient.JCClient(Callback,Context,Map)

SETTING_USER_NAME

public static final String SETTING_USER_NAME

Specify the current user’s name.

See also: JCClient.JCClient(Callback,Context,Map)

SETTING_VIDEO_CAPTURE_CLASS

public static final String SETTING_VIDEO_CAPTURE_CLASS

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: JCClient.JCClient(Callback,Context,Map)

Constructors

JCClient

public JCClient(Callback callback, Context context)

JCClient constructor. You should generally not create more than one within the application.

Example:

JCClient mJC = new JCClient(callback, getApplicationContext(), activity);
Parameters:

JCClient

public JCClient(Callback callback, Context context, Map<String, String> settings)

JCClient constructor. You should generally not create more than one within the application.

Settings map should use JCClient constants

Example:

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);
Parameters:
  • callbackJCClient.Callback implementation
  • contextContext object from Android application
  • settings – Provide custom settings for JumpChat client

Methods

checkVersion

public void checkVersion(String clientName)

Request a version check for a given client name. If the application is not registered, an empty string will be returned in JCClient.Callback.onVersionCheck(String)

Parameters:
  • clientName – String of the client name.

See also: JCClient.Callback.onVersionCheck(String)

createRoom

public void createRoom()

Request the server to create a new room. The result is ready, JCClient.Callback.onRoomCreated(String) is called.

See also: JCClient.Callback.onRoomCreated(String)

dispose

public void dispose()

Dispose the JCClient object. Cleans up allocated resources.

enableAudio

public boolean enableAudio(boolean enabled)

Mute/Unmute the recording microphone. Returns the new state.

Parameters:
  • enabledtrue if audio is enable, false otherwise
Returns:

true if audio is enable, false otherwise

enableHD

public boolean enableHD(boolean enable)

Enable/Disable capturing video in HD. HD resolutions is 1280x720. SD resolution is 640x480.

Parameters:
  • enabletrue if HD is enable, false otherwise
Returns:

true if HD is enable, false otherwise

enableVideo

public boolean enableVideo(boolean enabled)

Enable/Disable the camera. Return the new state.

Parameters:
  • enabledtrue if video is enable, false otherwise
Returns:

true if video is enable, false otherwise

encodeBitmap

public static String encodeBitmap(Bitmap img)

Encode a bitmap into Base64 encoded JPEG.

Parameters:
  • imgBitmap to be encoded to Base64 JPEG
Returns:

String representing the img

getAudioBandwidth

public int getAudioBandwidth()

Get the audio bandwidth limit in kilo bits per second for audio. Zero means unlimited.

Returns:Bandwidth limit value in kbps

getAvatar

public Bitmap getAvatar(String userid)

Retrieve the Bitmap avatar for a specific user.

Example:

Bitmap avatar = mJC.getAvatar(userid);
ImageView view = (ImageView)findViewById(R.id.image_view);
view.setImageBitmap(avatar);
Parameters:
  • userid – User id of the avatar. Can be me for current user’s avatar.
Returns:

Bitmap avatar of the user, null otherwise.

getInstance

public static JCClient getInstance()

Get the last instantiated instance of JCClient. Useful when JCClient is not readily available.

Example:

JCClient mJC = JCClient.getInstance();
Returns:last JCClient instance

getJoinUrl

public String getJoinUrl()

Retrieve the URL to join room. Used to invite others to room.

Example:

String url = mJC.getJoinUrl();
if (!url.isEmpty()) {
    // Send message to friend to click on URL
}
Returns:URL string of the room

getName

public String getName(String userid)

Get the name of a specific user.

Example:

String name = mJC.getName(userid);
Parameters:
  • userid – User id string. Can be me for current user’s avatar
Returns:

Name of the user

getPassword

public String getPassword()

Get the password for the current room.

Example:

String password = mJC.getPassword();
if (password.isEmpty()) {
    // unlocked
} else {
    // locked
}
Returns:Password for the room

getRoomName

public String getRoomName()

Retrieve the room name. Can be used for display.

Returns:String of the room name

getScreenShare

public boolean getScreenShare()

Find out if screen share is enabled or not.

Returns:true if sharing screen, false otherwise

getSessId

public String getSessId()

Retrieve the session id. Session ids represent the connection to the server.

Returns:String representing session id.

getUsers

public Map<String, JSONObject> getUsers()

Get a map of userid to JSONObject representing the user information.

Example:

Map users = mJC.getUsers();
for (Map.Entry entry : users.entrySet()) {
    System.out.println(entry.getKey() + "/" + entry.getValue().toString());
}
Returns:Map of the users

getVideoBandwidth

public int getVideoBandwidth()

Get the video bandwidth limit in kilo bits per second for audio. Zero means unlimited.

Returns:Bandwidth limit value in kbps

isAdmin

public boolean isAdmin()

Check if current user is admin. Shortcut for isAdmin("me").

Returns:true if user id admin, false otherwise

isAdmin

public boolean isAdmin(String userid)

Check if user id is admin.

Parameters:
  • userid – User id to look up if admin
Returns:

true if user id admin, false otherwise

isScreenShareAvailable

public static boolean isScreenShareAvailable()

Return if screen share feature is available.

Returns:true if screenshare is available, false otherwise

join

public void join(String roomName)

Join a room, given a room name.

Parameters:
  • roomName – String with the name of the room.

join

public void join(String roomName, String roomType)

Join a room, given a room name and room type.

Parameters:

joinUrl

public void joinUrl(String url)

Join a room, with a URL. This is used for federated JumpChat rooms.

Parameters:
  • url – URL that represents the JumpChat room

leave

public void leave()

Leave the joined room.

See also: JCClient.join(String), JCClient.join(String,String), JCClient.joinUrl(String)

muteAudioStream

public void muteAudioStream(boolean mute)

Mute/Unmute all incoming audio streams

Parameters:
  • mutetrue to mute audio, false otherwise

onActivityResult

public void onActivityResult(int requestCode, int resultCode, Intent data)

Called from activity to process the screen share request.

Parameters:
  • requestCode – Should be JCClient.CUSTOM_REQUEST_START_PROJECTION
  • resultCode – Result of the screen share request
  • data – Data for the screen share request

onPause

public void onPause()

Call from Activity.onPause() to release camera.

onResume

public void onResume()

Call from Activity.onResume() to acquire camera.

selectCamera

public void selectCamera(int cameraId)

Select camera to receive video from. Use JCClient.CAMERA_FRONT or CAMERA_BACK.

Parameters:
  • cameraId – Camera id to select to.

sendDataMessage

public void sendDataMessage(JSONObject dataMsg)

Send data message to everyone in the room.

Parameters:

sendDataMessage

public void sendDataMessage(String userid, JSONObject dataMsg)

Send data message to everyone a user in the room.

Parameters:
  • userid – Specific user id string to send data to.
  • dataMsgJSONObject representing the data

sendKick

public void sendKick(String userid)

Request a user be kicked. Only the admin can kick a user.

Parameters:
  • userid – User id string.

sendKnockAnswer

public void sendKnockAnswer(String sessid, Boolean answer)

Return the answer for a knock request. The session id is given in the onKnocking callback.

Parameters:
  • sessid – Session id of the user knocking.
  • answertrue if user is allowed in, false otherwise

sendLock

public void sendLock(Boolean lock)

Request room to be locked. Only the admin can lock the room.

Parameters:
  • locktrue if locking, false otherwise

See also: Callback.onRoomInfoUpdated()

sendTextMessage

public void sendTextMessage(String textMessage)

Send text message to everyone in the room.

Parameters:
  • textMessage – Message to send

sendTextMessage

public void sendTextMessage(String userid, String textMessage)

Send text message to a user in the room.

Parameters:
  • userid – User id string to send message to
  • textMessage – Message to send

setAudioBandwidth

public void setAudioBandwidth(int bw)

Set the audio bandwidth limit in kilo bits per second for audio. Zero means unlimited.

Parameters:
  • bw – Bandwidth limit value in kbps

setScreenShare

public void setScreenShare(boolean screenShare, Activity activity)

Find out if screen share is enabled or not.

Returns:true if sharing screen, false otherwise

setServerName

public void setServerName(String serverName)

Set the server name if using a federated server or running your own server.

Parameters:
  • serverName – Name of the server

See also: JCClient.SETTING_SERVER_NAME

setVideoBandwidth

public void setVideoBandwidth(int bw)

Set the audio bandwidth limit in kilo bits per second for audio. Zero means unlimited.

Parameters:
  • bw – Bandwidth limit value in kbps

toggleCamera

public int toggleCamera()

Toggle between front and back camera.

Returns:JCClient.CAMERA_FRONT or CAMERA_BACK

updateAvatar

public void updateAvatar(String encodedAvatar)

Send an updated avatar to everyone in the room. encodedAvatar is a base64 encoded string.

Parameters:
  • encodedAvatar – base64 encoded JPEG image

updateName

public void updateName(String name)

Send an updated name to everyone in the room.

Parameters:
  • name – Name to update