上一年在公司做了一个小小的IVR项目.觉得这是一个和硬件驱动交互编程的不错例子.
共享一下.也讨论一下.
代码:(这个是调用系统驱动的DLL)
using System;
using System.Text;
using DJVoiceCard.Lib;
namespace DJVoiceCard.DL
{
public class SysFunction
{
系统操作#region 系统操作
/**//// <summary>
/// 初始化系统
/// </summary>
/// <returns></returns>
public static bool SysInit(ref string sErr)
{
try
{
StringBuilder sSys_INC = new StringBuilder("");
StringBuilder sPrompt_INC = new StringBuilder("Prompt.ini");
int iSysInit = ISUP_Lib.DJISUP_InitSystem();
int iCardInit = DJFunction.DJSys_EnableCard(sSys_INC, sPrompt_INC);
bool iPromptInit = DJFunction.DJSys_EnableDtmfSend();
if (iSysInit == 1)
{
if (iCardInit == 0)
{
if (iPromptInit)
{
return true;
}
else
{
sErr = "未能加载声音文件" + iPromptInit.ToString();
return false;
}
}
else
{
sErr = iCardInit.ToString();
return false;
}
}
else
{
sErr = iSysInit.ToString();
return false;
}
}
catch (Exception ex)
{
sErr = ex.Message;
}
return false;
}
/**//// <summary>
/// 退出系统
/// </summary>
public static void SysExit()
{
DJFunction.DJSys_DisableCard();
ISUP_Lib.DJISUP_ExitSystem();
}
#endregion
中继通道操作#region 中继通道操作
/**//// <summary>
/// 获取中继通道总数
/// </summary>
/// <returns></returns>
public static int iTrkTotal()
{
return DJFunction.DJTrk_GetTotalTrunkNum();
}
/**//// <summary>
/// 信道状态;
/// </summary>
/// <param name="PCM_NO"></param>
/// <param name="Relay_NO"></param>
/// <returns></returns>
public static int iRaleyStetes(byte PCM_NO, byte Relay_NO)
{
return ISUP_Lib.DJISUP_GetChnState(PCM_NO, Relay_NO);
}
/**//// <summary>
/// 循环刷新缓存;
/// </summary>
public static void Push_GerEvent()
{
try
{
ISUP_Lib.DJISUP_GetEvent();
DJFunction.DJSys_PushPlay();
}
catch(Exception Ex)
{
}
}
/**//// <summary>
/// 获得中继号
/// </summary>
/// <param name="iTrunkID"></param>
/// <returns></returns>
public static int iPCMID(int iTrunkID)
{
return DJFunction.DJTrk_GetPcmID(iTrunkID);
}
/**//// <summary>
/// 被叫号码
/// </summary>
/// <param name="PCM_NO"></param>
/// <param name="Relay_NO"></param>
/// <returns></returns>
public static TC_INI_TYPE GetCallNum(int PCM_NO, int Relay_NO)
{
TC_INI_TYPE sReVal = new TC_INI_TYPE();
ISUP_Lib.DJISUP_GetCalleeNum((byte)PCM_NO, (byte)Relay_NO, ref sReVal);
return sReVal;
}
/**//// <summary>
/// 主叫号码
/// </summary>
/// <param name="PCM_NO"></param>
/// <param name="Relay_NO"></param>
/// <returns></returns>
public static TC_INI_TYPE GetCallerNum(int PCM_NO, int Relay_NO)
{
TC_INI_TYPE sReVal = new TC_INI_TYPE();
ISUP_Lib.DJISUP_GetCallerNum((byte)PCM_NO, (byte)Relay_NO, ref sReVal);
return sReVal;
}
/**//// <summary>
/// 获取用户按键
/// </summary>
/// <param name="Relay_NO"></param>
/// <returns></returns>
public static StringBuilder GetUserKeyPress(int Relay_NO)
{
return ISUP_Lib.DJTrk_GetDtmfCode(Relay_NO);
}
/**//// <summary>
/// 设置中继信道的状态;
/// </summary>
/// <param name="iTrunkID"></param>
/// <param name="States"></param>
public static void SetRelayStates(int iTrunkID, int States)
{
ISUP_Lib.DJISUP_SetChnState(((byte)(iTrunkID / 30)), ((byte)(iTrunkID % 30)), (byte)States);
}
/**//// <summary>
/// 呼出
/// </summary>
/// <param name="iTrunkID"></param>
/// <param name="CalleeNum"></param>
/// <param name="CallerNum"></param>
/// <returns></returns>
public static bool bCallOut(int iTrunkID, string CalleeNum, string CallerNum, ref string sErr)
{
StringBuilder Callee = new StringBuilder(CallerNum);
StringBuilder Caller = new StringBuilder(CalleeNum);
if (iTrunkID != -1)
{
bool bRel = ISUP_Lib.DJISUP_Callout(iTrunkID / 30, iTrunkID % 30, ref Callee, ref Caller);
//sErr = Callee.ToString() + "||" + Caller.ToString()+"||"+iTrunkID.ToString();
return bRel;
}
else
{
sErr = "NaN";
return false;
}
}
/**//// <summary>
/// string
/// </summary>
/// <param name="iTrunkID"></param>
/// <param name="CalleeNum"></param>
/// <param name="CallerNum"></param>
/// <returns></returns>
public static bool bCallOut(int iTrunkID, string CalleeNum, string CallerNum)
{
char[] telNum = new char[120];
PR p = new PR();
p.TelarrChar = telNum;
telNum = CalleeNum.ToCharArray();
byte[] _telNum = new byte[120];
_telNum = Encoding.ASCII.GetBytes(telNum);
char[] CallNum = new char[120];
CallNum = CallerNum.ToCharArray();
byte[] _CallNum = new byte[120];
p.CallarrChar = CallNum;
_CallNum = Encoding.ASCII.GetBytes(CallerNum);
if (iTrunkID != -1)
{
return ISUP_Lib.DJISUP_Callout(iTrunkID / 30, iTrunkID % 30, ref CalleeNum, ref CallerNum);
}
else
{
return false;
}
}
/**//// <summary>
/// byte][
/// </summary>
/// <param name="iTrunkID"></param>
/// <param name="CalleeNum"></param>
/// <param name="CallerNum"></param>
/// <returns></returns>
public static bool bCallOut(int iTrunkID, byte[] CalleeNum, byte[] CallerNum)
{
unsafe
{
if (iTrunkID != -1)
{
return ISUP_Lib.DJISUP_Callout(iTrunkID / 30, iTrunkID % 30, CalleeNum, CallerNum);
}
else
{
return false;
}
}
}
/**//// <summary>
/// char *
/// </summary>
/// <param name="iTrunkID"></param>
/// <param name="calleeNum"></param>
/// <param name="callerNum"></param>
/// <returns></returns>
public static unsafe bool bCallOut(int iTrunkID, StringBuilder calleeNum, StringBuilder callerNum)
{
unsafe
{
if (iTrunkID != -1)
{
return ISUP_Lib.DJISUP_Callout(iTrunkID / 30, iTrunkID % 30, calleeNum, callerNum);
}
else
{
return false;
}
}
}
/**//// <summary>
/// char *
/// </summary>
/// <param name="iTrunkID"></param>
/// <param name="CalleeNum"></param>
/// <param name="CallerNum"></param>
/// <returns></returns>
public static unsafe bool bCallOut(int iTrunkID, string sCalleeNum, string sCallerNum, bool isM, bool isMT)
{
unsafe
{
char[] sCallNumarr = sCalleeNum.ToCharArray();
char[] sCallerNumarr = sCallerNum.ToCharArray();
if (iTrunkID != -1)
{
return
ISUP_Lib.DJISUP_Callout(iTrunkID / 30, iTrunkID % 30, sCallNumarr, out sCallerNumarr, out isM,
out isMT);
}
else
{
return false;
}
}
}
/**//// <summary>
/// ulong
/// </summary>
/// <param name="iTrunkID"></param>
/// <param name="CalleeNum"></param>
/// <param name="CallerNum"></param>
/// <returns></returns>
public static bool bCallOut(int iTrunkID, ulong CalleeNum, ulong CallerNum)
{
unsafe
{
if (iTrunkID != -1)
{
return ISUP_Lib.DJISUP_Callout(iTrunkID / 30, iTrunkID % 30, ref CalleeNum, ref CallerNum);
}
else
{
return false;
}
}
}
/**//// <summary>
/// 初始化索引通道
/// </summary>
/// <param name="TrunkID"></param>
public static void PlayFileInit(int TrunkID)
{
DJFunction.DJVoc_InitIndexPlayFile(TrunkID);
}
/**//// <summary>
/// 添加索引文件
/// </summary>
/// <param name="TrunkID"></param>
/// <param name="FileName"></param>
/// <returns></returns>
public static bool AddIndexFile(int TrunkID, byte[] FileName)
{
return DJFunction.DJVoc_AddIndexPlayFile(TrunkID, FileName);
}
/**//// <summary>
/// 开始播放索引文件
/// </summary>
/// <param name="TrunkID"></param>
/// <returns></returns>
public static bool PlayFileStart(int TrunkID)
{
return DJFunction.DJVoc_StartIndexPlayFile(TrunkID);
}
/**//// <summary>
/// 停止播放索引文件
/// </summary>
/// <param name="TrunkID"></param>
/// <returns></returns>
public static void PlayFileEnd(int TrunkID)
{
DJFunction.DJVoc_StopIndexPlayFile(TrunkID);
}
/**//// <summary>
/// 检查是否索引播放结束
/// </summary>
/// <param name="TrunkID"></param>
/// <returns></returns>
public static bool PlayFileEndCHK(int TrunkID)
{
return DJFunction.DJVoc_CheckIndexPlayEnd(TrunkID);
}
#endregion
获取空闲中继信道#region 获取空闲中继信道
/**//// <summary>
/// 获取空闲中继信道
/// </summary>
/// <returns></returns>
public static int iFreePCM()
{
byte mo_NO = 0, dt_NO = 0;
if (ISUP_Lib.DJISUP_GetCalloutChnNew(ref mo_NO, ref dt_NO))
{
return (int)(mo_NO * 30 + dt_NO);
}
return -1;
}
#endregion
用户#region 用户
/**//// <summary>
/// 用户通道总数
/// </summary>
/// <returns></returns>
public static int iUserTotal()
{
return DJFunction.DJUser_GetTotalUserNum();
}
/**//// <summary>
/// 呼出状态
/// </summary>
/// <param name="iPCMID"></param>
/// <param name="iTrunkID"></param>
/// <returns></returns>
public static int iCallOutStates(int iPCMID, int iTrunkID)
{
return ISUP_Lib.DJISUP_GetCalloutState(iPCMID, iTrunkID);
}
/**//// <summary>
/// 获取路径
/// </summary>
/// <returns></returns>
//public static byte[] appDIR()
//{
// return DJFunction.DJSys_GetInstallDir();
//}
/**//// <summary>
/// 获取路径
/// </summary>
/// <returns></returns>
public static StringBuilder appDIRStr()
{
return DJFunction.DJSys_GetInstallDir();
}
/**//// <summary>
/// 播放语音
/// </summary>
/// <param name="iTrunkID"></param>
/// <returns></returns>
public static bool bISplayVoice(int iTrunkID, byte[] sVoiceFile)
{
int iISFree = DJFunction.DJVoc_SFVC_ForPlay_New(iTrunkID, true);
if (iISFree == -1)
{
return false;
}
//if()
bool bISPlayFile = DJFunction.DJVoc_PlayFile(iTrunkID, sVoiceFile);
//bool bISLink =DJFunction.DJExg_SetLinkPlayVoiceToTrunk(iTrunkID, iISFree);
if (!bISPlayFile)
{
return false;
}
//if (!bISLink)
//{
// return false;
//}
return true;
}
public static int iPlayVoice(int iVoiceChn)
{
return DJFunction.DJVoc_VoiceStart(iVoiceChn);
}
/**//// <summary>
/// 断开语音通道链接
///
/// </summary>
/// <param name="iTrunkID"></param>
/// <returns></returns>
public static bool ClearCHN(int iTrunkID)
{
return DJFunction.DJExg_ClearLinkTrunkAndUserByTrunk(iTrunkID);
}
/**//// <summary>
/// 初始化用户馈电
/// </summary>
/// <param name="iUserCHNID"></param>
public static void UserPowerOn(int iUserCHNID)
{
DJFunction.DJUser_SetPowerON(iUserCHNID);
}
/**//// <summary>
/// 允许用户通道在摘机时自动送拨号音,这是系统的缺省工作方式。
/// </summary>
/// <param name="iUserCHNID"></param>
/// <returns></returns>
public static bool UserEnableDailSound(int iUserCHNID)
{
return DJFunction.DJUser_EnableDialSound(iUserCHNID);
}
/**//// <summary>
/// 对给定的语音通道循环播放系统提示音。
/// </summary>
/// <param name="voiceCHNID"></param>
/// <param name="voiceFileName"></param>
/// <returns></returns>
public static bool LoopVoiceM(int voiceCHNID, StringBuilder voiceFileName)
{
return DJFunction.DJVoc_LoopPlayPromptFile(voiceCHNID, voiceFileName);
}
/**//// <summary>
/// 空闲语音通道
/// </summary>
/// <returns></returns>
public static int iFreeVoiceCHNID()
{
return DJFunction.DJVoc_SearchFreeVoiceChannelForPlay();
}
/**//// <summary>
/// 检查是否正在对用户模块振铃
/// </summary>
/// <param name="iUserID"></param>
/// <returns></returns>
public static bool bIsRingDerctor(int iUserCHNID)
{
return DJFunction.DJUser_RingDetect(iUserCHNID);
}
/**//// <summary>
/// 停止用户通道振铃
/// </summary>
/// <param name="iUserCHNID"></param>
/// <returns></returns>
public static bool bIsStopRing(int iUserCHNID)
{
return DJFunction.DJUser_StopRing(iUserCHNID);
}
/**//// <summary>
/// 断开放音语音通道和用户通道之间的联接
/// </summary>
/// <param name="iUserCHNID"></param>
/// <returns></returns>
public static bool bClearVoiceFromUser(int iUserCHNID)
{
return DJFunction.DJExg_ClearLinkPlayVoiceFromUser(iUserCHNID);
}
/**//// <summary>
/// 复位用户DTMF拨号信息,拨号位数置 0,DTMF缓冲区清空
/// </summary>
/// <param name="iUserCHNID"></param>
/// <returns></returns>
public static bool bIsInitDailBuf(int iUserCHNID)
{
return DJFunction.DJUser_InitDialBuf(iUserCHNID);
}
/**//// <summary>
/// 得用LINK方式联接在本通道上的用户通道号。
/// </summary>
/// <param name="iTrunkID"></param>
/// <returns></returns>
public static int iLinkUserCHNID(int iTrunkID)
{
return DJFunction.DJTrk_GetConnectUserID(iTrunkID);
}
/**//// <summary>
/// 取得给本通道放音的语音通道号,如果没有放音通道与本中继通道相连,返回-1
/// </summary>
/// <param name="iTrunkID"></param>
/// <returns></returns>
public static int iVoicePlayForTrunk(int iTrunkID)
{
return DJFunction.DJTrk_GetTrunkPlayID(iTrunkID);
}
/**//// <summary>
/// 断开中继通道和放音语音通道的连通。
/// </summary>
/// <param name="iTrunkID"></param>
/// <returns></returns>
public static bool bIsClearTrunkVoiceLink(int iTrunkID)
{
return DJFunction.DJExg_ClearLinkPlayVoiceFromTrunk(iTrunkID);
}
/**//// <summary>
/// 清空系统的DTMF缓冲区,如果在缓冲区中有DTMF按键的值,将会丢失
/// </summary>
/// <param name="iTrunkID"></param>
/// <returns></returns>
public static bool bIsInitDtmfByTrunkID(int iTrunkID)
{
return DJFunction.DJTrk_InitDtmfBuf(iTrunkID);
}
/**//// <summary>
/// 获取CPG返回
/// </summary>
/// <param name="iTrunkID"></param>
/// <returns></returns>
public static int iCPGReval(int iTrunkID)
{
return ISUP_Lib.DJISUP_GetEventInfo(iTrunkID / 30, iTrunkID % 30);
}
/**//// <summary>
/// 获取ISUP返回
/// </summary>
/// <param name="iTrunkID"></param>
/// <returns></returns>
public static int ISUPReVal(int iTrunkID)
{
return ISUP_Lib.DJISUP_GetRecvCauseValue(iTrunkID / 30, iTrunkID % 30);
}
/**//// <summary>
/// 检查该语音通道的语音操作是否结束,即录放音是否到达指定的大小。
/// </summary>
/// <param name="iVocCHNID"></param>
/// <returns></returns>
public static bool bIsVocPlayEnd(int iVocCHNID)
{
return DJFunction.DJVoc_CheckVoiceEnd(iVocCHNID);
}
/**//// <summary>
/// 停止文件放音。多次调用本函数没有影响
/// </summary>
/// <param name="iTrunkID"></param>
public static void StopPlayVocInTrunk(int iTrunkID)
{
DJFunction.DJVoc_StopPlayFile(iTrunkID);
}
#endregion
}
}
Code
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Runtime.InteropServices;
5
6namespace DJVoiceCard.Lib
7{
8 public class DJFunction
9 {
10 /**//// <summary>
11 /// 初始化东进七号信令中继语音卡的硬件
12 /// </summary>
13 /// <param name="sIncFileName">INI系统配置文件名</param>
14 /// <param name="sVoiceIncFileName">提示音对照表文件名,一般使用PROMPT.INI</param>
15 /// <returns>0,成功;其他:-12,在读取INI文件时错误;
16 /// -17,打开驱动程序的设备文件时错误[驱动程序名为:DJPCI-东进七号信令中继语音卡,NT;DJPCI2K 东进七号信令中继语音卡,2000];
17 /// -18,检查硬件失败;
18 /// -19,读取提示音文件时失败;
19 /// </returns>
20 [DllImport("Tce1_32.dll", CharSet = CharSet.Ansi)]
21 public static extern int DJSys_EnableCard(StringBuilder sIncFileName, StringBuilder sVoiceIncFileName);
22
23 /**//// <summary>
24 /// 结束所有中继语音卡的操作, 释放API所占用的资源, 复位中继语音卡的状态, 应该在程序结束前调用。
25 /// 由于同DJSys_EnableCard类似的原因,当调用本函数之后,你就不能再调用其他的有关数字中继卡的函数。
26 /// 只有DJSys_EnableCard函数成功后,才能调用本函数,并且要求成对出现。
27 /// </summary>
28 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
29 public static extern void DJSys_DisableCard();
30
31 /**//// <summary>
32 /// 得到系统内中继通道总数;
33 /// </summary>
34 /// <returns></returns>
35 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
36 public static extern int DJTrk_GetTotalTrunkNum();
37
38
39 /**//// <summary>
40 /// 维持文件录音和文件放音连续的函数。
41 /// 要求应用程序必须在小于4秒钟内调用本函数一次(允许多次)。
42 /// 在数字中继卡的底层驱动程序中,对每个语音通道开辟了64K的缓冲区。
43 /// 当进行文件方式的录音或放音时,不断的调用函数DJSys_PushPlay可以保证缓冲区的更新。
44 /// </summary>
45 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
46 public static extern void DJSys_PushPlay();
47
48 /**//// <summary>
49 /// 获得PCM中继ID
50 /// </summary>
51 /// <param name="trunkID">中继通道号;</param>
52 /// <returns></returns>
53 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
54 public static extern int DJTrk_GetPcmID(int trunkID);
55
56
57 /**//// <summary>
58 /// 根据中继通道号,来断开本中继通道与用户通道之间的双向连通,对应DJExg_SetLinkTrunkAndUser
59 /// </summary>
60 /// <param name="trunkID"></param>
61 /// <returns></returns>
62 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
63 public static extern bool DJExg_ClearLinkTrunkAndUserByTrunk(int trunkID);
64
65 /**//// <summary>
66 /// 使能发送DTMF的功能。
67 /// </summary>
68 /// <returns></returns>
69 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
70 public static extern bool DJSys_EnableDtmfSend();
71
72 /**//// <summary>
73 /// 取用户通道总数。如果是一片D161A/D081A卡,本函数返回16/8,依次类推。
74 /// 函数返回:● 系统内的用户通道数
75 /// </summary>
76 /// <returns> 系统内的用户通道数</returns>
77 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
78 public static extern int DJUser_GetTotalUserNum();
79
80 /**//// <summary>
81 /// 搜索一个空闲的语音通道
82 /// </summary>
83 /// <param name="trunkID"></param>
84 /// <param name="IsForTrunk"></param>
85 /// <returns></returns>
86 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
87 public static extern int DJVoc_SFVC_ForPlay_New(int trunkID, bool IsForTrunk);
88
89 /**//// <summary>
90 /// 播放语音文件
91 /// </summary>
92 /// <param name="voiceID"></param>
93 /// <param name="voiceName"></param>
94 /// <returns></returns>
95 [DllImport("Tce1_32.dll", CharSet = CharSet.Ansi)]
96 public static extern bool DJVoc_PlayPromptFile(int voiceID,byte[] voiceName);
97
98 /**//// <summary>
99 /// 建立放音语音通道到中继通道的连通。本函数在本质上是一个中继通道去听语音通道。
100 /// 当中继通道处于准备好状态,语音通道已经开始操作(直接或间接调用过DJVoc_VoiceStart 函数),
101 /// 则可通过此函数将语音通道中的语音放给中继通道上的电话用户听。
102 /// </summary>
103 /// <param name="trunkID"></param>
104 /// <param name="voiceID"></param>
105 /// <returns></returns>
106 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
107 public static extern bool DJExg_SetLinkPlayVoiceToTrunk(int trunkID, int voiceID);
108
109 /**//// <summary>
110 /// 对用户模块馈电,这是系统的初始状态,当userID越界时,调用DJSYS_GetErrCode得到_ERR_InvalidID。
111 /// 只有在直流电源正常工作状态下,用户通道才能正常操作,系统启动后缺省为开电源。
112 /// 如果你正常的接入电源,则调用完本函数后,与该userID相连的电话机将会处于有馈电的状态,拿起话机听筒,在电话机上按键,会听到按键的声音。
113 /// 当该用户通道插入的是中继模块,用来接入模拟电话线时,调用本函数,相当于电话机摘机。
114 /// 由于这是系统的缺省状态,所以,如果是中继模块,在初始化时,需要将所有的中继模块挂机,这可以通过调用函数DJUser_SetPowerOFF来完成。
115 /// </summary>
116 /// <param name="userID">用户通道号</param>
117 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
118 public static extern void DJUser_SetPowerON(int userID);
119
120 /**//// <summary>
121 /// 允许用户通道在摘机时自动送拨号音,这是系统的缺省工作方式。当userID越界时,返回 0,同时置ErrCode=_ERR_InvalidID.
122 /// 当处于使能方式时,用户通道所连接的电话机摘机后,系统自动送拨号音,如果按下电话机上的按键,会自动停止拨号音;
123 /// 电话机挂机,也自动停止拨号音。
124 /// </summary>
125 /// <param name="userID"></param>
126 /// <returns></returns>
127 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
128 public static extern bool DJUser_EnableDialSound(int userID);
129 /**//// <summary>
130 /// 对给定的语音通道循环播放系统提示音
131 /// 函数返回:1● 操作成功;0 ● 操作失败,调用DJSys_GetErrCode函数将返回失败原因;
132 /// </summary>
133 /// <param name="voiceID">语音通道号</param>
134 /// <param name="voiceName">系统提示音名字</param>
135 /// <returns></returns>
136 [DllImport("Tce1_32.dll", CharSet = CharSet.Ansi)]
137 public static extern bool DJVoc_LoopPlayPromptFile(int voiceID, StringBuilder voiceName);
138
139 /**//// <summary>
140 /// 搜索返回一个空闲的用于放音的语音通道
141 /// </summary>
142 /// <returns></returns>
143 [DllImport("Tce1_32.dll", CharSet = CharSet.Ansi)]
144 public static extern int DJVoc_SearchFreeVoiceChannelForPlay();
145
146 /**//// <summary>
147 /// 检查是否正在对用户模块振铃。当userID越界时,返回 0,同时置ErrCode=_ERR_InvalidID
148 /// 函数返回:
149 /// 1● 正在振铃
150 /// 0● 非振铃
151 /// </summary>
152 /// <param name="userID"> 用户通道号</param>
153 /// <returns></returns>
154 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
155 public static extern bool DJUser_RingDetect(int userID);
156
157 /**//// <summary>
158 /// 使用户通道开始振铃。当userID越界时,返回 0,同时置ErrCode=_ERR_InvalidID。
159 /// 调用本函数,将会对用户模块所连接的电话机振铃,该振铃是断续的振铃声,由底层驱动程序来控制振铃的时间间隔.
160 /// 函数返回
161 /// 1● 操作成功
162 /// 0● 操作失败,调用DJSys_GetErrCode()将返回失败原因
163 /// 如果要使电话机振铃,必须正确的接入外接电源和铃流源。
164 /// </summary>
165 /// <param name="userID"> 用户通道号</param>
166 /// <returns></returns>
167 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
168 public static extern bool DJUser_StartRing(int userID);
169
170 /**//// <summary>
171 /// 停止用户模块的振铃。当userID越界时,返回 0,同时置ErrCode=_ERR_InvalidID。
172 /// 函数返回:
173 /// 1● 操作成功
174 /// 0● 操作失败,调用DJSys_GetErrCode()将返回失败原因
175 /// </summary>
176 /// <param name="userID">用户通道号</param>
177 /// <returns></returns>
178 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
179 public static extern bool DJUser_StopRing(int userID);
180
181 /**//// <summary>
182 /// 断开放音语音通道和用户通道之间的联接
183 /// </summary>
184 /// <param name="userID"></param>
185 /// <returns></returns>
186 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
187 public static extern bool DJExg_ClearLinkPlayVoiceFromUser(int userID);
188
189 /**//// <summary>
190 /// 复位用户DTMF拨号信息,拨号位数置 0,DTMF缓冲区清空。当userID越界时,返回 0,同时置ErrCode=_ERR_InvalidID。
191 /// 参考函数DJUser_GetDialCode的功能描述。
192 /// 函数返回:
193 /// 1● 操作成功
194 /// 0● 操作失败,调用DJSys_GetErrCode()将返回失败原因
195 /// </summary>
196 /// <param name="userID">用户通道号</param>
197 /// <returns></returns>
198 ///
199 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
200 public static extern bool DJUser_InitDialBuf(int userID);
201
202
203 /**//// <summary>
204 /// 得用LINK方式联接在本通道上的用户通道号。
205 /// </summary>
206 /// <param name="trunkID"></param>
207 /// <returns></returns>
208 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
209 public static extern int DJTrk_GetConnectUserID(int trunkID);
210
211 /**//// <summary>
212 /// 取得给本通道放音的语音通道号,如果没有放音通道与本中继通道相连,返回-1
213 /// </summary>
214 /// <param name="trunkID"></param>
215 /// <returns></returns>
216 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
217 public static extern int DJTrk_GetTrunkPlayID(int trunkID);
218
219
220 /**//// <summary>
221 /// 断开中继通道和放音语音通道的连通。
222 /// </summary>
223 /// <param name="trunkID"></param>
224 /// <returns></returns>
225 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
226 public static extern bool DJExg_ClearLinkPlayVoiceFromTrunk(int trunkID);
227
228 /**//// <summary>
229 /// 清空系统的DTMF缓冲区,如果在缓冲区中有DTMF按键的值,将会丢失
230 /// </summary>
231 /// <param name="trunkID"></param>
232 /// <returns></returns>
233 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
234 public static extern bool DJTrk_InitDtmfBuf(int trunkID);
235
236 /**//// <summary>
237 /// 检查该语音通道的语音操作是否结束,即录放音是否到达指定的大小。
238 /// </summary>
239 /// <param name="voiceChannelID"></param>
240 /// <returns></returns>
241 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
242 public static extern bool DJVoc_CheckVoiceEnd(int voiceChannelID);
243
244 /**//// <summary>
245 /// 停止文件放音。多次调用本函数没有影响
246 /// </summary>
247 /// <param name="trunkID"></param>
248 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
249 public static extern void DJVoc_StopPlayFile(int trunkID);
250
251 /**//// <summary>
252 /// 得到当前软件开发系统的安装目录。该目录等于INI配置文件中的InstallDir的设置。
253 /// </summary>
254 /// <returns></returns>
255 //[DllImport("Tce1_32.dll", CharSet = CharSet.Ansi)]
256 //public static extern byte[] DJSys_GetInstallDir();
257 /**//// <summary>
258 /// 得到当前软件开发系统的安装目录。该目录等于INI配置文件中的InstallDir的设置。
259 /// </summary>
260 /// <returns></returns>
261 [DllImport("Tce1_32.dll", CharSet = CharSet.Ansi)]
262 public static extern StringBuilder DJSys_GetInstallDir();
263
264 /**//// <summary>
265 /// 放音
266 /// </summary>
267 /// <param name="trunkID"></param>
268 /// <param name="FileName"></param>
269 /// <returns></returns>
270 [DllImport("Tce1_32.dll", CharSet = CharSet.Ansi)]
271 public static extern bool DJVoc_PlayFile(int trunkID, byte[] FileName);
272 /**//// <summary>
273 /// 开始放音
274 /// </summary>
275 /// <param name="voiceChannelID"></param>
276 /// <returns></returns>
277 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
278 public static extern int DJVoc_VoiceStart(int voiceChannelID);
279 /**//// <summary>
280 /// 初始化中继通道索引放音
281 /// </summary>
282 /// <param name="trunkID">中继通道</param>
283 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
284 public static extern void DJVoc_InitIndexPlayFile(int trunkID);
285
286 /**//// <summary>
287 /// 增加索引放音文件。失败的可能原因有文件不存在,或者文件索引数组已满(最多100个)。
288 /// </summary>
289 /// <param name="trunkID">中继通道</param>
290 /// <param name="FileName">文件路径</param>
291 /// <returns></returns>
292 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
293 public static extern bool DJVoc_AddIndexPlayFile(int trunkID, byte[] FileName);
294
295
296 /**//// <summary>
297 /// 开始一次文件索引放音。
298 /// </summary>
299 /// <param name="trunkID">中继通道</param>
300 /// <returns></returns>
301 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
302 public static extern bool DJVoc_StartIndexPlayFile(int trunkID);
303
304
305 /**//// <summary>
306 /// 停止索引文件放音。该函数停止指定中继通道的索引文件放音,使用DJVoc_StartIndexPlayFile函数进行多文件放音结束,一定要调用该函数来停止放音
307 ///
308 /// </summary>
309 /// <param name="trinkID"></param>
310 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
311 public static extern void DJVoc_StopIndexPlayFile(int trinkID);
312
313 /**//// <summary>
314 /// 检查索引文件放音是否结束,并维护索引文件放音的持续。当进行索引文件放音时,必须调用该函数,以保证索引文件放音的连续性
315 /// </summary>
316 /// <param name="trunkID"></param>
317 /// <returns></returns>
318 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
319 public static extern bool DJVoc_CheckIndexPlayEnd(int trunkID);
320 }
321}
322
Code
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Runtime.InteropServices;
5
6namespace DJVoiceCard.Lib
7{
8 public struct TC_INI_TYPE
9 {
10 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
11 public byte[] bCallNum;
12 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
13 public byte[] bCalleeNum;
14 }
15 public struct FL_PA
16 {
17 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
18 public byte[] bFilePath;
19 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
20 public byte[] bVoiceFile;
21 }
22 public class ISUP_Lib
23 {
24 /**//// <summary>
25 ///
26 /// </summary>
27 /// <param name="mo_num">本机内的PCM逻辑编号,从0开始</param>
28 /// <param name="dt_num">PCM内的中继通道号,0-29</param>
29 /// <param name="state">本中继通道要采取的动作 </param>
30 /// <param name="Param1"></param>
31 /// <param name="Param2"></param>
32 /// <param name="Param3"></param>
33 /// <param name="Param4"></param>
34 [DllImport("TCISUP.dll", CharSet = CharSet.Auto)]
35 public static extern void DJISUP_SetChnState(byte mo_num, byte dt_num, byte state);
36
37 /**//// <summary>
38 /// 七号信令系统接口初始化,在应用程序初始化时调用。
39 /// 调用本函数,首先检查在本机内是否已经启动了七号信令链路的处理程序CCS7SERVER.EXE;
40 /// 如果已经运行,则初始化本程序和CCS7SERVER.EXE之间的接口,以便能够通过CCS7SERVER.EXE来收发有关七号信令的信息包。
41 /// 本函数应在DJSys_EnableCard之前调用
42 /// </summary>
43 /// <returns>1● 初始化成功;-1● 没有七号信令处理程序CCS7SERVER运行,或者在读取TC-NO7.INI时发生错误。</returns>
44 [DllImport("TCISUP.dll", CharSet = CharSet.Auto)]
45 public static extern int DJISUP_InitSystem();
46
47
48
49 /**//// <summary>
50 /// 本函数在程序退出时调用,用以释放调用初始化函数DJISUP_InitSystem时所分配的内存。
51 /// </summary>
52 [DllImport("TCISUP.dll", CharSet = CharSet.Auto)]
53 public static extern void DJISUP_ExitSystem();
54
55
56 /**//// <summary>
57 /// 中继通道(mo_num,dt_num)的当前状态,可能的返回值是:
58 /// #define ISUP_CH_FREE 1 // 空闲状态
59 /// #define ISUP_CH_WAIT_RELEASE 2 // DLL等待应用程序同步释放资源
60 /// #define ISUP_CH_LOCAL_BLOCK 3 // 本地闭塞状态
61 /// #define ISUP_CH_REMOTE_BLOCK 4 // 远端闭塞状态
62 /// #define ISUP_CH_LOCAL_AND_REMOTE_BLOCK 5 //本地和远端锁闭状态
63 /// #define ISUP_CH_UNAVIABLE 6 // 不可用态(网络不通等原因导致)
64 /// #define ISUP_CALLER_WAIT_ANM 7 //被叫闲,等待被叫应答
65 /// #define ISUP_CALLER_CONNECT 8 // 去话连通状态
66 /// #define ISUP_CALLEE_RECV_IAM 9 // 呼叫到达,接收全地址
67 /// #define ISUP_CALLEE_CONNECT 10 // 摘机,来话连通
68 /// #define ISUP_CH_LOCAL_SUSPEND 11 // 本地暂停
69 /// #define ISUP_CH_REMOTE_SUSPEND 12 // 远端暂停
70 /// 注意:
71 /// 应用层程序应循环调用该函数,并根据取得的状态采取相应的动作。
72 /// </summary>
73 /// <param name="mo_num">本机内的PCM逻辑编号,从0开始</param>
74 /// <param name="dt_num">PCM内的中继通道号,0-29</param>
75 /// <returns></returns>
76 [DllImport("TCISUP.dll", CharSet = CharSet.Auto)]
77 public static extern int DJISUP_GetChnState(byte PCM_NO, byte Relay_NO);
78
79 /**//// <summary>
80 /// 获取呼出的主叫号码
81 /// ref 参数所指的就是呼出主叫号码
82 /// </summary>
83 /// <param name="PCM_NO"></param>
84 /// <param name="Relay_NO"></param>
85 /// <param name="Call_NO"></param>
86 [DllImport("TCISUP.dll", CharSet = CharSet.Auto)]
87 public static extern void DJISUP_GetCallerNum(byte PCM_NO, byte Relay_NO, ref TC_INI_TYPE Call_NO);
88
89 /**//// <summary>
90 /// 呼叫到达时,用本函数来取得被叫号码。
91 /// 当函数返回后,在call_id所指向的字符串数组中,存放有已经收到的号码。
92 /// 注意,call_id所指向的字符串数组必须事先分配好空间。
93 /// </summary>
94 /// <param name="PCM_NO"></param>
95 /// <param name="Relay_NO"></param>
96 /// <param name="Callee_NO"></param>
97 [DllImport("TCISUP.dll", CharSet = CharSet.Auto)]
98 public static extern void DJISUP_GetCalleeNum(byte PCM_NO, byte Relay_NO, ref TC_INI_TYPE Callee_NO);
99
100
101 /**//// <summary>
102 /// 处理中继通道的事件,改变中继通道的状态。
103 /// 此函数要在主流程的大循环中调用,一般同函数DJSys_PushPlay放在一起。
104 /// 通过本函数,系统的状态才能发生变迁。
105 /// </summary>
106 [DllImport("TCISUP.dll", CharSet = CharSet.Auto)]
107 public static extern void DJISUP_GetEvent();
108
109 /**//// <summary>
110 /// 维持文件录音和文件放音连续的函数。
111 /// 要求应用程序必须在小于4秒钟内调用本函数一次(允许多次)。
112 /// 在数字中继卡的底层驱动程序中,对每个语音通道开辟了64K的缓冲区。
113 /// 当进行文件方式的录音或放音时,不断的调用函数DJSys_PushPlay可以保证缓冲区的更新。
114 /// </summary>
115 [DllImport("Tce1_32.dll", CharSet = CharSet.Auto)]
116 public static extern void DJSys_PushPlay();
117
118
119 /**//// <summary>
120 /// 获取Dtmf号码
121 /// </summary>
122 /// <param name="trunkID"></param>
123 /// <returns></returns>
124 [DllImport("Tce1_32.dll", CharSet = CharSet.Ansi)]
125 public static extern StringBuilder DJTrk_GetDtmfCode(int trunkID);
126
127
128 /**//// <summary>
129 /// 对某一个中继通道启动一次呼出
130 /// </summary>
131 /// <param name="nPCM">本机内的PCM逻辑编号,从0开始</param>
132 /// <param name="nCHN">PCM内的中继通道号,0-29</param>
133 /// <param name="szCalleeNumber">呼出时的被叫号码</param>
134 /// <param name="szCallerNumber">呼出时的主叫号码</param>
135 /// <returns></returns>
136 ///
137 //[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]
138 [DllImport("TCISUP.dll", CharSet = CharSet.Auto)]
139 public static extern bool DJISUP_Callout(int nPCM, int nCHN, char[] szCalleeNumber, out char[] szCallerNumber, out bool bCalleeSignalTerminal, out bool bCallerSignalTerminal);
140 /**//// <summary>
141 /// 对某一个中继通道启动一次呼出
142 /// </summary>
143 /// <param name="nPCM">本机内的PCM逻辑编号,从0开始</param>
144 /// <param name="nCHN">PCM内的中继通道号,0-29</param>
145 /// <param name="szCalleeNumber">呼出时的被叫号码</param>
146 /// <param name="szCallerNumber">呼出时的主叫号码</param>
147 /// <returns></returns>
148 ///
149 //[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]
150 [DllImport("TCISUP.dll", CharSet = CharSet.Ansi)]
151 public unsafe static extern bool DJISUP_Callout(int nPCM, int nCHN,StringBuilder szCalleeNumber,StringBuilder szCallerNumber);
152 /**//// <summary>
153 /// 对某一个中继通道启动一次呼出
154 /// </summary>
155 /// <param name="nPCM">本机内的PCM逻辑编号,从0开始</param>
156 /// <param name="nCHN">PCM内的中继通道号,0-29</param>
157 /// <param name="szCalleeNumber">呼出时的被叫号码</param>
158 /// <param name="szCallerNumber">呼出时的主叫号码</param>
159 /// <returns></returns>
160 ///
161 //[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]
162 [DllImport("TCISUP.dll", CharSet = CharSet.Ansi)]
163 public unsafe static extern bool DJISUP_Callout(int nPCM, int nCHN, ref ulong szCalleeNumber, ref ulong szCallerNumber);
164 /**//// <summary>
165 /// 对某一个中继通道启动一次呼出
166 /// </summary>
167 /// <param name="nPCM">本机内的PCM逻辑编号,从0开始</param>
168 /// <param name="nCHN">PCM内的中继通道号,0-29</param>
169 /// <param name="szCalleeNumber">呼出时的被叫号码</param>
170 /// <param name="szCallerNumber">呼出时的主叫号码</param>
171 /// <returns></returns>
172 ///
173 //[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]
174 [DllImport("TCISUP.dll", CharSet = CharSet.Ansi)]
175 public unsafe static extern bool DJISUP_Callout(int nPCM, int nCHN, ref StringBuilder szCalleeNumber, ref StringBuilder szCallerNumber);
176 /**//// <summary>
177 /// 对某一个中继通道启动一次呼出
178 /// </summary>
179 /// <param name="nPCM">本机内的PCM逻辑编号,从0开始</param>
180 /// <param name="nCHN">PCM内的中继通道号,0-29</param>
181 /// <param name="szCalleeNumber">呼出时的被叫号码</param>
182 /// <param name="szCallerNumber">呼出时的主叫号码</param>
183 /// <returns></returns>
184 ///
185 //[MarshalAs(UnmanagedType.ByValArray,SizeConst=32)]
186 [DllImport("TCISUP.dll", CharSet = CharSet.Ansi)]
187 public unsafe static extern bool DJISUP_Callout(int nPCM, int nCHN, ref char[] szCalleeNumber, ref char[] szCallerNumber);
188 /**//// <summary>
189 /// 对某一个中继通道启动一次呼出
190 /// </summary>
191 /// <param name="nPCM">本机内的PCM逻辑编号,从0开始</param>
192 /// <param name="nCHN">PCM内的中继通道号,0-29</param>
193 /// <param name="szCalleeNumber">呼出时的被叫号码</param>
194 /// <param name="szCallerNumber">呼出时的主叫号码</param>
195 /// <returns></returns>
196 ///
197 //[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]
198 [DllImport("TCISUP.dll", CharSet = CharSet.Ansi)]
199 public unsafe static extern bool DJISUP_Callout(int nPCM, int nCHN, ref string szCalleeNumber, ref string szCallerNumber);
200
201
202 /**//// <summary>
203 /// 对某一个中继通道启动一次呼出
204 /// </summary>
205 /// <param name="nPCM">本机内的PCM逻辑编号,从0开始</param>
206 /// <param name="nCHN">PCM内的中继通道号,0-29</param>
207 /// <param name="szCalleeNumber">呼出时的被叫号码</param>
208 /// <param name="szCallerNumber">呼出时的主叫号码</param>
209 /// <returns></returns>
210 ///
211 //[MarshalAs(UnmanagedType.ByValArray,SizeConst=32)]
212 [DllImport("TCISUP.dll", CharSet = CharSet.Ansi)]
213 public unsafe static extern bool DJISUP_Callout(int nPCM, int nCHN, byte[] szCalleeNumber, byte[] szCallerNumber);
214
215
216 /**//// <summary>
217 /// 调用DJISUP_Callout对某通道启动一次呼出之后,
218 /// 通过调用该函数获取呼出状态,
219 /// 其返回值以如下位掩码的形式存放,
220 /// 故将返回值与下列值做与(&)运算,即可知当前呼出状态。
221 /// </summary>
222 /// <param name="nPCM"></param>
223 /// <param name="nCHN"></param>
224 /// <returns></returns>
225 [DllImport("TCISUP.dll", CharSet = CharSet.Auto)]
226 public static extern int DJISUP_GetCalloutState(int nPCM, int nCHN);
227
228 /**//// <summary>
229 /// 该函数用来在单信令点时选择一个用来呼出的中继通道,
230 /// 此函数较DJISUP_GetCalloutChn增加了处理同抢的功能,
231 /// 且可选的呼出通道范围为本机内的所有通道。一般情况,
232 /// 应用程序也可以自己来查找一个空闲的中继通道。
233 /// </summary>
234 /// <param name="mo_num"></param>
235 /// <param name="dt_num"></param>
236 /// <returns></returns>
237 [DllImport("TCISUP.dll", CharSet = CharSet.Auto)]
238 public static extern bool DJISUP_GetCalloutChnNew( ref byte mo_num, ref byte dt_num );
239
240 /**//// <summary>
241 /// 本函数用于获取CPG消息的事件信息,协议规定的事件信息
242 /// </summary>
243 /// <param name="nPCM"></param>
244 /// <param name="nCHN"></param>
245 /// <returns></returns>
246 [DllImport("TCISUP.dll", CharSet = CharSet.Auto)]
247 public static extern int DJISUP_GetEventInfo(int nPCM, int nCHN);
248
249 /**//// <summary>
250 /// 对收到的ISUP消息,获取其中的原因值
251 /// </summary>
252 /// <param name="nPCM"></param>
253 /// <param name="nCHN"></param>
254 /// <returns></returns>
255 [DllImport("TCISUP.dll", CharSet = CharSet.Auto)]
256 public static extern int DJISUP_GetRecvCauseValue(int nPCM, int nCHN);
257
258 }
259}
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using DJVoiceCard.Lib;
namespace DJVoiceCard.DL
{
class DataInc
{
}
public enum RelaySet : int
{
ISUP_CH_SET_FREE=1,
//锁闭通道
ISUP_CH_SET_BLOCK=2,
//解除锁闭
ISUP_CH_SET_UNBLOCK=3,
//来话方动作,来话到达后,送被叫闲信号,话路接通,但不送应答信号
ISUP_CALLEE_SET_ACM=4,
//被叫摘机信号
ISUP_CALLEE_SET_ANM=5,
//来话方动作,来话到达后,送被叫闲信号,话路接通,送应答信号
ISUP_CALLEE_SET_CON =6,
//送线路释放信号
ISUP_CH_SET_REL =7,
//群锁闭
ISUP_CH_SET_CGB =8,
//群解除锁闭
ISUP_CH_SET_CGU =9,
//后续地址
ISUP_CALLER_SET_SAM=10,
//暂停
ISUP_CH_SET_SUS=11,
//恢复
ISUP_CH_SET_RES=12,
//锁闭通道证实
ISUP_CH_SET_BLA=0x81,
//解除锁闭证实
ISUP_CH_SET_UBA=0x82,
//电路复原
ISUP_CH_SET_RSC=0x83,
//信息请求
ISUP_CH_SET_INR=0x84,
//信息
ISUP_CH_SET_INF=0x85,
//群锁闭证实
ISUP_CH_SET_CGBA=0x92,
//群解除锁闭证实
ISUP_CH_SET_CGUA=0x94,
//群复原
ISUP_CH_SET_GRS=0x95,
//群复原证实
ISUP_CH_SET_GRA=0x96,
//群问讯
ISUP_CH_SET_CQM=0x97,
//群问讯响应
ISUP_CH_SET_CQR=0x98,
//释放完成
ISUP_CH_SET_RLC=0x99,
//混淆
ISUP_CH_SET_CFN=0x9a,
//呼叫进展
ISUP_CALLEE_SET_CPG=0xa2,
}
/**//// <summary>
/// 信道状态
/// </summary>
public enum RelayStates : int
{
/**//// <summary>
/// // 空闲状态
/// </summary>
ISUP_CH_FREE=1,
/**//// <summary>
/// // DLL等待应用程序同步释放资源
/// </summary>
ISUP_CH_WAIT_RELEASE=2 ,
/**//// <summary>
/// // 本地闭塞状态
/// </summary>
ISUP_CH_LOCAL_BLOCK=3 ,
/**//// <summary>
/// // 远端闭塞状态
/// </summary>
ISUP_CH_REMOTE_BLOCK=4 ,
/**//// <summary>
/// //本地和远端锁闭状态
/// </summary>
ISUP_CH_LOCAL_AND_REMOTE_BLOCK=5 ,
/**//// <summary>
/// // 不可用态(网络不通等原因导致)
/// </summary>
ISUP_CH_UNAVIABLE=6 ,
/**//// <summary>
/// //被叫闲,等待被叫应答
/// </summary>
ISUP_CALLER_WAIT_ANM=7 ,
/**//// <summary>
/// // 去话连通状态
/// </summary>
ISUP_CALLER_CONNECT=8 ,
/**//// <summary>
/// // 呼叫到达,接收全地址
/// </summary>
ISUP_CALLEE_RECV_IAM=9 ,
/**//// <summary>
/// // 摘机,来话连通
/// </summary>
ISUP_CALLEE_CONNECT=10 ,
/**//// <summary>
/// // 本地暂停
/// </summary>
ISUP_CH_LOCAL_SUSPEND=11,
/**//// <summary>
/// // 远端暂停
/// </summary>
ISUP_CH_REMOTE_SUSPEND=12,
/**//// <summary>
/// IAM消息到达
/// </summary>
CALLEE_IAM_REACHED=0xf0,
/**//// <summary>
/// SAM消息到达提示
/// </summary>
CALLEE_SAM_REACHED=0xf1,
}
/**//// <summary>
/// 语音资源类型
/// </summary>
public enum VoiceResourcesType:int
{
/**//// <summary>
/// 没有语音资源
/// </summary>
Res_NoRes = 0,
/**//// <summary>
/// 文件型语音资源
/// </summary>
Res_File = 1,
/**//// <summary>
/// 系统内存型语音资源
/// </summary>
Res_Xms = 2,
};
/**//// <summary>
/// 语音资源操作类型
/// </summary>
public enum VoiceOperatorType
{
/**//// <summary>
/// //没有语音操作
/// </summary>
OP_NoOperator = 0,
/**//// <summary>
/// //普通放音
/// </summary>
OP_Play = 1,
/**//// <summary>
/// //循环放音
/// </summary>
OP_LoopPlay = 2,
};
/**//// <summary>
/// 用户状态类型
/// </summary>
public enum USER_STATE
{
/**//// <summary>
/// 未摘机
/// </summary>
USR_OFFHOOK=0,
/**//// <summary>
/// 等待拨号
/// </summary>
USR_WAITDIAL=1,
/**//// <summary>
/// 拨号
/// </summary>
USR_DIAL=2,
/**//// <summary>
/// 结束
/// </summary>
USR_ENDSESSION=3,
/**//// <summary>
/// 等待语音
/// </summary>
USR_WAITONHOOK=4,
/**//// <summary>
/// 振铃
/// </summary>
USR_RING=5,
/**//// <summary>
/// 通话
/// </summary>
USR_CONNECT=6,
/**//// <summary>
/// 摘机中
/// </summary>
USR_ONHOOK = 50,
/**//// <summary>
/// 取消振铃
/// </summary>
USR_EXRING=51,
/**//// <summary>
/// 退出通话
/// </summary>
USR_EXCONNECT=52
};
/**//// <summary>
/// 中继信道状态
/// </summary>
public enum TRUNK_ST
{
/**//// <summary>
/// 空闲状态
/// </summary>
TRK_FREE=0, //free state
/**//// <summary>
/// 准备状态
/// </summary>
TRK_READY=1, //mfc stop state
/**//// <summary>
/// 振铃状态
/// </summary>
TRK_RING=2, //ring user
/**//// <summary>
/// 拨号状态
/// </summary>
TRK_CALLOUT=3, //user dial over, callout
/**//// <summary>
/// 等待摘机
/// </summary>
TRK_WAITUSEROFFHOOK=4, //ring user, wait offhok
/**//// <summary>
/// 摘机状态
/// </summary>
TRK_WAITUSERONHOOK=5,
/**//// <summary>
/// 结束谈话
/// </summary>
TRK_ENDSESSION=6, //end a talk
/**//// <summary>
/// 链接状态
/// </summary>
TRK_CONNECT=7,
/**//// <summary>
/// 为初始化状态
/// </summary>
TRK_NULLSTATE=8,
/**//// <summary>
/// 播放状态
/// </summary>
TRK_PLAY=9,
/**//// <summary>
/// 呼入状态
/// </summary>
TRK_CALLIN=10,
/**//// <summary>
/// 摘机状态
/// </summary>
TRK_ONHOOK=11,
/**//// <summary>
/// 挂机状态
/// </summary>
TRK_HANGUP=12,
};
/**//// <summary>
/// 用户状态
/// </summary>
public struct UR_ST
{
public int ConnUrID;
public USER_STATE ST;
public int ConnTrID;
}
/**//// <summary>
/// 对收到的ISUP消息,获取其中的原因值
/// </summary>
public enum CAUSE_VALUE:int
{
/**//// <summary>
/// 中继通道的范围越界
/// </summary>
RSN_PCMNULL_CALLER=-1,
/**//// <summary>
/// 收到的消息中不含有原因指示码,或没有新的ISUP消息到达
/// </summary>
RSN_UNKOWNNUM_ISUP=0,
/**//// <summary>
/// //空号
/// </summary>
RSN_UNALLOCATED_NUMBER = 0x01,
/**//// <summary>
/// //正常的呼叫清除
/// </summary>
RSN_NORMAL_CALL_CLEARING = 0x10,
/**//// <summary>
/// //用户忙
/// </summary>
RSN_USER_BUSY = 0x11,
/**//// <summary>
/// //无用户响应
/// </summary>
RSN_NO_USER_RESPONDING = 0x12,
/**//// <summary>
/// //被叫无应答,超时未摘机
/// </summary>
RSN_USER_ALERTING_NO_ANSWER = 0x13,
/**//// <summary>
/// //呼叫拒绝
/// </summary>
RSN_CALL_REJECTED = 0x15,
/**//// <summary>
/// //不完整的号码
/// </summary>
RSN_INCOMPLETE_NUMBER = 0x1c,
/**//// <summary>
/// //正常,未规定
/// </summary>
RSN_NORMAL_NO_SET = 0x1f,
/**//// <summary>
/// //无可用的电路
/// </summary>
RSN_NO_CIRCUIT_CHANNELAVAILABLE = 0x22,
/**//// <summary>
/// //请求的电路不可用
/// </summary>
RSN_REQUESTEDCIRCUIT_CHANNEL_NOTAVAILABLE = 0x2c,
/**//// <summary>
/// //定时器超时恢复
/// </summary>
RSN_RECOVERY_ON_TIME_EXPIRY = 0x66,
/**//// <summary>
/// //本地释放电路
/// </summary>
RSN_LOCAL_RLC = 0x20,
/**//// <summary>
/// //电路复原
/// </summary>
RSN_RECEIVE_RSC = 0x21,
};
/**//// <summary>
/// 信道状态
/// </summary>
public struct TRK_ST
{
public TRUNK_ST ST;
public int ConnUrID;
public int ConnTrID;
public string DialNum;
}
public struct PR
{
[MarshalAs(UnmanagedType.ByValArray,SizeConst=32)]
public char[] TelarrChar;
public char[] CallarrChar;
}
public struct TelNum
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] arrTelNum;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] arrCallNum;
}
}
这几个类是所有代码的核心内容.先贴出来,下一篇会详细说说在交互编程中遇到的问题.