Commit a3eb4b35 authored by Pekka Pessi's avatar Pekka Pessi

Updated API of soa_get_local_sdp() and friends.

Added parameter for returning SDP C structure to soa_get_capability_sdp(),
soa_get_remote_sdp(), soa_get_user_sdp(), and soa_get_local_sdp().

darcs-hash:20051014102916-65a35-ff9e762903bf91154ad3590f1da989bd7ffcfe6d.gz
parent f286f13e
......@@ -632,25 +632,31 @@ char const *soa_error_as_sip_reason(soa_session_t *ss)
* @retval -1 upon an error
*/
int soa_get_capability_sdp(soa_session_t const *ss,
char const **return_sdp,
sdp_session_t const **return_sdp,
char const **return_sdp_str,
int *return_len)
{
char const *sdp;
sdp_session_t const *sdp;
char const *sdp_str;
SU_DEBUG_9(("soa_get_capability_sdp(%s::%p) called\n",
ss ? ss->ss_actions->soa_name : "", ss));
SU_DEBUG_9(("soa_get_capability_sdp(%s::%p, [%p], [%p], [%p]) called\n",
ss ? ss->ss_actions->soa_name : "", ss,
return_sdp, return_sdp_str, return_len));
if (ss == NULL)
return (void)(errno = EFAULT), -1;
sdp = ss->ss_caps->ssd_str;
sdp = ss->ss_caps->ssd_sdp;
sdp_str = ss->ss_caps->ssd_str;
if (sdp == NULL)
return 0;
if (return_sdp)
*return_sdp = sdp;
if (return_sdp_str)
*return_sdp_str = sdp_str;
if (return_len)
*return_len = strlen(sdp);
*return_len = strlen(sdp_str);
return 1;
}
......@@ -660,8 +666,9 @@ int soa_set_capability_sdp(soa_session_t *ss,
sdp_session_t const *sdp,
char const *str, int len)
{
SU_DEBUG_9(("soa_set_capability_sdp(%s::%p, %p, %d) called\n",
ss ? ss->ss_actions->soa_name : "", ss, sdp, len));
SU_DEBUG_9(("soa_set_capability_sdp(%s::%p, %p, %p, %d) called\n",
ss ? ss->ss_actions->soa_name : "", ss, sdp, str,
str && len == -1 ? strlen(str) : len));
return soa_set_sdp(ss, soa_capability_sdp_kind, sdp, str, len);
}
......@@ -716,27 +723,29 @@ soa_base_set_capability_sdp(soa_session_t *ss,
* @retval -1 upon an error
*/
int soa_get_user_sdp(soa_session_t const *ss,
char const **return_sdp,
int *return_len)
sdp_session_t const **return_sdp,
char const **return_sdp_str,
int *return_len)
{
sdp_session_t const *sdp;
char const *sdp_str;
SU_DEBUG_9(("soa_get_user_sdp(%s::%p, ...) called\n",
ss ? ss->ss_actions->soa_name : "", ss));
SU_DEBUG_9(("soa_get_user_sdp(%s::%p, [%p], [%p], [%p]) called\n",
ss ? ss->ss_actions->soa_name : "", ss,
return_sdp, return_sdp_str, return_len));
if (ss == NULL)
return (void)(errno = EFAULT), -1;
/* return modified user SDP if available */
if (ss->ss_local->ssd_str)
sdp_str = ss->ss_local->ssd_str;
else
sdp_str = ss->ss_user->ssd_str;
sdp = ss->ss_user->ssd_sdp;
sdp_str = ss->ss_user->ssd_str;
if (sdp_str == NULL)
if (sdp == NULL)
return 0;
if (return_sdp)
*return_sdp = sdp_str;
*return_sdp = sdp;
if (return_sdp_str)
*return_sdp_str = sdp_str;
if (return_len)
*return_len = strlen(sdp_str);
......@@ -758,8 +767,9 @@ int soa_set_user_sdp(soa_session_t *ss,
sdp_session_t const *sdp,
char const *str, int len)
{
SU_DEBUG_9(("soa_set_user_sdp(%s::%p, %p, %d) called\n",
ss ? ss->ss_actions->soa_name : "", ss, sdp, len));
SU_DEBUG_9(("soa_set_user_sdp(%s::%p, %p, %p, %d) called\n",
ss ? ss->ss_actions->soa_name : "", ss, sdp, str,
str && len == -1 ? strlen(str) : len));
return soa_set_sdp(ss, soa_user_sdp_kind, sdp, str, len);
}
......@@ -778,25 +788,31 @@ int soa_base_set_user_sdp(soa_session_t *ss,
* @retval -1 upon an error
*/
int soa_get_remote_sdp(soa_session_t const *ss,
char const **return_sdp,
sdp_session_t const **return_sdp,
char const **return_sdp_str,
int *return_len)
{
char const *sdp;
sdp_session_t const *sdp;
char const *sdp_str;
SU_DEBUG_9(("soa_get_remote_sdp(%s::%p, ...) called\n",
ss ? ss->ss_actions->soa_name : "", ss));
SU_DEBUG_9(("soa_get_remote_sdp(%s::%p, [%p], [%p], [%p]) called\n",
ss ? ss->ss_actions->soa_name : "", ss,
return_sdp, return_sdp_str, return_len));
if (ss == NULL)
return (void)(errno = EFAULT), -1;
sdp = ss->ss_remote->ssd_str;
sdp = ss->ss_remote->ssd_sdp;
sdp_str = ss->ss_remote->ssd_str;
if (sdp == NULL)
return 0;
if (return_sdp)
*return_sdp = sdp;
if (return_sdp_str)
*return_sdp_str = sdp_str;
if (return_len)
*return_len = strlen(sdp);
*return_len = strlen(sdp_str);
return 1;
}
......@@ -816,8 +832,9 @@ int soa_set_remote_sdp(soa_session_t *ss,
sdp_session_t const *sdp,
char const *str, int len)
{
SU_DEBUG_9(("soa_set_remote_sdp(%s::%p, %p, %d) called\n",
ss ? ss->ss_actions->soa_name : "", ss, sdp, len));
SU_DEBUG_9(("soa_set_remote_sdp(%s::%p, %p, %p, %d) called\n",
ss ? ss->ss_actions->soa_name : "", ss, sdp, str,
str && len == -1 ? strlen(str) : len));
return soa_set_sdp(ss, soa_remote_sdp_kind, sdp, str, len);
}
......@@ -853,25 +870,31 @@ int soa_clear_remote_sdp(soa_session_t *ss)
}
int soa_get_local_sdp(soa_session_t const *ss,
char const **return_sdp,
sdp_session_t const **return_sdp,
char const **return_sdp_str,
int *return_len)
{
char const *sdp;
sdp_session_t const *sdp;
char const *sdp_str;
SU_DEBUG_9(("soa_get_local_sdp(%s::%p, ...) called\n",
ss ? ss->ss_actions->soa_name : "", ss));
SU_DEBUG_9(("soa_get_local_sdp(%s::%p, [%p], [%p], [%p]) called\n",
ss ? ss->ss_actions->soa_name : "", ss,
return_sdp, return_sdp_str, return_len));
if (ss == NULL)
return (void)(errno = EFAULT), -1;
sdp = ss->ss_local->ssd_str;
sdp = ss->ss_local->ssd_sdp;
sdp_str = ss->ss_local->ssd_str;
if (sdp == NULL)
return 0;
if (return_sdp)
*return_sdp = sdp;
if (return_sdp_str)
*return_sdp_str = sdp_str;
if (return_len)
*return_len = strlen(sdp);
*return_len = strlen(sdp_str);
return 1;
}
......
......@@ -74,7 +74,8 @@ int soa_set_capability_sdp(soa_session_t *ss,
char const *str, int len);
int soa_get_capability_sdp(soa_session_t const *ss,
char const **return_sdp,
struct sdp_session_s const **return_sdp,
char const **return_sdp_str,
int *return_len);
int soa_set_remote_sdp(soa_session_t *ss,
......@@ -82,7 +83,8 @@ int soa_set_remote_sdp(soa_session_t *ss,
char const *str, int len);
int soa_get_remote_sdp(soa_session_t const *ss,
char const **return_sdp,
struct sdp_session_s const **return_sdp,
char const **return_sdp_str,
int *return_len);
int soa_clear_remote_sdp(soa_session_t *ss);
......@@ -94,13 +96,15 @@ int soa_set_user_sdp(soa_session_t *ss,
char const *str, int len);
int soa_get_user_sdp(soa_session_t const *ss,
char const **return_sdp,
struct sdp_session_s const **return_sdp,
char const **return_sdp_str,
int *return_len);
int soa_get_user_version(soa_session_t const *ss);
int soa_get_local_sdp(soa_session_t const *ss,
char const **return_sdp,
struct sdp_session_s const **return_sdp,
char const **return_sdp_str,
int *return_len);
char const * const * soa_sip_require(soa_session_t const *ss);
......
......@@ -121,9 +121,10 @@ int test_api_errors(struct context *ctx)
TEST_1(soa_set_remote_sdp(NULL, NULL, NULL, -1) < 0);
TEST_1(soa_set_user_sdp(NULL, NULL, NULL, -1) < 0);
TEST_1(soa_get_capability_sdp(NULL, NULL, NULL) < 0);
TEST_1(soa_get_local_sdp(NULL, NULL, NULL) < 0);
TEST_1(soa_get_remote_sdp(NULL, NULL, NULL) < 0);
TEST_1(soa_get_capability_sdp(NULL, NULL, NULL, NULL) < 0);
TEST_1(soa_get_remote_sdp(NULL, NULL, NULL, NULL) < 0);
TEST_1(soa_get_user_sdp(NULL, NULL, NULL, NULL) < 0);
TEST_1(soa_get_local_sdp(NULL, NULL, NULL, NULL) < 0);
TEST_1(-1 == soa_generate_offer(NULL, 0, test_api_completed));
......@@ -266,29 +267,29 @@ int test_static_offer_answer(struct context *ctx)
1);
TEST(soa_set_capability_sdp(ctx->synch.a, 0, a_caps, strlen(a_caps)),
1);
TEST(soa_get_capability_sdp(ctx->synch.a, &caps, &capslen), 1);
TEST(soa_get_capability_sdp(ctx->synch.a, NULL, &caps, &capslen), 1);
TEST_1(caps != NULL && caps != NONE);
TEST_1(capslen > 0);
TEST(soa_set_user_sdp(ctx->synch.b, 0, b_caps, strlen(b_caps)), 1);
TEST(soa_get_capability_sdp(ctx->synch.a, &caps, &capslen), 1);
TEST(soa_get_capability_sdp(ctx->synch.a, NULL, &caps, &capslen), 1);
TEST_1(a = soa_clone(ctx->synch.a, ctx->root, ctx));
TEST_1(b = soa_clone(ctx->synch.b, ctx->root, ctx));
n = soa_get_local_sdp(a, &offer, &offerlen); TEST(n, 0);
n = soa_get_local_sdp(a, NULL, &offer, &offerlen); TEST(n, 0);
n = soa_set_user_sdp(a, 0, "m=audio 5004 RTP/AVP 0 8", -1); TEST(n, 1);
n = soa_generate_offer(a, 1, test_completed); TEST(n, 0);
n = soa_get_local_sdp(a, &offer, &offerlen); TEST(n, 1);
n = soa_get_local_sdp(a, NULL, &offer, &offerlen); TEST(n, 1);
TEST_1(offer != NULL && offer != NONE);
n = soa_set_remote_sdp(b, 0, offer, offerlen); TEST(n, 1);
n = soa_get_local_sdp(b, &answer, &answerlen); TEST(n, 0);
n = soa_get_local_sdp(b, NULL, &answer, &answerlen); TEST(n, 0);
n = soa_set_params(b,
SOATAG_LOCAL_SDP_STR("m=audio 5004 RTP/AVP 8"),
......@@ -299,7 +300,7 @@ int test_static_offer_answer(struct context *ctx)
TEST_1(soa_is_complete(b));
TEST(soa_activate(b, NULL), 0);
n = soa_get_local_sdp(b, &answer, &answerlen); TEST(n, 1);
n = soa_get_local_sdp(b, NULL, &answer, &answerlen); TEST(n, 1);
TEST_1(answer != NULL && answer != NONE);
n = soa_set_remote_sdp(a, 0, answer, -1); TEST(n, 1);
......@@ -323,14 +324,14 @@ int test_static_offer_answer(struct context *ctx)
TEST(soa_set_params(a, SOATAG_HOLD("*"), TAG_END()), 1);
TEST(soa_generate_offer(a, 1, test_completed), 0);
TEST(soa_get_local_sdp(a, &offer, &offerlen), 1);
TEST(soa_get_local_sdp(a, NULL, &offer, &offerlen), 1);
TEST_1(offer != NULL && offer != NONE);
TEST_1(strstr(offer, "a=sendonly"));
TEST(soa_set_remote_sdp(b, 0, offer, offerlen), 1);
TEST(soa_generate_answer(b, test_completed), 0);
TEST_1(soa_is_complete(b));
TEST(soa_activate(b, NULL), 0);
TEST(soa_get_local_sdp(b, &answer, &answerlen), 1);
TEST(soa_get_local_sdp(b, NULL, &answer, &answerlen), 1);
TEST_1(answer != NULL && answer != NONE);
TEST_1(strstr(answer, "a=recvonly"));
TEST(soa_set_remote_sdp(a, 0, answer, -1), 1);
......@@ -349,7 +350,7 @@ int test_static_offer_answer(struct context *ctx)
TAG_END()), 2);
TEST(soa_generate_offer(a, 1, test_completed), 0);
TEST(soa_get_local_sdp(a, &offer, &offerlen), 1);
TEST(soa_get_local_sdp(a, NULL, &offer, &offerlen), 1);
TEST_1(offer != NULL && offer != NONE);
TEST_1(!strstr(offer, "a=sendonly"));
TEST_1(strstr(offer, "m=video"));
......@@ -357,7 +358,7 @@ int test_static_offer_answer(struct context *ctx)
TEST(soa_generate_answer(b, test_completed), 0);
TEST_1(soa_is_complete(b));
TEST(soa_activate(b, NULL), 0);
TEST(soa_get_local_sdp(b, &answer, &answerlen), 1);
TEST(soa_get_local_sdp(b, NULL, &answer, &answerlen), 1);
TEST_1(answer != NULL && answer != NONE);
TEST_1(!strstr(answer, "a=recvonly"));
TEST_1(strstr(answer, "m=video"));
......@@ -395,7 +396,7 @@ int test_static_offer_answer(struct context *ctx)
TAG_END()), 1);
TEST(soa_generate_offer(b, 1, test_completed), 0);
TEST(soa_get_local_sdp(b, &offer, &offerlen), 1);
TEST(soa_get_local_sdp(b, NULL, &offer, &offerlen), 1);
TEST_1(offer != NULL && offer != NONE);
TEST_1(!strstr(offer, "b=sendonly"));
TEST_1(strstr(offer, "m=video"));
......@@ -403,7 +404,7 @@ int test_static_offer_answer(struct context *ctx)
TEST(soa_generate_answer(a, test_completed), 0);
TEST_1(soa_is_complete(a));
TEST(soa_activate(a, NULL), 0);
TEST(soa_get_local_sdp(a, &answer, &answerlen), 1);
TEST(soa_get_local_sdp(a, NULL, &answer, &answerlen), 1);
TEST_1(answer != NULL && answer != NONE);
TEST_1(!strstr(answer, "b=recvonly"));
TEST_1(strstr(answer, "m=video"));
......@@ -469,7 +470,7 @@ int test_asynch_offer_answer(struct context *ctx)
su_root_run(ctx->root); TEST(ctx->completed, ctx->asynch.a);
ctx->completed = NULL;
n = soa_get_local_sdp(ctx->asynch.a, &offer, &offerlen); TEST(n, 1);
n = soa_get_local_sdp(ctx->asynch.a, 0, &offer, &offerlen); TEST(n, 1);
n = soa_set_remote_sdp(ctx->asynch.b, 0, offer, offerlen); TEST(n, 1);
......@@ -481,7 +482,7 @@ int test_asynch_offer_answer(struct context *ctx)
TEST_1(soa_is_complete(ctx->asynch.b));
TEST(soa_activate(ctx->asynch.b, NULL), 0);
n = soa_get_local_sdp(ctx->asynch.b, &answer, &answerlen); TEST(n, 1);
n = soa_get_local_sdp(ctx->asynch.b, 0, &answer, &answerlen); TEST(n, 1);
n = soa_set_remote_sdp(ctx->asynch.a, 0, answer, answerlen); TEST(n, 1);
......
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