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;
{
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];
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) {
/* 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