pjsip2.1 ,hangup DTMF with asterisk 1.8 not working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




?
I am using pjsip on my iPhone application ?..|
am facing a problem that when i send a hangup dtmf '#' from iPhone
asterisk never receive it and the app keeps sending it again and a gain ..but it never recieved and a i get a timeout hangup cause from the asterisk server ...|

on asterisk 1.6 it worked ,,while it does not on asterisk 1.8 ...!!
am using 2.1 pjsip ,, and some methods from siphon project?
here is the code used to hangup...

FROM AKSIP

- (void)sendDTMFDigits:(NSString *)digits {
??
? ? pj_status_t status;
? ? pj_str_t pjDigits = [digits pjString];
? ? ?
? ? // Try to send RFC2833 DTMF first.
? ? status = pjsua_call_dial_dtmf(currentCalledID, &pjDigits);
?? ?
? ? if(status != PJ_SUCCESS) {? // Okay, that didn't work. Send INFO DTMF.
? ? ? ? const pj_str_t kSIPINFO = pj_str("INFO");
?? ? ? ?
? ? ? ? for (NSUInteger i = 0; i < [digits length]; ++i) {
? ? ? ? ? ? pjsua_msg_data messageData;
? ? ? ? ? ? pjsua_msg_data_init(&messageData);
? ? ? ? ? ? messageData.content_type = pj_str("application/dtmf-relay");
?? ? ? ? ? ?
? ? ? ? ? ? NSString *messageBody
? ? ? ? ? ? = [NSStringstringWithFormat:@"Signal=%C\r\nDuration=300",
?? ? ? ? ? ? ? [digits characterAtIndex:i]];
? ? ? ? ? ? messageData.msg_body = [messageBody pjString];
?? ? ? ? ? ?
? ? ? ? ? ? status = pjsua_call_send_request(currentCalledID, &kSIPINFO, &messageData);
? ? ? ? ? ? if (status != PJ_SUCCESS)
? ? ? ? ? ? ? ? NSLog(@"Error sending DTMF");
? ? ? ? }
? ? }
}

did not work ..

....
#include "dtmf.h"

#define THIS_FILE"dtmf.c"

struct my_call_data
{
?? pj_pool_t? ? ? ? ? *pool;
?? pjmedia_port ? ? ? *tonegen;
?? pjsua_conf_port_id? toneslot;
};

/**
?*/
static
struct my_call_data *call_init_tonegen(pjsua_call_id call_id)
{
? pj_pool_t *pool;
? structmy_call_data*cd;
? pjsua_call_infoci;
? pj_status_tstatus;

? pool = pjsua_pool_create("mycall", 512, 512);
? cd = PJ_POOL_ZALLOC_T(pool, struct my_call_data);
? cd->pool = pool;

? status = pjmedia_tonegen_create(cd->pool, 16000, 1, 160, 16, 0, &cd->tonegen);

? if (status == PJ_SUCCESS)
? {
? pjsua_conf_add_port(cd->pool, cd->tonegen, &cd->toneslot);

? pjsua_call_get_info(call_id, &ci);
? pjsua_conf_connect(cd->toneslot, ci.conf_slot);
? ? // Now keyboard plays dtmf sound on speaker/earphone
? //pjsua_conf_connect(cd->toneslot, 0); // speaker/earphone.

? pjsua_call_set_user_data(call_id, (void*) cd);
? }
? else
? {
? ? pjsua_perror(THIS_FILE, "Error: Error creating DTMF generator", status);
? ? pj_pool_release(pool);
? ? cd = NULL;
? }

? return cd;
}

/**
?*/
void sip_call_play_digit(pjsua_call_id call_id, char digit)
{
? pj_status_tstatus;
? char buf[2];
? ? char* digits;
??
? buf[0] = digit;
? buf[1] = 0;
? digits =? buf ;
#if 0
? PJ_UNUSED_ARG(status);
? sip_call_play_digits(call_id,? digits);
#else
?? ?
? ? pj_str_t? did=pj_str( digits);
? ? status = pjsua_call_dial_dtmf(call_id, &did);
?? ?
? ? NSLog(@"status is %i",status);
??
? ? if(status == PJMEDIA_RTP_EREMNORFC2833)
? {
? ? pjmedia_tone_digitd[1];
? ? structmy_call_data*cd;

? ? cd = (struct my_call_data*) pjsua_call_get_user_data(call_id);
?? ? ?
? ? if (cd == NULL)
? ? {
? ? ? cd = call_init_tonegen(call_id);
? ? ? if (cd == NULL)
? ? ? ? ? return;
? ? }
? ? //else if (pjmedia_tonegen_is_busy(cd->tonegen))
?? // pjmedia_tonegen_stop(cd->tonegen);

? ? d[0].digit = digit;
? ? d[0].on_msec = 100;
? ? d[0].off_msec = 100;
? ? d[0].volume = 16383;

? ? pjmedia_tonegen_play_digits(cd->tonegen, 1, d, 0);
? }
#endif
}

/**
?*/
void sip_call_play_digits(pjsua_call_id call_id, const char *digits)
{
? ? pjmedia_tone_digitd[16];
? ? unsigned i, count = strlen(digits);
? ? structmy_call_data*cd;
?? ?
? ? cd = (struct my_call_data*) pjsua_call_get_user_data(call_id);
? ? if (!cd)
? ? ? ? cd = call_init_tonegen(call_id);
?? ?
? ? if (count > PJ_ARRAY_SIZE(d))
? ? ? ? count = PJ_ARRAY_SIZE(d);
?? ?
? ? pj_bzero(d, sizeof(d));
? ? for (i=0; i<count; ++i) {
? ? ? ? d[i].digit = digits[i];
? ? ? ? d[i].on_msec = 100;
? ? ? ? d[i].off_msec = 200;
? ? ? ? d[i].volume = 0;
? ? }
?? ?
? ? pjmedia_tonegen_play_digits(cd->tonegen, count, d, 0);

}

/**
?*/
void sip_call_deinit_tonegen(pjsua_call_id call_id)
{
? structmy_call_data*cd;

? cd = (structmy_call_data*) pjsua_call_get_user_data(call_id);
? if (!cd)
?? ? return;

? pjsua_conf_remove_port(cd->toneslot);
? pjmedia_port_destroy(cd->tonegen);
? pj_pool_release(cd->pool);

? pjsua_call_set_user_data(call_id, NULL);
}
/**
?*/
void sip_call_play_info_digit(pjsua_call_id call_id, char digit)
{
#if 1
? pj_str_t digits;
? char buf[2];
??
? buf[0] = digit;
? buf[1] = 0;
? digits = pj_str(buf);
? sip_call_play_info_digits(call_id, &digits);
#else
? const pj_str_t SIP_INFO = pj_str("INFO");
? pj_status_t status;
? pjsua_msg_data msg_data;
? char body[80];
??
? pjsua_msg_data_init(&msg_data);
? msg_data.content_type = pj_str("application/dtmf-relay");
??
? pj_ansi_snprintf(body, sizeof(body),
?? ? ? ? ? ? ? ? ? "Signal=%c\r\n"
?? ? ? ? ? ? ? ? ? "Duration=160",
?? ? ? ? ? ? ? ? ? digit);
? msg_data.msg_body = pj_str(body);
??
? status = pjsua_call_send_request(call_id, &SIP_INFO,?
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? &msg_data);
#endif
}
/**
?*/
void sip_call_play_info_digits(pjsua_call_id call_id, pj_str_t *digits)
{
? const pj_str_t SIP_INFO = pj_str("INFO");
? pj_status_tstatus;
? pjsua_msg_datamsg_data;
? char body[80];
? pj_uint32_ti;
??
? for (i = 0; i < digits->slen; ++i)?
? { ? ?
? ? pjsua_msg_data_init(&msg_data);
? ? msg_data.content_type= pj_str("application/dtmf-relay");
?? ?
? ? pj_ansi_snprintf(body, sizeof(body),
?? ? ? ? ? ? ? ? ? ? "Signal=%c\r\n"
?? ? ? ? ? ? ? ? ? ? "Duration=160",
?? ? ? ? ? ? ? ? ? ? /*buf[i]*/digits->ptr[i]);
? ? msg_data.msg_body = pj_str(body);
?? ?
? ? status = pjsua_call_send_request(call_id, &SIP_INFO, &msg_data);
? ? if (status != PJ_SUCCESS)?
? ? {
break;
? ? }
? }
}


....

none of these worked on asterisk 1.8 ,, they worked on asterisk 1.6?

I tried many things like changing?
PJMEDIA_RTP_PT_TELEPHONE_EVENTS?
from 96 to 101

??PJMEDIA_RTP_PT_START = 102,

? ? PJMEDIA_RTP_PT_START = (PJMEDIA_RTP_PT_DYNAMIC-1),

in type.h

..

I wish anybody has a clue of why that happens??
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20130325/c0fdcd07/attachment-0001.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux