资源简介
SIP软拨号网络电话接口,只需要网络电话商提供服务IP、端口、账号、密码即可拨打电话,一般网络电话比较便宜,最便宜到3分钱/分钟。
代码片段和文件信息
using System;
using System.Diagnostics;
using System.Text;
using Ozeki.Media;
using Ozeki.Media.MediaHandlers;
using Ozeki.Network.Nat;
using Ozeki.VoIP;
using Ozeki.VoIP.Media;
using Ozeki.VoIP.SDK;
using Ozeki.Common;
namespace SoftPhoneLB
{
public class SoftPhone
{
ISoftPhone softPhone;
IPhoneLine phoneLine;
PhoneLineState phoneLineInformation;
IPhoneCall call;
Microphone microphone = Microphone.GetDefaultDevice();
Speaker speaker = Speaker.GetDefaultDevice();
MediaConnector connector = new MediaConnector();
PhoneCallAudioSender mediaSender = new PhoneCallAudioSender();
PhoneCallAudioReceiver mediaReceiver = new PhoneCallAudioReceiver();
bool inComingCall;
///
/// 麦克风状态
///
/// 是否正常
public bool GetMicrophoneState()
{
if (microphone == null)
return false;
return true;
}
///
/// 扩音器状态
///
/// 是否正常
public bool GetSpeakerState()
{
if (speaker == null)
return false;
return true;
}
///
/// 初始化
///
/// 注册名称
/// 注册密码
/// 主机域名或Ip
/// 端口
public bool InitializeSoftPhone(string registerName string registerPassword string ServerHost int ServerPort)
{
try
{
softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP() 5700 5750 5700);
softPhone.IncomingCall += new EventHandler>(softPhone_IncomingCall);
SIPAccount sipAccount = new SIPAccount(true registerName registerName registerName registerPassword ServerHost ServerPort);
phoneLine = softPhone.CreatePhoneLine(sipAccount new NatConfiguration(NatTraversalMethod.None));
phoneLine.PhoneLineStateChanged += new EventHandler>(phoneLine_PhoneLineInformation);
softPhone.RegisterPhoneLine(phoneLine);
return true;
}
catch (Exception ex)
{
//var sb = new StringBuilder();
//sb.AppendLine(“Some error happened.“);
//sb.AppendLine();
//sb.AppendLine(“Exception:“);
//sb.AppendLine(ex.Message);
//sb.AppendLine();
//if (ex.InnerException != null)
//{
// sb.AppendLine(“Inner Exception:“);
// sb.AppendLine(ex.InnerException.Message);
//
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 11776 2012-10-10 16:28 SoftPhoneLB\Bin\SoftPhoneLB.dll
文件 22016 2012-10-10 16:28 SoftPhoneLB\Bin\SoftPhoneLB.pdb
文件 40773120 2012-09-24 13:23 SoftPhoneLB\Bin\VoIPSDK.dll
文件 1152786 2012-09-24 13:40 SoftPhoneLB\Bin\VoIPSDK.xm
文件 5813 2012-10-10 16:28 SoftPhoneLB\SoftPhoneLB\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 17479 2012-10-10 15:03 SoftPhoneLB\SoftPhoneLB\obj\Debug\ResolveAssemblyReference.cache
文件 429 2012-10-10 15:24 SoftPhoneLB\SoftPhoneLB\obj\Debug\SoftPhoneLB.csproj.FileListAbsolute.txt
文件 11776 2012-10-10 16:28 SoftPhoneLB\SoftPhoneLB\obj\Debug\SoftPhoneLB.dll
文件 22016 2012-10-10 16:28 SoftPhoneLB\SoftPhoneLB\obj\Debug\SoftPhoneLB.pdb
文件 1381 2012-10-10 16:28 SoftPhoneLB\SoftPhoneLB\Properties\AssemblyInfo.cs
文件 13531 2012-10-10 16:21 SoftPhoneLB\SoftPhoneLB\SoftPhone.cs
文件 679 2012-10-10 15:56 SoftPhoneLB\SoftPhoneLB\SoftPhoneEH.cs
文件 2643 2012-10-10 15:24 SoftPhoneLB\SoftPhoneLB\SoftPhoneLB.csproj
文件 143 2012-10-10 14:52 SoftPhoneLB\SoftPhoneLB\SoftPhoneLB.csproj.user
文件 923 2012-10-10 14:52 SoftPhoneLB\SoftPhoneLB.sln
..A..H. 17408 2012-10-10 16:31 SoftPhoneLB\SoftPhoneLB.suo
目录 0 2012-10-10 14:52 SoftPhoneLB\SoftPhoneLB\obj\Debug\TempPE
目录 0 2012-10-10 14:52 SoftPhoneLB\SoftPhoneLB\bin\Debug
目录 0 2012-10-10 14:52 SoftPhoneLB\SoftPhoneLB\bin\Release
目录 0 2012-10-10 16:28 SoftPhoneLB\SoftPhoneLB\obj\Debug
目录 0 2012-10-10 14:52 SoftPhoneLB\SoftPhoneLB\obj\Release
目录 0 2012-10-10 14:52 SoftPhoneLB\SoftPhoneLB\bin
目录 0 2012-10-10 14:52 SoftPhoneLB\SoftPhoneLB\obj
目录 0 2012-10-10 14:52 SoftPhoneLB\SoftPhoneLB\Properties
目录 0 2012-10-10 15:03 SoftPhoneLB\Bin
目录 0 2012-10-10 15:08 SoftPhoneLB\SoftPhoneLB
目录 0 2012-10-10 14:54 SoftPhoneLB
----------- --------- ---------- ----- ----
42053919 27
............此处省略0个文件信息
评论
共有 条评论