Skip to content

Commit

Permalink
Merge branch 'release-0.2.10-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
naxuroqa committed Jun 25, 2019
2 parents e30f0c7 + e833db8 commit bd5d012
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ before_install:
- sudo add-apt-repository --yes ppa:chris-lea/libsodium
- sudo apt-get update --quiet
- sudo apt-get install --yes libsodium-dev libconfig-dev libopus-dev libvpx-dev cmake valac valadoc libglib2.0-dev
- wget https://github.com/TokTok/c-toxcore/archive/v0.2.9.tar.gz
- tar -xzf v0.2.9.tar.gz && cd c-toxcore-0.2.9/build
- wget https://github.com/TokTok/c-toxcore/archive/v0.2.10.tar.gz
- tar -xzf v0.2.10.tar.gz && cd c-toxcore-0.2.10/build
- cmake -D BUILD_AV_TEST=OFF -D CMAKE_INSTALL_PREFIX=/usr -D DEBUG=ON ..
- make && sudo make install && cd ../..

Expand Down
16 changes: 16 additions & 0 deletions tests/ToxAVTest.vala
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ namespace Tests {
assert(err_new == ErrNew.OK);
var ret = ToxAV.ToxAV.add_av_groupchat(tox, audio_callback);
assert(ret == 0);
assert(ToxAV.ToxAV.groupchat_av_enabled(tox, 0) == true);
assert(toxav != null);
}

Expand Down Expand Up @@ -176,6 +177,20 @@ namespace Tests {
assert(toxav != null);
}

private static void test_groupchat_audio_toggle() {
var tox = new ToxCore.Tox(null);
var toxav = new ToxAV.ToxAV(tox);

var conference_number = tox.conference_new();
assert(ToxAV.ToxAV.groupchat_av_enabled(tox, conference_number) == false);

var ret_enable = ToxAV.ToxAV.groupchat_enable_av(tox, conference_number, () => {});
assert(ret_enable == -1);

var ret_disable = ToxAV.ToxAV.groupchat_disable_av(tox, conference_number);
assert(ret_disable == -1);
}

private static void test_callbacks() {
var err_new_core = ToxCore.ErrNew.OK;
var tox = new ToxCore.Tox(null, out err_new_core);
Expand Down Expand Up @@ -251,6 +266,7 @@ namespace Tests {
Test.add_func(PREFIX + "test_add_av_groupchat", test_add_av_groupchat);
Test.add_func(PREFIX + "test_join_av_groupchat", test_join_av_groupchat);
Test.add_func(PREFIX + "test_group_send_audio", test_group_send_audio);
Test.add_func(PREFIX + "test_groupchat_audio_toggle", test_groupchat_audio_toggle);
Test.add_func(PREFIX + "test_callbacks", test_callbacks);
Test.add_func(PREFIX + "test_enums", test_enums);

Expand Down
12 changes: 12 additions & 0 deletions tests/ToxCoreTest.vala
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,15 @@ namespace Tests {
assert(err_conference_peer_query == ErrConferencePeerQuery.PEER_NOT_FOUND);
}

private static void test_conference_set_max_offline() {
var tox = new Tox();
var conference_number = tox.conference_new();
var err = ErrConferenceSetMaxOffline.OK;
var ret = tox.conference_set_max_offline(conference_number, 5, out err);
assert(err == ErrConferenceSetMaxOffline.OK);
assert(ret == true);
}

private static void test_hash() {
var data1 = new uint8[] { 0, 1, 2, 3, 4 };
var data2 = new uint8[] { 0, 1, 2, 3, 4 };
Expand Down Expand Up @@ -850,6 +859,8 @@ namespace Tests {
assert(ErrConferenceInvite.OK != ErrConferenceInvite.CONFERENCE_NOT_FOUND);
assert(ErrConferenceInvite.OK != ErrConferenceInvite.FAIL_SEND);

assert(ErrConferenceSetMaxOffline.OK != ErrConferenceSetMaxOffline.CONFERENCE_NOT_FOUND);

assert(ErrConferenceJoin.OK != ErrConferenceJoin.INVALID_LENGTH);
assert(ErrConferenceJoin.OK != ErrConferenceJoin.WRONG_TYPE);
assert(ErrConferenceJoin.OK != ErrConferenceJoin.FRIEND_NOT_FOUND);
Expand Down Expand Up @@ -1052,6 +1063,7 @@ namespace Tests {
Test.add_func(PREFIX + "test_conference_offline_peer_get_name", test_conference_offline_peer_get_name);
Test.add_func(PREFIX + "test_conference_offline_peer_get_public_key", test_conference_offline_peer_get_public_key);
Test.add_func(PREFIX + "test_conference_offline_peer_get_last_active", test_conference_offline_peer_get_last_active);
Test.add_func(PREFIX + "test_conference_set_max_offline", test_conference_set_max_offline);
Test.add_func(PREFIX + "test_hash", test_hash);
Test.add_func(PREFIX + "test_callbacks", test_callbacks);
Test.add_func(PREFIX + "test_enums", test_enums);
Expand Down
53 changes: 45 additions & 8 deletions vapi/toxav.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ namespace ToxAV {
* Start new A/V session. There can only be only one session per Tox instance.
*/
[CCode(cname = "toxav_new")]
public ToxAV(ToxCore.Tox tox, out ErrNew e);
public ToxAV(ToxCore.Tox tox, out ErrNew error = null);

/**
* Returns the {@link ToxCore.Tox} instance the A/V object was created for.
Expand Down Expand Up @@ -454,7 +454,7 @@ namespace ToxAV {
* @param video_bit_rate Video bit rate in Kb/sec. Set this to 0 to disable
* video sending.
*/
public bool call(uint32 friend_number, uint32 audio_bit_rate, uint32 video_bit_rate, out ErrCall error);
public bool call(uint32 friend_number, uint32 audio_bit_rate, uint32 video_bit_rate, out ErrCall error = null);

/**
* Set the callback for the `call` event. Pass NULL to unset.
Expand All @@ -475,7 +475,7 @@ namespace ToxAV {
* @param video_bit_rate Video bit rate in Kb/sec. Set this to 0 to disable
* video sending.
*/
public bool answer(uint32 friend_number, uint32 audio_bit_rate, uint32 video_bit_rate, out ErrAnswer error);
public bool answer(uint32 friend_number, uint32 audio_bit_rate, uint32 video_bit_rate, out ErrAnswer error = null);

/**
* Set the callback for the `call_state` event. Pass NULL to unset.
Expand All @@ -492,7 +492,7 @@ namespace ToxAV {
*
* @return true on success.
*/
public bool call_control(uint32 friend_number, CallControl control, out ErrCallControl error);
public bool call_control(uint32 friend_number, CallControl control, out ErrCallControl error = null);

/**
* Send an audio frame to a friend.
Expand All @@ -514,7 +514,7 @@ namespace ToxAV {
* @param sampling_rate Audio sampling rate used in this frame. Valid sampling
* rates are 8000, 12000, 16000, 24000, or 48000.
*/
public bool audio_send_frame(uint32 friend_number, [CCode(array_length = false)] int16[] pcm, size_t sample_count, uint8 channels, uint32 sampling_rate, out ErrSendFrame error);
public bool audio_send_frame(uint32 friend_number, [CCode(array_length = false)] int16[] pcm, size_t sample_count, uint8 channels, uint32 sampling_rate, out ErrSendFrame error = null);

/**
* Set the bit rate to be used in subsequent video frames.
Expand All @@ -528,7 +528,7 @@ namespace ToxAV {
* @return true on success.
*/
[Version(since = "0.2.0")]
public bool audio_set_bit_rate(uint32 friend_number, uint32 bit_rate, out ErrBitRateSet error);
public bool audio_set_bit_rate(uint32 friend_number, uint32 bit_rate, out ErrBitRateSet error = null);

/**
* Set the callback for the `audio_bit_rate` event. Pass NULL to unset.
Expand All @@ -553,7 +553,7 @@ namespace ToxAV {
* @param v V (Chroma) plane data.
*/
public bool video_send_frame(uint32 friend_number, uint16 width, uint16 height, [CCode(array_length = false)] uint8[] y,
[CCode(array_length = false)] uint8[] u, [CCode(array_length = false)] uint8[] v, out ErrSendFrame error);
[CCode(array_length = false)] uint8[] u, [CCode(array_length = false)] uint8[] v, out ErrSendFrame error = null);

/**
* Set the bit rate to be used in subsequent video frames.
Expand All @@ -567,7 +567,7 @@ namespace ToxAV {
* @return true on success.
*/
[Version(since = "0.2.0")]
public bool video_set_bit_rate(uint32 friend_number, uint32 bit_rate, out ErrBitRateSet error);
public bool video_set_bit_rate(uint32 friend_number, uint32 bit_rate, out ErrBitRateSet error = null);

/**
* Set the callback for the `video_bit_rate` event. Pass NULL to unset.
Expand Down Expand Up @@ -628,5 +628,42 @@ namespace ToxAV {
*
*/
public static int group_send_audio(ToxCore.Tox tox, uint32 group_number, [CCode(array_length = false)] int16[] pcm, uint samples, uint8 channels, uint32 sample_rate);

/**
* Enable A/V in a groupchat.
*
* A/V must be enabled on a groupchat for audio to be sent to it and for
* received audio to be handled.
*
* An A/V group created with toxav_add_av_groupchat or toxav_join_av_groupchat
* will start with A/V enabled.
*
* An A/V group loaded from a savefile will start with A/V disabled.
*
* Audio data callback format (same as the one for toxav_add_av_groupchat()):
* audio_callback(Tox *tox, uint32_t groupnumber, uint32_t peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, uint32_t sample_rate, void *userdata)
*
* Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
*
* @return 0 on success.
* @return -1 on failure.
*/
[Version(since = "0.2.10")]
public static int groupchat_enable_av(ToxCore.Tox tox, uint32 groupnumber, GroupchatAudioReceiveFrameCallback callback);

/**
* Disable A/V in a groupchat.
*
* @return 0 on success.
* @return -1 on failure.
*/
[Version(since = "0.2.10")]
public static int groupchat_disable_av(ToxCore.Tox tox, uint32 groupnumber);

/**
* Return whether A/V is enabled in the groupchat.
*/
[Version(since = "0.2.10")]
public static bool groupchat_av_enabled(ToxCore.Tox tox, uint32 groupnumber);
}
}
23 changes: 22 additions & 1 deletion vapi/toxcore.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,22 @@ namespace ToxCore {
NO_CONNECTION
}


[Version(since = "0.2.10")]
[CCode(cname = "Tox_Err_Conference_Set_Max_Offline", cprefix = "TOX_ERR_CONFERENCE_SET_MAX_OFFLINE_", has_type_id = false)]
public enum ErrConferenceSetMaxOffline {
/**
* The function returned successfully.
*/
[Version(since = "0.2.10")]
OK,
/**
* The conference number passed did not designate a valid conference.
*/
[Version(since = "0.2.10")]
CONFERENCE_NOT_FOUND,
}

[CCode(cname = "Tox_Err_Conference_Join", cprefix = "TOX_ERR_CONFERENCE_JOIN_", has_type_id = false)]
public enum ErrConferenceJoin {
/**
Expand Down Expand Up @@ -2493,13 +2509,18 @@ namespace ToxCore {
return _conference_offline_peer_get_public_key(conference_number, offline_peer_number, t, out error) ? t : null;
}


/**
* Return a unix-time timestamp of the last time offline_peer_number was seen to be active.
*/
[Version(since = "0.2.9")]
public uint64 conference_offline_peer_get_last_active(uint32 conference_number, uint32 offline_peer_number, out ErrConferencePeerQuery error = null);

/**
* Set maximum number of offline peers to store, overriding the default.
*/
[Version(since = "0.2.10")]
public bool conference_set_max_offline(uint32 conference_number, uint32 max_offline_peers, out ErrConferenceSetMaxOffline error = null);

/**
* Invites a friend to a conference.
*
Expand Down

0 comments on commit bd5d012

Please sign in to comment.