Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/api/api_changes_10.3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Changes introduced in AVS 10.3
==============================

Added API calls:
- wcall_set_duration
- wcall_set_config_version

The wcall_set_duration API is used to set the max duration of a conference call.
If the call is not terminated withing the time period (from the very start of the call)
the call will be force terminated after the duration has elapsed.
The duration parameter is expressend in seconds(s).

void wcall_set_duration(WUSER_HANDLE wuser, const char *convid, int duration);

The wcall_set_config_version API is used to set the version of the SFT and/or the TURN
server to use for processing. This is usefull in order to get test clients to connect
to different versions of the said servers depending on feature flags or other business logic.

void wcall_set_config_version(int sft_version, int turn_version);


1 change: 1 addition & 0 deletions include/avs_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void avs_print_network(void);
#define EDATACHANNEL (-1003)
#define ENOONEJOINED (-1004)
#define EEVERYONELEFT (-1005)
#define EDURATION (-1006)

#define E2EE_SESSIONKEY_SIZE 32

Expand Down
4 changes: 3 additions & 1 deletion include/avs_ccall.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int ccall_add_sft(struct icall *icall, const char *sft_url);

int ccall_start(struct icall *icall,
enum icall_call_type call_type,
bool audio_cbr);
bool audio_cbr, bool meeting);

int ccall_answer(struct icall *icall,
enum icall_call_type call_type,
Expand Down Expand Up @@ -100,6 +100,8 @@ int ccall_stats_struct(const struct ccall *ccall,
int ccall_debug(struct re_printf *pf, const struct icall* icall);

int ccall_activate(struct icall *icall, bool active);
void ccall_set_duration(struct icall *icall, int duration);


const char *ccall_state_name(enum ccall_state state);

Expand Down
2 changes: 1 addition & 1 deletion include/avs_ecall.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int ecall_add_turnserver(struct ecall *ecall,
struct zapi_ice_server *srv);
int ecall_start(struct ecall *ecall,
enum icall_call_type call_type,
bool audio_cbr);
bool audio_cbr, bool meeting);
int ecall_answer(struct ecall *ecall,
enum icall_call_type call_type,
bool audio_cbr);
Expand Down
2 changes: 1 addition & 1 deletion include/avs_egcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int egcall_add_turnserver(struct icall *icall,

int egcall_start(struct icall *icall,
enum icall_call_type call_type,
bool audio_cbr);
bool audio_cbr, bool meeting);

int egcall_answer(struct icall *icall,
enum icall_call_type call_type,
Expand Down
11 changes: 8 additions & 3 deletions include/avs_icall.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define ICALL_REASON_EVERYONE_LEFT 13
#define ICALL_REASON_AUTH_FAILED 14
#define ICALL_REASON_AUTH_FAILED_START 15
#define ICALL_REASON_DURATION 16

struct icall;
struct econn_message;
Expand Down Expand Up @@ -112,7 +113,8 @@ typedef int (icall_add_turnserver)(struct icall *icall,
typedef int (icall_add_sft)(struct icall *icall,
const char *sft_url);
typedef int (icall_start)(struct icall *icall,
enum icall_call_type call_type, bool audio_cbr);
enum icall_call_type call_type, bool audio_cbr,
bool meeting);
typedef int (icall_answer)(struct icall *icall,
enum icall_call_type call_type, bool audio_cbr);
typedef void (icall_end)(struct icall *icall);
Expand Down Expand Up @@ -151,6 +153,7 @@ typedef int (icall_stats)(struct re_printf *pf, const struct icall* icall);
typedef int (icall_set_background)(struct icall *icall, bool background);

typedef int (icall_activate)(struct icall *icall, bool active);
typedef void (icall_set_duration)(struct icall *icall, int duration);

/* Callbacks from icall */
typedef int (icall_sft_h)(struct icall *icall,
Expand Down Expand Up @@ -231,7 +234,6 @@ typedef void (icall_audio_level_h)(struct icall *icall, struct list *levell, voi
typedef void (icall_req_new_epoch_h)(struct icall *icall, void *arg);



struct icall {
icall_add_turnserver *add_turnserver;
icall_add_sft *add_sft;
Expand All @@ -256,6 +258,8 @@ struct icall {
icall_stats *stats;
icall_set_background *set_background;
icall_activate *activate;
icall_set_duration *set_duration;

icall_send_h *sendh;
icall_sft_h *sfth;
icall_start_h *starth;
Expand Down Expand Up @@ -309,7 +313,8 @@ void icall_set_functions(struct icall *icall,
icall_debug *debug,
icall_stats *stats,
icall_set_background *set_background,
icall_activate *activate);
icall_activate *activate,
icall_set_duration *set_duration);

void icall_set_callbacks(struct icall *icall,
icall_send_h *sendh,
Expand Down
4 changes: 4 additions & 0 deletions include/avs_msystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ void msystem_set_packet_size(int packet_size_ms);
bool msystem_get_muted(void);
void msystem_set_muted(bool muted);
void msystem_activate(bool active);
void msystem_set_config_version(int sft_version, int turn_version);
int msystem_get_sft_config_version(void);
int msystem_get_turn_config_version(void);



#endif
6 changes: 6 additions & 0 deletions include/avs_wcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ typedef void (wcall_req_new_epoch_h)(WUSER_HANDLE wuser,
#define WCALL_REASON_EVERYONE_LEFT 13
#define WCALL_REASON_AUTH_FAILED 14
#define WCALL_REASON_AUTH_FAILED_START 15
#define WCALL_REASON_DURATION 16


const char *wcall_reason_name(int reason);

Expand Down Expand Up @@ -444,6 +446,8 @@ int wcall_set_epoch_info(WUSER_HANDLE wuser,
void wcall_set_req_new_epoch_handler(WUSER_HANDLE wuser,
wcall_req_new_epoch_h *req_new_epochh);

void wcall_set_duration(WUSER_HANDLE wuser, const char *convid, int duration);

int wcall_get_mute(WUSER_HANDLE wuser);
void wcall_set_mute(WUSER_HANDLE wuser, int muted);
void wcall_set_mute_handler(WUSER_HANDLE wuser, wcall_mute_h *muteh, void *arg);
Expand Down Expand Up @@ -586,6 +590,8 @@ int wcall_setup_ex(int flags);
void wcall_set_mode(int mode);
int wcall_get_mode(void);

void wcall_set_config_version(int sft_version, int turn_version);

#ifdef __cplusplus
}
#endif
124 changes: 107 additions & 17 deletions src/ccall/ccall.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ static void destructor(void *arg)
tmr_cancel(&ccall->tmr_keepalive);
tmr_cancel(&ccall->tmr_alone);

tmr_cancel(&ccall->meeting.tmr_duration);

mem_deref(ccall->sft_url);
mem_deref(ccall->primary_sft_url);
mem_deref(ccall->sft_tuple);
Expand Down Expand Up @@ -267,6 +269,7 @@ static void set_state(struct ccall* ccall, enum ccall_state state)
tmr_cancel(&ccall->tmr_decrypt_check);
tmr_cancel(&ccall->tmr_keepalive);
tmr_cancel(&ccall->tmr_alone);
tmr_cancel(&ccall->meeting.tmr_duration);
break;

case CCALL_STATE_INCOMING:
Expand Down Expand Up @@ -343,6 +346,7 @@ static void set_state(struct ccall* ccall, enum ccall_state state)
tmr_cancel(&ccall->tmr_connect);
tmr_cancel(&ccall->tmr_keepalive);
tmr_cancel(&ccall->tmr_alone);
tmr_cancel(&ccall->meeting.tmr_duration);
break;

case CCALL_STATE_NONE:
Expand Down Expand Up @@ -989,6 +993,18 @@ static void ecall_aulevel_handler(struct icall *icall, struct list *levell, void
icall, levell, ccall->icall.arg);
}

static void durterm_timeout_handler(void *arg)
{
struct ccall *ccall = arg;

info("ccall(%p): duration terminate\n", ccall);

set_state(ccall, CCALL_STATE_IDLE);
ICALL_CALL_CB(ccall->icall, closeh,
&ccall->icall, ccall->error, &ccall->metrics,
ECONN_MESSAGE_TIME_UNKNOWN,
NULL, NULL, ccall->icall.arg);
}

static void ecall_close_handler(struct icall *icall,
int err,
Expand Down Expand Up @@ -1055,6 +1071,11 @@ static void ecall_close_handler(struct icall *icall,
false, NULL, false);
}
break;

case EDURATION:
if (!should_end) {
}
break;
}

if (metrics) {
Expand All @@ -1069,16 +1090,24 @@ static void ecall_close_handler(struct icall *icall,
if (should_end) {
set_state(ccall, CCALL_STATE_IDLE);

ICALL_CALL_CB(ccall->icall, closeh,
&ccall->icall, ccall->error, &ccall->metrics, msg_time,
NULL, NULL, ccall->icall.arg);
if (ccall->error != EDURATION) {
ICALL_CALL_CB(ccall->icall, closeh,
&ccall->icall, ccall->error, &ccall->metrics, msg_time,
NULL, NULL, ccall->icall.arg);
}
}
else {
set_state(ccall, CCALL_STATE_INCOMING);
if (ccall->error == EDURATION) {
tmr_start(&ccall->meeting.tmr_term, CCALL_DURATION_TERM_TIMEOUT,
durterm_timeout_handler, ccall);
}
else {
set_state(ccall, CCALL_STATE_INCOMING);

ICALL_CALL_CB(ccall->icall, leaveh,
&ccall->icall, ICALL_REASON_STILL_ONGOING,
msg_time, ccall->icall.arg);
ICALL_CALL_CB(ccall->icall, leaveh,
&ccall->icall, ICALL_REASON_STILL_ONGOING,
msg_time, ccall->icall.arg);
}
}

ccall->error = 0;
Expand Down Expand Up @@ -1778,6 +1807,14 @@ static void ccall_update_active_counts(struct ccall *ccall)
}
}

static void duration_timeout_handler(void *arg)
{
struct ccall *ccall = arg;

info("ccall(%p): duration expired\n");

ccall_end_with_err(ccall, EDURATION);
}

static void ecall_confpart_handler(struct ecall *ecall,
const struct econn_message *msg,
Expand Down Expand Up @@ -1846,10 +1883,40 @@ static void ecall_confpart_handler(struct ecall *ecall,
ccall->someone_joined = true;
}
else {
tmr_start(&ccall->tmr_alone,
ccall->someone_joined ? CCALL_EVERYONE_LEFT_TIMEOUT :
CCALL_NOONE_JOINED_TIMEOUT,
ccall_alone_timeout, ccall);
if (ccall->someone_joined) {
tmr_start(&ccall->tmr_alone,
CCALL_EVERYONE_LEFT_TIMEOUT,
ccall_alone_timeout,
ccall);
}
else if (!ccall->meeting.is_set) {
tmr_start(&ccall->tmr_alone,
CCALL_NOONE_JOINED_TIMEOUT,
ccall_alone_timeout,
ccall);
}
}

if (ccall->meeting.duration && first_confpart) {
int duration;

ccall->meeting.start_duration = (int)(timestamp - ccall->sft_timestamp);

duration = ccall->meeting.duration - ccall->meeting.start_duration;

info("ccall(%p): confpart: start=%d ts=%llu sft_ts=%llu meeting_duration=%d duration=%d\n",
ccall, ccall->meeting.start_duration, timestamp, ccall->sft_timestamp,
ccall->meeting.duration, duration);

if (duration <= 0) {
ccall_end_with_err(ccall, EDURATION);
}
else {
tmr_start(&ccall->meeting.tmr_duration,
duration,
duration_timeout_handler,
ccall);
}
}

if (first_confpart && ccall->ecall) {
Expand Down Expand Up @@ -2617,7 +2684,7 @@ int ccall_alloc(struct ccall **ccallp,
ccall->state = CCALL_STATE_IDLE;
ccall->stop_ringing_reason = CCALL_STOP_RINGING_NONE;
ccall->is_mls_call = is_mls_call;
ccall->meeting = meeting;
ccall->meeting.is_set = meeting;
ccall->metrics.conv_type = is_mls_call ? ICALL_CONV_TYPE_CONFERENCE_MLS : ICALL_CONV_TYPE_CONFERENCE;

tmr_init(&ccall->tmr_connect);
Expand Down Expand Up @@ -2651,7 +2718,8 @@ int ccall_alloc(struct ccall **ccallp,
ccall_debug,
ccall_stats,
ccall_set_background,
ccall_activate);
ccall_activate,
ccall_set_duration);
out:
if (err == 0) {
*ccallp = ccall;
Expand Down Expand Up @@ -3000,12 +3068,14 @@ static int ccall_req_cfg_join(struct ccall *ccall,

int ccall_start(struct icall *icall,
enum icall_call_type call_type,
bool audio_cbr)
bool audio_cbr,
bool meeting)
{
struct ccall *ccall = (struct ccall*)icall;
int err;

ccall->error = 0;
ccall->meeting.is_set = meeting;
switch (ccall->state) {
case CCALL_STATE_INCOMING:
warning("ccall(%p): call_start attempt to start call in "
Expand Down Expand Up @@ -3409,7 +3479,7 @@ static int ccall_handle_confstart_check(struct ccall* ccall,
should_ring = false;
}

if (ccall->meeting) {
if (ccall->meeting.is_set) {
should_ring = false;
}
ccall->is_ringing = should_ring;
Expand Down Expand Up @@ -3929,13 +3999,24 @@ int ccall_activate(struct icall *icall, bool active)
struct ccall *ccall = (struct ccall *)icall;

info("ccall(%p): activate: active=%d\n", ccall, active);

if (ccall->ecall) {
ecall_activate(ccall->ecall, active);
ecall_activate(ccall->ecall, active);
}

return 0;
}

void ccall_set_duration(struct icall *icall, int duration)
{
struct ccall *ccall = (struct ccall *)icall;

info("ccall(%p): set_duration: duratione=%ds\n", ccall, duration);

ccall->meeting.duration = duration * 1000;
}


static void ccall_connect_timeout(void *arg)
{
struct ccall *ccall = arg;
Expand Down Expand Up @@ -3976,6 +4057,10 @@ static void ccall_end_with_err(struct ccall *ccall, int err)
reason = ICALL_REASON_EVERYONE_LEFT;
break;

case EDURATION:
reason = ICALL_REASON_DURATION;
break;

case EACCES:
reason = ICALL_REASON_AUTH_FAILED;
break;
Expand Down Expand Up @@ -4008,7 +4093,12 @@ static void ccall_end_with_err(struct ccall *ccall, int err)
case CCALL_STATE_CONNECTING:
case CCALL_STATE_CONNECTED:
case CCALL_STATE_ACTIVE:
set_state(ccall, CCALL_STATE_TERMINATING);
set_state(ccall, CCALL_STATE_TERMINATING);
if (err == EDURATION ) {
ICALL_CALL_CB(ccall->icall, leaveh,
&ccall->icall, ICALL_REASON_DURATION,
ECONN_MESSAGE_TIME_UNKNOWN, ccall->icall.arg);
}
break;
}

Expand Down
Loading