CarrierHandler

public interface CarrierHandler

The interface to Carrier node.

Methods

onAudioReceived

void onAudioReceived(Carrier carrier, String friendid, short[] pcm, int sampleCount, int channels, int sampleRate)

~English An application-defined function that is called when received audio frame from a friend.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • friendid – [in] Friend who sent the audio.

  • pcm – [in] Array of audio sample. Its size is sample_count * channels.

  • sampleCount – [in] Number of samples in the frames.

  • channels – [in] Number of audio channels. Can only be 1 or 2.

  • sampleRate – [in] Sample rate of the audio. Valid values are 8000, 12000, 16000, 24000, 48000.

onCallBitrateStatus

void onCallBitrateStatus(Carrier carrier, String friendid, int audiobitrate, int videobitrate)

~English An application-defined function that is called when AV core suggest new bit rates due to network status changes.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • friendid – [in] Friend who sent the video.

  • audiobitrate – [in] Suggested maximum audio bit rate in Kb/sec.

  • videobitrate – [in] Suggested maximum video bit rate in Kb/sec.

onConnection

void onConnection(Carrier carrier, ConnectionStatus status)

The callback function to process the self connection status.

Parameters
  • carrier – Carrier node instance

  • status – Current connection status. @see ConnectionStatus

onFriendAdded

void onFriendAdded(Carrier carrier, FriendInfo friendInfo)

The callback function to process the new friend added event.

Parameters
  • carrier – Carrier node instance

  • friendInfo – The added friend’s information

onFriendCallAnswered

void onFriendCallAnswered(Carrier carrier, String friendid)

~English An application-defined function that is called when friend answered our call request.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • friendid – [in] Friend who answered the call.

onFriendCallHangup

void onFriendCallHangup(Carrier carrier, String friendid)

~English An application-defined function that is called when friend hang up the call.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • friendid – [in] Friend who hang up the call.

onFriendCallPaused

void onFriendCallPaused(Carrier carrier, String friendid)

~English An application-defined function that is called when friend paused a call.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • friendid – [in] Friend who paused the call.

onFriendCallResumed

void onFriendCallResumed(Carrier carrier, String friendid)

~English An application-defined function that is called when friend resumed a paused call.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • friendid – [in] Friend who resumed the call.

onFriendCalled

void onFriendCalled(Carrier carrier, String friendid, boolean isAudioEnabled, boolean isVideoEnabled)

~English An application-defined function that is called when received a AV request from friends.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • friendid – [in] Friend who sent the request.

  • isAudioEnabled – [in] If this call requires audio.

  • isVideoEnabled – [in] If this call requires video.

onFriendConnection

void onFriendConnection(Carrier carrier, String friendId, ConnectionStatus status)

The callback function to process the friend connections status changed event.

Parameters
  • carrier – carrier node instance.

  • friendId – The friend’s user id.

  • status – The connection status of friend. @see ConnectionStatus

onFriendFileAborted

void onFriendFileAborted(Carrier carrier, String friendid, String filename, String fileid, long totalsize, long transferredsize)

The callback function to notify the friend file aborted.

Parameters
  • carrier – Carrier node instance

  • friendid – The user id

  • filename – The transferred file name

  • fileid – The file id

  • totalsize – The total file size

  • transferredsize – The transferred file size

onFriendFileAccepted

void onFriendFileAccepted(Carrier carrier, String receiver, String fileid, String filepath, long filesize)

The callback function to process the friend file accepted.

Parameters
  • carrier – Carrier node instance

  • receiver – The user id who accepts the file sending request

  • fileid – The file id accepted by receiver

  • filepath – The full file path accepted by receiver

  • filesize – The file size accepts by receiver

onFriendFileCanceled

void onFriendFileCanceled(Carrier carrier, String friendid, String fileid, String filepath)

The callback function to notify the file is canceled.

Parameters
  • carrier – Carrier node instance

  • friendid – The friend id

  • fileid – The fileid

onFriendFileCompleted

void onFriendFileCompleted(Carrier carrier, String friendid, String fileid, String filepath)

The callback function to notify the file is completed.

Parameters
  • carrier – Carrier node instance

  • friendid – The friend id

  • fileid – The fileid

  • filepath – The full path of the completed file including file name

onFriendFilePaused

void onFriendFilePaused(Carrier carrier, String friendid, String fileid, String filepath)

The callback function to notify the file is paused.

Parameters
  • carrier – Carrier node instance

  • friendid – The friend id

  • fileid – The file id

onFriendFileProgress

void onFriendFileProgress(Carrier carrier, String friendid, String filepath, String fileid, long totalsize, long transferredsize)

The callback function to process the friend file transferred.

Parameters
  • carrier – Carrier node instance

  • friendid – The user id

  • filepath – The full path of the transferred file

  • fileid – The file id

  • totalsize – The total file size

  • transferredsize – The transferred file size

onFriendFileQueried

void onFriendFileQueried(Carrier carrier, String userid, String filename, String message)

The callback function to process the friend file queried.

Parameters
  • carrier – Carrier node instance

  • userid – The user id who queries the file

  • filename – The queried file name

  • message – The extra message from friend

onFriendFileRequest

void onFriendFileRequest(Carrier carrier, String from, String fileid, String filename, long filesize)

The callback function to process the friend file request.

Parameters
  • carrier – Carrier node instance

  • from – The user id from who send the file request

  • fileid – The file id of the sending file

  • filename – The file name sent from friend

  • filesize – The file size sent from friend

onFriendFileResumed

void onFriendFileResumed(Carrier carrier, String friendid, String fileid, String filepath)

The callback function to notify the file is resumed.

Parameters
  • carrier – Carrier node instance

  • friendid – The friend id

  • fileid – The fileid

onFriendInfoChanged

void onFriendInfoChanged(Carrier carrier, String friendId, FriendInfo info)

The callback function to process the friend information changed event.

Parameters
  • carrier – Carrier node instance

  • friendId – The friend’s user id

  • info – The update friend information

onFriendInviteRequest

void onFriendInviteRequest(Carrier carrier, String from, String data)

The callback function to process the friend invite request.

Parameters
  • carrier – Carrier node instance

  • from – The user id from who send the invite request

  • data – The application defined data sent from friend

onFriendMessage

void onFriendMessage(Carrier carrier, String from, String message)

The callback function to process the friend message.

Parameters
  • carrier – Carrier node instance

  • from – The id from who send the message

  • message – The message content

onFriendPresence

void onFriendPresence(Carrier carrier, String friendId, PresenceStatus presence)

The callback function to process the friend presence changed event.

Parameters
  • carrier – Carrier node instance

  • friendId – The friend’s user id

  • presence – The presence status of the friend

onFriendRemoved

void onFriendRemoved(Carrier carrier, String friendId)

The callback function to process the friend removed event.

Parameters
  • carrier – Carrier node instance

  • friendId – The friend’s user id

onFriendRequest

void onFriendRequest(Carrier carrier, String userId, UserInfo info, String hello)

The callback function to process the friend request.

Parameters
  • carrier – Carrier node instance

  • userId – The user id who want be friend with current user

  • info – The user information to userId

  • hello – The PIN for target user, or any application defined content

onFriendTunnelAccept

void onFriendTunnelAccept(Carrier carrier, int tunnelid, String friendid)

~English An application-defined function that is called when a friend accepted our previous tunnel request.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • tunnelid – [in] ID to uniquely identify this tunnel.

  • friendid – [in] The friend who sent the request.

onFriendTunnelCancel

void onFriendTunnelCancel(Carrier carrier, int tunnelid, String friendid)

~English An application-defined function that is called when an existing tunnel is canceled or shutdown.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • tunnelid – [in] ID to uniquely identify this tunnel.

  • friendid – [in] The friend who canceled the tunnel.

onFriendTunnelData

void onFriendTunnelData(Carrier carrier, int tunnelid, String friendid, byte[] data, int length)

~English An application-defined function that is called when we received data from a tunnel.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • tunnelid – [in] ID to uniquely identify this tunnel.

  • friendid – [in] The friend who sent the data.

  • data – [in] The data received.

  • length – [in] Size of the data in bytes.

onFriendTunnelRequest

void onFriendTunnelRequest(Carrier carrier, int tunnelid, String friendid, String password)

~English An application-defined function that is called when a friend sent us a tunnel request.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • tunnelid – [in] ID to uniquely identify this tunnel.

  • friendid – [in] The friend who sent the request.

  • password – [in] A shared secret sent by friend for authentication purpose.

onFriends

void onFriends(Carrier carrier, List<FriendInfo> friends)

The callback function to iterate the each friend item in friend list.

Parameters
  • carrier – Carrier node instance

  • friends – The friends list.

onIdle

void onIdle(Carrier carrier)

The callback function that perform idle work.

Parameters
  • carrier – Carrier node instance

onReady

void onReady(Carrier carrier)

The callback function to process the ready notification. Application should wait this callback invoked before calling any function to interact with friends.

Parameters
  • carrier – Carrier node instance

onScDownloadCompleted

void onScDownloadCompleted(Carrier carrier, String fileid, String fullpath, int totalCount)

~English An application-defined function that is called when content search and download is completed.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • fileid – [in] The completed download file id.

  • fullpath – [in] The full downloaded file path

onScDownloadFailed

void onScDownloadFailed(Carrier carrier, String fileid, int errorCode)

~English An application-defined function that is called when content search and download is failed.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • fileid – [in] The completed failed file id.

  • errorCode – [in] The error code

onScDownloadProgress

void onScDownloadProgress(Carrier carrier, String fileid, String filename, int count, int totalCount)

~English Callback function when downloading progress event occurred. This callback is triggered when a part of the file is downloaded.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • fileid – [in] The downloading file id.

  • filename – [in] The downloading file name.

  • count – [in] Current finished number of parts.

  • totalCount – [in] Total number of parts.

onSelfInfoChanged

void onSelfInfoChanged(Carrier carrier, UserInfo userInfo)

The callback function to process the self info changed event.

Parameters
  • carrier – Carrier node instance

  • userInfo – The updated user information

onVideoReceived

void onVideoReceived(Carrier carrier, String friendid, int width, int height, byte[] y, byte[] u, byte[] v, int ystride, int ustride, int vstride)

~English An application-defined function that is called when received video frame from a friend. The size of plane data is derived from width and height as documented below. Strides represent padding for each plane that may or may not be present. You must handle strides in your image processing code. Strides are negative if the image is bottom-up hence why you MUST abs() it when calculating plane buffer size.

Parameters
  • carrier – [in] A handle to the Carrier node instance.

  • friendid – [in] Friend who sent the video.

  • width – [in] Width of the frame in pixels.

  • height – [in] Height of the frame in pixels.

  • y – [in] Luminosity plane. Size = MAX(width, abs(ystride)) * height.

  • u – [in] U chroma plane. Size = MAX(width/2, abs(ustride)) * (height/2).

  • v – [in] V chroma plane. Size = MAX(width/2, abs(vstride)) * (height/2).

  • ystride – [in] Luminosity plane stride.

  • ustride – [in] U chroma plane stride.

  • vstride – [in] V chroma plane stride.