提交 1923ccc8 authored 作者: James Green's avatar James Green

Update, changing core assembly name to FreeSwitch.NET.dll as to not conflict…

Update, changing core assembly name to FreeSwitch.NET.dll as to not conflict with the real freeswitch.dll on Windows.


git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2750 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 ccb32b0e
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
using System; using System;
using System.Reflection; using System.Reflection;
namespace FreeSwitch.NET namespace FreeSwitch
{ {
public class Common public class Common
{ {
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
<ProjectGuid>{251CAABC-16C3-4593-A491-603B908094E0}</ProjectGuid> <ProjectGuid>{251CAABC-16C3-4593-A491-603B908094E0}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FreeSwitch.NET</RootNamespace> <RootNamespace>FreeSwitch</RootNamespace>
<AssemblyName>Freeswitch</AssemblyName> <AssemblyName>FreeSwitch.NET</AssemblyName>
<StartupObject> <StartupObject>
</StartupObject> </StartupObject>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
...@@ -42,11 +42,17 @@ ...@@ -42,11 +42,17 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Common.cs" /> <Compile Include="Common.cs" />
<Compile Include="Log.cs" />
<Compile Include="Ivr.cs" />
<Compile Include="Marshaling\BufferMarshaler.cs" /> <Compile Include="Marshaling\BufferMarshaler.cs" />
<Compile Include="Marshaling\CallerExtensionMarshaler.cs" /> <Compile Include="Marshaling\CallerExtensionMarshaler.cs" />
<Compile Include="Marshaling\CallerProfileMarshaler.cs" /> <Compile Include="Marshaling\CallerProfileMarshaler.cs" />
<Compile Include="Marshaling\ChannelMarshaler.cs" /> <Compile Include="Marshaling\ChannelMarshaler.cs" />
<Compile Include="Marshaling\ChannelTimetableMarshaler.cs" /> <Compile Include="Marshaling\ChannelTimetableMarshaler.cs" />
<Compile Include="Marshaling\CodecMarshaler.cs" />
<Compile Include="Marshaling\StateHandlerTableMarshaler.cs" />
<Compile Include="Marshaling\TimerMarshaler.cs" />
<Compile Include="Marshaling\SpeechHandleMarshaler.cs" />
<Compile Include="Marshaling\StreamHandleMarshaler.cs" /> <Compile Include="Marshaling\StreamHandleMarshaler.cs" />
<Compile Include="Marshaling\CoreSessionMarshaler.cs" /> <Compile Include="Marshaling\CoreSessionMarshaler.cs" />
<Compile Include="Marshaling\EventMarshaler.cs" /> <Compile Include="Marshaling\EventMarshaler.cs" />
...@@ -65,6 +71,9 @@ ...@@ -65,6 +71,9 @@
<Compile Include="Marshaling\Types\CodecInterfaceMarshal.cs" /> <Compile Include="Marshaling\Types\CodecInterfaceMarshal.cs" />
<Compile Include="Marshaling\Types\CodecMarshal.cs" /> <Compile Include="Marshaling\Types\CodecMarshal.cs" />
<Compile Include="Marshaling\Types\CodecTypeMarshal.cs" /> <Compile Include="Marshaling\Types\CodecTypeMarshal.cs" />
<Compile Include="Marshaling\Types\StateHandlerTableMarshal.cs" />
<Compile Include="Marshaling\Types\TimerMarshal.cs" />
<Compile Include="Marshaling\Types\SpeechHandleMarshal.cs" />
<Compile Include="Marshaling\Types\StreamHandleMarshal.cs" /> <Compile Include="Marshaling\Types\StreamHandleMarshal.cs" />
<Compile Include="Marshaling\Types\TypesMarshal.cs" /> <Compile Include="Marshaling\Types\TypesMarshal.cs" />
<Compile Include="Marshaling\Types\FileHandleMarshal.cs" /> <Compile Include="Marshaling\Types\FileHandleMarshal.cs" />
...@@ -79,6 +88,8 @@ ...@@ -79,6 +88,8 @@
<Compile Include="Switch\CallerProfile.cs" /> <Compile Include="Switch\CallerProfile.cs" />
<Compile Include="Switch\Channel.cs" /> <Compile Include="Switch\Channel.cs" />
<Compile Include="Switch\Console.cs" /> <Compile Include="Switch\Console.cs" />
<Compile Include="Switch\Log.cs" />
<Compile Include="Switch\Event.cs" />
<Compile Include="Switch\StreamHandle.cs" /> <Compile Include="Switch\StreamHandle.cs" />
<Compile Include="Switch\CoreSession.cs" /> <Compile Include="Switch\CoreSession.cs" />
<Compile Include="Switch\Ivr.cs" /> <Compile Include="Switch\Ivr.cs" />
...@@ -96,6 +107,13 @@ ...@@ -96,6 +107,13 @@
<Compile Include="Modules\Application.cs" /> <Compile Include="Modules\Application.cs" />
<Compile Include="Types\ApplicationFunction.cs" /> <Compile Include="Types\ApplicationFunction.cs" />
<Compile Include="Types\CallCause.cs" /> <Compile Include="Types\CallCause.cs" />
<Compile Include="Types\Codec.cs" />
<Compile Include="Types\LogLevel.cs" />
<Compile Include="Types\StateHandlerTable.cs" />
<Compile Include="Types\Timer.cs" />
<Compile Include="Types\SpeechHandle.cs" />
<Compile Include="Types\EventCallback.cs" />
<Compile Include="Types\EventType.cs" />
<Compile Include="Types\InputCallbackFunction.cs" /> <Compile Include="Types\InputCallbackFunction.cs" />
<Compile Include="Types\InputType.cs" /> <Compile Include="Types\InputType.cs" />
<Compile Include="Types\ModuleInterfaces.cs" /> <Compile Include="Types\ModuleInterfaces.cs" />
......
using System;
using System.Runtime.InteropServices;
using System.Text;
using FreeSwitch.Types;
using FreeSwitch.Marshaling.Types;
namespace FreeSwitch
{
public class Ivr
{
public static Status MultiThreadedBridge(CoreSession session, CoreSession peerSession, InputCallbackFunction dtmfCallback)
{
return Switch.switch_ivr_multi_threaded_bridge(session, peerSession, dtmfCallback, IntPtr.Zero, IntPtr.Zero);
}
public static Status Originate(CoreSession session, CoreSession peerSession, CallCause callCause, string data, uint timelimit)
{
IntPtr callCausePtr = Marshal.AllocHGlobal(4);
IntPtr dataPtr = Marshal.StringToHGlobalAnsi(data);
Marshal.StructureToPtr(callCause, callCausePtr, true);
return Switch.switch_ivr_originate(session, ref peerSession, callCausePtr, dataPtr, timelimit, null, null, null, null);
}
public static Status RecordFile(CoreSession coreSession, FileHandle fileHandle, string file, DtmfCallbackFunction dtmfCallbackFunction)
{
Byte[] filename = Encoding.Default.GetBytes(file);
Console.WriteLine("File: {0}", file);
dtmfCallbackFunction(coreSession, "1");
dtmfCallbackFunction(coreSession, "2");
dtmfCallbackFunction(coreSession, "3");
Encoding ansiEncoding = Encoding.GetEncoding(1252);
//filename = Encoding.Convert(Encoding.Default, ansiEncoding, filename);
Console.WriteLine("Filename: {0}", file);
//Console.WriteLine("Status record: {0}", status.ToString());
return Status.Success;
}
}
}
\ No newline at end of file
using System;
using System.Runtime.InteropServices;
using System.Text;
using FreeSwitch.Types;
using FreeSwitch.Marshaling.Types;
namespace FreeSwitch
{
public class Log
{
public static void Printf(LogLevel level, string message)
{
Switch.switch_log_printf(null, "File", "Func.NET", 123, level, message);
}
}
}
\ No newline at end of file
...@@ -2,7 +2,7 @@ all: $(MODNAME).so ...@@ -2,7 +2,7 @@ all: $(MODNAME).so
$(MODNAME).so: $(MODNAME).so:
/usr/local/freeswitch/bin/gmcs -debug -unsafe -t:library -keyfile:public.snk \ /usr/local/freeswitch/bin/gmcs -debug -unsafe -t:library -keyfile:public.snk \
-out:FreeSwitch.dll -reference:Mono.Posix.dll \ -out:FreeSwitch.NET.dll -reference:Mono.Posix.dll \
Properties/AssemblyInfo.cs \ Properties/AssemblyInfo.cs \
Marshaling/Types/ApiInterfaceMarshal.cs \ Marshaling/Types/ApiInterfaceMarshal.cs \
Marshaling/Types/ApplicationInterfaceMarshal.cs \ Marshaling/Types/ApplicationInterfaceMarshal.cs \
...@@ -24,26 +24,35 @@ $(MODNAME).so: ...@@ -24,26 +24,35 @@ $(MODNAME).so:
Marshaling/Types/IOEventHooksMarshal.cs \ Marshaling/Types/IOEventHooksMarshal.cs \
Marshaling/Types/LoadableModuleInterfaceMarshal.cs \ Marshaling/Types/LoadableModuleInterfaceMarshal.cs \
Marshaling/Types/LoadableModuleMarshal.cs \ Marshaling/Types/LoadableModuleMarshal.cs \
Marshaling/Types/SpeechHandleMarshal.cs \
Marshaling/Types/StateHandlerTableMarshal.cs \
Marshaling/Types/StreamHandleMarshal.cs \ Marshaling/Types/StreamHandleMarshal.cs \
Marshaling/Types/TypesMarshal.cs \ Marshaling/Types/TypesMarshal.cs \
Marshaling/Types/TimerMarshal.cs \
Marshaling/BufferMarshaler.cs \ Marshaling/BufferMarshaler.cs \
Marshaling/CallerExtensionMarshaler.cs \ Marshaling/CallerExtensionMarshaler.cs \
Marshaling/CallerProfileMarshaler.cs \ Marshaling/CallerProfileMarshaler.cs \
Marshaling/ChannelMarshaler.cs \ Marshaling/ChannelMarshaler.cs \
Marshaling/ChannelTimetableMarshaler.cs \ Marshaling/ChannelTimetableMarshaler.cs \
Marshaling/CodecMarshaler.cs \
Marshaling/CoreSessionMarshaler.cs \ Marshaling/CoreSessionMarshaler.cs \
Marshaling/EventMarshaler.cs \ Marshaling/EventMarshaler.cs \
Marshaling/FileHandleMarshaler.cs \ Marshaling/FileHandleMarshaler.cs \
Marshaling/MemoryPoolMarshaler.cs \ Marshaling/MemoryPoolMarshaler.cs \
Marshaling/SpeechHandleMarshaler.cs \
Marshaling/StateHandlerTableMarshaler.cs \
Marshaling/StreamHandleMarshaler.cs \ Marshaling/StreamHandleMarshaler.cs \
Marshaling/TimerMarshaler.cs \
Modules/Api.cs \ Modules/Api.cs \
Modules/Application.cs \ Modules/Application.cs \
Switch/CallerProfile.cs \ Switch/CallerProfile.cs \
Switch/Channel.cs \ Switch/Channel.cs \
Switch/Console.cs \ Switch/Console.cs \
Switch/CoreSession.cs \ Switch/CoreSession.cs \
Switch/Event.cs \
Switch/Ivr.cs \ Switch/Ivr.cs \
Switch/LoadableModule.cs \ Switch/LoadableModule.cs \
Switch/Log.cs \
Switch/StreamHandle.cs \ Switch/StreamHandle.cs \
Types/ApiFunction.cs \ Types/ApiFunction.cs \
Types/ApplicationFunction.cs \ Types/ApplicationFunction.cs \
...@@ -56,24 +65,33 @@ $(MODNAME).so: ...@@ -56,24 +65,33 @@ $(MODNAME).so:
Types/ChannelFlag.cs \ Types/ChannelFlag.cs \
Types/ChannelState.cs \ Types/ChannelState.cs \
Types/ChannelTimetable.cs \ Types/ChannelTimetable.cs \
Types/Codec.cs \
Types/CoreSession.cs \ Types/CoreSession.cs \
Types/DtmfCallbackFunction.cs \ Types/DtmfCallbackFunction.cs \
Types/InputCallbackFunction.cs \ Types/InputCallbackFunction.cs \
Types/InputType.cs \ Types/InputType.cs \
Types/Event.cs \ Types/Event.cs \
Types/EventCallback.cs \
Types/EventType.cs \
Types/FileHandle.cs \ Types/FileHandle.cs \
Types/LoadableModule.cs \ Types/LoadableModule.cs \
Types/LoadableModuleInterface.cs \ Types/LoadableModuleInterface.cs \
Types/LogLevel.cs \
Types/MemoryPool.cs \ Types/MemoryPool.cs \
Types/Module.cs \ Types/Module.cs \
Types/Status.cs \ Types/Status.cs \
Types/SpeechHandle.cs \
Types/StateHandlerTable.cs \
Types/StreamHandle.cs \ Types/StreamHandle.cs \
Types/TextChannel.cs \ Types/TextChannel.cs \
Types/Timer.cs \
Common.cs \ Common.cs \
Module.cs \ Module.cs \
Ivr.cs \
Log.cs \
clean: clean:
rm -fr *.dll rm -fr *.dll
install: install:
cp -f FreeSwitch.dll /usr/local/freeswitch/lib/ cp -f FreeSwitch.NET.dll /usr/local/freeswitch/lib/
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* CodecMarshaler.cs --
*
*/
using System;
using System.Collections;
using FreeSwitch.Marshaling.Types;
using FreeSwitch.Types;
using System.Runtime.InteropServices;
namespace FreeSwitch.Marshaling
{
class CodecMarshaler : ICustomMarshaler
{
private static CodecMarshaler Instance = new CodecMarshaler();
public static ICustomMarshaler GetInstance(string s)
{
return Instance;
}
public void CleanUpManagedData(object o)
{
}
public void CleanUpNativeData(IntPtr pNativeData)
{
}
public int GetNativeDataSize()
{
return IntPtr.Size;
}
public IntPtr MarshalManagedToNative(object obj)
{
Codec streamHandleObj = (Codec)obj;
return streamHandleObj.marshaledObject.Handle;
}
public object MarshalNativeToManaged(IntPtr codecPtr)
{
CodecMarshal codecMarshal = new CodecMarshal();
Codec codecObj = new Codec();
Marshal.PtrToStructure(codecPtr, codecMarshal);
codecObj.marshaledObject = new HandleRef(codecMarshal, codecPtr);
return codecObj;
}
}
}
\ No newline at end of file
...@@ -61,8 +61,28 @@ namespace FreeSwitch.Marshaling ...@@ -61,8 +61,28 @@ namespace FreeSwitch.Marshaling
public IntPtr MarshalManagedToNative(object obj) public IntPtr MarshalManagedToNative(object obj)
{ {
CoreSession coreSession = (CoreSession)obj; CoreSession coreSession = (CoreSession)obj;
return coreSession.marshaledObject.Handle; Console.WriteLine("CoreSession: Marshalling Managed to Native");
if (coreSession.marshaledObject.Handle != IntPtr.Zero)
{
Console.WriteLine("Returning: 0x{0:x}", coreSession.marshaledObject.Handle.ToInt32());
return coreSession.marshaledObject.Handle;
}
else
{
CoreSessionMarshal coreSessionMarshal = new CoreSessionMarshal();
IntPtr coreSessionPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CoreSessionMarshal)));
Marshal.StructureToPtr(coreSessionMarshal, coreSessionPtr, true);
coreSession.marshaledObject = new HandleRef(coreSessionMarshal, coreSessionPtr);
Console.WriteLine("CoreSession: NO OBJECT EXISTS OMG");
Console.WriteLine("Returning: 0x{0:x}", coreSession.marshaledObject.Handle.ToInt32());
return coreSession.marshaledObject.Handle;
}
} }
public object MarshalNativeToManaged(IntPtr coreSessionPtr) public object MarshalNativeToManaged(IntPtr coreSessionPtr)
...@@ -70,6 +90,8 @@ namespace FreeSwitch.Marshaling ...@@ -70,6 +90,8 @@ namespace FreeSwitch.Marshaling
CoreSessionMarshal coreSessionMarshal = new CoreSessionMarshal(); CoreSessionMarshal coreSessionMarshal = new CoreSessionMarshal();
CoreSession coreSession = new CoreSession(); CoreSession coreSession = new CoreSession();
Console.WriteLine("CoreSession: Marshalling Native to Managed");
Marshal.PtrToStructure(coreSessionPtr, coreSessionMarshal); Marshal.PtrToStructure(coreSessionPtr, coreSessionMarshal);
coreSession.marshaledObject = new HandleRef(coreSessionMarshal, coreSessionPtr); coreSession.marshaledObject = new HandleRef(coreSessionMarshal, coreSessionPtr);
......
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* SpeechHandleMarshaler.cs --
*
*/
using System;
using System.Collections;
using FreeSwitch.Marshaling.Types;
using FreeSwitch.Types;
using System.Runtime.InteropServices;
namespace FreeSwitch.Marshaling
{
class SpeechHandleMarshaler : ICustomMarshaler
{
private static SpeechHandleMarshaler Instance = new SpeechHandleMarshaler();
public static ICustomMarshaler GetInstance(string s)
{
return Instance;
}
public void CleanUpManagedData(object o)
{
}
public void CleanUpNativeData(IntPtr pNativeData)
{
}
public int GetNativeDataSize()
{
return IntPtr.Size;
}
public IntPtr MarshalManagedToNative(object obj)
{
SpeechHandle speechHandleObj = (SpeechHandle)obj;
return speechHandleObj.marshaledObject.Handle;
}
public object MarshalNativeToManaged(IntPtr speechHandlePtr)
{
SpeechHandleMarshal speechHandleMarshal = new SpeechHandleMarshal();
SpeechHandle speechHandleObj = new SpeechHandle();
Marshal.PtrToStructure(speechHandlePtr, speechHandleMarshal);
speechHandleObj.marshaledObject = new HandleRef(speechHandleMarshal, speechHandlePtr);
return speechHandleObj;
}
}
}
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* StateHandlerTableMarshaler.cs --
*
*/
using System;
using System.Collections;
using FreeSwitch.Marshaling.Types;
using FreeSwitch.Types;
using System.Runtime.InteropServices;
namespace FreeSwitch.Marshaling
{
class StateHandlerTableMarshaler : ICustomMarshaler
{
private static StateHandlerTableMarshaler Instance = new StateHandlerTableMarshaler();
public static ICustomMarshaler GetInstance(string s)
{
return Instance;
}
public void CleanUpManagedData(object o)
{
}
public void CleanUpNativeData(IntPtr pNativeData)
{
}
public int GetNativeDataSize()
{
return IntPtr.Size;
}
public IntPtr MarshalManagedToNative(object obj)
{
StateHandlerTable stateHandlerTableObj = (StateHandlerTable)obj;
return stateHandlerTableObj.marshaledObject.Handle;
}
public object MarshalNativeToManaged(IntPtr stateHandlerTablePtr)
{
StateHandlerTableMarshal stateHandlerTableMarshal = new StateHandlerTableMarshal();
StateHandlerTable stateHandlerTableObj = new StateHandlerTable();
Marshal.PtrToStructure(stateHandlerTablePtr, stateHandlerTableMarshal);
stateHandlerTableObj.marshaledObject = new HandleRef(stateHandlerTableMarshal, stateHandlerTablePtr);
return stateHandlerTableObj;
}
}
}
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* TimerMarshaler.cs --
*
*/
using System;
using System.Collections;
using FreeSwitch.Marshaling.Types;
using FreeSwitch.Types;
using System.Runtime.InteropServices;
namespace FreeSwitch.Marshaling
{
class TimerMarshaler : ICustomMarshaler
{
private static TimerMarshaler Instance = new TimerMarshaler();
public static ICustomMarshaler GetInstance(string s)
{
return Instance;
}
public void CleanUpManagedData(object o)
{
}
public void CleanUpNativeData(IntPtr pNativeData)
{
}
public int GetNativeDataSize()
{
return IntPtr.Size;
}
public IntPtr MarshalManagedToNative(object obj)
{
Timer timerObj = (Timer)obj;
return timerObj.marshaledObject.Handle;
}
public object MarshalNativeToManaged(IntPtr timerPtr)
{
TimerMarshal timerMarshal = new TimerMarshal();
Timer timerObj = new Timer();
Marshal.PtrToStructure(timerPtr, timerMarshal);
timerObj.marshaledObject = new HandleRef(timerMarshal, timerPtr);
return timerObj;
}
}
}
...@@ -38,9 +38,9 @@ namespace FreeSwitch.Marshaling.Types ...@@ -38,9 +38,9 @@ namespace FreeSwitch.Marshaling.Types
{ {
internal IntPtr codec_interface; internal IntPtr codec_interface;
internal IntPtr implementation; internal IntPtr implementation;
//internal CodecSettingsMarshal codec_settings; internal IntPtr codec_settings;
internal UInt32 flags; internal UInt32 flags;
//internal MemoryPoolMarshal memory_pool; internal IntPtr memory_pool;
internal IntPtr private_info; internal IntPtr private_info;
} }
} }
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* SpeechHandleMarshal.cs --
*
*/
using System;
using System.Runtime.InteropServices;
using FreeSwitch.Types;
namespace FreeSwitch.Marshaling.Types
{
[StructLayout(LayoutKind.Sequential)]
internal class SpeechHandleMarshal
{
internal IntPtr speech_interface;
internal UInt32 flags;
internal IntPtr name;
internal UInt32 rate;
internal UInt32 speed;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=80)]
internal byte[] voice;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=80)]
internal byte[] engine;
internal IntPtr memory_pool;
internal IntPtr private_info;
}
}
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* StateHandlerTableMarshal.cs --
*
*/
using System;
using System.Runtime.InteropServices;
using FreeSwitch.Types;
namespace FreeSwitch.Marshaling.Types
{
[StructLayout(LayoutKind.Sequential)]
internal class StateHandlerTableMarshal
{
internal IntPtr on_init;
internal IntPtr on_ring;
internal IntPtr on_execute;
internal IntPtr on_hangup;
internal IntPtr on_loopback;
internal IntPtr on_transmit;
internal IntPtr on_hold;
}
}
\ No newline at end of file
...@@ -43,6 +43,8 @@ namespace FreeSwitch.Marshaling.Types ...@@ -43,6 +43,8 @@ namespace FreeSwitch.Marshaling.Types
internal IntPtr end; internal IntPtr end;
internal int data_size; internal int data_size;
internal int data_len; internal int data_len;
internal int alloc_len;
internal int alloc_chunk;
internal IntPtr _event; internal IntPtr _event;
} }
} }
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* TimerMarshal.cs --
*
*/
using System;
using System.Runtime.InteropServices;
using FreeSwitch.Types;
namespace FreeSwitch.Marshaling.Types
{
[StructLayout(LayoutKind.Sequential)]
internal class TimerMarshal
{
int interval;
UInt32 flags;
uint samples;
uint samplecount;
IntPtr timer_interface;
IntPtr memory_pool;
IntPtr private_info;
}
}
...@@ -34,12 +34,11 @@ using System.Collections; ...@@ -34,12 +34,11 @@ using System.Collections;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using FreeSwitch.NET;
using FreeSwitch.Types; using FreeSwitch.Types;
using FreeSwitch.Modules; using FreeSwitch.Modules;
using FreeSwitch.Marshaling.Types; using FreeSwitch.Marshaling.Types;
namespace FreeSwitch.NET namespace FreeSwitch
{ {
/// <summary> /// <summary>
/// Base class for all Freeswitch.NET modules /// Base class for all Freeswitch.NET modules
...@@ -92,19 +91,25 @@ namespace FreeSwitch.NET ...@@ -92,19 +91,25 @@ namespace FreeSwitch.NET
/* Set the module_name field of the LoadableModuleInterface */ /* Set the module_name field of the LoadableModuleInterface */
module_interface.module_name = Marshal.StringToHGlobalAnsi(filename); module_interface.module_name = Marshal.StringToHGlobalAnsi(filename);
/* Grab the first ApiInterface in our array and add a pointer to this in our ModuleInterface*/ if (apiInterfaces.Count > 0)
Api apiIndex = (Api)apiInterfaces[0]; {
/* Grab the first ApiInterface in our array and add a pointer to this in our ModuleInterface*/
module_interface.api_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApiInterfaceMarshal))); Api apiIndex = (Api)apiInterfaces[0];
Marshal.StructureToPtr(apiIndex.handle.Wrapper, module_interface.api_interface, true); module_interface.api_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApiInterfaceMarshal)));
/* For each Application interface */ Marshal.StructureToPtr(apiIndex.handle.Wrapper, module_interface.api_interface, true);
Application applicationIndex = (Application)applicationInterfaces[0]; }
module_interface.application_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApplicationInterfaceMarshal))); if (applicationInterfaces.Count > 0)
{
Marshal.StructureToPtr(applicationIndex.handle.Wrapper, module_interface.application_interface, true); /* For each Application interface */
Application applicationIndex = (Application)applicationInterfaces[0];
module_interface.application_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApplicationInterfaceMarshal)));
Marshal.StructureToPtr(applicationIndex.handle.Wrapper, module_interface.application_interface, true);
}
/* Finally, marshal the moduleinterface class and return */ /* Finally, marshal the moduleinterface class and return */
Marshal.StructureToPtr(module_interface, module, true); Marshal.StructureToPtr(module_interface, module, true);
...@@ -200,6 +205,10 @@ namespace FreeSwitch.NET ...@@ -200,6 +205,10 @@ namespace FreeSwitch.NET
module.module_shutdown); module.module_shutdown);
} }
public string Name
{
set { name = value; }
get { return name; }
}
} }
} }
...@@ -84,6 +84,15 @@ namespace FreeSwitch ...@@ -84,6 +84,15 @@ namespace FreeSwitch
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ChannelMarshaler))] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ChannelMarshaler))]
Channel channel); Channel channel);
[DllImport("freeswitch")]
[return: MarshalAs(UnmanagedType.LPStr)]
public extern static
string switch_channel_get_variable(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ChannelMarshaler))]
Channel channel,
[MarshalAs(UnmanagedType.LPStr)]
string varname);
[DllImport("freeswitch")] [DllImport("freeswitch")]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))] [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))]
public extern static public extern static
......
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* Channel.cs --
*
*/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using FreeSwitch.Types;
using FreeSwitch.Marshaling;
namespace FreeSwitch
{
public partial class Switch
{
[DllImport("freeswitch")]
public extern static
Status switch_event_bind(
[MarshalAs(UnmanagedType.LPStr)]
string id,
EventType eventType,
string subClassName,
EventCallback callback,
IntPtr userData);
}
}
...@@ -40,12 +40,67 @@ namespace FreeSwitch ...@@ -40,12 +40,67 @@ namespace FreeSwitch
{ {
public partial class Switch public partial class Switch
{ {
[DllImport("freeswitch")]
public extern static
Status switch_ivr_sleep(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
UInt32 ms);
[DllImport("freeswitch")]
public extern static
Status switch_ivr_park(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session);
[DllImport("freeswitch")]
public extern static
Status switch_ivr_collect_digits_callback(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
InputCallbackFunction dtmfCallback,
IntPtr buf,
uint buflen);
[DllImport("freeswitch")]
public extern static
Status switch_ivr_collect_digits_count(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
[MarshalAs(UnmanagedType.LPStr)]
string buffer,
uint buflen,
uint maxdigits,
[MarshalAs(UnmanagedType.LPStr)]
string terminators,
[MarshalAs(UnmanagedType.LPStr)]
string terminator,
uint timeout);
[DllImport("freeswitch")]
public extern static
Status switch_ivr_record_session(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
[MarshalAs(UnmanagedType.LPStr)]
string file,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileHandleMarshaler))]
FileHandle fh);
[DllImport("freeswitch")]
public extern static
Status switch_ivr_stop_record_session(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
[MarshalAs(UnmanagedType.LPStr)]
string file);
[DllImport("freeswitch")] [DllImport("freeswitch")]
extern public static extern public static
Status switch_ivr_play_file( Status switch_ivr_play_file(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session, CoreSession session,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FileHandleMarshaler))] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileHandleMarshaler))]
FileHandle fh, FileHandle fh,
[MarshalAs(UnmanagedType.LPStr)] [MarshalAs(UnmanagedType.LPStr)]
string file, string file,
...@@ -55,6 +110,72 @@ namespace FreeSwitch ...@@ -55,6 +110,72 @@ namespace FreeSwitch
IntPtr buf, IntPtr buf,
uint buflen); uint buflen);
[DllImport("freeswitch")]
public extern static
Status switch_ivr_record_file(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileHandleMarshaler))]
FileHandle fh,
IntPtr file,
InputCallbackFunction input_callback,
IntPtr buf,
uint buflen);
[DllImport("freeswitch")]
public extern static
Status switch_ivr_speak_text_handle(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(SpeechHandleMarshaler))]
SpeechHandle sh,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CodecMarshaler))]
Codec codec,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(TimerMarshaler))]
Timer timer,
InputCallbackFunction dtmfCallback,
[MarshalAs(UnmanagedType.LPStr)]
string text,
IntPtr buf,
uint buflen);
[DllImport("freeswitch")]
public extern static
Status switch_ivr_speak_text(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
[MarshalAs(UnmanagedType.LPStr)]
string tts_name,
[MarshalAs(UnmanagedType.LPStr)]
string voice_name,
[MarshalAs(UnmanagedType.LPStr)]
string timer_name,
uint rate,
InputCallbackFunction dtmfCallback,
[MarshalAs(UnmanagedType.LPStr)]
string text,
IntPtr buf,
uint buflen);
[DllImport("freeswitch")]
public extern static
Status switch_ivr_originate(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
ref CoreSession bleg,
IntPtr cause,
IntPtr bridgeto,
UInt32 timelimit_sec,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StateHandlerTableMarshaler))]
StateHandlerTable table,
[MarshalAs(UnmanagedType.LPStr)]
string cid_name_override,
[MarshalAs(UnmanagedType.LPStr)]
string cid_num_override,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))]
CallerProfile caller_profile_override);
[DllImport("freeswitch")] [DllImport("freeswitch")]
public extern static public extern static
Status switch_ivr_multi_threaded_bridge( Status switch_ivr_multi_threaded_bridge(
...@@ -62,21 +183,20 @@ namespace FreeSwitch ...@@ -62,21 +183,20 @@ namespace FreeSwitch
CoreSession session, CoreSession session,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession peer_session, CoreSession peer_session,
uint timelimit, InputCallbackFunction dtmfCallback,
IntPtr dtmf_callback,
IntPtr session_data, IntPtr session_data,
IntPtr peer_session_data); IntPtr peer_session_data);
[DllImport("freeswitch")] [DllImport("freeswitch")]
public extern static public extern static
Status switch_ivr_record_file( Status switch_ivr_session_transfer(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session, CoreSession session,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileHandleMarshaler))] [MarshalAs(UnmanagedType.LPStr)]
FileHandle fh, string extension,
IntPtr file, [MarshalAs(UnmanagedType.LPStr)]
InputCallbackFunction input_callback, string dialplan,
IntPtr buf, [MarshalAs(UnmanagedType.LPStr)]
uint buflen); string context);
} }
} }
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* Log.cs --
*
*/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using FreeSwitch.Types;
using FreeSwitch.Marshaling;
using FreeSwitch.Marshaling.Types;
namespace FreeSwitch
{
/*
src/switch_log.c:SWITCH_DECLARE(const char *) switch_log_level2str(switch_log_level_t level)
src/switch_log.c:SWITCH_DECLARE(switch_log_level_t) switch_log_str2level(const char *str)
src/switch_log.c:SWITCH_DECLARE(switch_status_t) switch_log_bind_logger(switch_log_function_t function, switch_log_level_t level)
src/switch_log.c:SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, char *file, const char *func, int line, switch_log_level_t level, char *fmt, ...)
src/switch_log.c:SWITCH_DECLARE(switch_status_t) switch_log_init(switch_memory_pool_t *pool)
src/switch_log.c:SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void)
*/
public partial class Switch
{
[DllImport("freeswitch")]
public extern static
void switch_log_printf(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))]
Channel channel,
string file,
string func,
int line,
LogLevel level,
string format);
}
}
...@@ -219,5 +219,15 @@ namespace FreeSwitch.Types ...@@ -219,5 +219,15 @@ namespace FreeSwitch.Types
{ {
return Switch.switch_channel_answer(this); return Switch.switch_channel_answer(this);
} }
public ChannelState Hangup(CallCause cause)
{
return Switch.switch_channel_perform_hangup(this, "file", "func", 666, cause);
}
public string GetVariable(string varname)
{
return Switch.switch_channel_get_variable(this, varname);
}
} }
} }
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* Codec.cs --
*
*/
using System;
using System.Runtime.InteropServices;
using FreeSwitch.Marshaling;
using FreeSwitch.Marshaling.Types;
namespace FreeSwitch.Types
{
public class Codec
{
internal HandleRef marshaledObject;
}
}
\ No newline at end of file
...@@ -109,7 +109,7 @@ namespace FreeSwitch.Types ...@@ -109,7 +109,7 @@ namespace FreeSwitch.Types
get get
{ {
CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper; CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper;
if (coreSessionMarshal.thread_running <= 0) if (coreSessionMarshal.thread_running <= 0)
return false; return false;
else else
......
...@@ -101,20 +101,4 @@ namespace FreeSwitch.Types ...@@ -101,20 +101,4 @@ namespace FreeSwitch.Types
public string Name; public string Name;
public string Value; public string Value;
} }
public enum EventType
{
SWITCH_EVENT_CUSTOM,
SWITCH_EVENT_CHANNEL_STATE,
SWITCH_EVENT_CHANNEL_ANSWER,
SWITCH_EVENT_CHANNEL_HANGUP,
SWITCH_EVENT_API,
SWITCH_EVENT_LOG,
SWITCH_EVENT_INBOUND_CHAN,
SWITCH_EVENT_OUTBOUND_CHAN,
SWITCH_EVENT_STARTUP,
SWITCH_EVENT_SHUTDOWN,
SWITCH_EVENT_ALL
}
} }
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* EventCallback.cs --
*
*/
using System;
using System.Runtime.InteropServices;
using FreeSwitch.Marshaling;
namespace FreeSwitch.Types
{
public delegate void EventCallback(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(EventMarshaler))]
Event _event);
}
\ No newline at end of file
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* EventType.cs --
*
*/
using System;
using System.Collections;
using System.Text;
using System.Runtime.InteropServices;
namespace FreeSwitch.Types
{
public enum EventType
{
Custom,
Create,
Destroy,
State,
Answer,
Hangup,
Execute,
Bridge,
UnBridge,
Progress,
Outgoing,
Park,
UnPark,
Api,
Log,
InboundChan,
OutboundChan,
Startup,
Shutdown,
Publish,
UnPublish,
Talk,
NoTalk,
SessionCrash,
ModuleLoad,
Dtmf,
Message,
Codec,
BackgroundJob,
All
}
}
\ No newline at end of file
...@@ -36,7 +36,7 @@ using FreeSwitch.Marshaling; ...@@ -36,7 +36,7 @@ using FreeSwitch.Marshaling;
namespace FreeSwitch.Types namespace FreeSwitch.Types
{ {
public delegate Status InputCallbackFunction( public delegate Status InputCallbackFunction(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StreamHandleMarshaler))] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))]
CoreSession session, CoreSession session,
[MarshalAs(UnmanagedType.LPStr)] [MarshalAs(UnmanagedType.LPStr)]
string input, string input,
......
...@@ -37,11 +37,7 @@ using FreeSwitch.Marshaling; ...@@ -37,11 +37,7 @@ using FreeSwitch.Marshaling;
namespace FreeSwitch.Types namespace FreeSwitch.Types
{ {
public delegate Status WriteFunction(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StreamHandleMarshaler))]
StreamHandle streamHandle,
[MarshalAs(UnmanagedType.LPStr)]
string fmt);
//public delegate void ModuleLoad(); //public delegate void ModuleLoad();
......
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* LogLevel.cs --
*
*/
using System;
using System.Collections;
using System.Text;
using System.Runtime.InteropServices;
namespace FreeSwitch.Types
{
public enum LogLevel
{
Console,
Debug,
Info,
Notice,
Warning,
Error,
Crit,
Alert,
Emerg
}
}
\ No newline at end of file
...@@ -49,11 +49,13 @@ namespace FreeSwitch.Types ...@@ -49,11 +49,13 @@ namespace FreeSwitch.Types
CoreSession session, CoreSession session,
[MarshalAs(UnmanagedType.LPStr)] [MarshalAs(UnmanagedType.LPStr)]
string data); string data);
public delegate Status public delegate Status
ApiFunction( ApiFunction(
[MarshalAs(UnmanagedType.LPStr)] [MarshalAs(UnmanagedType.LPStr)]
string command, string input,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StreamHandleMarshaler))] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StreamHandleMarshaler))]
StreamHandle streamHandle); StreamHandle streamHandle);
} }
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* SpeechHandle.cs --
*
*/
using System;
using System.Runtime.InteropServices;
using FreeSwitch.Marshaling;
using FreeSwitch.Marshaling.Types;
namespace FreeSwitch.Types
{
/*
internal IntPtr speech_interface;
internal UInt32 flags;
internal IntPtr name;
internal UInt32 rate;
internal UInt32 speed;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)]
internal byte[] voice;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)]
internal byte[] engine;
internal IntPtr memory_pool;
internal IntPtr private_info;
*/
public class SpeechHandle
{
internal HandleRef marshaledObject;
public UInt32 flags
{
get
{
SpeechHandleMarshal speechHandleMarshal = (SpeechHandleMarshal)marshaledObject.Wrapper;
return speechHandleMarshal.flags;
}
}
}
}
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* StateHandlerTable.cs --
*
*/
using System;
using System.Runtime.InteropServices;
using FreeSwitch.Marshaling;
using FreeSwitch.Marshaling.Types;
namespace FreeSwitch.Types
{
public class StateHandlerTable
{
internal HandleRef marshaledObject;
}
}
...@@ -30,20 +30,26 @@ ...@@ -30,20 +30,26 @@
* *
*/ */
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using FreeSwitch.Marshaling;
using FreeSwitch.Marshaling.Types; using FreeSwitch.Marshaling.Types;
namespace FreeSwitch.Types namespace FreeSwitch.Types
{ {
public delegate Status StreamHandleWriteFunction(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StreamHandleMarshaler))]
StreamHandle streamHandle,
[MarshalAs(UnmanagedType.LPStr)]
string fmt);
public class StreamHandle public class StreamHandle
{ {
internal HandleRef marshaledObject; internal HandleRef marshaledObject;
internal WriteFunction writeFunction;
public void Write(string data) public void Write(string data)
{ {
StreamHandleMarshal streamHandleMarshal = (StreamHandleMarshal)marshaledObject.Wrapper; StreamHandleMarshal streamHandleMarshal = (StreamHandleMarshal)marshaledObject.Wrapper;
WriteFunction writeFunction = (WriteFunction)Marshal.GetDelegateForFunctionPointer(streamHandleMarshal.write_function, typeof(WriteFunction)); StreamHandleWriteFunction writeFunction = (StreamHandleWriteFunction)Marshal.GetDelegateForFunctionPointer(streamHandleMarshal.write_function, typeof(StreamHandleWriteFunction));
writeFunction(this, data); writeFunction(this, data);
} }
......
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2006, James Martelletti <james@nerdc0re.com>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* James Martelletti <james@nerdc0re.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* James Martelletti <james@nerdc0re.com>
*
*
* Timer.cs --
*
*/
using System;
using System.Runtime.InteropServices;
using FreeSwitch.Marshaling;
using FreeSwitch.Marshaling.Types;
namespace FreeSwitch.Types
{
public class Timer
{
internal HandleRef marshaledObject;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论