Skip to content

Commit 5d6ea7d

Browse files
committed
style: Run ktlint --format on everything
1 parent e3ab649 commit 5d6ea7d

40 files changed

+2190
-1988
lines changed

lib/src/main/java/im/tox/tox4j/av/ToxAv.kt

Lines changed: 141 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -29,136 +29,155 @@ import java.io.Closeable
2929
* forcibly terminated without notifying peers.
3030
*/
3131
interface ToxAv : Closeable {
32+
/**
33+
* Start new A/V session. There can only be only one session per Tox instance.
34+
*
35+
* @param tox A compatible ToxCore implementation.
36+
* @return the new A/V session.
37+
*/
38+
// @throws[ToxavNewException]
39+
fun create(tox: ToxCore): ToxAv
3240

33-
/**
34-
* Start new A/V session. There can only be only one session per Tox instance.
35-
*
36-
* @param tox A compatible ToxCore implementation.
37-
* @return the new A/V session.
38-
*/
39-
// @throws[ToxavNewException]
40-
fun create(tox: ToxCore): ToxAv
41+
/**
42+
* Releases all resources associated with the A/V session.
43+
*
44+
* If any calls were ongoing, these will be forcibly terminated without notifying peers. After
45+
* calling this function, no other functions may be called and the av pointer becomes invalid.
46+
*/
47+
override fun close(): Unit
4148

42-
/**
43-
* Releases all resources associated with the A/V session.
44-
*
45-
* If any calls were ongoing, these will be forcibly terminated without notifying peers. After
46-
* calling this function, no other functions may be called and the av pointer becomes invalid.
47-
*/
48-
override fun close(): Unit
49+
/** Returns the interval in milliseconds when the next [[iterate]] call should be. */
50+
val iterationInterval: Int
4951

50-
/** Returns the interval in milliseconds when the next [[iterate]] call should be. */
51-
val iterationInterval: Int
52+
/**
53+
* Main loop for the session. This function needs to be called in intervals of
54+
* [[iterationInterval]] milliseconds. It is best called in the separate thread from
55+
* [[ToxCore.iterate]].
56+
*/
57+
fun <S> iterate(
58+
handler: ToxAvEventListener<S>,
59+
state: S,
60+
): S
5261

53-
/**
54-
* Main loop for the session. This function needs to be called in intervals of
55-
* [[iterationInterval]] milliseconds. It is best called in the separate thread from
56-
* [[ToxCore.iterate]].
57-
*/
58-
fun <S> iterate(handler: ToxAvEventListener<S>, state: S): S
62+
/**
63+
* Call a friend. This will start ringing the friend.
64+
*
65+
* It is the client's responsibility to stop ringing after a certain timeout, if such behaviour is
66+
* desired. If the client does not stop ringing, the library will not stop until the friend is
67+
* disconnected.
68+
*
69+
* @param friendNumber The friend number of the friend that should be called.
70+
* @param audioBitRate Audio bit rate in Kb/sec. Set this to 0 to disable audio sending.
71+
* @param videoBitRate Video bit rate in Kb/sec. Set this to 0 to disable video sending.
72+
*/
73+
// @throws[ToxavCallException]
74+
fun call(
75+
friendNumber: ToxFriendNumber,
76+
audioBitRate: BitRate,
77+
videoBitRate: BitRate,
78+
): Unit
5979

60-
/**
61-
* Call a friend. This will start ringing the friend.
62-
*
63-
* It is the client's responsibility to stop ringing after a certain timeout, if such behaviour is
64-
* desired. If the client does not stop ringing, the library will not stop until the friend is
65-
* disconnected.
66-
*
67-
* @param friendNumber The friend number of the friend that should be called.
68-
* @param audioBitRate Audio bit rate in Kb/sec. Set this to 0 to disable audio sending.
69-
* @param videoBitRate Video bit rate in Kb/sec. Set this to 0 to disable video sending.
70-
*/
71-
// @throws[ToxavCallException]
72-
fun call(friendNumber: ToxFriendNumber, audioBitRate: BitRate, videoBitRate: BitRate): Unit
80+
/**
81+
* Accept an incoming call.
82+
*
83+
* If answering fails for any reason, the call will still be pending and it is possible to try and
84+
* answer it later.
85+
*
86+
* @param friendNumber The friend number of the friend that is calling.
87+
* @param audioBitRate Audio bit rate in Kb/sec. Set this to 0 to disable audio sending.
88+
* @param videoBitRate Video bit rate in Kb/sec. Set this to 0 to disable video sending.
89+
*/
90+
// @throws[ToxavAnswerException]
91+
fun answer(
92+
friendNumber: ToxFriendNumber,
93+
audioBitRate: BitRate,
94+
videoBitRate: BitRate,
95+
): Unit
7396

74-
/**
75-
* Accept an incoming call.
76-
*
77-
* If answering fails for any reason, the call will still be pending and it is possible to try and
78-
* answer it later.
79-
*
80-
* @param friendNumber The friend number of the friend that is calling.
81-
* @param audioBitRate Audio bit rate in Kb/sec. Set this to 0 to disable audio sending.
82-
* @param videoBitRate Video bit rate in Kb/sec. Set this to 0 to disable video sending.
83-
*/
84-
// @throws[ToxavAnswerException]
85-
fun answer(friendNumber: ToxFriendNumber, audioBitRate: BitRate, videoBitRate: BitRate): Unit
97+
/**
98+
* Sends a call control command to a friend.
99+
*
100+
* @param friendNumber The friend number of the friend to send the call control to.
101+
* @param control The control command to send.
102+
*/
103+
// @throws[ToxavCallControlException]
104+
fun callControl(
105+
friendNumber: ToxFriendNumber,
106+
control: ToxavCallControl,
107+
): Unit
86108

87-
/**
88-
* Sends a call control command to a friend.
89-
*
90-
* @param friendNumber The friend number of the friend to send the call control to.
91-
* @param control The control command to send.
92-
*/
93-
// @throws[ToxavCallControlException]
94-
fun callControl(friendNumber: ToxFriendNumber, control: ToxavCallControl): Unit
109+
/**
110+
* Set the audio bit rate to be used in subsequent audio frames.
111+
*
112+
* @param friendNumber The friend number of the friend for which to set the audio bit rate.
113+
* @param audioBitRate The new audio bit rate in Kb/sec. Set to 0 to disable audio sending. Pass
114+
* -1 to leave unchanged.
115+
*/
116+
// @throws[ToxavBitRateSetException]
117+
fun setAudioBitRate(
118+
friendNumber: ToxFriendNumber,
119+
audioBitRate: BitRate,
120+
): Unit
95121

96-
/**
97-
* Set the audio bit rate to be used in subsequent audio frames.
98-
*
99-
* @param friendNumber The friend number of the friend for which to set the audio bit rate.
100-
* @param audioBitRate The new audio bit rate in Kb/sec. Set to 0 to disable audio sending. Pass
101-
* -1 to leave unchanged.
102-
*/
103-
// @throws[ToxavBitRateSetException]
104-
fun setAudioBitRate(friendNumber: ToxFriendNumber, audioBitRate: BitRate): Unit
122+
/**
123+
* Set the video bit rate to be used in subsequent audio frames.
124+
*
125+
* @param friendNumber The friend number of the friend for which to set the audio bit rate.
126+
* @param videoBitRate The new video bit rate in Kb/sec. Set to 0 to disable video sending. Pass
127+
* -1 to leave unchanged.
128+
*/
129+
// @throws[ToxavBitRateSetException]
130+
fun setVideoBitRate(
131+
friendNumber: ToxFriendNumber,
132+
videoBitRate: BitRate,
133+
): Unit
105134

106-
/**
107-
* Set the video bit rate to be used in subsequent audio frames.
108-
*
109-
* @param friendNumber The friend number of the friend for which to set the audio bit rate.
110-
* @param videoBitRate The new video bit rate in Kb/sec. Set to 0 to disable video sending. Pass
111-
* -1 to leave unchanged.
112-
*/
113-
// @throws[ToxavBitRateSetException]
114-
fun setVideoBitRate(friendNumber: ToxFriendNumber, videoBitRate: BitRate): Unit
135+
/**
136+
* Send an audio frame to a friend.
137+
*
138+
* The expected format of the PCM data is: [s1c1][s1c2][...][s2c1][s2c2][...]... Meaning: sample 1
139+
* for channel 1, sample 1 for channel 2, ... For mono audio, this has no meaning, every sample is
140+
* subsequent. For stereo, this means the expected format is LRLRLR... with samples for left and
141+
* right alternating.
142+
*
143+
* @param friendNumber The friend number of the friend to which to send an audio frame.
144+
* @param pcm An array of audio samples. The size of this array must be sample_count * channels.
145+
* @param sampleCount Number of samples in this frame in milliseconds. Valid numbers here are
146+
* ((sample rate) * (audio length) / 1000), where audio length can be 2.5, 5, 10, 20, 40 or 60
147+
* milliseconds.
148+
* @param channels Number of audio channels. Supported values are 1 and 2.
149+
* @param samplingRate Audio sampling rate used in this frame in Hz. Valid sampling rates are
150+
* 8000, 12000, 16000, 24000, or 48000.
151+
*/
152+
// @throws[ToxavSendFrameException]
153+
fun audioSendFrame(
154+
friendNumber: ToxFriendNumber,
155+
pcm: ShortArray,
156+
sampleCount: SampleCount,
157+
channels: AudioChannels,
158+
samplingRate: SamplingRate,
159+
): Unit
115160

116-
/**
117-
* Send an audio frame to a friend.
118-
*
119-
* The expected format of the PCM data is: [s1c1][s1c2][...][s2c1][s2c2][...]... Meaning: sample 1
120-
* for channel 1, sample 1 for channel 2, ... For mono audio, this has no meaning, every sample is
121-
* subsequent. For stereo, this means the expected format is LRLRLR... with samples for left and
122-
* right alternating.
123-
*
124-
* @param friendNumber The friend number of the friend to which to send an audio frame.
125-
* @param pcm An array of audio samples. The size of this array must be sample_count * channels.
126-
* @param sampleCount Number of samples in this frame in milliseconds. Valid numbers here are
127-
* ((sample rate) * (audio length) / 1000), where audio length can be 2.5, 5, 10, 20, 40 or 60
128-
* milliseconds.
129-
* @param channels Number of audio channels. Supported values are 1 and 2.
130-
* @param samplingRate Audio sampling rate used in this frame in Hz. Valid sampling rates are
131-
* 8000, 12000, 16000, 24000, or 48000.
132-
*/
133-
// @throws[ToxavSendFrameException]
134-
fun audioSendFrame(
135-
friendNumber: ToxFriendNumber,
136-
pcm: ShortArray,
137-
sampleCount: SampleCount,
138-
channels: AudioChannels,
139-
samplingRate: SamplingRate
140-
): Unit
141-
142-
/**
143-
* Send a video frame to a friend.
144-
*
145-
* Y - plane should be of size: height * width U - plane should be of size: (height/2) * (width/2)
146-
* V - plane should be of size: (height/2) * (width/2)
147-
*
148-
* @param friendNumber The friend number of the friend to which to send a video frame.
149-
* @param width Width of the frame in pixels.
150-
* @param height Height of the frame in pixels.
151-
* @param y Y (Luminance) plane data.
152-
* @param u U (Chroma) plane data.
153-
* @param v V (Chroma) plane data.
154-
*/
155-
// @throws[ToxavSendFrameException]
156-
fun videoSendFrame(
157-
friendNumber: ToxFriendNumber,
158-
width: Int,
159-
height: Int,
160-
y: ByteArray,
161-
u: ByteArray,
162-
v: ByteArray
163-
): Unit
161+
/**
162+
* Send a video frame to a friend.
163+
*
164+
* Y - plane should be of size: height * width U - plane should be of size: (height/2) * (width/2)
165+
* V - plane should be of size: (height/2) * (width/2)
166+
*
167+
* @param friendNumber The friend number of the friend to which to send a video frame.
168+
* @param width Width of the frame in pixels.
169+
* @param height Height of the frame in pixels.
170+
* @param y Y (Luminance) plane data.
171+
* @param u U (Chroma) plane data.
172+
* @param v V (Chroma) plane data.
173+
*/
174+
// @throws[ToxavSendFrameException]
175+
fun videoSendFrame(
176+
friendNumber: ToxFriendNumber,
177+
width: Int,
178+
height: Int,
179+
y: ByteArray,
180+
u: ByteArray,
181+
v: ByteArray,
182+
): Unit
164183
}

lib/src/main/java/im/tox/tox4j/av/callbacks/AudioBitRateCallback.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import im.tox.tox4j.core.data.ToxFriendNumber
88
* point core suggests new bit rates.
99
*/
1010
interface AudioBitRateCallback<ToxCoreState> {
11-
/**
12-
* @param friendNumber The friend number of the friend for which to set the audio bit rate.
13-
* @param audioBitRate Suggested maximum audio bit rate in Kb/sec.
14-
*/
15-
fun audioBitRate(
16-
friendNumber: ToxFriendNumber,
17-
audioBitRate: BitRate,
18-
state: ToxCoreState
19-
): ToxCoreState = state
11+
/**
12+
* @param friendNumber The friend number of the friend for which to set the audio bit rate.
13+
* @param audioBitRate Suggested maximum audio bit rate in Kb/sec.
14+
*/
15+
fun audioBitRate(
16+
friendNumber: ToxFriendNumber,
17+
audioBitRate: BitRate,
18+
state: ToxCoreState,
19+
): ToxCoreState = state
2020
}

lib/src/main/java/im/tox/tox4j/av/callbacks/AudioReceiveFrameCallback.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import im.tox.tox4j.core.data.ToxFriendNumber
66

77
/** Called when an audio frame is received. */
88
interface AudioReceiveFrameCallback<ToxCoreState> {
9-
/**
10-
* @param friendNumber The friend number of the friend who sent an audio frame.
11-
* @param pcm An array of audio samples (sample_count * channels elements).
12-
* @param channels Number of audio channels.
13-
* @param samplingRate Sampling rate used in this frame.
14-
*/
15-
fun audioReceiveFrame(
16-
friendNumber: ToxFriendNumber,
17-
pcm: ShortArray,
18-
channels: AudioChannels,
19-
samplingRate: SamplingRate,
20-
state: ToxCoreState
21-
): ToxCoreState = state
9+
/**
10+
* @param friendNumber The friend number of the friend who sent an audio frame.
11+
* @param pcm An array of audio samples (sample_count * channels elements).
12+
* @param channels Number of audio channels.
13+
* @param samplingRate Sampling rate used in this frame.
14+
*/
15+
fun audioReceiveFrame(
16+
friendNumber: ToxFriendNumber,
17+
pcm: ShortArray,
18+
channels: AudioChannels,
19+
samplingRate: SamplingRate,
20+
state: ToxCoreState,
21+
): ToxCoreState = state
2222
}

lib/src/main/java/im/tox/tox4j/av/callbacks/CallCallback.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import im.tox.tox4j.core.data.ToxFriendNumber
44

55
/** Triggered when a friend calls us. */
66
interface CallCallback<ToxCoreState> {
7-
/**
8-
* @param friendNumber The friend number from which the call is incoming.
9-
* @param audioEnabled True if friend is sending audio.
10-
* @param videoEnabled True if friend is sending video.
11-
*/
12-
fun call(
13-
friendNumber: ToxFriendNumber,
14-
audioEnabled: Boolean,
15-
videoEnabled: Boolean,
16-
state: ToxCoreState
17-
): ToxCoreState = state
7+
/**
8+
* @param friendNumber The friend number from which the call is incoming.
9+
* @param audioEnabled True if friend is sending audio.
10+
* @param videoEnabled True if friend is sending video.
11+
*/
12+
fun call(
13+
friendNumber: ToxFriendNumber,
14+
audioEnabled: Boolean,
15+
videoEnabled: Boolean,
16+
state: ToxCoreState,
17+
): ToxCoreState = state
1818
}

lib/src/main/java/im/tox/tox4j/av/callbacks/CallStateCallback.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import java.util.EnumSet
66

77
/** Called when the call state changes. */
88
interface CallStateCallback<ToxCoreState> {
9-
/**
10-
* @param friendNumber The friend number this call state change is for.
11-
* @param callState A set of ToxCallState values comprising the new call state. Although this is a
12-
* Collection (therefore might actually be a List), this is effectively a Set. Any
13-
* [[ToxavFriendCallState]] value is contained exactly 0 or 1 times.
14-
*/
15-
fun callState(
16-
friendNumber: ToxFriendNumber,
17-
callState: EnumSet<ToxavFriendCallState>,
18-
state: ToxCoreState
19-
): ToxCoreState = state
9+
/**
10+
* @param friendNumber The friend number this call state change is for.
11+
* @param callState A set of ToxCallState values comprising the new call state. Although this is a
12+
* Collection (therefore might actually be a List), this is effectively a Set. Any
13+
* [[ToxavFriendCallState]] value is contained exactly 0 or 1 times.
14+
*/
15+
fun callState(
16+
friendNumber: ToxFriendNumber,
17+
callState: EnumSet<ToxavFriendCallState>,
18+
state: ToxCoreState,
19+
): ToxCoreState = state
2020
}

0 commit comments

Comments
 (0)