[Freeswitch-svn] [commit] r2750 - in freeswitch/trunk/src/dotnet: . Marshaling Marshaling/Types Switch Types
Freeswitch SVN
james at freeswitch.org
Tue Sep 19 08:47:46 EDT 2006
Author: james
Date: Tue Sep 19 08:47:44 2006
New Revision: 2750
Added:
freeswitch/trunk/src/dotnet/Ivr.cs
freeswitch/trunk/src/dotnet/Log.cs
freeswitch/trunk/src/dotnet/Marshaling/CodecMarshaler.cs
freeswitch/trunk/src/dotnet/Marshaling/SpeechHandleMarshaler.cs
freeswitch/trunk/src/dotnet/Marshaling/StateHandlerTableMarshaler.cs
freeswitch/trunk/src/dotnet/Marshaling/TimerMarshaler.cs
freeswitch/trunk/src/dotnet/Marshaling/Types/SpeechHandleMarshal.cs
freeswitch/trunk/src/dotnet/Marshaling/Types/StateHandlerTableMarshal.cs
freeswitch/trunk/src/dotnet/Marshaling/Types/TimerMarshal.cs
freeswitch/trunk/src/dotnet/Switch/Event.cs
freeswitch/trunk/src/dotnet/Switch/Log.cs
freeswitch/trunk/src/dotnet/Types/Codec.cs
freeswitch/trunk/src/dotnet/Types/EventCallback.cs
freeswitch/trunk/src/dotnet/Types/EventType.cs
freeswitch/trunk/src/dotnet/Types/LogLevel.cs
freeswitch/trunk/src/dotnet/Types/SpeechHandle.cs
freeswitch/trunk/src/dotnet/Types/StateHandlerTable.cs
freeswitch/trunk/src/dotnet/Types/Timer.cs
Modified:
freeswitch/trunk/src/dotnet/Common.cs
freeswitch/trunk/src/dotnet/FreeSwitch.NET.csproj
freeswitch/trunk/src/dotnet/Makefile
freeswitch/trunk/src/dotnet/Marshaling/CoreSessionMarshaler.cs
freeswitch/trunk/src/dotnet/Marshaling/Types/CodecMarshal.cs
freeswitch/trunk/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs
freeswitch/trunk/src/dotnet/Module.cs
freeswitch/trunk/src/dotnet/Switch/Channel.cs
freeswitch/trunk/src/dotnet/Switch/Ivr.cs
freeswitch/trunk/src/dotnet/Types/Channel.cs
freeswitch/trunk/src/dotnet/Types/CoreSession.cs
freeswitch/trunk/src/dotnet/Types/Event.cs
freeswitch/trunk/src/dotnet/Types/InputCallbackFunction.cs
freeswitch/trunk/src/dotnet/Types/LoadableModuleInterface.cs
freeswitch/trunk/src/dotnet/Types/Module.cs
freeswitch/trunk/src/dotnet/Types/StreamHandle.cs
Log:
Update, changing core assembly name to FreeSwitch.NET.dll as to not conflict with the real freeswitch.dll on Windows.
Modified: freeswitch/trunk/src/dotnet/Common.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Common.cs (original)
+++ freeswitch/trunk/src/dotnet/Common.cs Tue Sep 19 08:47:44 2006
@@ -32,7 +32,7 @@
using System;
using System.Reflection;
-namespace FreeSwitch.NET
+namespace FreeSwitch
{
public class Common
{
Modified: freeswitch/trunk/src/dotnet/FreeSwitch.NET.csproj
==============================================================================
--- freeswitch/trunk/src/dotnet/FreeSwitch.NET.csproj (original)
+++ freeswitch/trunk/src/dotnet/FreeSwitch.NET.csproj Tue Sep 19 08:47:44 2006
@@ -7,8 +7,8 @@
<ProjectGuid>{251CAABC-16C3-4593-A491-603B908094E0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>FreeSwitch.NET</RootNamespace>
- <AssemblyName>Freeswitch</AssemblyName>
+ <RootNamespace>FreeSwitch</RootNamespace>
+ <AssemblyName>FreeSwitch.NET</AssemblyName>
<StartupObject>
</StartupObject>
<SignAssembly>true</SignAssembly>
@@ -42,11 +42,17 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Common.cs" />
+ <Compile Include="Log.cs" />
+ <Compile Include="Ivr.cs" />
<Compile Include="Marshaling\BufferMarshaler.cs" />
<Compile Include="Marshaling\CallerExtensionMarshaler.cs" />
<Compile Include="Marshaling\CallerProfileMarshaler.cs" />
<Compile Include="Marshaling\ChannelMarshaler.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\CoreSessionMarshaler.cs" />
<Compile Include="Marshaling\EventMarshaler.cs" />
@@ -65,6 +71,9 @@
<Compile Include="Marshaling\Types\CodecInterfaceMarshal.cs" />
<Compile Include="Marshaling\Types\CodecMarshal.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\TypesMarshal.cs" />
<Compile Include="Marshaling\Types\FileHandleMarshal.cs" />
@@ -79,6 +88,8 @@
<Compile Include="Switch\CallerProfile.cs" />
<Compile Include="Switch\Channel.cs" />
<Compile Include="Switch\Console.cs" />
+ <Compile Include="Switch\Log.cs" />
+ <Compile Include="Switch\Event.cs" />
<Compile Include="Switch\StreamHandle.cs" />
<Compile Include="Switch\CoreSession.cs" />
<Compile Include="Switch\Ivr.cs" />
@@ -96,6 +107,13 @@
<Compile Include="Modules\Application.cs" />
<Compile Include="Types\ApplicationFunction.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\InputType.cs" />
<Compile Include="Types\ModuleInterfaces.cs" />
Added: freeswitch/trunk/src/dotnet/Ivr.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Ivr.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,44 @@
+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
Added: freeswitch/trunk/src/dotnet/Log.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Log.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,16 @@
+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
Modified: freeswitch/trunk/src/dotnet/Makefile
==============================================================================
--- freeswitch/trunk/src/dotnet/Makefile (original)
+++ freeswitch/trunk/src/dotnet/Makefile Tue Sep 19 08:47:44 2006
@@ -2,7 +2,7 @@
$(MODNAME).so:
/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 \
Marshaling/Types/ApiInterfaceMarshal.cs \
Marshaling/Types/ApplicationInterfaceMarshal.cs \
@@ -24,26 +24,35 @@
Marshaling/Types/IOEventHooksMarshal.cs \
Marshaling/Types/LoadableModuleInterfaceMarshal.cs \
Marshaling/Types/LoadableModuleMarshal.cs \
+ Marshaling/Types/SpeechHandleMarshal.cs \
+ Marshaling/Types/StateHandlerTableMarshal.cs \
Marshaling/Types/StreamHandleMarshal.cs \
Marshaling/Types/TypesMarshal.cs \
+ Marshaling/Types/TimerMarshal.cs \
Marshaling/BufferMarshaler.cs \
Marshaling/CallerExtensionMarshaler.cs \
Marshaling/CallerProfileMarshaler.cs \
Marshaling/ChannelMarshaler.cs \
Marshaling/ChannelTimetableMarshaler.cs \
+ Marshaling/CodecMarshaler.cs \
Marshaling/CoreSessionMarshaler.cs \
Marshaling/EventMarshaler.cs \
Marshaling/FileHandleMarshaler.cs \
Marshaling/MemoryPoolMarshaler.cs \
+ Marshaling/SpeechHandleMarshaler.cs \
+ Marshaling/StateHandlerTableMarshaler.cs \
Marshaling/StreamHandleMarshaler.cs \
+ Marshaling/TimerMarshaler.cs \
Modules/Api.cs \
Modules/Application.cs \
Switch/CallerProfile.cs \
Switch/Channel.cs \
Switch/Console.cs \
Switch/CoreSession.cs \
+ Switch/Event.cs \
Switch/Ivr.cs \
Switch/LoadableModule.cs \
+ Switch/Log.cs \
Switch/StreamHandle.cs \
Types/ApiFunction.cs \
Types/ApplicationFunction.cs \
@@ -56,24 +65,33 @@
Types/ChannelFlag.cs \
Types/ChannelState.cs \
Types/ChannelTimetable.cs \
+ Types/Codec.cs \
Types/CoreSession.cs \
Types/DtmfCallbackFunction.cs \
Types/InputCallbackFunction.cs \
Types/InputType.cs \
Types/Event.cs \
+ Types/EventCallback.cs \
+ Types/EventType.cs \
Types/FileHandle.cs \
Types/LoadableModule.cs \
Types/LoadableModuleInterface.cs \
+ Types/LogLevel.cs \
Types/MemoryPool.cs \
Types/Module.cs \
Types/Status.cs \
+ Types/SpeechHandle.cs \
+ Types/StateHandlerTable.cs \
Types/StreamHandle.cs \
Types/TextChannel.cs \
+ Types/Timer.cs \
Common.cs \
Module.cs \
+ Ivr.cs \
+ Log.cs \
clean:
rm -fr *.dll
install:
- cp -f FreeSwitch.dll /usr/local/freeswitch/lib/
+ cp -f FreeSwitch.NET.dll /usr/local/freeswitch/lib/
Added: freeswitch/trunk/src/dotnet/Marshaling/CodecMarshaler.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/CodecMarshaler.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,82 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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
Modified: freeswitch/trunk/src/dotnet/Marshaling/CoreSessionMarshaler.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Marshaling/CoreSessionMarshaler.cs (original)
+++ freeswitch/trunk/src/dotnet/Marshaling/CoreSessionMarshaler.cs Tue Sep 19 08:47:44 2006
@@ -61,14 +61,36 @@
public IntPtr MarshalManagedToNative(object 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)
{
CoreSessionMarshal coreSessionMarshal = new CoreSessionMarshal();
CoreSession coreSession = new CoreSession();
+
+ Console.WriteLine("CoreSession: Marshalling Native to Managed");
Marshal.PtrToStructure(coreSessionPtr, coreSessionMarshal);
Added: freeswitch/trunk/src/dotnet/Marshaling/SpeechHandleMarshaler.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/SpeechHandleMarshaler.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,81 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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;
+ }
+ }
+}
Added: freeswitch/trunk/src/dotnet/Marshaling/StateHandlerTableMarshaler.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/StateHandlerTableMarshaler.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,81 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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;
+ }
+ }
+}
Added: freeswitch/trunk/src/dotnet/Marshaling/TimerMarshaler.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/TimerMarshaler.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,81 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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;
+ }
+ }
+}
Modified: freeswitch/trunk/src/dotnet/Marshaling/Types/CodecMarshal.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Marshaling/Types/CodecMarshal.cs (original)
+++ freeswitch/trunk/src/dotnet/Marshaling/Types/CodecMarshal.cs Tue Sep 19 08:47:44 2006
@@ -38,9 +38,9 @@
{
internal IntPtr codec_interface;
internal IntPtr implementation;
- //internal CodecSettingsMarshal codec_settings;
+ internal IntPtr codec_settings;
internal UInt32 flags;
- //internal MemoryPoolMarshal memory_pool;
+ internal IntPtr memory_pool;
internal IntPtr private_info;
}
}
Added: freeswitch/trunk/src/dotnet/Marshaling/Types/SpeechHandleMarshal.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/Types/SpeechHandleMarshal.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,53 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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;
+ }
+}
Added: freeswitch/trunk/src/dotnet/Marshaling/Types/StateHandlerTableMarshal.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/Types/StateHandlerTableMarshal.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,49 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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
Modified: freeswitch/trunk/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs (original)
+++ freeswitch/trunk/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs Tue Sep 19 08:47:44 2006
@@ -43,6 +43,8 @@
internal IntPtr end;
internal int data_size;
internal int data_len;
+ internal int alloc_len;
+ internal int alloc_chunk;
internal IntPtr _event;
}
}
Added: freeswitch/trunk/src/dotnet/Marshaling/Types/TimerMarshal.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/Types/TimerMarshal.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,49 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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;
+ }
+}
Modified: freeswitch/trunk/src/dotnet/Module.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Module.cs (original)
+++ freeswitch/trunk/src/dotnet/Module.cs Tue Sep 19 08:47:44 2006
@@ -34,12 +34,11 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
-using FreeSwitch.NET;
using FreeSwitch.Types;
using FreeSwitch.Modules;
using FreeSwitch.Marshaling.Types;
-namespace FreeSwitch.NET
+namespace FreeSwitch
{
/// <summary>
/// Base class for all Freeswitch.NET modules
@@ -92,20 +91,26 @@
/* Set the module_name field of the LoadableModuleInterface */
module_interface.module_name = Marshal.StringToHGlobalAnsi(filename);
- /* Grab the first ApiInterface in our array and add a pointer to this in our ModuleInterface*/
- Api apiIndex = (Api)apiInterfaces[0];
-
- module_interface.api_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApiInterfaceMarshal)));
-
- Marshal.StructureToPtr(apiIndex.handle.Wrapper, module_interface.api_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);
+ if (apiInterfaces.Count > 0)
+ {
+ /* Grab the first ApiInterface in our array and add a pointer to this in our ModuleInterface*/
+ Api apiIndex = (Api)apiInterfaces[0];
+ module_interface.api_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApiInterfaceMarshal)));
+
+ Marshal.StructureToPtr(apiIndex.handle.Wrapper, module_interface.api_interface, true);
+ }
+
+ if (applicationInterfaces.Count > 0)
+ {
+ /* 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 */
Marshal.StructureToPtr(module_interface, module, true);
@@ -200,6 +205,10 @@
module.module_shutdown);
}
-
+ public string Name
+ {
+ set { name = value; }
+ get { return name; }
+ }
}
}
Modified: freeswitch/trunk/src/dotnet/Switch/Channel.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Switch/Channel.cs (original)
+++ freeswitch/trunk/src/dotnet/Switch/Channel.cs Tue Sep 19 08:47:44 2006
@@ -85,6 +85,15 @@
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")]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))]
public extern static
CallerProfile switch_channel_get_originator_caller_profile(
Added: freeswitch/trunk/src/dotnet/Switch/Event.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Switch/Event.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,52 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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);
+ }
+}
Modified: freeswitch/trunk/src/dotnet/Switch/Ivr.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Switch/Ivr.cs (original)
+++ freeswitch/trunk/src/dotnet/Switch/Ivr.cs Tue Sep 19 08:47:44 2006
@@ -41,11 +41,66 @@
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")]
extern public static
Status switch_ivr_play_file(
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))]
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FileHandleMarshaler))]
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileHandleMarshaler))]
FileHandle fh,
[MarshalAs(UnmanagedType.LPStr)]
string file,
@@ -57,26 +112,91 @@
[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")]
+ public extern static
Status switch_ivr_multi_threaded_bridge(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession peer_session,
- uint timelimit,
- IntPtr dtmf_callback,
+ InputCallbackFunction dtmfCallback,
IntPtr session_data,
IntPtr peer_session_data);
[DllImport("freeswitch")]
public extern static
- Status switch_ivr_record_file(
+ Status switch_ivr_session_transfer(
[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);
+ [MarshalAs(UnmanagedType.LPStr)]
+ string extension,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string dialplan,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string context);
}
}
Added: freeswitch/trunk/src/dotnet/Switch/Log.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Switch/Log.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,62 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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);
+ }
+}
Modified: freeswitch/trunk/src/dotnet/Types/Channel.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/Channel.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/Channel.cs Tue Sep 19 08:47:44 2006
@@ -219,5 +219,15 @@
{
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);
+ }
}
}
Added: freeswitch/trunk/src/dotnet/Types/Codec.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/Codec.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,44 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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
Modified: freeswitch/trunk/src/dotnet/Types/CoreSession.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/CoreSession.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/CoreSession.cs Tue Sep 19 08:47:44 2006
@@ -109,7 +109,7 @@
get
{
CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper;
-
+
if (coreSessionMarshal.thread_running <= 0)
return false;
else
Modified: freeswitch/trunk/src/dotnet/Types/Event.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/Event.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/Event.cs Tue Sep 19 08:47:44 2006
@@ -101,20 +101,4 @@
public string Name;
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
- }
-
}
Added: freeswitch/trunk/src/dotnet/Types/EventCallback.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/EventCallback.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,41 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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
Added: freeswitch/trunk/src/dotnet/Types/EventType.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/EventType.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,72 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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
Modified: freeswitch/trunk/src/dotnet/Types/InputCallbackFunction.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/InputCallbackFunction.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/InputCallbackFunction.cs Tue Sep 19 08:47:44 2006
@@ -36,7 +36,7 @@
namespace FreeSwitch.Types
{
public delegate Status InputCallbackFunction(
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StreamHandleMarshaler))]
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))]
CoreSession session,
[MarshalAs(UnmanagedType.LPStr)]
string input,
Modified: freeswitch/trunk/src/dotnet/Types/LoadableModuleInterface.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/LoadableModuleInterface.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/LoadableModuleInterface.cs Tue Sep 19 08:47:44 2006
@@ -37,11 +37,7 @@
namespace FreeSwitch.Types
{
- public delegate Status WriteFunction(
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StreamHandleMarshaler))]
- StreamHandle streamHandle,
- [MarshalAs(UnmanagedType.LPStr)]
- string fmt);
+
//public delegate void ModuleLoad();
Added: freeswitch/trunk/src/dotnet/Types/LogLevel.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/LogLevel.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,51 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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
Modified: freeswitch/trunk/src/dotnet/Types/Module.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/Module.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/Module.cs Tue Sep 19 08:47:44 2006
@@ -49,11 +49,13 @@
CoreSession session,
[MarshalAs(UnmanagedType.LPStr)]
string data);
-
+
public delegate Status
ApiFunction(
[MarshalAs(UnmanagedType.LPStr)]
- string command,
+ string input,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
+ CoreSession session,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StreamHandleMarshaler))]
StreamHandle streamHandle);
}
Added: freeswitch/trunk/src/dotnet/Types/SpeechHandle.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/SpeechHandle.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,66 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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;
+ }
+ }
+ }
+}
Added: freeswitch/trunk/src/dotnet/Types/StateHandlerTable.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/StateHandlerTable.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,44 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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;
+
+ }
+}
Modified: freeswitch/trunk/src/dotnet/Types/StreamHandle.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/StreamHandle.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/StreamHandle.cs Tue Sep 19 08:47:44 2006
@@ -30,20 +30,26 @@
*
*/
using System;
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
+using FreeSwitch.Marshaling;
using FreeSwitch.Marshaling.Types;
namespace FreeSwitch.Types
-{
+{
+ public delegate Status StreamHandleWriteFunction(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StreamHandleMarshaler))]
+ StreamHandle streamHandle,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string fmt);
+
public class StreamHandle
{
internal HandleRef marshaledObject;
- internal WriteFunction writeFunction;
public void Write(string data)
{
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);
}
Added: freeswitch/trunk/src/dotnet/Types/Timer.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/Timer.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,44 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james at 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 at nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james at 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;
+
+ }
+}
More information about the Freeswitch-svn
mailing list