summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xasterisk.c1
-rwxr-xr-xchannels/chan_sip.c21
-rwxr-xr-xrtp.c5
3 files changed, 24 insertions, 3 deletions
diff --git a/asterisk.c b/asterisk.c
index e403c7f8c..5aedc3495 100755
--- a/asterisk.c
+++ b/asterisk.c
@@ -395,6 +395,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart)
ast_verbose("Asterisk %s ending (%d).\n", ast_active_channels() ? "uncleanly" : "cleanly", num);
else if (option_debug)
ast_log(LOG_DEBUG, "Asterisk ending (%d).\n", num);
+ manager_event(EVENT_FLAG_SYSTEM, "Shutdown", "Shutdown: %s\r\nRestart: %s\r\n", ast_active_channels() ? "Uncleanly" : "Cleanly", restart ? "True" : "False");
if (ast_socket > -1) {
close(ast_socket);
ast_socket = -1;
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index f579f7366..557e83b6a 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1632,8 +1632,10 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p, struct ast_rtp *
{
int len;
int codec;
+ int alreadysent = 0;
char costr[80];
struct sockaddr_in sin;
+ struct sip_codec_pref *cur;
char v[256];
char s[256];
char o[256];
@@ -1665,8 +1667,25 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p, struct ast_rtp *
snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", inet_ntoa(dest.sin_addr));
snprintf(t, sizeof(t), "t=0 0\r\n");
snprintf(m, sizeof(m), "m=audio %d RTP/AVP", ntohs(dest.sin_port));
+ /* Start by sending our preferred codecs */
+ cur = prefs;
+ while(cur) {
+ if (p->capability & cur->codec) {
+ if (sipdebug)
+ ast_verbose("Answering with preferred capability %d\n", cur->codec);
+ if ((codec = ast2rtp(cur->codec)) > -1) {
+ snprintf(costr, sizeof(costr), " %d", codec);
+ strcat(m, costr);
+ snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast2rtpn(x));
+ strcat(a, costr);
+ }
+ }
+ alreadysent |= cur->codec;
+ cur = cur->next;
+ }
+ /* Now send anything else in no particular order */
for (x=1;x<= AST_FORMAT_MAX_AUDIO; x <<= 1) {
- if (p->capability & x) {
+ if ((p->capability & x) && !(alreadysent & x)) {
if (sipdebug)
ast_verbose("Answering with capability %d\n", x);
if ((codec = ast2rtp(x)) > -1) {
diff --git a/rtp.c b/rtp.c
index a93823c43..aba47dbb5 100755
--- a/rtp.c
+++ b/rtp.c
@@ -592,11 +592,12 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec
/* Re-calculate last TS */
rtp->lastts = ms * 8;
-
+#if 0 /* XXX Experiment -- Make timestamp always relative XXX */
/* If it's close to ou prediction, go for it */
if (abs(rtp->lastts - pred) < 640)
+#endif
rtp->lastts = pred;
-#if 1
+#if 0
else
printf("Difference is %d, ms is %d\n", abs(rtp->lastts - pred), ms);
#endif