mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
Add sayunixtime, chan_sip updates for codec negotiation
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1589 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -24,7 +24,7 @@ APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_intercom.
|
|||||||
app_authenticate.so app_softhangup.so app_lookupblacklist.so \
|
app_authenticate.so app_softhangup.so app_lookupblacklist.so \
|
||||||
app_waitforring.so app_privacy.so app_db.so app_chanisavail.so \
|
app_waitforring.so app_privacy.so app_db.so app_chanisavail.so \
|
||||||
app_enumlookup.so app_voicemail2.so app_transfer.so app_setcidnum.so app_cdr.so \
|
app_enumlookup.so app_voicemail2.so app_transfer.so app_setcidnum.so app_cdr.so \
|
||||||
app_hasnewvoicemail.so
|
app_hasnewvoicemail.so app_sayunixtime.so
|
||||||
|
|
||||||
#APPS+=app_sql_postgres.so
|
#APPS+=app_sql_postgres.so
|
||||||
#APPS+=app_sql_odbc.so
|
#APPS+=app_sql_odbc.so
|
||||||
|
117
apps/app_sayunixtime.c
Executable file
117
apps/app_sayunixtime.c
Executable file
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* Asterisk -- A telephony toolkit for Linux.
|
||||||
|
*
|
||||||
|
* SayUnixTime application
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003 Tilghman Lesher. All rights reserved.
|
||||||
|
*
|
||||||
|
* Tilghman Lesher <app_sayunixtime__200309@the-tilghman.com>
|
||||||
|
*
|
||||||
|
* This code is in the public domain.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <asterisk/file.h>
|
||||||
|
#include <asterisk/logger.h>
|
||||||
|
#include <asterisk/options.h>
|
||||||
|
#include <asterisk/channel.h>
|
||||||
|
#include <asterisk/pbx.h>
|
||||||
|
#include <asterisk/module.h>
|
||||||
|
#include <asterisk/say.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
static char *tdesc = "Say time";
|
||||||
|
|
||||||
|
static char *app_sayunixtime = "SayUnixTime";
|
||||||
|
|
||||||
|
static char *sayunixtime_synopsis = "Says a specified time in a custom format";
|
||||||
|
|
||||||
|
static char *sayunixtime_descrip =
|
||||||
|
"SayUnixTime([unixtime][|[timezone][|format]])\n"
|
||||||
|
" unixtime: time, in seconds since Jan 1, 1970. May be negative.\n"
|
||||||
|
" defaults to now.\n"
|
||||||
|
" timezone: timezone, see /usr/share/zoneinfo for a list.\n"
|
||||||
|
" defaults to machine default.\n"
|
||||||
|
" format: a format the time is to be said in. See voicemail.conf.\n"
|
||||||
|
" defaults to \"ABdY 'digits/at' IMp\"\n"
|
||||||
|
" Returns 0 or -1 on hangup.\n";
|
||||||
|
|
||||||
|
STANDARD_LOCAL_USER;
|
||||||
|
|
||||||
|
LOCAL_USER_DECL;
|
||||||
|
|
||||||
|
static int sayunixtime_exec(struct ast_channel *chan, void *data)
|
||||||
|
{
|
||||||
|
int res=0;
|
||||||
|
struct localuser *u;
|
||||||
|
char *s,*zone=NULL,*timec;
|
||||||
|
time_t unixtime;
|
||||||
|
char *format = "ABdY 'digits/at' IMp";
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
LOCAL_USER_ADD(u);
|
||||||
|
|
||||||
|
gettimeofday(&tv,NULL);
|
||||||
|
unixtime = (time_t)tv.tv_sec;
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
s = data;
|
||||||
|
s = strdupa(s);
|
||||||
|
if (s) {
|
||||||
|
timec = strsep(&s,"|");
|
||||||
|
if ((timec) && (*timec != '\0')) {
|
||||||
|
long timein;
|
||||||
|
if (sscanf(timec,"%ld",&timein) == 1) {
|
||||||
|
unixtime = (time_t)timein;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (s) {
|
||||||
|
zone = strsep(&s,"|");
|
||||||
|
if (zone && (*zone == '\0'))
|
||||||
|
zone = NULL;
|
||||||
|
if (s) {
|
||||||
|
format = s;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_ERROR, "Out of memory error\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res = ast_say_date_with_format(chan, unixtime, AST_DIGIT_ANY, chan->language, format, zone);
|
||||||
|
|
||||||
|
LOCAL_USER_REMOVE(u);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
STANDARD_HANGUP_LOCALUSERS;
|
||||||
|
return ast_unregister_application(app_sayunixtime);
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module(void)
|
||||||
|
{
|
||||||
|
return ast_register_application(app_sayunixtime, sayunixtime_exec, sayunixtime_synopsis, sayunixtime_descrip);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *description(void)
|
||||||
|
{
|
||||||
|
return tdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usecount(void)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
STANDARD_USECOUNT(res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
@@ -2423,7 +2423,7 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p, struct ast_rtp *
|
|||||||
/* Start by sending our preferred codecs */
|
/* Start by sending our preferred codecs */
|
||||||
cur = prefs;
|
cur = prefs;
|
||||||
while(cur) {
|
while(cur) {
|
||||||
if (p->capability & cur->codec) {
|
if (p->jointcapability & cur->codec) {
|
||||||
if (sipdebug)
|
if (sipdebug)
|
||||||
ast_verbose("Answering with preferred capability %d\n", cur->codec);
|
ast_verbose("Answering with preferred capability %d\n", cur->codec);
|
||||||
codec = ast_rtp_lookup_code(p->rtp, 1, cur->codec);
|
codec = ast_rtp_lookup_code(p->rtp, 1, cur->codec);
|
||||||
@@ -2445,7 +2445,7 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p, struct ast_rtp *
|
|||||||
}
|
}
|
||||||
/* Now send any other common codecs, and non-codec formats: */
|
/* Now send any other common codecs, and non-codec formats: */
|
||||||
for (x = 1; x <= AST_FORMAT_MAX_AUDIO; x <<= 1) {
|
for (x = 1; x <= AST_FORMAT_MAX_AUDIO; x <<= 1) {
|
||||||
if ((p->capability & x) && !(alreadysent & x)) {
|
if ((p->jointcapability & x) && !(alreadysent & x)) {
|
||||||
if (sipdebug)
|
if (sipdebug)
|
||||||
ast_verbose("Answering with capability %d\n", x);
|
ast_verbose("Answering with capability %d\n", x);
|
||||||
codec = ast_rtp_lookup_code(p->rtp, 1, x);
|
codec = ast_rtp_lookup_code(p->rtp, 1, x);
|
||||||
|
Reference in New Issue
Block a user