Commit be6d2af5 authored by Pekka Pessi's avatar Pekka Pessi

soa.c: using session state in soa_set_activity()

The media mode bits are set using (local) session description instead of
remote offer/answer when O/A has been completed.

darcs-hash:20080121190635-65a35-ff36e581cfbaf2fddb0656c880dc534cb565425a.gz
parent 40fcee44
......@@ -70,10 +70,6 @@ static char const __func__[] = "soa";
/* ======================================================================== */
/* Internal prototypes */
void soa_set_activity(soa_session_t *ss,
sdp_media_t const *,
int remote);
su_inline int soa_media_is_ready(soa_session_t const *ss);
enum soa_sdp_kind {
......@@ -1171,7 +1167,7 @@ int soa_base_set_remote_sdp(soa_session_t *ss,
if (!new_version)
return 0;
soa_set_activity(ss, sdp->sdp_media, 1);
soa_set_activity(ss, sdp->sdp_media, soa_activity_remote);
ss->ss_remote_version++;
......@@ -1454,7 +1450,7 @@ int soa_base_generate_offer(soa_session_t *ss,
if (!sdp)
return -1;
soa_set_activity(ss, sdp->sdp_media, 0);
soa_set_activity(ss, sdp->sdp_media, soa_activity_local); /* Wanted activity */
ss->ss_offer_sent = 1;
ss->ss_answer_recv = 0;
......@@ -1542,8 +1538,7 @@ int soa_base_generate_answer(soa_session_t *ss,
su_free(ss->ss_home, ss->ss_rsession);
ss->ss_rsession = rsession;
soa_set_activity(ss, l_sdp->sdp_media, 0);
soa_set_activity(ss, r_sdp->sdp_media, 1);
soa_set_activity(ss, l_sdp->sdp_media, soa_activity_session);
ss->ss_offer_recv = 1;
ss->ss_answer_sent = 1;
......@@ -1624,8 +1619,7 @@ int soa_base_process_answer(soa_session_t *ss,
su_free(ss->ss_home, ss->ss_rsession);
ss->ss_rsession = rsession;
soa_set_activity(ss, l_sdp->sdp_media, 0);
soa_set_activity(ss, r_sdp->sdp_media, 1);
soa_set_activity(ss, l_sdp->sdp_media, soa_activity_session);
ss->ss_answer_recv = 1;
ss->ss_complete = 1;
......@@ -1692,7 +1686,7 @@ int soa_base_process_reject(soa_session_t *ss,
if (!l_sdp)
return -1;
soa_set_activity(ss, l_sdp->sdp_media, 0);
soa_set_activity(ss, l_sdp->sdp_media, soa_activity_session);
ss->ss_offer_sent = 0;
......@@ -1783,8 +1777,7 @@ void soa_base_terminate(soa_session_t *ss, char const *option)
ss->ss_oa_rounds = 0;
soa_description_free(ss, ss->ss_remote);
soa_set_activity(ss, NULL, 0);
soa_set_activity(ss, NULL, 1);
soa_set_activity(ss, NULL, soa_activity_session);
}
/** Return true if the SDP Offer/Answer negotation is complete.
......@@ -1889,56 +1882,75 @@ int soa_media_is_ready(soa_session_t const *ss)
void soa_set_activity(soa_session_t *ss,
sdp_media_t const *m,
int remote)
enum soa_activity activity)
{
struct soa_media_activity *ma;
sdp_connection_t const *c;
int mode;
int ma_audio = SOA_ACTIVE_DISABLED;
int ma_video = SOA_ACTIVE_DISABLED;
int ma_chat = SOA_ACTIVE_DISABLED;
int ma_image = SOA_ACTIVE_DISABLED;
int *p;
remote = !!remote;
int mode, swap;
int l_audio = SOA_ACTIVE_DISABLED, r_audio = SOA_ACTIVE_DISABLED;
int l_video = SOA_ACTIVE_DISABLED, r_video = SOA_ACTIVE_DISABLED;
int l_chat = SOA_ACTIVE_DISABLED, r_chat = SOA_ACTIVE_DISABLED;
int l_image = SOA_ACTIVE_DISABLED, r_image = SOA_ACTIVE_DISABLED;
ma = remote ? ss->ss_remote_activity : ss->ss_local_activity;
int *l, *r;
for (; m; m = m->m_next) {
if (m->m_type == sdp_media_audio)
p = &ma_audio;
l = &l_audio, r = &r_audio;
else if (m->m_type == sdp_media_video)
p = &ma_video;
l = &l_video, r = &r_video;
else if (m->m_type == sdp_media_image)
p = &ma_image;
l = &l_image, r = &r_image;
else if (strcasecmp(m->m_type_name, "message") == 0)
p = &ma_chat;
l = &l_chat, r = &r_chat;
else
continue;
if (m->m_rejected) {
if (*p < 0)
*p = SOA_ACTIVE_REJECTED;
if (*l < 0) *l = SOA_ACTIVE_REJECTED;
if (*r < 0) *r = SOA_ACTIVE_REJECTED;
continue;
}
mode = m->m_mode;
mode = m->m_mode, swap = ((mode << 1) & 2) | ((mode >> 1) & 1);
c = sdp_media_connections((sdp_media_t *)m);
if (remote != (c && c->c_mcast))
mode = ((mode << 1) & 2) | ((mode >> 1) & 1);
switch (activity) {
case soa_activity_local:
*l &= SOA_ACTIVE_SENDRECV;
*l |= c && c->c_mcast ? swap : mode;
break;
case soa_activity_remote:
*r &= SOA_ACTIVE_SENDRECV;
*r = c && c->c_mcast ? mode : swap;
break;
case soa_activity_session:
*l &= SOA_ACTIVE_SENDRECV;
*l |= c && c->c_mcast ? swap : mode;
*r &= SOA_ACTIVE_SENDRECV;
*r = c && c->c_mcast ? swap : mode;
break;
}
}
if (*p < 0)
*p = mode;
else
*p |= mode;
if (activity == soa_activity_local ||
activity == soa_activity_session) {
ma = ss->ss_local_activity;
ma->ma_audio = l_audio;
ma->ma_video = l_video;
ma->ma_image = l_image;
ma->ma_chat = l_chat;
}
ma->ma_audio = ma_audio;
ma->ma_video = ma_video;
ma->ma_image = ma_image;
ma->ma_chat = ma_chat;
if (activity == soa_activity_remote ||
activity == soa_activity_session) {
ma = ss->ss_remote_activity;
ma->ma_audio = r_audio;
ma->ma_video = r_video;
ma->ma_image = r_image;
ma->ma_chat = r_chat;
}
}
/* ----------------------------------------------------------------------*/
......
......@@ -238,8 +238,11 @@ SOFIAPUBFUN int soa_has_received_sdp(soa_session_t const *ss);
SOFIAPUBFUN int soa_set_status(soa_session_t *ss,
int status, char const *phrase);
enum soa_activity { soa_activity_local, soa_activity_remote, soa_activity_session };
SOFIAPUBFUN void soa_set_activity(soa_session_t *ss,
sdp_media_t const *m, int remote);
sdp_media_t const *m,
enum soa_activity activity);
SOFIAPUBFUN int soa_description_set(soa_session_t *ss,
struct soa_description *ssd,
......
......@@ -1351,7 +1351,7 @@ int test_asynch_offer_answer(struct context *ctx)
{
BEGIN();
#if 0
#if 0 /* This has never been implemented */
int n;
char const *caps = NONE, *offer = NONE, *answer = NONE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment