[Freeswitch-branches] [commit] r2268 - in freeswitch/branches/james/src: dotnet dotnet/Marshaling dotnet/Marshaling/Types dotnet/Modules dotnet/Switch dotnet/Types mod/dotnet/Info mod/dotnet/Info/Properties mod/dotnet/Info/bin mod/dotnet/Info/bin/Debug mod/dotnet/Info/obj mod/dotnet/Info/obj/Debug mod/dotnet/Info/obj/Debug/Refactor mod/dotnet/Info/obj/Debug/TempPE mod/languages/mod_mono
Author: james Date: Sat Aug 12 00:43:19 2006 New Revision: 2268 Added: freeswitch/branches/james/src/dotnet/FreeSwitchDotNet.csproj (contents, props changed) freeswitch/branches/james/src/dotnet/Marshaling/StreamHandleMarshaler.cs (contents, props changed) freeswitch/branches/james/src/dotnet/Switch/StreamHandle.cs (contents, props changed) freeswitch/branches/james/src/dotnet/Types/Module.cs (contents, props changed) freeswitch/branches/james/src/dotnet/Types/ModuleInterfaces.cs (contents, props changed) freeswitch/branches/james/src/dotnet/Types/StreamHandle.cs (contents, props changed) freeswitch/branches/james/src/mod/dotnet/Info/ freeswitch/branches/james/src/mod/dotnet/Info/Info.cs (contents, props changed) freeswitch/branches/james/src/mod/dotnet/Info/Info.csproj (contents, props changed) freeswitch/branches/james/src/mod/dotnet/Info/Info.dll (contents, props changed) freeswitch/branches/james/src/mod/dotnet/Info/Info.suo (contents, props changed) freeswitch/branches/james/src/mod/dotnet/Info/Makefile freeswitch/branches/james/src/mod/dotnet/Info/Properties/ freeswitch/branches/james/src/mod/dotnet/Info/Properties/AssemblyInfo.cs (contents, props changed) freeswitch/branches/james/src/mod/dotnet/Info/bin/ freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/ freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Freeswitch.dll (contents, props changed) freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Freeswitch.pdb (contents, props changed) freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Info.dll (contents, props changed) freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Info.pdb (contents, props changed) freeswitch/branches/james/src/mod/dotnet/Info/obj/ freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/ freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/Info.dll (contents, props changed) freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/Refactor/ freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/ResolveAssemblyReference.cache (contents, props changed) freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/TempPE/ freeswitch/branches/james/src/mod/dotnet/Info/obj/Info.csproj.FileList.txt (contents, props changed) Modified: freeswitch/branches/james/src/dotnet/Common.cs freeswitch/branches/james/src/dotnet/Core.cs freeswitch/branches/james/src/dotnet/Makefile freeswitch/branches/james/src/dotnet/Marshaling/Types/ApiInterfaceMarshal.cs freeswitch/branches/james/src/dotnet/Marshaling/Types/ApplicationInterfaceMarshal.cs freeswitch/branches/james/src/dotnet/Marshaling/Types/BufferMarshal.cs freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerExtensionMarshal.cs freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerProfileMarshal.cs freeswitch/branches/james/src/dotnet/Marshaling/Types/ChannelMarshal.cs freeswitch/branches/james/src/dotnet/Marshaling/Types/CodecInterfaceMarshal.cs freeswitch/branches/james/src/dotnet/Marshaling/Types/CoreSessionMarshal.cs freeswitch/branches/james/src/dotnet/Marshaling/Types/FrameMarshal.cs freeswitch/branches/james/src/dotnet/Marshaling/Types/IOEventHooksMarshal.cs freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleInterfaceMarshal.cs freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleMarshal.cs freeswitch/branches/james/src/dotnet/Module.cs freeswitch/branches/james/src/dotnet/Modules/Api.cs freeswitch/branches/james/src/dotnet/Modules/Application.cs freeswitch/branches/james/src/dotnet/Switch/CallerProfile.cs freeswitch/branches/james/src/dotnet/Switch/Channel.cs freeswitch/branches/james/src/dotnet/Switch/LoadableModule.cs freeswitch/branches/james/src/dotnet/Types/ApiFunction.cs freeswitch/branches/james/src/dotnet/Types/ApplicationFunction.cs freeswitch/branches/james/src/dotnet/Types/ApplicationInterface.cs freeswitch/branches/james/src/dotnet/Types/CallerExtension.cs freeswitch/branches/james/src/dotnet/Types/CallerProfile.cs freeswitch/branches/james/src/dotnet/Types/Channel.cs freeswitch/branches/james/src/dotnet/Types/CoreSession.cs freeswitch/branches/james/src/dotnet/Types/LoadableModuleInterface.cs freeswitch/branches/james/src/mod/languages/mod_mono/mod_mono.c Log: Codey Codey. Modified: freeswitch/branches/james/src/dotnet/Common.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Common.cs (original) +++ freeswitch/branches/james/src/dotnet/Common.cs Sat Aug 12 00:43:19 2006 @@ -30,6 +30,7 @@ * */ using System; +using System.Reflection; namespace Freeswitch { @@ -40,6 +41,17 @@ Console.WriteLine("DUMP-{0}:", label); DumpHex(pointer, length); + } + + public static void DumpProperties(string label, object dumpObject) + { + Type type = dumpObject.GetType(); + PropertyInfo[] properties = type.GetProperties(); + + foreach (PropertyInfo p in properties) + { + Console.WriteLine("%%% - {0}: {1}:{2}", label, p.Name, p.GetValue(dumpObject, null)); + } } public static void DumpHex(IntPtr pointer, int length) Modified: freeswitch/branches/james/src/dotnet/Core.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Core.cs (original) +++ freeswitch/branches/james/src/dotnet/Core.cs Sat Aug 12 00:43:19 2006 @@ -48,13 +48,11 @@ */ public class Core { - private static readonly Core instance = new Core(); - [DllImport("__Internal")] public static extern void switch_console_printf(SwitchTextChannel channel, string file, string func, int line, string fmt, string msg); /* Constructor */ - public Core() +/* public Core() { if (instance == null) { @@ -68,7 +66,7 @@ // switch_loadable_module_register(module); } } - +*/ public enum SwitchTextChannel { SwitchChannelIdConsole, @@ -77,13 +75,13 @@ } /* Instance property to get singleton instance of FreeSwitch */ - public static Core Instance +/* public static Core Instance { get { return instance; } } - - public void Application(IntPtr session, IntPtr data) - { - } + */ +// public void Application(IntPtr session, IntPtr data) +// { +// } } } Added: freeswitch/branches/james/src/dotnet/FreeSwitchDotNet.csproj ============================================================================== --- (empty file) +++ freeswitch/branches/james/src/dotnet/FreeSwitchDotNet.csproj Sat Aug 12 00:43:19 2006 @@ -0,0 +1,126 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{251CAABC-16C3-4593-A491-603B908094E0}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Freeswitch</RootNamespace> + <AssemblyName>Freeswitch</AssemblyName> + <StartupObject> + </StartupObject> + <SignAssembly>true</SignAssembly> + <AssemblyOriginatorKeyFile>public.snk</AssemblyOriginatorKeyFile> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Deployment" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Common.cs" /> + <Compile Include="Core.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\StreamHandleMarshaler.cs" /> + <Compile Include="Marshaling\CoreSessionMarshaler.cs" /> + <Compile Include="Marshaling\EventMarshaler.cs" /> + <Compile Include="Marshaling\MemoryPoolMarshaler.cs" /> + <Compile Include="Marshaling\Types\BufferMarshal.cs" /> + <Compile Include="Marshaling\Types\CallerExtensionMarshal.cs" /> + <Compile Include="Marshaling\Types\CallerProfileMarshal.cs" /> + <Compile Include="Marshaling\FileHandleMarshaler.cs" /> + <Compile Include="Marshaling\Types\ChannelFlagMarshal.cs" /> + <Compile Include="Marshaling\Types\ChannelMarshal.cs" /> + <Compile Include="Marshaling\Types\ChannelStateMarshal.cs" /> + <Compile Include="Marshaling\Types\ChannelTimetableMarshal.cs" /> + <Compile Include="Marshaling\Types\ApplicationInterfaceMarshal.cs" /> + <Compile Include="Marshaling\Types\ApiInterfaceMarshal.cs" /> + <Compile Include="Marshaling\Types\CodecImplementationMarshal.cs" /> + <Compile Include="Marshaling\Types\CodecInterfaceMarshal.cs" /> + <Compile Include="Marshaling\Types\CodecMarshal.cs" /> + <Compile Include="Marshaling\Types\CodecTypeMarshal.cs" /> + <Compile Include="Marshaling\Types\IMarshaledObject.cs" /> + <Compile Include="Marshaling\Types\TypesMarshal.cs" /> + <Compile Include="Marshaling\Types\FileHandleMarshal.cs" /> + <Compile Include="Marshaling\Types\LoadableModuleInterfaceMarshal.cs" /> + <Compile Include="Marshaling\Types\LoadableModuleMarshal.cs" /> + <Compile Include="Marshaling\Types\CoreSessionMarshal.cs" /> + <Compile Include="Marshaling\Types\EventMarshal.cs" /> + <Compile Include="Marshaling\Types\FrameMarshal.cs" /> + <Compile Include="Marshaling\Types\IOEventHooksMarshal.cs" /> + <Compile Include="Module.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Switch\CallerProfile.cs" /> + <Compile Include="Switch\Channel.cs" /> + <Compile Include="Switch\Console.cs" /> + <Compile Include="Switch\StreamHandle.cs" /> + <Compile Include="Switch\CoreSession.cs" /> + <Compile Include="Switch\Ivr.cs" /> + <Compile Include="Switch\LoadableModule.cs" /> + <Compile Include="Modules\Api.cs" /> + <Compile Include="Types\ApiFunction.cs" /> + <Compile Include="Types\ApplicationInterface.cs" /> + <Compile Include="Types\Buffer.cs" /> + <Compile Include="Types\CallerExtension.cs" /> + <Compile Include="Types\CallerProfile.cs" /> + <Compile Include="Types\Channel.cs" /> + <Compile Include="Types\ChannelFlag.cs" /> + <Compile Include="Types\ChannelState.cs" /> + <Compile Include="Types\ChannelTimetable.cs" /> + <Compile Include="Modules\Application.cs" /> + <Compile Include="Types\ApplicationFunction.cs" /> + <Compile Include="Types\CallCause.cs" /> + <Compile Include="Types\ModuleInterfaces.cs" /> + <Compile Include="Types\StreamHandle.cs" /> + <Compile Include="Types\Module.cs" /> + <Compile Include="Types\DtmfCallbackFunction.cs" /> + <Compile Include="Types\FileHandle.cs" /> + <Compile Include="Types\MemoryPool.cs" /> + <Compile Include="Types\LoadableModule.cs" /> + <Compile Include="Types\LoadableModuleInterface.cs" /> + <Compile Include="Types\TextChannel.cs" /> + <Compile Include="Types\CoreSession.cs" /> + <Compile Include="Types\Event.cs" /> + <Compile Include="Types\Status.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="Makefile" /> + <None Include="public.snk" /> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Modified: freeswitch/branches/james/src/dotnet/Makefile ============================================================================== --- freeswitch/branches/james/src/dotnet/Makefile (original) +++ freeswitch/branches/james/src/dotnet/Makefile Sat Aug 12 00:43:19 2006 @@ -13,13 +13,17 @@ Marshaling/Types/ChannelMarshal.cs \ Marshaling/Types/ChannelStateMarshal.cs \ Marshaling/Types/ChannelTimetableMarshal.cs \ + Marshaling/Types/CodecImplementationMarshal.cs \ + Marshaling/Types/CodecInterfaceMarshal.cs \ + Marshaling/Types/CodecMarshal.cs \ + Marshaling/Types/CodecTypeMarshal.cs \ Marshaling/Types/CoreSessionMarshal.cs \ Marshaling/Types/EventMarshal.cs \ Marshaling/Types/FileHandleMarshal.cs \ Marshaling/Types/FrameMarshal.cs \ Marshaling/Types/IOEventHooksMarshal.cs \ - Marshaling/Types/LoadableModuleMarshal.cs \ Marshaling/Types/LoadableModuleInterfaceMarshal.cs \ + Marshaling/Types/LoadableModuleMarshal.cs \ Marshaling/Types/TypesMarshal.cs \ Marshaling/BufferMarshaler.cs \ Marshaling/CallerExtensionMarshaler.cs \ @@ -30,6 +34,7 @@ Marshaling/EventMarshaler.cs \ Marshaling/FileHandleMarshaler.cs \ Marshaling/MemoryPoolMarshaler.cs \ + Marshaling/StreamHandleMarshaler.cs \ Modules/Api.cs \ Modules/Application.cs \ Switch/CallerProfile.cs \ @@ -38,8 +43,10 @@ Switch/CoreSession.cs \ Switch/Ivr.cs \ Switch/LoadableModule.cs \ + Switch/StreamHandle.cs \ Types/ApiFunction.cs \ Types/ApplicationFunction.cs \ + Types/ApplicationInterface.cs \ Types/Buffer.cs \ Types/CallCause.cs \ Types/CallerExtension.cs \ @@ -52,9 +59,13 @@ Types/DtmfCallbackFunction.cs \ Types/Event.cs \ Types/FileHandle.cs \ + Types/LoadableModule.cs \ Types/LoadableModuleInterface.cs \ Types/MemoryPool.cs \ + Types/Module.cs \ Types/Status.cs \ + Types/StreamHandle.cs \ + Types/TextChannel.cs \ Common.cs \ Core.cs \ Ivr.cs \ @@ -64,4 +75,4 @@ rm -fr *.dll install: - cp -f $(MODNAME).dll $(PREFIX)/mod/mono + cp -f Freeswitch.dll /usr/local/freeswitch/lib/ Added: freeswitch/branches/james/src/dotnet/Marshaling/StreamHandleMarshaler.cs ============================================================================== --- (empty file) +++ freeswitch/branches/james/src/dotnet/Marshaling/StreamHandleMarshaler.cs Sat Aug 12 00:43:19 2006 @@ -0,0 +1,81 @@ +/* + * 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> + * + * + * StreamHandleMarshaler.cs -- + * + */ +using System; +using System.Collections; +using Freeswitch.Marshaling.Types; +using Freeswitch.Types; +using System.Runtime.InteropServices; + +namespace Freeswitch.Marshaling +{ + class StreamHandleMarshaler : ICustomMarshaler + { + private static StreamHandleMarshaler Instance = new StreamHandleMarshaler(); + + 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) + { + StreamHandle streamHandleObj = (StreamHandle)obj; + + return streamHandleObj.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr streamHandlePtr) + { + StreamHandleMarshal streamHandleMarshal = new StreamHandleMarshal(); + StreamHandle streamHandleObj = new StreamHandle(); + + Marshal.PtrToStructure(streamHandlePtr, streamHandleMarshal); + + streamHandleObj.marshaledObject = new HandleRef(streamHandleMarshal, streamHandlePtr); + + return streamHandleObj; + } + } +} Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/ApiInterfaceMarshal.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Marshaling/Types/ApiInterfaceMarshal.cs (original) +++ freeswitch/branches/james/src/dotnet/Marshaling/Types/ApiInterfaceMarshal.cs Sat Aug 12 00:43:19 2006 @@ -35,14 +35,14 @@ namespace Freeswitch.Marshaling.Types { - internal delegate Status ApiFunctionMarshal(IntPtr text_in, IntPtr text_out, uint outlen); - [StructLayout(LayoutKind.Sequential)] internal class ApiInterfaceMarshal { - internal IntPtr interface_name; - internal IntPtr desc; - internal ApiFunctionMarshal function; - internal IntPtr next; + //[MarshalAs(UnmanagedType.LPStr)] + internal IntPtr interface_name; + //[MarshalAs(UnmanagedType.LPStr)] + internal IntPtr desc; + internal ApiFunction function; + internal IntPtr next; } } Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/ApplicationInterfaceMarshal.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Marshaling/Types/ApplicationInterfaceMarshal.cs (original) +++ freeswitch/branches/james/src/dotnet/Marshaling/Types/ApplicationInterfaceMarshal.cs Sat Aug 12 00:43:19 2006 @@ -32,24 +32,21 @@ using System; using System.Runtime.InteropServices; using Freeswitch.Types; -using Freeswitch.Marshaling; namespace Freeswitch.Marshaling.Types { - internal delegate void - ApplicationFunctionMarshal( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))] - CoreSession session, - IntPtr data); - [StructLayout(LayoutKind.Sequential)] internal class ApplicationInterfaceMarshal { - internal IntPtr interface_name; - internal ApplicationFunctionMarshal application_function; - internal IntPtr long_desc; - internal IntPtr short_desc; - internal IntPtr syntax; - internal IntPtr next; + // [MarshalAs(UnmanagedType.LPStr)] + internal IntPtr interface_name; + internal ApplicationFunction application_function; + // [MarshalAs(UnmanagedType.LPStr)] + internal IntPtr long_desc; + //[MarshalAs(UnmanagedType.LPStr)] + internal IntPtr short_desc; + //[MarshalAs(UnmanagedType.LPStr)] + internal IntPtr syntax; + internal IntPtr next; } -} +} \ No newline at end of file Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/BufferMarshal.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Marshaling/Types/BufferMarshal.cs (original) +++ freeswitch/branches/james/src/dotnet/Marshaling/Types/BufferMarshal.cs Sat Aug 12 00:43:19 2006 @@ -37,8 +37,10 @@ [StructLayout(LayoutKind.Sequential)] internal class BufferMarshal { + [MarshalAs(UnmanagedType.LPStr)] internal string data; internal int used; internal int datalen; + internal UInt32 id; } } Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerExtensionMarshal.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerExtensionMarshal.cs (original) +++ freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerExtensionMarshal.cs Sat Aug 12 00:43:19 2006 @@ -37,8 +37,8 @@ [StructLayout(LayoutKind.Sequential)] internal class CallerExtensionMarshal { - internal string extension_name; - internal string extension_number; + internal IntPtr extension_name; + internal IntPtr extension_number; internal IntPtr current_application; internal IntPtr last_application; internal IntPtr applications; Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerProfileMarshal.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerProfileMarshal.cs (original) +++ freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerProfileMarshal.cs Sat Aug 12 00:43:19 2006 @@ -37,16 +37,32 @@ [StructLayout(LayoutKind.Sequential)] internal class CallerProfileMarshal { - internal IntPtr dialplan; - internal IntPtr caller_id_name; - internal IntPtr caller_id_number; - internal IntPtr network_addr; - internal IntPtr ani; - internal IntPtr ani2; - internal IntPtr rdnis; - internal IntPtr destination_number; - internal IntPtr source; - internal IntPtr chan_name; - internal IntPtr uuid; + [MarshalAs(UnmanagedType.LPStr)] + internal string username; + [MarshalAs(UnmanagedType.LPStr)] + internal string dialplan; + [MarshalAs(UnmanagedType.LPStr)] + internal string caller_id_name; + [MarshalAs(UnmanagedType.LPStr)] + internal string caller_id_number; + [MarshalAs(UnmanagedType.LPStr)] + internal string network_addr; + [MarshalAs(UnmanagedType.LPStr)] + internal string ani; + [MarshalAs(UnmanagedType.LPStr)] + internal string ani2; + [MarshalAs(UnmanagedType.LPStr)] + internal string rdnis; + [MarshalAs(UnmanagedType.LPStr)] + internal string destination_number; + [MarshalAs(UnmanagedType.LPStr)] + internal string source; + [MarshalAs(UnmanagedType.LPStr)] + internal string chan_name; + [MarshalAs(UnmanagedType.LPStr)] + internal string uuid; + [MarshalAs(UnmanagedType.LPStr)] + internal string context; + internal IntPtr next; } } Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/ChannelMarshal.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Marshaling/Types/ChannelMarshal.cs (original) +++ freeswitch/branches/james/src/dotnet/Marshaling/Types/ChannelMarshal.cs Sat Aug 12 00:43:19 2006 @@ -31,32 +31,36 @@ */ using System; using System.Runtime.InteropServices; +using Freeswitch.Types; namespace Freeswitch.Marshaling.Types { [StructLayout(LayoutKind.Sequential)] internal class ChannelMarshal { - internal IntPtr name; - internal IntPtr dtmf_buffer; - internal IntPtr dtmf_mutex; - internal IntPtr session; - internal ChannelStateMarshal state; - internal ChannelFlagMarshal flags; - internal IntPtr caller_profile; - internal IntPtr originator_caller_profile; - internal IntPtr originatee_caller_profile; - internal IntPtr caller_extension; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 120)] - internal byte[] state_handlers; - internal int state_handler_index; - internal IntPtr variables; - internal ChannelTimetableMarshal times; - internal IntPtr private_info; - internal int freq; - internal int bits; - internal int channels; - internal int ms; - internal int kbps; + internal IntPtr name; + internal IntPtr dtmf_buffer; + internal IntPtr dtmf_mutex; + internal IntPtr flag_mutex; + internal IntPtr profile_mutex; + internal IntPtr session; + internal ChannelState state; + internal UInt32 flags; + internal IntPtr caller_profile; + internal IntPtr originator_caller_profile; + internal IntPtr originatee_caller_profile; + internal IntPtr caller_extension; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=120)] + internal byte[] state_handlers; + internal int state_handler_index; + internal IntPtr variables; + internal IntPtr times; + internal IntPtr private_info; + internal IntPtr hangup_cause; + internal int freq; + internal int bits; + internal int channels; + internal int ms; + internal int kbps; } } Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/CodecInterfaceMarshal.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Marshaling/Types/CodecInterfaceMarshal.cs (original) +++ freeswitch/branches/james/src/dotnet/Marshaling/Types/CodecInterfaceMarshal.cs Sat Aug 12 00:43:19 2006 @@ -35,4 +35,29 @@ namespace Freeswitch.Marshaling.Types { + [StructLayout(LayoutKind.Sequential)] + internal class CodecInterfaceMarshal + { + [MarshalAs(UnmanagedType.LPStr)] + internal string interface_name; + /* + internal CodecImplementation application_function; + [MarshalAs(UnmanagedType.LPStr)] + internal string long_desc; + [MarshalAs(UnmanagedType.LPStr)] + internal string short_desc; + [MarshalAs(UnmanagedType.LPStr)] + internal string syntax; + internal IntPtr next; } + + +struct switch_codec_interface { + ! the name of the interface + const char *interface_name; + ! a list of codec implementations related to the codec + const switch_codec_implementation_t *implementations; + const struct switch_codec_interface *next; +};*/ + } +} \ No newline at end of file Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/CoreSessionMarshal.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Marshaling/Types/CoreSessionMarshal.cs (original) +++ freeswitch/branches/james/src/dotnet/Marshaling/Types/CoreSessionMarshal.cs Sat Aug 12 00:43:19 2006 @@ -35,11 +35,12 @@ namespace Freeswitch.Marshaling.Types { - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Sequential, Pack=1)] internal class CoreSessionMarshal { - internal uint id; - internal IntPtr name; + internal UInt32 id; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=80)] + internal byte[] name; internal int thread_running; internal IntPtr pool; internal IntPtr channel; @@ -51,24 +52,29 @@ internal IntPtr raw_write_buffer; internal FrameMarshal raw_write_frame; internal FrameMarshal enc_write_frame; - /* -switch_frame raw_write_frame -switch_frame enc_write_frame -unsigned char * raw_write_buf [SWITCH_RECCOMMENDED_BUFFER_SIZE] -unsigned char * enc_write_buf [SWITCH_RECCOMMENDED_BUFFER_SIZE] -switch_buffer * raw_read_buffer -switch_frame raw_read_frame -switch_frame enc_read_frame -unsigned char * raw_read_buf [SWITCH_RECCOMMENDED_BUFFER_SIZE] -unsigned char * enc_read_buf [SWITCH_RECCOMMENDED_BUFFER_SIZE] -switch_audio_resampler * read_resampler -switch_audio_resampler * write_resampler -switch_mutex_t * mutex -switch_thread_cond_t * cond -void * streams [SWITCH_MAX_STREAMS] -int stream_count -char uuid_str [SWITCH_UUID_FORMATTED_LENGTH+1] -void * private_info */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst=2048)] + internal byte[] raw_write_buf; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=2048)] + internal byte[] enc_write_buf; + internal IntPtr raw_read_buffer; + internal FrameMarshal raw_read_frame; + internal FrameMarshal enc_read_frame; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=2048)] + internal byte[] raw_read_buf; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=2048)] + internal byte[] enc_read_buf; + internal IntPtr read_resampler; + internal IntPtr write_resampler; + internal IntPtr mutex; + internal IntPtr cond; + internal IntPtr rwlock; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=128)] + internal IntPtr[] streams; + internal int stream_count; + /* 36 + 1 char string, but need to grab 40 bytes */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst=40)] + internal byte[] uuid_str; + internal IntPtr private_info; + internal IntPtr event_queue; } - } Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/FrameMarshal.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Marshaling/Types/FrameMarshal.cs (original) +++ freeswitch/branches/james/src/dotnet/Marshaling/Types/FrameMarshal.cs Sat Aug 12 00:43:19 2006 @@ -31,6 +31,7 @@ */ using System; using System.Runtime.InteropServices; +using Freeswitch.Types; namespace Freeswitch.Marshaling.Types { @@ -38,10 +39,16 @@ internal class FrameMarshal { internal IntPtr codec; + internal IntPtr source; + internal IntPtr packet; + internal UInt32 packetlen; internal IntPtr data; - internal int datalen; - internal int buflen; - internal int samples; - internal int rate; + internal UInt32 datalen; + internal UInt32 buflen; + internal UInt32 samples; + internal UInt32 rate; + internal byte payload; + internal UInt32 timestamp; + internal byte flags; } } Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/IOEventHooksMarshal.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Marshaling/Types/IOEventHooksMarshal.cs (original) +++ freeswitch/branches/james/src/dotnet/Marshaling/Types/IOEventHooksMarshal.cs Sat Aug 12 00:43:19 2006 @@ -40,6 +40,7 @@ internal IntPtr outgoing_channel; internal IntPtr answer_channel; internal IntPtr receive_message; + internal IntPtr receive_event; internal IntPtr read_frame; internal IntPtr write_frame; internal IntPtr kill_channel; Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleInterfaceMarshal.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleInterfaceMarshal.cs (original) +++ freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleInterfaceMarshal.cs Sat Aug 12 00:43:19 2006 @@ -31,6 +31,7 @@ */ using System; using System.Runtime.InteropServices; +using Freeswitch.Types; namespace Freeswitch.Marshaling.Types { @@ -48,4 +49,17 @@ internal IntPtr speech_interface; internal IntPtr directory_interface; } + + + [StructLayout(LayoutKind.Sequential)] + internal class StreamHandleMarshal + { + internal IntPtr write_function; + internal IntPtr data; + internal IntPtr end; + internal int data_size; + internal int data_len; + internal IntPtr _event; + } + } Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleMarshal.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleMarshal.cs (original) +++ freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleMarshal.cs Sat Aug 12 00:43:19 2006 @@ -35,26 +35,20 @@ namespace Freeswitch.Marshaling.Types { - public delegate Status ModuleLoadMarshal(ref IntPtr loadable_module_interface, string blah); - public delegate Status ModuleReloadMarshal(); - public delegate bool ModulePauseMarshal(); - public delegate bool ModuleResumeMarshal(); - public delegate bool ModuleStatusMarshal(); - public delegate Status ModuleRuntimeMarshal(); - public delegate bool ModuleShutdownMarshal(); + [StructLayout(LayoutKind.Sequential)] public class LoadableModuleMarshal { - public IntPtr filename; - public IntPtr module_interface; - public IntPtr lib; - public ModuleLoadMarshal module_load; - public ModuleReloadMarshal module_reload; - public ModulePauseMarshal module_pause; - public ModuleResumeMarshal module_resume; - public ModuleStatusMarshal module_status; - public ModuleRuntimeMarshal module_runtime; - public ModuleShutdownMarshal module_shutdown; + public IntPtr filename; + public IntPtr module_interface; + public IntPtr lib; + public ModuleLoad module_load; + public ModuleReload module_reload; + public ModulePause module_pause; + public ModuleResume module_resume; + public ModuleStatus module_status; + public ModuleRuntime module_runtime; + public ModuleShutdown module_shutdown; } } Modified: freeswitch/branches/james/src/dotnet/Module.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Module.cs (original) +++ freeswitch/branches/james/src/dotnet/Module.cs Sat Aug 12 00:43:19 2006 @@ -31,6 +31,7 @@ */ using System; using System.Collections; +using System.Reflection; using System.Runtime.InteropServices; using System.Text; using Freeswitch; @@ -42,32 +43,38 @@ { public class Module { + + + ModuleLoad load; + private LoadableModuleInterfaceMarshal module_interface = new LoadableModuleInterfaceMarshal(); private ArrayList apiInterfaces = new ArrayList(); private ArrayList applicationInterfaces = new ArrayList(); - protected ModuleLoad moduleLoad; + //protected ModuleLoad moduleLoad; private string name; - - public string Name - { - set { name = value; } - get { return name; } - } + private string filename = Assembly.GetCallingAssembly().GetName().Name; + private LoadableModuleMarshal module = new LoadableModuleMarshal(); public Module() { - Console.WriteLine("Running module .ctor"); + Console.WriteLine("Running module .blehctor"); + + load = new ModuleLoad(Load); } + /// <summary> + /// Implementation of ModuleLoad Delegate + /// </summary> + /// <param name="module"></param> + /// <param name="name"></param> + /// <returns></returns> public Status Load(ref IntPtr module, string name) { - if (moduleLoad != null) - moduleLoad(); - module = Marshal.AllocHGlobal(Marshal.SizeOf(module_interface)); - module_interface.module_name = Marshal.StringToHGlobalAnsi(Name); + module_interface.module_name = Marshal.StringToHGlobalAnsi(filename); + /* For each API interface */ if (apiInterfaces.Count > 0) { foreach (Api api in apiInterfaces) @@ -75,11 +82,9 @@ ApiInterfaceMarshal apiInterfaceMarshal = new ApiInterfaceMarshal(); IntPtr apiInterfacePtr = Marshal.AllocHGlobal(Marshal.SizeOf(apiInterfaceMarshal)); - Console.WriteLine(api.Name); - apiInterfaceMarshal.interface_name = Marshal.StringToHGlobalAnsi(api.Name); apiInterfaceMarshal.desc = Marshal.StringToHGlobalAnsi(api.Description); - apiInterfaceMarshal.function = new ApiFunctionMarshal(api.ApiFunctionWrapper); + apiInterfaceMarshal.function = new ApiFunction(api.ApiFunction); api.handle = new HandleRef(apiInterfaceMarshal, apiInterfacePtr); @@ -89,26 +94,25 @@ 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); - - /* APPLICATIONS */ + } + /* For each Application interface */ + if (applicationInterfaces.Count > 0) + { foreach (Application application in applicationInterfaces) { ApplicationInterfaceMarshal applicationInterfaceMarshal = new ApplicationInterfaceMarshal(); IntPtr applicationInterfacePtr = Marshal.AllocHGlobal(Marshal.SizeOf(applicationInterfaceMarshal)); - Console.WriteLine("APPLICATION: {0}", application.Name); - applicationInterfaceMarshal.interface_name = Marshal.StringToHGlobalAnsi(application.Name); applicationInterfaceMarshal.syntax = Marshal.StringToHGlobalAnsi(application.Syntax); applicationInterfaceMarshal.long_desc = Marshal.StringToHGlobalAnsi(application.LongDescription); applicationInterfaceMarshal.short_desc = Marshal.StringToHGlobalAnsi(application.ShortDescription); - applicationInterfaceMarshal.application_function = new ApplicationFunctionMarshal(application.ApplicationFunctionWrapper); + applicationInterfaceMarshal.application_function = new ApplicationFunction(application.ApplicationFunction); application.handle = new HandleRef(applicationInterfaceMarshal, applicationInterfacePtr); Marshal.StructureToPtr(applicationInterfaceMarshal, application.handle.Handle, true); - } Application applicationIndex = (Application)applicationInterfaces[0]; @@ -133,13 +137,12 @@ public void Register() { - LoadableModuleMarshal module = new LoadableModuleMarshal(); - - module.filename = Marshal.StringToHGlobalAnsi(Name); - - module.module_load = new ModuleLoadMarshal(Load); + module.module_load = new ModuleLoad(Load); - Switch.switch_loadable_module_build_dynamic("filename", module.module_load, module.module_runtime, module.module_shutdown); + Switch.switch_loadable_module_build_dynamic(filename, + module.module_load, + module.module_runtime, + module.module_shutdown); } Modified: freeswitch/branches/james/src/dotnet/Modules/Api.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Modules/Api.cs (original) +++ freeswitch/branches/james/src/dotnet/Modules/Api.cs Sat Aug 12 00:43:19 2006 @@ -61,21 +61,5 @@ set { apiFunction = value; } get { return apiFunction; } } - - public Status ApiFunctionWrapper(IntPtr text_in, IntPtr text_out, uint outlen) - { - Encoding ansiEncoding = Encoding.GetEncoding(1252); - string command = Marshal.PtrToStringAnsi(text_in); - int outputLength = (int)outlen; - - string output = ApiFunction(command); - - if (output.Length < outputLength) - outputLength = output.Length; - - Marshal.Copy(ansiEncoding.GetBytes(output.ToString()), 0, text_out, outputLength); - - return Status.Success; - } } } \ No newline at end of file Modified: freeswitch/branches/james/src/dotnet/Modules/Application.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Modules/Application.cs (original) +++ freeswitch/branches/james/src/dotnet/Modules/Application.cs Sat Aug 12 00:43:19 2006 @@ -77,12 +77,5 @@ set { applicationFunction = value; } get { return applicationFunction; } } - - public void ApplicationFunctionWrapper(CoreSession session, IntPtr data) - { - string applicationData = Marshal.PtrToStringAnsi(data); - - ApplicationFunction(session, applicationData); - } } } \ No newline at end of file Modified: freeswitch/branches/james/src/dotnet/Switch/CallerProfile.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Switch/CallerProfile.cs (original) +++ freeswitch/branches/james/src/dotnet/Switch/CallerProfile.cs Sat Aug 12 00:43:19 2006 @@ -34,18 +34,41 @@ using System.Runtime.InteropServices; using Freeswitch.Types; using Freeswitch.Marshaling; +using Freeswitch.Marshaling.Types; namespace Freeswitch { public partial class Switch { + /* + * TODO: Figure out how to stop mono from trying to free the returned string. + */ [DllImport("freeswitch")] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CallerProfileMarshaler))] + //[return: MarshalAs(UnmanagedType.LPStr)] public extern static + IntPtr switch_caller_get_field_by_name( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))] + CallerProfile caller_profile, + [MarshalAs(UnmanagedType.LPStr)] + string name); + /* + [DllImport("freeswitch")] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))] + public extern static + CallerProfile switch_caller_profile_clone( + [MarshalAs + switch_core_session_t *session, switch_caller_profile_t *tocopy) + */ + + [DllImport("freeswitch")] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))] + public extern static CallerProfile switch_caller_profile_new( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(MemoryPoolMarshaler))] + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(MemoryPoolMarshaler))] MemoryPool pool, [MarshalAs(UnmanagedType.LPStr)] + string username, + [MarshalAs(UnmanagedType.LPStr)] string dialplan, [MarshalAs(UnmanagedType.LPStr)] string callerIdName, @@ -61,6 +84,8 @@ string rdnis, [MarshalAs(UnmanagedType.LPStr)] string source, + [MarshalAs(UnmanagedType.LPStr)] + string context, [MarshalAs(UnmanagedType.LPStr)] string destinationNumber); } Modified: freeswitch/branches/james/src/dotnet/Switch/Channel.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Switch/Channel.cs (original) +++ freeswitch/branches/james/src/dotnet/Switch/Channel.cs Sat Aug 12 00:43:19 2006 @@ -40,42 +40,56 @@ public partial class Switch { [DllImport("freeswitch")] - extern public static + public extern static ChannelState switch_channel_set_state( [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] Channel channel, ChannelState channelState); [DllImport("freeswitch")] - extern public static + public extern static ChannelState switch_channel_get_state( [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] Channel channel); [DllImport("freeswitch")] - extern public static + public extern static Status switch_channel_answer( [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] Channel channel); [DllImport("freeswitch")] - extern public static + public extern static Status switch_channel_hangup( [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] Channel channel); [DllImport("freeswitch")] [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerExtensionMarshaler))] - extern public static + public extern static CallerExtension switch_channel_get_caller_extension( [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] Channel channel); [DllImport("freeswitch")] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CallerProfileMarshaler))] public extern static CallerProfile switch_channel_get_caller_profile( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ChannelMarshaler))] + Channel channel); + + [DllImport("freeswitch")] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))] + public extern static + CallerProfile switch_channel_get_originator_caller_profile( [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] + Channel channel); + + [DllImport("freeswitch")] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CallerProfileMarshaler))] + public extern static + CallerProfile switch_channel_get_originatee_caller_profile( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ChannelMarshaler))] Channel channel); [DllImport("freeswitch")] Modified: freeswitch/branches/james/src/dotnet/Switch/LoadableModule.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Switch/LoadableModule.cs (original) +++ freeswitch/branches/james/src/dotnet/Switch/LoadableModule.cs Sat Aug 12 00:43:19 2006 @@ -61,8 +61,11 @@ Status switch_loadable_module_build_dynamic( string filename, - ModuleLoadMarshal switch_module_load, - ModuleRuntimeMarshal switch_module_runtime, - ModuleShutdownMarshal switch_module_shutdown); + [MarshalAs(UnmanagedType.FunctionPtr)] + ModuleLoad switch_module_load, + [MarshalAs(UnmanagedType.FunctionPtr)] + ModuleRuntime switch_module_runtime, + [MarshalAs(UnmanagedType.FunctionPtr)] + ModuleShutdown switch_module_shutdown); } } Added: freeswitch/branches/james/src/dotnet/Switch/StreamHandle.cs ============================================================================== --- (empty file) +++ freeswitch/branches/james/src/dotnet/Switch/StreamHandle.cs Sat Aug 12 00:43:19 2006 @@ -0,0 +1,61 @@ +/* + * 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> + * + * + * LoadableModule.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using Freeswitch.Types; +using Freeswitch.Marshaling.Types; + +namespace Freeswitch +{ + /* + * SWITCH_DECLARE(switch_status_t) switch_loadable_module_load_module(char *dir, char *fname) + * SWITCH_DECLARE(switch_status_t) switch_loadable_module_build_dynamic(char *filename, + * SWITCH_DECLARE(switch_status_t) switch_loadable_module_init() + * SWITCH_DECLARE(void) switch_loadable_module_shutdown(void) + * SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoint_interface(char *name) + * SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(char *name) + * SWITCH_DECLARE(switch_dialplan_interface_t *) switch_loadable_module_get_dialplan_interface(char *name) + * SWITCH_DECLARE(switch_timer_interface_t *) switch_loadable_module_get_timer_interface(char *name) + * SWITCH_DECLARE(switch_application_interface_t *) switch_loadable_module_get_application_interface(char *name) + * SWITCH_DECLARE(switch_api_interface_t *) switch_loadable_module_get_api_interface(char *name) + * SWITCH_DECLARE(switch_file_interface_t *) switch_loadable_module_get_file_interface(char *name) + * SWITCH_DECLARE(switch_speech_interface_t *) switch_loadable_module_get_speech_interface(char *name) + * SWITCH_DECLARE(switch_directory_interface_t *) switch_loadable_module_get_directory_interface(char *name) + * SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, switch_codec_interface_t **array, + * SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_codec_interface_t **array, + * SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, char *retbuf, switch_size_t len) + */ + public partial class Switch + { + + } +} Modified: freeswitch/branches/james/src/dotnet/Types/ApiFunction.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Types/ApiFunction.cs (original) +++ freeswitch/branches/james/src/dotnet/Types/ApiFunction.cs Sat Aug 12 00:43:19 2006 @@ -28,10 +28,4 @@ * * ApiFunction.cs -- * - */ -using System; - -namespace Freeswitch.Types -{ - public delegate string ApiFunction(string command); -} + */ \ No newline at end of file Modified: freeswitch/branches/james/src/dotnet/Types/ApplicationFunction.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Types/ApplicationFunction.cs (original) +++ freeswitch/branches/james/src/dotnet/Types/ApplicationFunction.cs Sat Aug 12 00:43:19 2006 @@ -33,5 +33,5 @@ namespace Freeswitch.Types { - public delegate void ApplicationFunction(CoreSession coreSession, string data); + } Modified: freeswitch/branches/james/src/dotnet/Types/ApplicationInterface.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Types/ApplicationInterface.cs (original) +++ freeswitch/branches/james/src/dotnet/Types/ApplicationInterface.cs Sat Aug 12 00:43:19 2006 @@ -36,6 +36,7 @@ namespace Freeswitch.Types { + /* public class ApplicationInterface { private string interface_name; @@ -45,4 +46,5 @@ private string syntax; //const struct switch_application_interface *next; } + * */ } Modified: freeswitch/branches/james/src/dotnet/Types/CallerExtension.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Types/CallerExtension.cs (original) +++ freeswitch/branches/james/src/dotnet/Types/CallerExtension.cs Sat Aug 12 00:43:19 2006 @@ -31,6 +31,7 @@ */ using System; using System.Runtime.InteropServices; +using Freeswitch.Marshaling.Types; namespace Freeswitch.Types { @@ -40,12 +41,22 @@ public string ExtensionName { - get { throw new NotImplementedException(); } + get + { + CallerExtensionMarshal callerExtension = (CallerExtensionMarshal)marshaledObject.Wrapper; + + return Marshal.PtrToStringAnsi(callerExtension.extension_name); + } } public string ExtensionNumber { - get { throw new NotImplementedException(); } + get + { + CallerExtensionMarshal callerExtension = (CallerExtensionMarshal)marshaledObject.Wrapper; + + return Marshal.PtrToStringAnsi(callerExtension.extension_number); + } } } } Modified: freeswitch/branches/james/src/dotnet/Types/CallerProfile.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Types/CallerProfile.cs (original) +++ freeswitch/branches/james/src/dotnet/Types/CallerProfile.cs Sat Aug 12 00:43:19 2006 @@ -39,11 +39,8 @@ { internal HandleRef marshaledObject; - public CallerProfile() - { - } - - public CallerProfile(CoreSession session, + public static CallerProfile New(MemoryPool pool, + string username, string dialplan, string callerIdName, string callerIdNumber, @@ -52,105 +49,91 @@ string ani2, string rdnis, string source, + string context, string destinationNumber) { - MemoryPool pool = session.Pool; + return Switch.switch_caller_profile_new(pool, username, dialplan, callerIdName, callerIdNumber, networkAddress, ani, ani2, rdnis, source, context, destinationNumber); + } + + public string GetFieldByName(string field) + { + IntPtr ptr; - CallerProfile profile = Switch.switch_caller_profile_new(pool, dialplan, callerIdName, callerIdNumber, networkAddress, ani, ani2, rdnis, source, destinationNumber); + ptr = Switch.switch_caller_get_field_by_name(this, field); - marshaledObject = profile.marshaledObject; + if (ptr != IntPtr.Zero) + return Marshal.PtrToStringAnsi(ptr); + else + return ""; } - + + /* + * Properties + */ public string Dialplan { - set { throw new NotImplementedException(); } - get - { - CallerProfileMarshal profile = (CallerProfileMarshal)marshaledObject.Wrapper; - - return Marshal.PtrToStringAnsi(profile.dialplan); - } + get { return GetFieldByName("dialplan"); } } public string CallerIdName { - set - { - throw new NotImplementedException(); - } - get - { - CallerProfileMarshal profile = (CallerProfileMarshal)marshaledObject.Wrapper; - - return Marshal.PtrToStringAnsi(profile.caller_id_name); - } + get { return GetFieldByName("caller_id_name"); } } public string CallerIdNumber { - set - { - throw new NotImplementedException(); - } - get - { - CallerProfileMarshal profile = (CallerProfileMarshal)marshaledObject.Wrapper; - - return Marshal.PtrToStringAnsi(profile.caller_id_number); - } + get { return GetFieldByName("caller_id_number"); } } public string NetworkAddress { - set { throw new NotImplementedException(); } - get - { - CallerProfileMarshal profile = (CallerProfileMarshal)marshaledObject.Wrapper; - - return Marshal.PtrToStringAnsi(profile.network_addr); - } + get { return GetFieldByName("network_addr"); } } public string Ani { - set { throw new NotImplementedException(); } - get { throw new NotImplementedException(); } + get { return GetFieldByName("ani"); } } public string Ani2 { - set { throw new NotImplementedException(); } - get { throw new NotImplementedException(); } + get { return GetFieldByName("ani2"); } } public string Rdnis { - set { throw new NotImplementedException(); } - get - { - CallerProfileMarshal profile = (CallerProfileMarshal)marshaledObject.Wrapper; + get { return GetFieldByName("rdnis"); } + } - return Marshal.PtrToStringAnsi(profile.rdnis); - } + public string Source + { + get { return GetFieldByName("source"); } } + public string Context + { + get { return GetFieldByName("context"); } + } + public string DestinationNumber { - set { throw new NotImplementedException(); } - get { throw new NotImplementedException(); } + get { return GetFieldByName("destination_number"); } } public string ChannelName { - set { throw new NotImplementedException(); } - get { throw new NotImplementedException(); } + get { return GetFieldByName("chan_name"); } } public string Uuid { - set { throw new NotImplementedException(); } - get { throw new NotImplementedException(); } + get{ return GetFieldByName("uuid"); } + } + + public string Username + { + get { return GetFieldByName("username"); } } } } Modified: freeswitch/branches/james/src/dotnet/Types/Channel.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Types/Channel.cs (original) +++ freeswitch/branches/james/src/dotnet/Types/Channel.cs Sat Aug 12 00:43:19 2006 @@ -35,6 +35,31 @@ namespace Freeswitch.Types { + /* + * char *name; + switch_buffer_t *dtmf_buffer; + switch_mutex_t *dtmf_mutex; + switch_mutex_t *flag_mutex; + switch_mutex_t *profile_mutex; + switch_core_session_t *session; + switch_channel_state_t state; + uint32_t flags; + switch_caller_profile_t *caller_profile; + switch_caller_profile_t *originator_caller_profile; + switch_caller_profile_t *originatee_caller_profile; + switch_caller_extension_t *caller_extension; + const switch_state_handler_table_t *state_handlers[SWITCH_MAX_STATE_HANDLERS]; + int state_handler_index; + switch_hash_t *variables; + switch_channel_timetable_t *times; + void *private_info; + switch_call_cause_t hangup_cause; + int freq; + int bits; + int channels; + int ms; + int kbps; + */ public class Channel { internal HandleRef marshaledObject; @@ -43,7 +68,7 @@ { get { - ChannelMarshal channel = (ChannelMarshal)marshaledObject.Wrapper; + ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper; return Marshal.PtrToStringAnsi(channel.name); } @@ -51,7 +76,12 @@ public Buffer DtmfBuffer { - get { throw new NotImplementedException(); } + get + { + Console.WriteLine("Buffer"); + return new Buffer(); + //throw new NotImplementedException(); + } } public ChannelState State @@ -81,7 +111,12 @@ public ChannelFlag Flags { - get { throw new NotImplementedException(); } + get + { + Console.WriteLine("ChannelFlag"); + return new ChannelFlag(); + //throw new NotImplementedException(); + } } public CallerProfile CallerProfile @@ -94,48 +129,82 @@ public CallerProfile OriginatorCallerProfile { - get { throw new NotImplementedException(); } + get + { + return Switch.switch_channel_get_originator_caller_profile(this); + } } public CallerProfile OriginateeCallerProfile { - get { throw new NotImplementedException(); } + get + { + return Switch.switch_channel_get_originatee_caller_profile(this); + } } public CallerExtension CallerExtension { - get { throw new NotImplementedException(); } + get + { + return Switch.switch_channel_get_caller_extension(this); + } } public ChannelTimetable Times { - get { throw new NotImplementedException(); } + get + { + Console.WriteLine("Channel Timetable"); + return new ChannelTimetable(); + // throw new NotImplementedException(); + } } public int Freq { - get { throw new NotImplementedException(); } + get + { + ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper; + + return channel.freq; + } } public int Bits { - get { throw new NotImplementedException(); } + get + { + ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper; + + return channel.bits; + } } public int Channels { - get { throw new NotImplementedException(); } + get + { + ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper; + + return channel.channels; + } } public int Ms { - get { throw new NotImplementedException(); } + get + { + ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper; + + return channel.ms; + } } public int Kbps { get { - ChannelMarshal channel = (ChannelMarshal)marshaledObject.Wrapper; + ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper; return channel.kbps; } Modified: freeswitch/branches/james/src/dotnet/Types/CoreSession.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Types/CoreSession.cs (original) +++ freeswitch/branches/james/src/dotnet/Types/CoreSession.cs Sat Aug 12 00:43:19 2006 @@ -37,25 +37,95 @@ namespace Freeswitch.Types { + /* + * uint32_t id; + char name[80]; + int thread_running; + switch_memory_pool_t *pool; + switch_channel_t *channel; + switch_thread_t *thread; + const switch_endpoint_interface_t *endpoint_interface; + switch_io_event_hooks_t event_hooks; + switch_codec_t *read_codec; + switch_codec_t *write_codec; + + switch_buffer_t *raw_write_buffer; + switch_frame_t raw_write_frame; + switch_frame_t enc_write_frame; + uint8_t raw_write_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE]; + uint8_t enc_write_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE]; + + switch_buffer_t *raw_read_buffer; + switch_frame_t raw_read_frame; + switch_frame_t enc_read_frame; + uint8_t raw_read_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE]; + uint8_t enc_read_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE]; + + + switch_audio_resampler_t *read_resampler; + switch_audio_resampler_t *write_resampler; + + switch_mutex_t *mutex; + switch_thread_cond_t *cond; + + switch_thread_rwlock_t *rwlock; + + void *streams[SWITCH_MAX_STREAMS]; + int stream_count; + + char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; + void *private_info; + switch_queue_t *event_queue; + */ public class CoreSession { public HandleRef marshaledObject; - public ulong Id + /* + * Properties + */ + public UInt32 Id { - get { throw new NotImplementedException(); } + get + { + CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper; + + return coreSessionMarshal.id; + } } public string Name { - get { throw new NotImplementedException(); } + get + { + CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal) marshaledObject.Wrapper; + + return Encoding.ASCII.GetString(coreSessionMarshal.name); + } } - public int IsThreadRunning + public bool IsThreadRunning { - get { throw new NotImplementedException(); ; } + get + { + CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper; + + if (coreSessionMarshal.thread_running <= 0) + return false; + else + return true; + } } + public MemoryPool Pool + { + get + { + return Switch.switch_core_session_get_pool(this); + } + } + + public Channel Channel { get @@ -64,13 +134,16 @@ } } - public MemoryPool Pool + public string Uuid { get { - return Switch.switch_core_session_get_pool(this); + CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper; + + return Encoding.ASCII.GetString(coreSessionMarshal.uuid_str); } } + public CoreSession OutgoingChannel(string endpointName, CallerProfile callerProfile) { Modified: freeswitch/branches/james/src/dotnet/Types/LoadableModuleInterface.cs ============================================================================== --- freeswitch/branches/james/src/dotnet/Types/LoadableModuleInterface.cs (original) +++ freeswitch/branches/james/src/dotnet/Types/LoadableModuleInterface.cs Sat Aug 12 00:43:19 2006 @@ -33,10 +33,17 @@ using System.Collections; using System.Runtime.InteropServices; using System.Text; +using Freeswitch.Marshaling; namespace Freeswitch.Types { - public delegate void ModuleLoad(); + public delegate Status WriteFunction( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StreamHandleMarshaler))] + StreamHandle streamHandle, + [MarshalAs(UnmanagedType.LPStr)] + string fmt); + + //public delegate void ModuleLoad(); public class LoadableModuleInterface { Added: freeswitch/branches/james/src/dotnet/Types/Module.cs ============================================================================== --- (empty file) +++ freeswitch/branches/james/src/dotnet/Types/Module.cs Sat Aug 12 00:43:19 2006 @@ -0,0 +1,59 @@ +/* + * 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> + * + * + * Module.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using Freeswitch.Marshaling; + +namespace Freeswitch.Types +{ + public delegate Status ModuleReload(); + public delegate bool ModulePause(); + public delegate bool ModuleResume(); + public delegate bool ModuleStatus(); + public delegate Status ModuleRuntime(); + public delegate bool ModuleShutdown(); + public delegate Status ModuleLoad(ref IntPtr module, string name); + + public delegate void + ApplicationFunction( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.LPStr)] + string data); + + public delegate Status + ApiFunction( + [MarshalAs(UnmanagedType.LPStr)] + string command, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StreamHandleMarshaler))] + StreamHandle streamHandle); +} Added: freeswitch/branches/james/src/dotnet/Types/ModuleInterfaces.cs ============================================================================== --- (empty file) +++ freeswitch/branches/james/src/dotnet/Types/ModuleInterfaces.cs Sat Aug 12 00:43:19 2006 @@ -0,0 +1,69 @@ +/* + * 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> + * + * + * ApplicationInterface.cs -- + * + */ +using System; +using System.Collections; +using System.Runtime.InteropServices; +using System.Text; + +namespace Freeswitch.Types +{ + /* + public class ApplicationInterface + { + private string interface_name; + private ApplicationFunction application_function; + private string long_desc; + private string short_desc; + private string syntax; + //const struct switch_application_interface *next; + + public string InterfaceName + { + get { return interface_name; } + } + + public ApplicationFunction ApplicationFunction + { + get { return application_function; } + } + + public string LongDesc + { + get { return long_desc; } + } + + public string ShortDesc + { + get { return short_desc; } + } + }*/ +} Added: freeswitch/branches/james/src/dotnet/Types/StreamHandle.cs ============================================================================== --- (empty file) +++ freeswitch/branches/james/src/dotnet/Types/StreamHandle.cs Sat Aug 12 00:43:19 2006 @@ -0,0 +1,59 @@ +/* + * 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> + * + * + * StreamHandle.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using Freeswitch.Marshaling.Types; + +namespace Freeswitch.Types +{ + public class StreamHandle + { + internal HandleRef marshaledObject; + internal WriteFunction writeFunction; + //internal WriteFunctions; //switch_stream_handle_write_function_t write_function; + /* + * internal + void *data; + void *end; + switch_size_t data_size; + switch_size_t data_len; + switch_event_t *event; + */ + public void Write(string data) + { + StreamHandleMarshal streamHandleMarshal = (StreamHandleMarshal) marshaledObject.Wrapper; + WriteFunction writeFunction = (WriteFunction) Marshal.GetDelegateForFunctionPointer(streamHandleMarshal.write_function, typeof(WriteFunction)); + + writeFunction(this, data); + } + } +} Added: freeswitch/branches/james/src/mod/dotnet/Info/Info.cs ============================================================================== --- (empty file) +++ freeswitch/branches/james/src/mod/dotnet/Info/Info.cs Sat Aug 12 00:43:19 2006 @@ -0,0 +1,124 @@ +using System; +using System.Text; +using Freeswitch; +using Freeswitch.Modules; +using Freeswitch.Types; + +namespace Info +{ + public class Info : Module + { + public Info() + { + Console.WriteLine("Running INFO ctor"); + + AddApiInterface(new InfoApi()); + AddApplicationInterface(new InfoApplication()); + + Register(); + } + + } + + public class InfoApplication : Application + { + public InfoApplication() + { + Name = "dotnetbridge"; + Syntax = "record /file/name"; + ShortDescription = "short description"; + LongDescription = "long description, long description, long description"; + ApplicationFunction = new ApplicationFunction(BridgeApplicationFunction); + } + + public Status OnDtmf(CoreSession session, string dtmf) + { + + Console.WriteLine("Digits: {0}", dtmf); + + return Status.Success; + } + + public void BridgeApplicationFunction(CoreSession coreSession, string data) + { + Console.WriteLine("%%% Processing new call"); + Console.WriteLine("%%% Data: {0}", data); + Common.DumpProperties("coreSession", coreSession); + Common.DumpProperties("coreSession.Channel", coreSession.Channel); + + Common.DumpProperties("coreSession.Channel.CallerExtension", coreSession.Channel.CallerExtension); + Common.DumpProperties("coreSession.Channel.CallerProfile", coreSession.Channel.CallerProfile); + //Console.WriteLine("%%% Name: {0}", coreSession.Name); + //Console.WriteLine("%%% Name: {0}", coreSession.Name); + //Console.WriteLine("%%% Name: {0}", coreSession.Name); + //Console.WriteLine("%%% Name: {0}", coreSession.Name); + + + CoreSession peerSession; + Channel callerChannel = coreSession.Channel; + + CallerProfile callerProfile; + CallerProfile callerCallerProfile = callerChannel.CallerProfile; + + string chanType = "exosip"; + string chanData = "666@10.0.0.60"; + uint timelimit = 60; + + Console.WriteLine(callerCallerProfile.Dialplan); + Console.WriteLine(callerCallerProfile.CallerIdName); + Console.WriteLine(callerCallerProfile.CallerIdNumber); + Console.WriteLine(callerCallerProfile.NetworkAddress); + + try + { + callerProfile = CallerProfile.New(coreSession.Pool, + callerCallerProfile.Username, + callerCallerProfile.Dialplan, + callerCallerProfile.CallerIdName, + callerCallerProfile.CallerIdNumber, + callerCallerProfile.NetworkAddress, + "ani", + "ani2", + callerCallerProfile.Rdnis, + callerCallerProfile.Source, + callerCallerProfile.Context, + chanData); + + Console.WriteLine(callerProfile.Dialplan); + Console.WriteLine(callerProfile.CallerIdName); + Console.WriteLine(callerProfile.CallerIdNumber); + Console.WriteLine(callerProfile.NetworkAddress); + + peerSession = coreSession.OutgoingChannel(chanType, callerProfile); + + Console.WriteLine("Peer Channel Name: " + peerSession.Channel.Name); + + } + catch (Exception e) + { + callerChannel.Hangup(); + return; + } + + Ivr.MultiThreadedBridge(coreSession, peerSession, timelimit); + + } + } + + public class InfoApi : Api + { + public InfoApi() + { + Name = "info"; + Description = "blah blah blah"; + ApiFunction = new ApiFunction(InfoApiFunction); + } + + public Status InfoApiFunction(string command, StreamHandle streamHandle) + { + streamHandle.Write("It is " + DateTime.Now.ToLongTimeString()); + + return Status.Success; + } + } +} Added: freeswitch/branches/james/src/mod/dotnet/Info/Info.csproj ============================================================================== --- (empty file) +++ freeswitch/branches/james/src/mod/dotnet/Info/Info.csproj Sat Aug 12 00:43:19 2006 @@ -0,0 +1,53 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{B8A7E58B-2480-4A56-B39B-5FF9698A7124}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Info</RootNamespace> + <AssemblyName>Info</AssemblyName> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Info.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\dotnet\FreeSwitchDotNet.csproj"> + <Project>{251CAABC-16C3-4593-A491-603B908094E0}</Project> + <Name>FreeSwitch</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Added: freeswitch/branches/james/src/mod/dotnet/Info/Info.dll ============================================================================== Binary file. No diff available. Added: freeswitch/branches/james/src/mod/dotnet/Info/Info.suo ============================================================================== Binary file. No diff available. Added: freeswitch/branches/james/src/mod/dotnet/Info/Makefile ============================================================================== --- (empty file) +++ freeswitch/branches/james/src/mod/dotnet/Info/Makefile Sat Aug 12 00:43:19 2006 @@ -0,0 +1,10 @@ +all: Info.so + +Info.so: + gmcs -t:library -r:../../../dotnet/Freeswitch.dll -out:Info.dll Properties/AssemblyInfo.cs Info.cs + +clean: + rm -fr *.dll + +install: + cp -f Info.dll /usr/local/freeswitch/mod/mono Added: freeswitch/branches/james/src/mod/dotnet/Info/Properties/AssemblyInfo.cs ============================================================================== --- (empty file) +++ freeswitch/branches/james/src/mod/dotnet/Info/Properties/AssemblyInfo.cs Sat Aug 12 00:43:19 2006 @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Info")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Info")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("92e4523b-8d54-4152-bb7b-fedb39ea4a5a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Added: freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Freeswitch.dll ============================================================================== Binary file. No diff available. Added: freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Freeswitch.pdb ============================================================================== Binary file. No diff available. Added: freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Info.dll ============================================================================== Binary file. No diff available. Added: freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Info.pdb ============================================================================== Binary file. No diff available. Added: freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/Info.dll ============================================================================== Binary file. No diff available. Added: freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/ResolveAssemblyReference.cache ============================================================================== Binary file. No diff available. Added: freeswitch/branches/james/src/mod/dotnet/Info/obj/Info.csproj.FileList.txt ============================================================================== --- (empty file) +++ freeswitch/branches/james/src/mod/dotnet/Info/obj/Info.csproj.FileList.txt Sat Aug 12 00:43:19 2006 @@ -0,0 +1,7 @@ +obj\Debug\ResolveAssemblyReference.cache +bin\Debug\Info.dll +bin\Debug\Info.pdb +bin\Debug\FreeSwitch.dll +bin\Debug\FreeSwitch.pdb +obj\Debug\Info.dll +obj\Debug\Info.pdb Modified: freeswitch/branches/james/src/mod/languages/mod_mono/mod_mono.c ============================================================================== --- freeswitch/branches/james/src/mod/languages/mod_mono/mod_mono.c (original) +++ freeswitch/branches/james/src/mod/languages/mod_mono/mod_mono.c Sat Aug 12 00:43:19 2006 @@ -42,37 +42,10 @@ #define SWITCH_MONO_MODULES "/usr/local/freeswitch/mod/mono" #define SWITCH_MONO_ASSEMBLY "Freeswitch.dll" -/* -typedef switch_status (*switch_module_load_t) (switch_loadable_module_interface **, char *); -typedef switch_status (*switch_module_reload_t) (void); -typedef switch_status (*switch_module_pause_t) (void); -typedef switch_status (*switch_module_resume_t) (void); -typedef switch_status (*switch_module_status_t) (void); -typedef switch_status (*switch_module_runtime_t) (void); -typedef switch_status (*switch_module_shutdown_t) (void); -*/ - -SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void); -switch_status_t mod_mono_check_api(MonoImage *image); -switch_status_t mod_mono_load_managed(); switch_status_t mod_mono_load_plugins(); -//SWITCH_MOD_DECLARE(switch_status_t) mod_mono_api_function(char *in, char *out, size_t outlen); void mono_switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt, char *msg); -SWITCH_DECLARE(void) event_handler(switch_event_t *event); MonoClass* find_assembly_class(MonoImage *image); -static void mod_mono_application_function(switch_core_session_t *session, char *data); -/* -const char *mod_mono_public_key = "\x00\x24\x00\x00\x04\x80\x00\x00\x94\x00\x00\x00\x06\x02\x00\x00" - "\x00\x24\x00\x00\x52\x53\x41\x31\x00\x04\x00\x00\x11\x00\x00\x00" - "\x25\x45\x19\xB7\xFF\xB9\x3A\x67\xDD\x9E\x39\x0D\x29\xEF\x31\xAD" - "\x30\x77\xE3\x01\xAF\x28\x2C\xAC\x7A\x09\x34\xDF\x39\x4C\x9A\x26" - "\xF8\x5A\x84\xF8\x88\x53\x00\x5A\x94\xC9\x65\x82\x2A\xF3\x40\x4B" - "\x0F\x82\xA1\xB9\x61\x52\xFE\x23\x2E\xAC\xE9\x71\x97\xC4\xFE\xA7" - "\x11\x17\xCE\x69\x05\xB1\xB7\xD0\xE2\xAE\x8A\xAF\x96\x1A\x58\x91" - "\x84\x1D\x7C\x2F\x26\x6E\x31\x84\x38\xD8\xC8\xD5\xE9\xE5\x4A\xC0" - "\x0F\x6B\x4A\x57\x4F\xA2\xFC\x13\x7A\x8E\xB6\x3A\xA4\xC1\xE5\xC2" - "\xAD\x17\xA5\xFF\xBC\xE1\x35\x4F\x7F\x83\x48\x2A\x2E\x15\x83\xB3"; -*/ + static const char modname[] = "mod_mono"; switch_memory_pool_t *mono_pool; @@ -94,18 +67,9 @@ MonoClass *class; MonoObject *object; } mono_plugin; -static const switch_application_interface_t mono_application_interface = { - /*.interface_name */ "mod_mono", - /*.application_function */ mod_mono_application_function -}; static switch_loadable_module_interface_t mono_module_interface = { /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ &mono_application_interface, }; void mono_switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt, char *msg) @@ -113,47 +77,7 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, msg); } -static void mod_mono_application_function(switch_core_session_t *session, char *data) -{ - MonoObject *exception; - MonoString *string; - void *params[2]; - - mono_thread_attach(globals.domain); - - params[0] = &session; - params[1] = &data; - string = (MonoString *)mono_runtime_invoke(globals.application, globals.object, params, &exception); - - if (exception) - mono_print_unhandled_exception(exception); -} /* -SWITCH_MOD_DECLARE(switch_status_t) mod_mono_api_function(char *in, char *out, size_t outlen) -{ - MonoObject *exception; - MonoString *string; - void *params[3]; - - mono_thread_attach(globals.domain); - - params[0] = ∈ - params[1] = &out; - params[2] = &outlen; - string = (MonoString *)mono_runtime_invoke(globals.api, globals.object, params, &exception); - - if (exception) - { - mono_print_unhandled_exception(exception); - return SWITCH_STATUS_FALSE; - } - - switch_copy_string(out, mono_string_to_utf8(string), outlen); - - return SWITCH_STATUS_SUCCESS; -} -*/ -/* * Load mod_mono module and initialise domain * * This function will initialise the memory pool and plugin hash for this module, @@ -184,12 +108,6 @@ } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Initialised mono runtime.\n"); - - /* Load our core assembly */ - if (mod_mono_load_managed() != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error loading our core assembly.\n"); - return SWITCH_STATUS_FALSE; - } /* Load our plugins */ if (mod_mono_load_plugins() != SWITCH_STATUS_SUCCESS) { @@ -197,9 +115,6 @@ return SWITCH_STATUS_FALSE; } - /* Start our core assembly */ - //mono_runtime_object_init(globals.object); - for (plugin = switch_hash_first(mono_pool, mono_plugins); plugin; plugin = switch_hash_next(plugin)) { mono_plugin *p = (mono_plugin *)switch_core_alloc(mono_pool, sizeof(*p)); apr_ssize_t *key_length = NULL; @@ -233,86 +148,6 @@ /* * This function will load the managed portion of mod_mono. */ -switch_status_t mod_mono_load_managed() -{ -// MonoAssembly *assembly; -// MonoImage *image; -// MonoMethod *method; -// gpointer iter = NULL; -// int len; -// char *file; - - /* Construct the file path and name for FreeSwitch.dll */ -// len = strlen(SWITCH_MONO_MODULES) + strlen(SWITCH_MONO_ASSEMBLY) + 2; -// file = (char *)switch_core_alloc(mono_pool, len); -// snprintf(file, len, "%s/%s", SWITCH_MONO_MODULES, SWITCH_MONO_ASSEMBLY); - - /* Attempt to open FreeSwitch.dll */ -// assembly = mono_domain_assembly_open(globals.domain, file); - -// if (!assembly) { -// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Could not locate managed library (Freeswitch.dll)\n"); -// return SWITCH_STATUS_FALSE; -// } - - /* Get the image for our core assembly */ -// image = mono_assembly_get_image(assembly); - - /* Check that the assembly is our core */ -// if (mod_mono_check_api(image) != SWITCH_STATUS_SUCCESS) -// { -// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Freeswitch.dll is an invalid assembly.\n"); -// return SWITCH_STATUS_FALSE; -// } - -// globals.assembly = assembly; -// globals.image = image; - -// globals.class = mono_class_from_name(globals.image, "Freeswitch", "Core"); -// if (!globals.class) -// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Could not create object from class.\n"); - -// globals.object = mono_object_new(globals.domain, globals.class); -// mono_runtime_object_init(globals.object); - -// while ((method = mono_class_get_methods(globals.class, &iter))) { -// if (!strcmp(mono_method_get_name(method), "Event")) { -// globals.event = method; - -// if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) { -// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Could not bind events.\n"); -// return SWITCH_STATUS_FALSE; -// } -// } -// if (!strcmp(mono_method_get_name(method), "Api")) { -// globals.api = method; -// } -// if (!strcmp(mono_method_get_name(method), "Application")) { -// globals.application = method; -// } -// } - return SWITCH_STATUS_SUCCESS; -} - -/* -SWITCH_DECLARE(void) event_handler(switch_event_t *event) -{ - MonoObject *exception; - void *params[1]; - - mono_thread_attach(globals.domain); - - params[0] = &event; - mono_runtime_invoke(globals.event, globals.object, params, &exception); -*/ - /* Catch any exceptions */ -/* if (exception) - mono_print_unhandled_exception(exception); -} -*/ -/* - * This function will load the managed portion of mod_mono. - */ switch_status_t mod_mono_load_plugins() { char *file; @@ -336,10 +171,9 @@ /* Read the modules directory */ while (apr_dir_read(&finfo, finfo_flags, module_dir_handle) == APR_SUCCESS) - { + { assembly = (MonoAssembly *)switch_core_alloc(mono_pool, sizeof(assembly)); image = (MonoImage *)switch_core_alloc(mono_pool, sizeof(image)); - //*image = NULL; const char *fname = finfo.fname; if (finfo.filetype != APR_REG) @@ -368,52 +202,24 @@ /* Get the image from assembly */ image = mono_assembly_get_image(assembly); + + plugin = (mono_plugin *)switch_core_alloc(mono_pool, sizeof(*plugin)); - /* Check that the laoded assembly is not our core assembly */ - //if (mod_mono_check_api(image) == SWITCH_STATUS_SUCCESS) - // continue; - //else { - plugin = (mono_plugin *)switch_core_alloc(mono_pool, sizeof(*plugin)); + plugin->assembly = assembly; + plugin->class = find_assembly_class(mono_assembly_get_image(plugin->assembly)); - plugin->assembly = assembly; - - plugin->class = find_assembly_class(mono_assembly_get_image(plugin->assembly)); - if (!plugin->class) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No plugin class ;(\n"); - } + if (!plugin->class) + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No plugin class\n"); - plugin->object = mono_object_new(globals.domain, plugin->class); - //mono_runtime_object_init(plugin->object); + plugin->object = mono_object_new(globals.domain, plugin->class); - switch_core_hash_insert(mono_plugins, (char *)mono_image_get_name(mono_assembly_get_image(assembly)), plugin); + switch_core_hash_insert(mono_plugins, (char *) mono_image_get_name(mono_assembly_get_image(assembly)), plugin); - //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loaded %s [0x%x]I - A:0x%x, C:0x%x, O:0x%x\n", - // (char *)mono_image_get_name(mono_assembly_get_image(assembly)), - // plugin, plugin->assembly, plugin->class, plugin->object); - plugin = NULL; - //} + plugin = NULL; } return SWITCH_STATUS_SUCCESS; } -/* - * This function will retrieve the public key from the assembly and check - * it against the public key defined in this file to ensure that we are - * loading the correct assembly. - */ -/* -switch_status_t mod_mono_check_api(MonoImage *image) -{ - unsigned int size = 0; - const char *public_key = mono_image_get_public_key(image, &size); - - if (size > 0) - if (memcmp(public_key, mod_mono_public_key, size) == 0) - return SWITCH_STATUS_SUCCESS; - - return SWITCH_STATUS_FALSE; -} -*/ MonoClass* find_assembly_class(MonoImage *image) { MonoClass *class, *parent_class = NULL;
participants (1)
-
Freeswitch SVN