Skip to content

Commit

Permalink
feat: Add conferences to native java bindings.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Nov 13, 2024
1 parent aa235fa commit c20501e
Show file tree
Hide file tree
Showing 176 changed files with 6,901 additions and 1,635 deletions.
1 change: 1 addition & 0 deletions .restyled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ exclude:
- "gradlew"
- "**/*.cpp"
- "**/*.h"
- "**/*Jni.java"
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ kt_jvm_library(
kt_jvm_test(
name = "ToxCoreTest",
size = "small",
srcs = ["lib/src/jvmTest/java/im/tox/tox4j/core/ToxCoreTest.kt"],
srcs = glob(["lib/src/jvmTest/**/*.kt"]),
jvm_flags = ["-Djava.library.path=jvm-toxcore-c"],
test_class = "im.tox.tox4j.core.ToxCoreTest",
deps = [
Expand Down
22 changes: 11 additions & 11 deletions lib/src/commonMain/kotlin/im/tox/tox4j/av/ToxAv.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ interface ToxAv : AutoCloseable {
/**
* Call a friend. This will start ringing the friend.
*
* It is the client's responsibility to stop ringing after a certain timeout, if such behaviour is
* desired. If the client does not stop ringing, the library will not stop until the friend is
* disconnected.
* It is the client's responsibility to stop ringing after a certain timeout, if such behaviour
* is desired. If the client does not stop ringing, the library will not stop until the friend
* is disconnected.
*
* @param friendNumber The friend number of the friend that should be called.
* @param audioBitRate Audio bit rate in Kb/sec. Set this to 0 to disable audio sending.
Expand All @@ -80,8 +80,8 @@ interface ToxAv : AutoCloseable {
/**
* Accept an incoming call.
*
* If answering fails for any reason, the call will still be pending and it is possible to try and
* answer it later.
* If answering fails for any reason, the call will still be pending and it is possible to try
* and answer it later.
*
* @param friendNumber The friend number of the friend that is calling.
* @param audioBitRate Audio bit rate in Kb/sec. Set this to 0 to disable audio sending.
Expand Down Expand Up @@ -135,10 +135,10 @@ interface ToxAv : AutoCloseable {
/**
* Send an audio frame to a friend.
*
* The expected format of the PCM data is: [s1c1][s1c2][...][s2c1][s2c2][...]... Meaning: sample 1
* for channel 1, sample 1 for channel 2, ... For mono audio, this has no meaning, every sample is
* subsequent. For stereo, this means the expected format is LRLRLR... with samples for left and
* right alternating.
* The expected format of the PCM data is: [s1c1][s1c2][...][s2c1][s2c2][...]... Meaning: sample
* 1 for channel 1, sample 1 for channel 2, ... For mono audio, this has no meaning, every
* sample is subsequent. For stereo, this means the expected format is LRLRLR... with samples
* for left and right alternating.
*
* @param friendNumber The friend number of the friend to which to send an audio frame.
* @param pcm An array of audio samples. The size of this array must be sample_count * channels.
Expand All @@ -161,8 +161,8 @@ interface ToxAv : AutoCloseable {
/**
* Send a video frame to a friend.
*
* Y - plane should be of size: height * width U - plane should be of size: (height/2) * (width/2)
* V - plane should be of size: (height/2) * (width/2)
* Y - plane should be of size: height * width U - plane should be of size: (height/2) *
* (width/2) V - plane should be of size: (height/2) * (width/2)
*
* @param friendNumber The friend number of the friend to which to send a video frame.
* @param width Width of the frame in pixels.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import im.tox.tox4j.core.data.ToxFriendNumber
interface CallStateCallback<ToxCoreState> {
/**
* @param friendNumber The friend number this call state change is for.
* @param callState A set of ToxCallState values comprising the new call state. Although this is a
* Collection (therefore might actually be a List), this is effectively a Set. Any
* @param callState A set of ToxCallState values comprising the new call state. Although this is
* a Collection (therefore might actually be a List), this is effectively a Set. Any
* [[ToxavFriendCallState]] value is contained exactly 0 or 1 times.
*/
fun callState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ interface VideoReceiveFrameCallback<ToxCoreState> {
* @param height Height of the frame in pixels.
* @param y Y-plane.
* @param u U-plane.
* @param v V-plane. The size of plane data is derived from width and height where Y = max(width,
* abs(yStride)) * height U = max(width/2, abs(uStride)) * (height/2) V = max(width/2,
* abs(vStride)) * (height/2).
* @param v V-plane. The size of plane data is derived from width and height where Y =
* max(width, abs(yStride)) * height U = max(width/2, abs(uStride)) * (height/2) V =
* max(width/2, abs(vStride)) * (height/2).
* @param yStride Stride length for Y-plane.
* @param uStride Stride length for U-plane.
* @param vStride Stride length for V-plane. 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.
* @param vStride Stride length for V-plane. 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.
*/
fun videoReceiveFrame(
friendNumber: ToxFriendNumber,
Expand All @@ -36,9 +36,9 @@ interface VideoReceiveFrameCallback<ToxCoreState> {
): ToxCoreState = state

/**
* An implementation may choose to keep the arrays to copy the data to around as an optimisation.
* If this method does not return [[null]], the arrays in the return value are passed to
* [[videoReceiveFrame]] as y, u, and v.
* An implementation may choose to keep the arrays to copy the data to around as an
* optimisation. If this method does not return [[null]], the arrays in the return value are
* passed to [[videoReceiveFrame]] as y, u, and v.
*/
fun videoFrameCachedYUV(
height: Height,
Expand Down
36 changes: 11 additions & 25 deletions lib/src/commonMain/kotlin/im/tox/tox4j/av/enums/ToxavCallControl.kt
Original file line number Diff line number Diff line change
@@ -1,50 +1,36 @@
package im.tox.tox4j.av.enums

/**
* Call control.
*/
/** Call control. */
enum class ToxavCallControl {
/**
* Resume a previously paused call. Only valid if the pause was caused by this
* client, if not, this control is ignored. Not valid before the call is
* accepted.
* Resume a previously paused call. Only valid if the pause was caused by this client, if not,
* this control is ignored. Not valid before the call is accepted.
*/
RESUME,

/**
* Put a call on hold. Not valid before the call is accepted.
*/
/** Put a call on hold. Not valid before the call is accepted. */
PAUSE,

/**
* Reject a call if it was not answered, yet. Cancel a call after it was
* answered.
*/
/** Reject a call if it was not answered, yet. Cancel a call after it was answered. */
CANCEL,

/**
* Request that the friend stops sending audio. Regardless of the friend's
* compliance, this will cause the {@link
* im.tox.tox4j.av.callbacks.AudioReceiveFrameCallback} event to stop being
* Request that the friend stops sending audio. Regardless of the friend's compliance, this will
* cause the {@link im.tox.tox4j.av.callbacks.AudioReceiveFrameCallback} event to stop being
* triggered on receiving an audio frame from the friend.
*/
MUTE_AUDIO,

/**
* Calling this control will notify client to start sending audio again.
*/
/** Calling this control will notify client to start sending audio again. */
UNMUTE_AUDIO,

/**
* Request that the friend stops sending video. Regardless of the friend's
* compliance, this will cause the {@link
* im.tox.tox4j.av.callbacks.VideoReceiveFrameCallback} event to stop being
* Request that the friend stops sending video. Regardless of the friend's compliance, this will
* cause the {@link im.tox.tox4j.av.callbacks.VideoReceiveFrameCallback} event to stop being
* triggered on receiving an video frame from the friend.
*/
HIDE_VIDEO,

/**
* Calling this control will notify client to start sending video again.
*/
/** Calling this control will notify client to start sending video again. */
SHOW_VIDEO,
}
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
package im.tox.tox4j.av.enums

/**
* Call state graph.
*/
/** Call state graph. */
enum class ToxavFriendCallState {
/**
* Set by the AV core if an error occurred on the remote end or if friend
* timed out. This is the final state after which no more state
* transitions can occur for the call. This call state will never be triggered
* in combination with other call states.
* Set by the AV core if an error occurred on the remote end or if friend timed out. This is the
* final state after which no more state transitions can occur for the call. This call state
* will never be triggered in combination with other call states.
*/
ERROR,

/**
* The call has finished. This is the final state after which no more state
* transitions can occur for the call. This call state will never be
* triggered in combination with other call states.
* The call has finished. This is the final state after which no more state transitions can
* occur for the call. This call state will never be triggered in combination with other call
* states.
*/
FINISHED,

/**
* The flag that marks that friend is sending audio.
*/
/** The flag that marks that friend is sending audio. */
SENDING_A,

/**
* The flag that marks that friend is sending video.
*/
/** The flag that marks that friend is sending video. */
SENDING_V,

/**
* The flag that marks that friend is receiving audio.
*/
/** The flag that marks that friend is receiving audio. */
ACCEPTING_A,

/**
* The flag that marks that friend is receiving video.
*/
/** The flag that marks that friend is receiving video. */
ACCEPTING_V,
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,26 @@ import im.tox.tox4j.exceptions.ToxException

class ToxavAnswerException : ToxException {
enum class Code {
/**
* Failed to initialise codecs for call session.
*/
/** Failed to initialise codecs for call session. */
CODEC_INITIALIZATION,

/**
* The friend was valid, but they are not currently trying to initiate a call.
* This is also returned if this client is already in a call with the friend.
* The friend was valid, but they are not currently trying to initiate a call. This is also
* returned if this client is already in a call with the friend.
*/
FRIEND_NOT_CALLING,

/**
* The friend number did not designate a valid friend.
*/
/** The friend number did not designate a valid friend. */
FRIEND_NOT_FOUND,

/**
* Audio or video bit rate is invalid.
*/
/** Audio or video bit rate is invalid. */
INVALID_BIT_RATE,

/**
* Synchronization error occurred.
*/
/** Synchronization error occurred. */
SYNC,
}

constructor(code: Code) : this(code, "")

constructor(code: Code, message: String) : super(code, message)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,20 @@ import im.tox.tox4j.exceptions.ToxException

class ToxavBitRateSetException : ToxException {
enum class Code {
/**
* The friend_number passed did not designate a valid friend.
*/
/** The friend_number passed did not designate a valid friend. */
FRIEND_NOT_FOUND,

/**
* This client is currently not in a call with the friend.
*/
/** This client is currently not in a call with the friend. */
FRIEND_NOT_IN_CALL,

/**
* The bit rate passed was not one of the supported values.
*/
/** The bit rate passed was not one of the supported values. */
INVALID_BIT_RATE,

/**
* Synchronization error occurred.
*/
/** Synchronization error occurred. */
SYNC,
}

constructor(code: Code) : this(code, "")

constructor(code: Code, message: String) : super(code, message)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,26 @@ import im.tox.tox4j.exceptions.ToxException

class ToxavCallControlException : ToxException {
enum class Code {
/**
* The friend number did not designate a valid friend.
*/
/** The friend number did not designate a valid friend. */
FRIEND_NOT_FOUND,

/**
* This client is currently not in a call with the friend. Before the call is
* answered, only CANCEL is a valid control
* This client is currently not in a call with the friend. Before the call is answered, only
* CANCEL is a valid control
*/
FRIEND_NOT_IN_CALL,

/**
* Happens if user tried to pause an already paused call or if trying to
* resume a call that is not paused.
* Happens if user tried to pause an already paused call or if trying to resume a call that
* is not paused.
*/
INVALID_TRANSITION,

/**
* Synchronization error occurred.
*/
/** Synchronization error occurred. */
SYNC,
}

constructor(code: Code) : this(code, "")

constructor(code: Code, message: String) : super(code, message)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,26 @@ import im.tox.tox4j.exceptions.ToxException

class ToxavCallException : ToxException {
enum class Code {
/**
* Attempted to call a friend while already in an audio or video call with them.
*/
/** Attempted to call a friend while already in an audio or video call with them. */
FRIEND_ALREADY_IN_CALL,

/**
* The friend was valid, but not currently connected.
*/
/** The friend was valid, but not currently connected. */
FRIEND_NOT_CONNECTED,

/**
* The friend number did not designate a valid friend.
*/
/** The friend number did not designate a valid friend. */
FRIEND_NOT_FOUND,

/**
* Audio or video bit rate is invalid.
*/
/** Audio or video bit rate is invalid. */
INVALID_BIT_RATE,

/**
* A memory allocation error occurred.
*/
/** A memory allocation error occurred. */
MALLOC,

/**
* Synchronization error occurred.
*/
/** Synchronization error occurred. */
SYNC,
}

constructor(code: Code) : this(code, "")

constructor(code: Code, message: String) : super(code, message)
}
Loading

0 comments on commit c20501e

Please sign in to comment.