Index: chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.797 diff -u -r1.797 chan_sip.c --- chan_sip.c 28 Jul 2005 18:24:04 -0000 1.797 +++ chan_sip.c 28 Jul 2005 22:20:35 -0000 @@ -7635,7 +7635,10 @@ unsigned int event; char resp = 0; struct ast_frame f; - char *c; + char *c = NULL; + + if (sip_debug_test_pvt(p)) + ast_log(LOG_NOTICE, "Receiving INFO from %s\n", p->callid); /* Need to check the media/type */ if (!strcasecmp(get_header(req, "Content-Type"), "application/dtmf-relay") || @@ -7683,10 +7686,47 @@ transmit_response(p, "200 OK", req); return; } else { - transmit_response(p, "481 Call leg/transaction does not exist", req); + transmit_response(p, "481 Call/Transaction Does Not Exist", req); ast_set_flag(p, SIP_NEEDDESTROY); } return; + } else if ((c = get_header(req, "Record"))) { + /* Record button on SNOM */ + if (!strcasecmp(c, "on")) { + if (sip_debug_test_pvt(p)) + ast_log(LOG_NOTICE, "Record State 'On' from %s\n", p->exten); + if (!p->owner->monitor) { + time_t t; + struct tm tm; + char date[20]; + + time(&t); + localtime_r(&t, &tm); + strftime(date, sizeof(date), "%Y%m%d_%H%M%S", &tm); + snprintf(buf, sizeof(buf), "/var/spool/asterisk/monitor/%s/%s", p->exten, date); + + if (!(ast_monitor_start(p->owner, NULL, buf, 0))) { + ast_monitor_setjoinfiles(p->owner, 1); /* join the two audio files */ + transmit_response(p, "200 OK", req); /* i don't really know how to answer to this, so the phone toggles recording on/off */ + ast_log(LOG_NOTICE, "Recording extension: %s to file: %s\n", p->exten, buf); + } + } else { + if (!(ast_monitor_stop(p->owner, 0))) { + transmit_response(p, "200 OK", req); /* i don't really know how to answer to this, so the phone toggles recording on/off */ + ast_log(LOG_NOTICE, "Stopped Recording extension %s\n", p->exten); + } + } + } else if (!strcasecmp(c, "off")) { + if (sip_debug_test_pvt(p)) + ast_log(LOG_NOTICE, "Record State 'Off' from %s\n", p->callid); + if (!(ast_monitor_stop(p->owner, 0))) { + transmit_response(p, "200 OK", req); /* i don't really know how to answer to this, so the phone toggles recording on/off */ + ast_log(LOG_NOTICE, "Stopped Recording extension %s\n", p->exten); + } + } else { + transmit_response(p, "405 Method Not Allowed", req); + } + return; } else if ((c = get_header(req, "X-ClientCode"))) { /* Client code (from SNOM phone) */ if (ast_test_flag(p, SIP_USECLIENTCODE)) { @@ -7704,7 +7744,7 @@ /* if (get_msg_text(buf, sizeof(buf), req)) { */ ast_log(LOG_WARNING, "Unable to parse INFO message from %s. Content %s\n", p->callid, buf); - transmit_response(p, "415 Unsupported media type", req); + transmit_response(p, "501 Not Implemented", req); return; } @@ -9670,8 +9710,6 @@ break; case SIP_INFO: if (!ignore) { - if (debug) - ast_verbose("Receiving DTMF!\n"); receive_info(p, req); } else { /* if ignoring, transmit response */ transmit_response(p, "200 OK", req);