summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2014-04-05 16:59:53 +0200
committerAlfred E. Heggestad <aeh@db.org>2014-04-05 16:59:53 +0200
commit5fc1c61109c1368fc781a287d6cfc0ef1abe1d35 (patch)
tree83dc7b4f54eddc0c96e798b5e0a462ec91baaef6 /src
parent1efeb23ab6899ce901cc05032299c54b89e32e01 (diff)
parentc8f2d1852309be78cba0fd1cc570e65e5eaa3b8f (diff)
Merge branch 'master' into next
Diffstat (limited to 'src')
-rw-r--r--src/call.c40
-rw-r--r--src/config.c4
-rw-r--r--src/stream.c8
-rw-r--r--src/ua.c12
4 files changed, 50 insertions, 14 deletions
diff --git a/src/call.c b/src/call.c
index 5708608..a947c25 100644
--- a/src/call.c
+++ b/src/call.c
@@ -62,6 +62,7 @@ struct call {
struct tmr tmr_inv; /**< Timer for incoming calls */
struct tmr tmr_dtmf; /**< Timer for incoming DTMF events */
time_t time_start; /**< Time when call started */
+ time_t time_conn; /**< Time when call initiated */
time_t time_stop; /**< Time when call stopped */
bool got_offer; /**< Got SDP Offer from Peer */
struct mnat_sess *mnats; /**< Media NAT session */
@@ -631,7 +632,10 @@ int call_hangup(struct call *call, uint16_t scode, const char *reason)
break;
default:
- info("call: terminate call with %s\n", call->peer_uri);
+ info("call: terminate call '%s' with %s\n",
+ sip_dialog_callid(sipsess_dialog(call->sess)),
+ call->peer_uri);
+
call->sess = mem_deref(call->sess);
break;
}
@@ -694,7 +698,7 @@ int call_answer(struct call *call, uint16_t scode)
return err;
err = sipsess_answer(call->sess, scode, "Answering", desc,
- "Allow: %s\r\n", uag_allowed_methods());
+ "Allow: %s\r\n", uag_allowed_methods());
mem_deref(desc);
@@ -1116,7 +1120,7 @@ static void sipsess_refer_handler(struct sip *sip, const struct sip_msg *msg,
ua_cuser(call->ua), "message/sipfrag",
auth_handler, call->acc, true,
sipnot_close_handler, call,
- "Allow: %s\r\n", uag_allowed_methods());
+ "Allow: %s\r\n", uag_allowed_methods());
if (err) {
warning("call: refer: sipevent_accept failed: %m\n", err);
return;
@@ -1309,6 +1313,9 @@ static int send_invite(struct call *call)
warning("call: sipsess_connect: %m\n", err);
}
+ /* save call setup timer */
+ call->time_conn = time(NULL);
+
mem_deref(desc);
return err;
@@ -1332,6 +1339,22 @@ uint32_t call_duration(const struct call *call)
/**
+ * Get the current call setup time in seconds
+ *
+ * @param call Call object
+ *
+ * @return Call setup in seconds
+ */
+uint32_t call_setup_duration(const struct call *call)
+{
+ if (!call || !call->time_conn || call->time_conn <= 0 )
+ return 0;
+
+ return (uint32_t)(call->time_start - call->time_conn);
+}
+
+
+/**
* Get the audio object for the current call
*
* @param call Call object
@@ -1555,7 +1578,12 @@ void call_set_handlers(struct call *call, call_event_h *eh,
if (!call)
return;
- call->eh = eh;
- call->dtmfh = dtmfh;
- call->arg = arg;
+ if (eh)
+ call->eh = eh;
+
+ if (dtmfh)
+ call->dtmfh = dtmfh;
+
+ if (arg)
+ call->arg = arg;
}
diff --git a/src/config.c b/src/config.c
index dd65c52..4a84b67 100644
--- a/src/config.c
+++ b/src/config.c
@@ -334,6 +334,8 @@ static const char *default_audio_device(void)
return "oss,/dev/dsp";
#elif defined (WIN32)
return "winwave,nil";
+#elif defined (ANDROID)
+ return "opensles";
#else
return "alsa,default";
#endif
@@ -583,6 +585,8 @@ int config_write_template(const char *file, const struct config *cfg)
(void)re_fprintf(f, "module\t\t\t" MOD_PRE "mda" MOD_EXT "\n");
#elif defined (DARWIN)
(void)re_fprintf(f, "module\t\t\t" MOD_PRE "coreaudio" MOD_EXT "\n");
+#elif defined (ANDROID)
+ (void)re_fprintf(f, "module\t\t\t" MOD_PRE "opensles" MOD_EXT "\n");
#else
(void)re_fprintf(f, "module\t\t\t" MOD_PRE "oss" MOD_EXT "\n");
(void)re_fprintf(f, "module\t\t\t" MOD_PRE "alsa" MOD_EXT "\n");
diff --git a/src/stream.c b/src/stream.c
index bb2600b..f30bf0c 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -76,11 +76,15 @@ static void print_rtp_stats(struct stream *s)
{
info("\n%-9s Transmit: Receive:\n"
"packets: %7u %7u\n"
- "avg. bitrate: %7.1f %7.1f (kbit/s)\n",
+ "avg. bitrate: %7.1f %7.1f (kbit/s)\n"
+ "errors: %7d %7d\n"
+ ,
sdp_media_name(s->sdp),
s->metric_tx.n_packets, s->metric_rx.n_packets,
1.0*metric_avg_bitrate(&s->metric_tx)/1000,
- 1.0*metric_avg_bitrate(&s->metric_rx)/1000);
+ 1.0*metric_avg_bitrate(&s->metric_rx)/1000,
+ s->metric_tx.n_err, s->metric_rx.n_err
+ );
if (s->rtcp_stats.tx.sent || s->rtcp_stats.rx.sent) {
diff --git a/src/ua.c b/src/ua.c
index 6d66ca4..c30be6a 100644
--- a/src/ua.c
+++ b/src/ua.c
@@ -474,18 +474,18 @@ int ua_alloc(struct ua **uap, const char *aor)
ua->af = AF_INET;
#endif
- /* generate a unique contact-user, this is needed to route
- incoming requests when using multiple useragents */
- err = re_sdprintf(&ua->cuser, "%p", ua);
- if (err)
- goto out;
-
/* Decode SIP address */
err = account_alloc(&ua->acc, aor);
if (err)
goto out;
+ /* generate a unique contact-user, this is needed to route
+ incoming requests when using multiple useragents */
+ err = re_sdprintf(&ua->cuser, "%r-%p", &ua->acc->luri.user, ua);
+ if (err)
+ goto out;
+
if (ua->acc->sipnat) {
ua_printf(ua, "Using sipnat: `%s'\n", ua->acc->sipnat);
}