[SIPForum-discussion] SIP Debug Assertion Failed
hayder haouaneb
hayder.haouaneb at gmail.com
Wed Sep 1 09:56:09 UTC 2010
Hi all,
I use eXosip in my program (build in debug mode with visual c++ 2008)
I have this error message :
=============================================================
Debug Assertion Failed
Program : voip_test.exe
File : f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c
ligne : 1317
Expression: _CrtIsValidHeapPointer(pUserDATA)
==============================================================
> eXosip2.dll!_free_base(void * pBlock=0x4e7c94d5) Ligne 109 + 0x12
octets C
==============================================================
Event with a small example, i have the same error message.
Thanks for help :)
example code
######################################################################
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
#include <winsock.h>
#include <eXosip2/eXosip.h>
#pragma comment(lib, "osip2.lib")
#pragma comment(lib, "osipparser2.lib")
#pragma comment(lib, "eXosip2.lib")
/***********************************************************************************************************************************************************
* Function : make_Sdp_Offer
* Purpose : this function builds a SDP message as an offer to negotiate
with the destination
*
************************************************************************************************************************************************************/
void make_Sdp_Offer(osip_message_t * invite,char* localip, int id,int
data_port)
{
int i;
//SIP sdp message body
char msg[4096];
snprintf (msg, 4096,
"v=0\r\n" //protocole version
"o= anonymous 0 0 IN IP4 %s\r\n" // identifier
"s=conversation\r\n" //connection
information
"c=IN IP4 %s\r\n" //addr to send me
data
"t=0 0\r\n" //satrt session
"m=audio %d RTP/AVP 0 8 101\r\n" // %s=data_port :
port to send me data
"a=rtpmap:0 PCMU/8000\r\n" //I can accept RTP
packets of type G.711 Ulaw 0= G711
"a=rtpmap:8 PCMA/8000\r\n" //I can accept other
protocols
"a=rtpmap:101 telephone-event/8000\r\n"
"a=fmtp:101 0-11\r\n"
, localip, localip, data_port);
printf("%s", msg);
printf("%d",id);
//set SIP message body
i=osip_message_set_body (invite, msg, strlen (msg));
osip_message_set_content_type (invite, "application/sdp");
}
void make_Sdp_Response(osip_message_t * answer, int data_port, char* destIP,
char* srcIP)
{
//SIP sdp message body
char msg[4096];
snprintf(msg, 4096,
"v=0\r\n"
"o=- 1 1 IN IP4 %s\r\n"
"c=IN IP4 %s\r\n"
"t=0 0\r\n"
"m=audio %d RTP/AVP 0 101\r\n"
"a=rtpmap:0 PCMU/8000\r\n"
"a=rtpmap:101 telephone-event/8000\r\n"
,srcIP,srcIP,data_port);
osip_message_set_body (answer, msg, strlen(msg));
osip_message_set_content_type (answer, "application/sdp");
}
int main()
{
int i;
//SIP ACK message
osip_message_t *ack = NULL;
//Structure for SIP Message (REQUEST and RESPONSE)
osip_message_t *invite;
//Structure for SIP event description
eXosip_event_t *event;
//SIP ANSWER for Invite request
osip_message_t *answer = NULL;
//TO : sip header part
char DestCall[128]= "sip:129.32.200.5:5060";
//PAU local IP
char localip[128]="127.0.0.1";
//FROM : sip header part carte HYPERT
char SrcCall[128] = "sip:Hayder at 129.32.200.4 <sip%3AHayder at 129.32.200.4>
";
// flag end com
int flag_end = 0;
//data receive port
int data_port = 5000;
//message id
int identifier ;
srand( (unsigned)time( NULL ) );
identifier = rand();
i = eXosip_init ();
if (i != 0)
{
return -1;
}
i = eXosip_listen_addr (IPPROTO_UDP, NULL, 5060, AF_INET, 0);
if (i != 0)
{
eXosip_quit ();
return -1;
}
//Build a default INVITE message for a new call.
/*i= eXosip_call_build_initial_invite(&invite,
DestCall,
SrcCall,
NULL,
"INVITE for a new call");*/
//osip_message_set_supported (invite, "100rel");
//sdp negociation
//eXosip_guess_localip (AF_INET, localip, 128);
//make_Sdp_Offer(invite,localip,identifier,data_port);
//send invite cmd
eXosip_lock ();
//i = eXosip_call_send_initial_invite (invite);
while(flag_end != 1){
//wait for event
event = eXosip_event_wait (15,0);
if (event==NULL)
//15sec after sending INVITE request, if no response then we close
call
//and we try with anthoer destination else call finished
{
printf("NO EVENT...\n");
}
else
{
switch (event->type) {
case EXOSIP_CALL_INVITE: //case incomming call
eXosip_lock ();
printf(" INVITE... \n");
eXosip_call_send_answer (event->tid, 180, NULL);
//build final response OK
i = eXosip_call_build_answer (event->tid, 200, &answer);
if (i != 0)
{
eXosip_call_send_answer (event->tid, 400, NULL);
}
else
{
//build sdp message
make_Sdp_Response(answer,data_port,"129.32.200.5","129.32.200.4");
//send answer ok(200)
eXosip_call_send_answer (event->tid, 200, answer);
//syslog(LOG_INFO,"%s - response 200! ",
_NAME_PAUSIP);
}
eXosip_unlock ();
break;
case EXOSIP_CALL_PROCEEDING:
printf("PROCEEDING... \n");
break;
case EXOSIP_CALL_RINGING:
//received in outgoing call
printf(" RINGING... \n");
break;
case EXOSIP_CALL_ANSWERED:
printf(" ANSWERED... \n");
printf("Call ID %d Dialog ID %d!
",event->did,event->did);
//build ACK for the call destination
eXosip_call_build_ack (event->did, &ack);
// send ACK message
eXosip_call_send_ack (event->did, ack,"129.32.200.5");
break;
case EXOSIP_CALL_CLOSED:
//close call
printf(" Closed... \n");
eXosip_lock ();
eXosip_call_terminate (event->cid, event->did);
eXosip_unlock ();
flag_end = 0;
break;
case EXOSIP_CALL_MESSAGE_ANSWERED :
printf("Request Message Answered ... \n");
case EXOSIP_CALL_ACK:
printf(" ACK... \n");
break;
case EXOSIP_CALL_SERVERFAILURE:
break;
case EXOSIP_CALL_GLOBALFAILURE:
break;
default:
break;
}
eXosip_event_free (event);
}
}
return 0;
}
###############################################################################
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sipforum.org/pipermail/discussion/attachments/20100901/135d9c4f/attachment-0002.html>
More information about the discussion
mailing list