Using pjsipdll.dll wrapper from SipekSdk

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

 



I am trying to use pjsipdll.dll file unmanaged DLL file from SipekSdk. Since
it is already compiled I don't feel need to compile this myself. I'm trying
to use this in my code but seem to face all sorts of run-time errors and
crashes. 

I would appreciate if anyone has some link to any tutorial on how to use
pjsipdll.

For reference, this is my sample project:

// pjsip Test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <Windows.h>
#include <conio.h>

#include "pjsipDll.h"

//typedef int dll_init();
typedef int (__stdcall *dll_initFn)();
// Callback registration 
typedef int (__stdcall *onRegStateCallbackFn)(fptr_regstate cb);	  //
register registration notifier
typedef int (__stdcall *onCallStateCallbackFn)(fptr_callstate cb); //
register call notifier
typedef int (__stdcall *onCallIncomingFn)(fptr_callincoming cb); // register
incoming call notifier
typedef int (__stdcall *onCallHoldConfirmCallbackFn)(fptr_callholdconf cb);
// register call notifier
//typedef int (__stdcall *onCallRetrieveConfirmFn)(fptr_callretrieveconf
cb); // register call notifier
typedef int (__stdcall *onMessageReceivedCallbackFn)(fptr_msgrec cb); //
register call notifier
typedef int (__stdcall *onBuddyStatusChangedCallbackFn)(fptr_buddystatus
cb); // register call notifier
typedef int (__stdcall *onDtmfDigitCallbackFn)(fptr_dtmfdigit cb); //
register dtmf digit notifier
typedef int (__stdcall *onMessageWaitingCallbackFn)(fptr_mwi cb); //
register MWI notifier
typedef int (__stdcall *onCallReplacedFn)(fptr_crep cb); // register Call
replaced notifier

// pjsip common API
typedef void (__stdcall *dll_setSipConfigFn)(SipConfigStruct* config);
typedef int (__stdcall *dll_initFn)();
typedef int (__stdcall *dll_shutdownFn)(); 
typedef int (__stdcall *dll_mainFn)(void);
typedef int (__stdcall *dll_getNumOfCodecsFn)();
typedef int (__stdcall *dll_getCodecFn)(int index, char* codec);
typedef int (__stdcall *dll_setCodecPriorityFn)(char* name, int index);
// pjsip call API
typedef int (__stdcall *dll_registerAccountFn)(char* uri, char* reguri,
char* name, char* username, 
				char* password, char* proxy, bool
isdefault);
typedef int (__stdcall *dll_makeCallFn)(int accountId, char* uri); 
typedef int (__stdcall *dll_releaseCallFn)(int callId); 
typedef int (__stdcall *dll_answerCallFn)(int callId, int code);
typedef int (__stdcall *dll_holdCallFn)(int callId);
typedef int (__stdcall *dll_retrieveCallFn)(int callId);
typedef int (__stdcall *dll_xferCallFn)(int callid, char* uri);
typedef int (__stdcall *dll_xferCallWithReplacesFn)(int callId, int
dstSession);
typedef int (__stdcall *dll_serviceReqFn)(int callId, int serviceCode, const
char* destUri);
typedef int (__stdcall *dll_dialDtmfFn)(int callId, char* digits, int mode);
typedef int (__stdcall *dll_removeAccountsFn)();
typedef int (__stdcall *dll_sendInfoFn)(int callid, char* content);
typedef int (__stdcall *dll_getCurrentCodecFn)(int callId, char* codec);
typedef int (__stdcall *dll_makeConferenceFn)(int callId);
typedef int (__stdcall *dll_sendCallMessageFn)(int callId, char* message);
// IM & Presence api
typedef int (__stdcall *dll_addBuddyFn)(char* uri, bool subscribe);
typedef int (__stdcall *dll_removeBuddyFn)(int buddyId);
typedef int (__stdcall *dll_sendMessageFn)(int accId, char* uri, char*
message);
typedef int (__stdcall *dll_setStatusFn)(int accId, int presence_state);

typedef int (__stdcall *dll_setSoundDeviceFn)(char* playbackDeviceId, char*
recordingDeviceId);

typedef int (__stdcall *dll_pollForEventsFn)(int timeout);

int __stdcall on_callincoming( int call_id, char* number )
{
	return 0;
}

int __stdcall on_callstateChanged( int call_id, int state_id )
{
	return 0;
}

int __stdcall on_callholdconf(int call_id)
{
	return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
	const char *dllfile = "pjsipDll.dll";
	HMODULE libInst = LoadLibrary(dllfile);
	int rv = 0;
	SipConfigStruct config;
	config.listenPort = 8080;
	strcpy(config.nameServer, "173.255.221.125");

	dll_setSipConfigFn			dll_setSipConfigFn_
= (dll_setSipConfigFn)GetProcAddress(libInst, "dll_setSipConfig");
	dll_registerAccountFn		dll_registerAccountFn_
= (dll_registerAccountFn)GetProcAddress(libInst, "dll_registerAccount");
    dll_initFn					dll_initFn_
= (dll_initFn)GetProcAddress(libInst, "dll_init");
    dll_shutdownFn				dll_shutdownFn_
= (dll_shutdownFn)GetProcAddress(libInst, "dll_shutdown");
	dll_mainFn					dll_mainFn_
= (dll_mainFn)GetProcAddress(libInst, "dll_main");
	dll_makeCallFn				dll_makeCallFn_
= (dll_makeCallFn)GetProcAddress(libInst, "dll_makeCall");
	
	onCallIncomingFn			onCallIncomingFn_
= (onCallIncomingFn) GetProcAddress(libInst, "onCallIncoming");
	onCallStateCallbackFn		onCallStateCallbackFn_
= (onCallStateCallbackFn) GetProcAddress( libInst, "onCallStateCallback");
	onCallHoldConfirmCallbackFn onCallHoldConfirmCallbackFn_	=
(onCallHoldConfirmCallbackFn) GetProcAddress( libInst,
"onCallHoldConfirmCallback" );
	
	onCallIncomingFn_( on_callincoming );
	onCallStateCallbackFn_( on_callstateChanged );
	onCallHoldConfirmCallbackFn_( on_callholdconf );

	dll_initFn_();
	rv = dll_registerAccountFn_("sip:1004", "sip:192.168.1.125:5060",
"192.168.1.125:5060", "1004", "1234", NULL, true );
	char str[90];
	printf("\n acc ID : %d", rv );
	dll_mainFn_();
	rv = dll_makeCallFn_(rv, "sip:1005 at 192.168.1.125:5060");
	while(1)
	{
		if ( _kbhit() ) 
			break;
	}
	dll_shutdownFn_();
	return 0;
}





[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