Skip to content

Commit

Permalink
Fix oneway video sdp on answering call (#2615)
Browse files Browse the repository at this point in the history
* call: add sent_answer bool

* static_menu: answerdir: set mdir if no SDP answer sent

If answerdir is called and no SDP answer has been sent before, we have
to call `call_set_media_direction` which sets the media directions of
the streams because in this case they have not been set before.
  • Loading branch information
maximilianfridrich committed Jun 13, 2023
1 parent 36535a6 commit 8347ada
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/baresip.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const char *call_user_data(const struct call *call);
int call_set_user_data(struct call *call, const char *user_data);
void call_set_evstop(struct call *call, bool stop);
bool call_is_evstop(struct call *call);
bool call_sent_answer(const struct call *call);

/*
* Custom headers
Expand Down
6 changes: 5 additions & 1 deletion modules/menu/static_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ static int cmd_answerdir(struct re_printf *pf, void *arg)
ua = call_get_ua(call);
}

(void)call_set_media_estdir(call, adir, vdir);
if (call_sent_answer(call))
(void)call_set_media_estdir(call, adir, vdir);
else
(void)call_set_media_direction(call, adir, vdir);

err = answer_call(ua, call);
if (err)
re_hprintf(pf, "could not answer call (%m)\n", err);
Expand Down
16 changes: 15 additions & 1 deletion src/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct call {
bool outgoing; /**< True if outgoing, false if incoming */
bool answered; /**< True if call has been answered */
bool got_offer; /**< Got SDP Offer from Peer */
bool sent_answer; /**< Sent an SDP Answer to Peer */
bool on_hold; /**< True if call is on hold (local) */
bool ans_queued; /**< True if an (auto) answer is queued */
struct mnat_sess *mnats; /**< Media NAT session */
Expand Down Expand Up @@ -1183,6 +1184,8 @@ int call_modify(struct call *call)
err = sipsess_modify(call->sess, desc);
if (err)
goto out;

call->sent_answer = false;
}
}

Expand Down Expand Up @@ -1310,8 +1313,10 @@ int call_progress_dir(struct call *call, enum sdp_dir adir, enum sdp_dir vdir)
if (err)
goto out;

if (call->got_offer)
if (call->got_offer) {
err = update_media(call);
call->sent_answer = true;
}

if (err)
goto out;
Expand Down Expand Up @@ -1395,6 +1400,8 @@ int call_answer(struct call *call, uint16_t scode, enum vidmode vmode)
"Allow: %H\r\n"
"%H", ua_print_allowed, call->ua,
ua_print_supported, call->ua);
if (!err)
call->sent_answer = call->got_offer;
}
else {
err = sipsess_answer(call->sess, scode, "Answering", desc,
Expand Down Expand Up @@ -1813,6 +1820,7 @@ static int sipsess_offer_handler(struct mbuf **descp,
if (got_offer) {

call->got_offer = true;
call->sent_answer = false;

/* Decode SDP Offer */
err = sdp_decode(call->sdp, msg->mb, true);
Expand Down Expand Up @@ -3161,3 +3169,9 @@ bool call_is_evstop(struct call *call)

return call->evstop;
}


bool call_sent_answer(const struct call *call)
{
return call ? call->sent_answer : false;
}

5 comments on commit 8347ada

@juha-h
Copy link
Collaborator

@juha-h juha-h commented on 8347ada Jun 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, how the answer could have been sent before the call is answered, i.e., before user gives /acceptdir command?

@cspiel1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first SDP answer can be sent with a 183 Session Progress. The second answer then is SIP 200 Answering with same SDP.

@juha-h
Copy link
Collaborator

@juha-h juha-h commented on 8347ada Jun 15, 2023 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cspiel1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nobody said this. The baresip core calls call_progress() if the account was configured for early-media. Please see ua.c function call_event_handler()!

@juha-h
Copy link
Collaborator

@juha-h juha-h commented on 8347ada Jun 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I tried to find menu command to answer with early media.

Please sign in to comment.