From: <bra...@us...> - 2007-06-12 08:53:12
|
Revision: 1027 http://svn.sourceforge.net/iaxclient/?rev=1027&view=rev Author: brazierd Date: 2007-06-12 01:53:13 -0700 (Tue, 12 Jun 2007) Log Message: ----------- .NET wrapper Added Paths: ----------- trunk/simpleclient/IAXClientDotNetWrapper/ trunk/simpleclient/IAXClientDotNetWrapper/IAXClient.cs trunk/simpleclient/IAXClientDotNetWrapper/IAXClientDotNetWrapper.csproj trunk/simpleclient/IAXClientDotNetWrapper/IAXClientDotNetWrapper.sln trunk/simpleclient/IAXClientDotNetWrapper/IAXEvents.cs trunk/simpleclient/IAXClientDotNetWrapper/IAXUnmanaged.cs trunk/simpleclient/IAXClientDotNetWrapper/ReadMe.txt Added: trunk/simpleclient/IAXClientDotNetWrapper/IAXClient.cs =================================================================== --- trunk/simpleclient/IAXClientDotNetWrapper/IAXClient.cs (rev 0) +++ trunk/simpleclient/IAXClientDotNetWrapper/IAXClient.cs 2007-06-12 08:53:13 UTC (rev 1027) @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel; + +namespace IAX.Client +{ + public class IAXClient : Component + { + public event LevelsEventHandler LevelsEvent; + public event NetStatsEventHandler NetStatsEvent; + public event RegistrationEventHandler RegistrationEvent; + public event StateEventHandler StateEvent; + public event TextEventHandler TextEvent; + public event UrlEventHandler UrlEvent; + public event VideoEventHandler VideoEvent; + + private IAXUnmanaged.iaxc_event_callback_t CallbackDelegate; + + public IAXClient() : this(IAXAudioType.Internal, 1) + { + } + + public IAXClient(IAXAudioType AudioType) : this(AudioType, 1) + { + } + + public IAXClient(int NumCalls) : this(IAXAudioType.Internal, NumCalls) + { + } + + public IAXClient(IAXAudioType AudioType, int NumCalls) + { + IAXUnmanaged.iaxc_initialize((int)AudioType, NumCalls); + CallbackDelegate = new IAXUnmanaged.iaxc_event_callback_t(IAXCallback); + IAXUnmanaged.iaxc_set_event_callback(CallbackDelegate); + IAXUnmanaged.iaxc_start_processing_thread(); + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + IAXUnmanaged.iaxc_stop_processing_thread(); + IAXUnmanaged.iaxc_shutdown(); + } + + public IAXFilter Filters + { + get + { + return IAXUnmanaged.iaxc_get_filters(); + } + set + { + IAXUnmanaged.iaxc_set_filters(value); + } + } + + public bool MicBoost + { + get + { + return IAXUnmanaged.iaxc_mic_boost_get() != 0; + } + set + { + IAXUnmanaged.iaxc_mic_boost_set(value ? 1 : 0); + } + } + + internal unsafe int IAXCallback(IAXUnmanaged.iaxc_event e) + { + IAXUnmanaged.iaxc_event ev = e; + while (true) + { + switch (ev.type) + { + case IAXUnmanaged.IAXC_EVENT_LEVELS: + if (LevelsEvent != null) + LevelsEvent(this, new IAXLevelsEventArgs(ev)); + break; + case IAXUnmanaged.IAXC_EVENT_NETSTAT: + if (NetStatsEvent != null) + NetStatsEvent(this, new IAXNetStatsEventArgs(ev)); + break; + case IAXUnmanaged.IAXC_EVENT_REGISTRATION: + if (RegistrationEvent != null) + RegistrationEvent(this, new IAXRegistrationEventArgs(ev)); + break; + case IAXUnmanaged.IAXC_EVENT_STATE: + if (StateEvent != null) + StateEvent(this, new IAXStateEventArgs(ev)); + break; + case IAXUnmanaged.IAXC_EVENT_TEXT: + if (TextEvent != null) + TextEvent(this, new IAXTextEventArgs(ev)); + break; + case IAXUnmanaged.IAXC_EVENT_URL: + if (UrlEvent != null) + UrlEvent(this, new IAXUrlEventArgs(ev)); + break; + case IAXUnmanaged.IAXC_EVENT_VIDEO: + if (VideoEvent != null) + VideoEvent(this, new IAXVideoEventArgs(ev)); + break; + } + + // see if there is a "next" event + if (ev.next == null) + return 0; + else + ev = *ev.next; + } + } + + public int Register(string User, string Password, string Server) + { + return IAXUnmanaged.iaxc_register(User, Password, Server); + } + + public int Unregister(int ID) + { + return IAXUnmanaged.iaxc_unregister(ID); + } + + public void Call(string IAX) + { + IAXUnmanaged.iaxc_call(IAX); + } + + public void Call(string Server, string Number) + { + Call(String.Format("{0}/{1}", Server, Number)); + } + + public void Call(string User, string Server, string Number) + { + Call(String.Format("{0}@{1}/{2}", User, Server, Number)); + } + + public void Call(string User, string Password, string Server, string Number) + { + Call(String.Format("{0}:{1}@{2}/{3}", User, Password, Server, Number)); + } + + public void Transfer(string number) + { + IAXUnmanaged.iaxc_blind_transfer_call(IAXUnmanaged.iaxc_selected_call(), number); + } + + public void Hangup() + { + IAXUnmanaged.iaxc_dump_call(); + } + + public void SetFormats(IAXFormat preferred, IAXFormat allowed) + { + IAXUnmanaged.iaxc_set_formats((int)preferred, (int)allowed); + } + + public void Answer() + { + IAXUnmanaged.iaxc_answer_call(0); + } + + + } +} Added: trunk/simpleclient/IAXClientDotNetWrapper/IAXClientDotNetWrapper.csproj =================================================================== --- trunk/simpleclient/IAXClientDotNetWrapper/IAXClientDotNetWrapper.csproj (rev 0) +++ trunk/simpleclient/IAXClientDotNetWrapper/IAXClientDotNetWrapper.csproj 2007-06-12 08:53:13 UTC (rev 1027) @@ -0,0 +1,59 @@ +<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>{3FC6D6AC-581B-43C1-96E0-04065C17B440}</ProjectGuid> + <OutputType>Library</OutputType> + <RootNamespace>IAX.Client</RootNamespace> + <AssemblyName>IAX.Client</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> + <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.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="IAXClient.cs"> + <SubType>Component</SubType> + </Compile> + <Compile Include="IAXEvents.cs" /> + <Compile Include="IAXUnmanaged.cs" /> + </ItemGroup> + <ItemGroup> + <Content Include="iaxclient.dll"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="ReadMe.txt" /> + </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> + --> + <PropertyGroup> + <PreBuildEvent>copy /Y $(ProjectDir)..\..\lib\win\vs2005\DebugDLL $(ProjectDir)</PreBuildEvent> + </PropertyGroup> +</Project> \ No newline at end of file Added: trunk/simpleclient/IAXClientDotNetWrapper/IAXClientDotNetWrapper.sln =================================================================== --- trunk/simpleclient/IAXClientDotNetWrapper/IAXClientDotNetWrapper.sln (rev 0) +++ trunk/simpleclient/IAXClientDotNetWrapper/IAXClientDotNetWrapper.sln 2007-06-12 08:53:13 UTC (rev 1027) @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IAXClientDotNetWrapper", "IAXClientDotNetWrapper.csproj", "{3FC6D6AC-581B-43C1-96E0-04065C17B440}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3FC6D6AC-581B-43C1-96E0-04065C17B440}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3FC6D6AC-581B-43C1-96E0-04065C17B440}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3FC6D6AC-581B-43C1-96E0-04065C17B440}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3FC6D6AC-581B-43C1-96E0-04065C17B440}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Added: trunk/simpleclient/IAXClientDotNetWrapper/IAXEvents.cs =================================================================== --- trunk/simpleclient/IAXClientDotNetWrapper/IAXEvents.cs (rev 0) +++ trunk/simpleclient/IAXClientDotNetWrapper/IAXEvents.cs 2007-06-12 08:53:13 UTC (rev 1027) @@ -0,0 +1,179 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IAX.Client +{ + public abstract class IAXEventArgs : EventArgs + { + internal IAXEventArgs(IAXUnmanaged.iaxc_event ev) + { + } + + protected static unsafe string BytesToString(byte* bs) + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < IAXUnmanaged.IAXC_EVENT_BUFSIZ; i++) + if (bs[i] == 0) + return sb.ToString(); + else + sb.Append((char)bs[i]); + return sb.ToString(); + } + } + + public class IAXLevelsEventArgs : IAXEventArgs + { + public float Input; + public float Output; + + internal IAXLevelsEventArgs(IAXUnmanaged.iaxc_event e) + : base(e) + { + Input = e.levels.input; + Output = e.levels.output; + } + } + + public class IAXNetStats + { + public int Jitter; + public int LossPercent; + public int LossCount; + public int Packets; + public int Delay; + public int Dropped; + public int OutOfOrder; + + internal IAXNetStats(IAXUnmanaged.iaxc_netstat n) + { + Jitter = n.jitter; + LossPercent = n.losspct; + LossCount = n.losscnt; + Packets = n.packets; + Delay = n.delay; + Dropped = n.dropped; + OutOfOrder = n.ooo; + } + } + + public class IAXNetStatsEventArgs : IAXEventArgs + { + public int CallNo; + public int RoundTripTime; + public IAXNetStats Local; + public IAXNetStats Remote; + + internal unsafe IAXNetStatsEventArgs(IAXUnmanaged.iaxc_event e) + : base(e) + { + CallNo = e.netstats.callNo; + RoundTripTime = e.netstats.rtt; + Local = new IAXNetStats(e.netstats.local); + Remote = new IAXNetStats(e.netstats.remote); + } + + public override string ToString() + { + string f = "J={0} L={2} {1}% P={3} D={4} Dr={5} O={6}"; + string l = String.Format(f, Local.Jitter, Local.LossPercent, Local.LossCount, Local.Packets, Local.Delay, Local.Dropped, Local.OutOfOrder); + string r = String.Format(f, Remote.Jitter, Remote.LossPercent, Remote.LossCount, Remote.Packets, Remote.Delay, Remote.Dropped, Remote.OutOfOrder); + return String.Format("RTT={0} Local[{1}] Remote[{2}]", RoundTripTime, l, r); + } + } + + public class IAXRegistrationEventArgs : IAXEventArgs + { + public int ID; + public IAXRegistrationReply Reply; + public int MessageCount; + + internal unsafe IAXRegistrationEventArgs(IAXUnmanaged.iaxc_event e) + : base(e) + { + ID = e.reg.id; + Reply = (IAXRegistrationReply)e.reg.reply; + MessageCount = e.reg.msgcount; + } + } + + public class IAXStateEventArgs : IAXEventArgs + { + public int CallNo; + public IAXCallState State; + public IAXFormat Format; + public string Remote; + public string RemoteName; + public string Local; + public string LocalContext; + + internal unsafe IAXStateEventArgs(IAXUnmanaged.iaxc_event e) + : base(e) + { + CallNo = e.call.callNo; + State = (IAXCallState)e.call.state; + Format = (IAXFormat)e.call.format; + Remote = BytesToString(e.call.remote); + RemoteName = BytesToString(e.call.remote_name); + Local = BytesToString(e.call.local); + LocalContext = BytesToString(e.call.local_context); + } + } + + public class IAXTextEventArgs : IAXEventArgs + { + public IAXTTextEventType Type; + public int CallNo; + public string Message; + + internal unsafe IAXTextEventArgs(IAXUnmanaged.iaxc_event e) + : base(e) + { + Type = (IAXTTextEventType)e.text.type; + CallNo = e.text.callNo; + Message = BytesToString(e.text.message); + } + } + + public class IAXUrlEventArgs : IAXEventArgs + { + public int CallNo; + public IAXUrlEventType Type; + public string Url; + + internal unsafe IAXUrlEventArgs(IAXUnmanaged.iaxc_event e) + : base(e) + { + CallNo = e.url.callNo; + Type = (IAXUrlEventType)e.url.type; + Url = BytesToString(e.url.url); + } + } + + public class IAXVideoEventArgs : IAXEventArgs + { + public int CallNo; + public int Format; // TODO: should be enum? + public int Width; + public int Height; + public object Data; + + internal unsafe IAXVideoEventArgs(IAXUnmanaged.iaxc_event e) + : base(e) + { + CallNo = e.video.callNo; + Format = e.video.format; + Width = e.video.width; + Height = e.video.height; + Data = null; // TODO: how to interpret data? + } + } + + public delegate void LevelsEventHandler(object sender, IAXLevelsEventArgs e); + public delegate void NetStatsEventHandler(object sender, IAXNetStatsEventArgs e); + public delegate void RegistrationEventHandler(object sender, IAXRegistrationEventArgs e); + public delegate void StateEventHandler(object sender, IAXStateEventArgs e); + public delegate void TextEventHandler(object sender, IAXTextEventArgs e); + public delegate void UrlEventHandler(object sender, IAXUrlEventArgs e); + public delegate void VideoEventHandler(object sender, IAXVideoEventArgs e); +} Added: trunk/simpleclient/IAXClientDotNetWrapper/IAXUnmanaged.cs =================================================================== --- trunk/simpleclient/IAXClientDotNetWrapper/IAXUnmanaged.cs (rev 0) +++ trunk/simpleclient/IAXClientDotNetWrapper/IAXUnmanaged.cs 2007-06-12 08:53:13 UTC (rev 1027) @@ -0,0 +1,490 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + +namespace IAX.Client +{ + // Define audio type constants + public enum IAXAudioType + { + Internal = 0, InternalPA = 1, InternalFile = 2, InternalAlsa = 3, External = 99 + } + + // Data formats for capabilities and frames alike + [Flags] + public enum IAXFormat + { + G723_1 = 1 << 0, GSM = 1 << 1, ULAW = 1 << 2, ALAW = 1 << 3, G726 = 1 << 4, ADPCM = 1 << 5, + SLINEAR = 1 << 6, LPC10 = 1 << 7, G729A = 1 << 8, SPEEX = 1 << 9, ILBC = 1 << 10, MAX_AUDIO = 1 << 15, + JPEG = 1 << 16, PNG = 1 << 17, H261 = 1 << 18, H263 = 1 << 19, H263_PLUS = 1 << 20, MPEG4 = 1 << 21, + H264 = 1 << 23, THEORA = 1 << 24 + } + + [Flags] + public enum IAXCallState + { + Free = 0, Active = 1 << 1, Outgoing = 1 << 2, Ringing = 1 << 3, Complete = 1 << 4, + Selected = 1 << 5, Busy = 1 << 6, Transfer = 1 << 7 + } + + public enum IAXTTextEventType + { + Status = 1, Notice = 2, Error = 3, FatalError = 4, IAX = 5 // FATAL ERROR: User Agent should probably display error, then die. + } + + public enum IAXRegistrationReply + { + Ack = 18, // IAX_EVENT_REGACC + Reject = 30, // IAX_EVENT_REGREJ + Timeout = 6 // IAX_EVENT_TIMEOUT + } + + public enum IAXUrlEventType + { + Url = 1, // URL received + LoadComplete = 2, // URL loading complete + LunkUrl = 3, // URL link request + LinkReject = 4, // URL link reject + Unlink = 5 // URL unlink + } + + [Flags] + public enum IAXFilter + { + IAXC_FILTER_DENOISE = 1 << 0, + IAXC_FILTER_AGC = 1 << 1, + IAXC_FILTER_ECHO = 1 << 2, + IAXC_FILTER_AAGC = 1 << 3, // Analog (mixer-based) AGC + IAXC_FILTER_CN = 1 << 4 // Send CN frames when silence detected + } + + // this class declares the unmanaged types & functions from iaxclient.dll + internal class IAXUnmanaged + { + internal const int IAXC_EVENT_TEXT = 1; + internal const int IAXC_EVENT_LEVELS = 2; + internal const int IAXC_EVENT_STATE = 3; + internal const int IAXC_EVENT_NETSTAT = 4; + internal const int IAXC_EVENT_URL = 5; // URL push via IAX(2) + internal const int IAXC_EVENT_VIDEO = 6; // video data (pointer) + internal const int IAXC_EVENT_REGISTRATION = 7; + + internal const int IAXC_EVENT_BUFSIZ = 256; + + //struct iaxc_ev_levels { + // float input; + // float output; + //}; + [StructLayout(LayoutKind.Sequential)] + internal struct iaxc_ev_levels + { + internal float input; + internal float output; + } + + //struct iaxc_ev_text { + // int type; + // int callNo; /* call number for IAX text */ + // char message[IAXC_EVENT_BUFSIZ]; + //}; + [StructLayout(LayoutKind.Sequential)] + internal struct iaxc_ev_text + { + internal int type; + internal int callNo; + internal unsafe fixed byte message[IAXC_EVENT_BUFSIZ]; + } + + //struct iaxc_ev_call_state { + // int callNo; + // int state; + // int format; + // char remote[IAXC_EVENT_BUFSIZ]; + // char remote_name[IAXC_EVENT_BUFSIZ]; + // char local[IAXC_EVENT_BUFSIZ]; + // char local_context[IAXC_EVENT_BUFSIZ]; + //}; + [StructLayout(LayoutKind.Sequential)] + internal struct iaxc_ev_call_state + { + internal int callNo; + internal int state; + internal int format; + internal unsafe fixed byte remote[IAXC_EVENT_BUFSIZ]; + internal unsafe fixed byte remote_name[IAXC_EVENT_BUFSIZ]; + internal unsafe fixed byte local[IAXC_EVENT_BUFSIZ]; + internal unsafe fixed byte local_context[IAXC_EVENT_BUFSIZ]; + } + + //struct iaxc_netstat { + // int jitter; + // int losspct; + // int losscnt; + // int packets; + // int delay; + // int dropped; + // int ooo; + //}; + [StructLayout(LayoutKind.Sequential)] + internal struct iaxc_netstat + { + internal int jitter; + internal int losspct; + internal int losscnt; + internal int packets; + internal int delay; + internal int dropped; + internal int ooo; + } + + //struct iaxc_ev_netstats { + // int callNo; + // int rtt; + // struct iaxc_netstat local; + // struct iaxc_netstat remote; + //}; + [StructLayout(LayoutKind.Sequential)] + internal struct iaxc_ev_netstats + { + internal int callNo; + internal int rtt; + internal iaxc_netstat local; + internal iaxc_netstat remote; + } + + //struct iaxc_ev_url { + // int callNo; + // int type; + // char url[IAXC_EVENT_BUFSIZ]; + //}; + [StructLayout(LayoutKind.Sequential)] + internal struct iaxc_ev_url + { + internal int callNo; + internal int type; + internal unsafe fixed byte url[IAXC_EVENT_BUFSIZ]; + } + + //struct iaxc_ev_video { + // int callNo; + // int format; + // int width; + // int height; + // unsigned char *data; + //}; + [StructLayout(LayoutKind.Sequential)] + internal unsafe struct iaxc_ev_video + { + internal int callNo; + internal int format; + internal int width; + internal int height; + internal void* data; + } + + //struct iaxc_ev_registration { + // int id; + // int reply; + // int msgcount; + //}; + [StructLayout(LayoutKind.Sequential)] + internal struct iaxc_ev_registration + { + internal int id; + internal int reply; + internal int msgcount; + } + + //typedef struct iaxc_event_struct { + // struct iaxc_event_struct *next; + // int type; + // union { + // struct iaxc_ev_levels levels; + // struct iaxc_ev_text text; + // struct iaxc_ev_call_state call; + // struct iaxc_ev_netstats netstats; + // struct iaxc_ev_url url; + // struct iaxc_ev_video video; + // struct iaxc_ev_registration reg; + // } ev; + //} iaxc_event; + [StructLayout(LayoutKind.Explicit)] + internal unsafe struct iaxc_event + { + [FieldOffset(0)] + internal iaxc_event* next; + [FieldOffset(4)] + internal int type; + [FieldOffset(8)] + internal iaxc_ev_levels levels; + [FieldOffset(8)] + internal iaxc_ev_text text; + [FieldOffset(8)] + internal iaxc_ev_call_state call; + [FieldOffset(8)] + internal iaxc_ev_netstats netstats; + [FieldOffset(8)] + internal iaxc_ev_url url; + [FieldOffset(8)] + internal iaxc_ev_video video; + [FieldOffset(8)] + internal iaxc_ev_registration reg; + } + + //typedef int (*iaxc_event_callback_t)(iaxc_event e); + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate int iaxc_event_callback_t(iaxc_event e); + + //EXPORT void iaxc_set_event_callback(iaxc_event_callback_t func); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_set_event_callback(iaxc_event_callback_t func); + + ///* Sets iaxclient to post a pointer to a copy of event using o/s specific Post method */ + //EXPORT int iaxc_set_event_callpost(void *handle, int id); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_set_event_callpost(IntPtr handle, int id); + + ///* frees event delivered via o/s specific Post method */ + //EXPORT void iaxc_free_event(iaxc_event *e); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_free_event(ref iaxc_event e); + + ///* Event Accessors */ + //EXPORT struct iaxc_ev_levels *iaxc_get_event_levels(iaxc_event *e); + //EXPORT struct iaxc_ev_text *iaxc_get_event_text(iaxc_event *e); + //EXPORT struct iaxc_ev_call_state *iaxc_get_event_state(iaxc_event *e); + + //EXPORT void iaxc_set_preferred_source_udp_port(int sourceUdpPort); //must be called before iaxc_initialize() + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_set_preferred_source_udp_port(int sourceUdpPort); + + //EXPORT int iaxc_initialize(int audType, int nCalls); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_initialize(int audType, int nCalls); + + //EXPORT void iaxc_shutdown(); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_shutdown(); + + //EXPORT void iaxc_set_formats(int preferred, int allowed); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_set_formats(int preferred, int allowed); + + //EXPORT void iaxc_set_min_outgoing_framesize(int samples); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_set_min_outgoing_framesize(int samples); + + //EXPORT void iaxc_set_callerid(char *name, char *number); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_set_callerid(string name, string number); + + //EXPORT void iaxc_process_calls(); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_process_calls(); + + //EXPORT int iaxc_service_audio(); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_service_audio(); + + //EXPORT int iaxc_start_processing_thread(); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_start_processing_thread(); + + //EXPORT int iaxc_stop_processing_thread(); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_stop_processing_thread(); + + //EXPORT void iaxc_call(char *num); + [DllImport("iaxclient.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_call(string num); + + //EXPORT int iaxc_unregister( int id ); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_unregister(int id); + + //EXPORT int iaxc_register(char *user, char *pass, char *host); + [DllImport("iaxclient.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_register(string user, string pass, string host); + + //EXPORT void iaxc_answer_call(int callNo); + [DllImport("iaxclient.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_answer_call(int callNo); + + //EXPORT void iaxc_blind_transfer_call(int callNo, char *number); + [DllImport("iaxclient.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_blind_transfer_call(int callNo, string number); + + //EXPORT void iaxc_dump_all_calls(void); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_dump_all_calls(); + + //EXPORT void iaxc_dump_call(void); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_dump_call(); + + //EXPORT void iaxc_reject_call(void); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_reject_call(); + + //EXPORT void iaxc_reject_call_number(int callNo); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_reject_call_number(int callNo); + + //EXPORT void iaxc_send_dtmf(char digit); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_send_dtmf(char digit); + + //EXPORT void iaxc_send_text(char *text); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_send_text(string text); + + //EXPORT void iaxc_send_url(char *url, int link); /* link == 1 ? AST_HTML_LINKURL : AST_HTML_URL */ + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_send_url(string url, int link); + + //EXPORT int iaxc_was_call_answered(); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_was_call_answered(); + + //EXPORT void iaxc_millisleep(long ms); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_millisleep(long ms); + + //EXPORT void iaxc_set_silence_threshold(double thr); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_set_silence_threshold(double thr); + + //EXPORT void iaxc_set_audio_output(int mode); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_set_audio_output(int mode); + + //EXPORT int iaxc_select_call(int callNo); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_select_call(int callNo); + + //EXPORT int iaxc_first_free_call(); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_first_free_call(); + + //EXPORT int iaxc_selected_call(); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_selected_call(); + + //EXPORT int iaxc_quelch(int callNo, int MOH); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_quelch(int callNo, int MOH); + + //EXPORT int iaxc_unquelch(int call); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_unquelch(int call); + + //EXPORT int iaxc_mic_boost_get( void ) ; + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_mic_boost_get(); + + //EXPORT int iaxc_mic_boost_set( int enable ) ; + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_mic_boost_set(int enable); + + //EXPORT char* iaxc_version(char *ver); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern string iaxc_version(string ver); + + ///* application-defined networking; give substiture sendto and recvfrom functions, + // * must be called before iaxc_initialize! */ + //EXPORT void iaxc_set_networking(iaxc_sendto_t st, iaxc_recvfrom_t rf) ; + + ///* wrapper for libiax2 get_netstats */ + //EXPORT int iaxc_get_netstats(int call, int *rtt, struct iaxc_netstat *local, struct iaxc_netstat *remote); + + //#define IAXC_AD_INPUT (1<<0) + //#define IAXC_AD_OUTPUT (1<<1) + //#define IAXC_AD_RING (1<<2) + //#define IAXC_AD_INPUT_DEFAULT (1<<3) + //#define IAXC_AD_OUTPUT_DEFAULT (1<<4) + //#define IAXC_AD_RING_DEFAULT (1<<5) + + //struct iaxc_audio_device { + // char *name; /* name of the device */ + // long capabilities; /* flags, defined above */ + // int devID; /* driver-specific ID */ + //}; + + ///* Get audio device information: + // * **devs: a pointer to an array of device structures, as declared above. function + // * will give you a pointer to the proper array, which will be valid as long as iaxc is + // * initialized. + // * + // * *nDevs: a pointer to an int, to which the count of devices in the array devs will be + // * written + // * + // * *input, *output, *ring: the currently selected devices for input, output, ring will + // * be written to the int pointed to by these pointers. + // */ + //EXPORT int iaxc_audio_devices_get(struct iaxc_audio_device **devs, int *nDevs, int *input, int *output, int *ring); + //EXPORT int iaxc_audio_devices_set(int input, int output, int ring); + + //EXPORT double iaxc_input_level_get(); + //EXPORT double iaxc_output_level_get(); + //EXPORT int iaxc_input_level_set(double level); + //EXPORT int iaxc_output_level_set(double level); + + + //struct iaxc_sound { + // short *data; /* sound data */ + // long len; /* length of sample */ + // int malloced; /* should the library free() the data after it is played? */ + // int channel; /* 0 for outputSelected, 1 for ringSelected */ + // int repeat; /* number of times to repeat (-1 = infinite) */ + // long pos; /* internal use: current play position */ + // int id; /* internal use: sound ID */ + // struct iaxc_sound *next; /* internal use: next in list */ + //}; + + ///* play a sound. sound = an iaxc_sound structure, ring: 0: play through output device; 1: play through "ring" device */ + //EXPORT int iaxc_play_sound(struct iaxc_sound *sound, int ring); + + ///* stop sound with ID "id" */ + //EXPORT int iaxc_stop_sound(int id); + + //EXPORT int iaxc_get_filters(void); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern IAXFilter iaxc_get_filters(); + + //EXPORT void iaxc_set_filters(int filters); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern void iaxc_set_filters(IAXFilter filters); + + //EXPORT int iaxc_set_files(FILE *input, FILE *output); + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + internal static extern int iaxc_set_files(Microsoft.Win32.SafeHandles.SafeFileHandle input, Microsoft.Win32.SafeHandles.SafeFileHandle output); + + ///* speex specific codec settings */ + ///* a good choice is (1,-1,-1,0,8000,3): 8kbps ABR */ + ///* Decode options: + // * decode_enhance: 1/0 perceptual enhancement for decoder + // * quality: Generally, set either quality (0-9) or bitrate. + // * -1 for "default" + // * bitrate: in kbps. Applies to CBR only; -1 for default. + // * (overrides "quality" for CBR mode) + // * vbr: Variable bitrate mode: 0/1 + // * abr mode/rate: 0 for not ABR, bitrate for ABR mode + // * complexity: algorithmic complexity. Think -N for gzip. + // * Higher numbers take more CPU for better quality. 3 is + // * default and good choice. + //*/ + //EXPORT void iaxc_set_speex_settings(int decode_enhance, float quality, int bitrate, int vbr, int abr, int complexity); + + ///* set/get video mode */ + //#define IAXC_VIDEO_MODE_NONE 0 /* don't send video at all */ + //#define IAXC_VIDEO_MODE_ACTIVE 1 /* send video */ + //#define IAXC_VIDEO_MODE_PREVIEW_RAW 2 /* send video, and show raw preview */ + //#define IAXC_VIDEO_MODE_PREVIEW_ENCODED 3 /* send video, and show encoded preview */ + //EXPORT int iaxc_video_mode_set(int mode); + //EXPORT int iaxc_video_mode_get(); + + ///* set allowed/preferred video encodings */ + //EXPORT void iaxc_video_format_set(int preferred, int allowed, int framerate, int bitrate, int width, int height); + } +} Added: trunk/simpleclient/IAXClientDotNetWrapper/ReadMe.txt =================================================================== --- trunk/simpleclient/IAXClientDotNetWrapper/ReadMe.txt (rev 0) +++ trunk/simpleclient/IAXClientDotNetWrapper/ReadMe.txt 2007-06-12 08:53:13 UTC (rev 1027) @@ -0,0 +1,39 @@ +This VS 2005 project builds a managed wrapper for iaxclient. It copies the DLL +from the vs2005 directory using a VS build event. This is referenced by the lines +like these in IAXUnmanaged.cs: + + [DllImport("iaxclient.dll", CallingConvention = CallingConvention.StdCall)] + +Create an IAXClient, register for events and use the methods to make calls etc: + + IAXClient iax = new IAXClient(); + iax.SetFormats(IAXFormat.ULAW, IAXFormat.ULAW | IAXFormat.ALAW); + StateDelegate = new StateEventHandler(SafeStateEvent); + iax.StateEvent += new StateEventHandler(iax_StateEvent); + + iax.Call(user, password, server, number); +... + iax.Hangup(); + +The events are handled via BeginInvoke because they may be raised on a different +thread to the UI (see .NET documentation about this): + + private void iax_StateEvent(object sender, IAXStateEventArgs e) + { + if (!labelCallStatus.IsDisposed) // labelCallStatus is some control in the UI + labelCallStatus.BeginInvoke(StateDelegate, new object[] { sender, e }); + } + + private void SafeStateEvent(object sender, IAXStateEventArgs e) + { + if (labelCallStatus.IsDisposed) + return; + labelCallStatus.Text = e.State.ToString(); + } + +Plenty of iaxclient fucntionality is not covered, but it should be straightforward +to extend it. + +David Brazier +d...@br... +June 2007 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-04-15 22:16:22
|
Revision: 1404 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1404&view=rev Author: jpgrayson Date: 2008-04-15 15:16:27 -0700 (Tue, 15 Apr 2008) Log Message: ----------- Update Makefile.am for stresstest, testcall, and vtestcall to use variables from pkgconfig to get all of the appropriate compile and link flags. Modified Paths: -------------- trunk/simpleclient/stresstest/Makefile.am trunk/simpleclient/testcall/Makefile.am trunk/simpleclient/vtestcall/Makefile.am Modified: trunk/simpleclient/stresstest/Makefile.am =================================================================== --- trunk/simpleclient/stresstest/Makefile.am 2008-04-15 22:14:46 UTC (rev 1403) +++ trunk/simpleclient/stresstest/Makefile.am 2008-04-15 22:16:27 UTC (rev 1404) @@ -1,16 +1,20 @@ -bin_PROGRAMS=stresstest -stresstest_SOURCES=stresstest.c file.c file.h +bin_PROGRAMS = stresstest -AM_CPPFLAGS=-I$(top_srcdir)/lib $(SDL_CFLAGS) $(OGGZ_CFLAGS) $(THEORA_CFLAGS) -stresstest_LDADD=$(top_builddir)/lib/libiaxclient.la $(OGGZ_LIBS) $(THEORA_LIBS) +stresstest_SOURCES = stresstest.c file.c file.h -if MACOSX -stresstest_LDFLAGS = \ - -framework AudioToolbox \ - -framework AudioUnit \ - -framework Carbon \ - -framework CoreAudio \ - -framework QuartzCore \ - -framework QuickTime -endif +stresstest_CPPFLAGS = -I$(top_srcdir)/lib +stresstest_CFLAGS = $(OGGZ_CFLAGS) \ + $(THEORA_CFLAGS) \ + $(PORTAUDIO_CFLAGS) \ + $(SPEEX_CFLAGS) \ + $(VIDCAP_CFLAGS) +stresstest_LDFLAGS = +stresstest_LDADD = $(top_builddir)/lib/libiaxclient.la \ + $(OGGZ_LIBS) \ + $(THEORA_LIBS) \ + $(PORTAUDIO_LIBS) \ + $(SPEEX_LIBS) \ + $(VIDCAP_LIBS) + + Modified: trunk/simpleclient/testcall/Makefile.am =================================================================== --- trunk/simpleclient/testcall/Makefile.am 2008-04-15 22:14:46 UTC (rev 1403) +++ trunk/simpleclient/testcall/Makefile.am 2008-04-15 22:16:27 UTC (rev 1404) @@ -1,11 +1,16 @@ -bin_PROGRAMS=testcall -testcall_SOURCES=testcall.c +bin_PROGRAMS = testcall -AM_CPPFLAGS=-I$(top_srcdir)/lib -LDADD=$(top_builddir)/lib/libiaxclient.la +testcall_SOURCES = testcall.c -if ! WIN32 -AM_CPPFLAGS += -DPOSIXSLEEP +testcall_CPPFLAGS = -I$(top_srcdir)/lib +testcall_CFLAGS = $(PORTAUDIO_CFLAGS) $(SPEEX_CFLAGS) +testcall_LDFLAGS = +testcall_LDADD = $(top_builddir)/lib/libiaxclient.la \ + $(PORTAUDIO_LIBS) $(SPEEX_LIBS) + +if VIDEO +testcall_CFLAGS += $(THEORA_CFLAGS) $(VIDCAP_CFLAGS) +testcall_LDADD += $(THEORA_LIBS) $(VIDCAP_LIBS) endif EXTRA_DIST = testcall-jb.c Modified: trunk/simpleclient/vtestcall/Makefile.am =================================================================== --- trunk/simpleclient/vtestcall/Makefile.am 2008-04-15 22:14:46 UTC (rev 1403) +++ trunk/simpleclient/vtestcall/Makefile.am 2008-04-15 22:16:27 UTC (rev 1404) @@ -1,7 +1,21 @@ -bin_PROGRAMS=vtestcall -vtestcall_SOURCES=vtestcall.c +bin_PROGRAMS = vtestcall +vtestcall_SOURCES = vtestcall.c -AM_CPPFLAGS=-I$(top_srcdir)/lib $(SDL_CFLAGS) $(OGGZ_CFLAGS) -vtestcall_LDADD=$(top_builddir)/lib/libiaxclient.la $(SDL_LIBS) $(OGGZ_LIBS) +vtestcall_CPPFLAGS = -I$(top_srcdir)/lib +vtestcall_CFLAGS = $(SDL_CFLAGS) \ + $(OGGZ_CFLAGS) \ + $(PORTAUDIO_CFLAGS) \ + $(SPEEX_CFLAGS) \ + $(THEORA_CFLAGS) \ + $(VIDCAP_CFLAGS) +vtestcall_LDADD = $(top_builddir)/lib/libiaxclient.la \ + $(SDL_LIBS) \ + $(OGGZ_LIBS) \ + $(PORTAUDIO_LIBS) \ + $(SPEEX_LIBS) \ + $(THEORA_LIBS) \ + $(VIDCAP_LIBS) + EXTRA_DIST = + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |