lem1x Intermediate
Joined: July 06 2012 Posts: 2
|
Posted: July 12 2012 at 3:29am | IP Logged
|
|
|
Hi,
I got this kind of error after initalizing VOIP Media Engine.
Code:
Cannot pass a GCHandle across AppDomains.
Parameter name: handle
at System.Runtime.InteropServices.GCHandle.InternalCheckDomain(IntPtr handle)
at System.Runtime.InteropServices.GCHandle.FromIntPtr(IntPtr value)
at System.Runtime.InteropServices.GCHandle.op_Explicit(IntPtr value)
at MainEventHandler_Unmanaged(Void* hStateMachine, SIP_NOTIFY_TYPE NotifyType, Int32 PhoneLine, TELEPHONY_RETURN_VALUE TelephonyEvent, Void* pUserDefinedData, Void* pEventData) |
|
|
Here is the code I used:
Code:
public void InitializeVoip()
{
var status = _mediaEngine.InitializeMediaEngine(0, 0);
var startParams = new VoipMediaEngine.START_SIP_TELEPHONY_PARAMS();
startParams.PersonalityMicrocode = Microcode.LanScapeVME_F186495C_7AFF_4742_ADB7_87EA48A42633;
// set this to an even number of lines.
startParams.NumPhoneLinesRequested = 1;
startParams.LineMode = VoipMediaEngine.LINE_MODE.SWITCH_LINE;
startParams.UserNotifyCallbackProc = MediaEngineCallbackProc;
// set the main callback instance data.
startParams.UserDefinedData = null;
startParams.SipPort = 5060;
// use media engine internal default values.
startParams.MaxSipMesageLength = 0;
startParams.SipUdpReceiveBufferSizeInBytes = 0;
startParams.SipUdpTransmitBufferSizeInBytes = 0;
startParams.MaxSipMessageReceiveFifoLength = 0;
startParams.MaxRtpPacketLength = 0;
startParams.PhoneName = "[CUT]";
startParams.PhoneDisplayName = "[CUT]";
startParams.DtmfEnabled = false;
startParams.DtmfTonesPlayedLocally = false;
startParams.DtmfTonesTransmittedOutPhoneLines = false;
startParams.DtmfLocalAudioPlaybackBuffering = 2;
startParams.DtmfPhoneLineAudioBuffering = 2;
// use media engine internal default value.
startParams.DtmfIncomingPhoneLineEventBuffers = 0;
startParams.CallConferenceEnabled = false;
startParams.FarEndCallTransferEnabled = false;
startParams.RandomlyAssignIncomingCallsToPhoneLines = false;
startParams.MinLocalRtpPort = 8000;
startParams.MaxLocalRtpPort = 8400;
startParams.UseSequentialRtpPorts = false;
var UseAudioDevice = true;
if (UseAudioDevice)
{
startParams.ZeroBasedAudioInDeviceId = VoipMediaEngine.SIP_USE_PREFERED_AUDIO_DEVICE;
startParams.ZeroBasedAudioOutDeviceId = VoipMediaEngine.SIP_USE_PREFERED_AUDIO_DEVICE;
}
else
{
startParams.ZeroBasedAudioInDeviceId = VoipMediaEngine.SIP_AUDIO_DEVICE_NOT_USED;
startParams.ZeroBasedAudioOutDeviceId = VoipMediaEngine.SIP_AUDIO_DEVICE_NOT_USED;
}
startParams.AudioRecordBandWidth = VoipMediaEngine.AUDIO_BANDWIDTH.AUDIO_BW_PCM_22K;
startParams.AudioPlaybackBandWidth = VoipMediaEngine.AUDIO_BANDWIDTH.AUDIO_BW_PCM_22K;
startParams.PlaybackBufferingDefault = 4;
startParams.PlaybackBufferingDuringSounds = 4;
startParams.PhoneLinePlayoutBuffering = 2;
startParams.PhoneLineTransmitBuffering = 2;
startParams.LogSipMessages = false;
startParams.SipLogFileName = string.Empty;
startParams.EnableEventLogServers = false;
startParams.EventLogServerList = null;
startParams.EventLogServerPortList = null;
startParams.EnablePhoneLineRecording = false;
startParams.PhoneLineRecordBuffering = 0;
startParams.MaxMixerLinebuffers = 0;
startParams.SendLineInitializedEvents = true;
startParams.StartupFlags = 0;
GlobProcs.IpAddressStringToBytes("[CUT]", ref startParams.IpAddressOfThisHost);
try
{
status = _mediaEngine.StartSipTelephony(startParams);
status = _mediaEngine.AddAuthorizationCredentials(
"[CUT]",
"[CUT]",
"[CUT]"
);
// set the VOIP domain.
status = _mediaEngine.EnableSipDomain("[CUT]");
///////////////////////////////////////////////////
//
// IMPORTANT:
//
// Enable the media engine's ability to receive
// SIP protocol packets from the network before
// configuring registration cycles.
//
///////////////////////////////////////////////////
status = _mediaEngine.SipTelephonyEnable();
String[] RegistrarInfo = null;
int NumRegistrarInfo = GlobProcs.Tokenize("[CUT]", ':', ref RegistrarInfo);
if (NumRegistrarInfo == 2)
{
int RegistrarPort = int.Parse(RegistrarInfo[1]);
// set the time we wait in between failed registrations.
status = _mediaEngine.RegistationErrorRetryTime(2000);
status = _mediaEngine.EnableSipRegisterServer(
"[CUT]",
false, // register individual phone lines.
false, // send register requests to specified regsitar.
RegistrarInfo[0], // registrar server address.
(uint)RegistrarPort, // registrar server port.
3600, // periodic update interval.
3600, // registration durstion.
4000, // response timeout
false // detect NAT on register cycles.
);
}
}
catch (Exception exception)
{
} |
|
|
Do you have any ideas how to fix it?
|