|
调用库
- public interface VoiceLibrary extends StdCallLibrary {
- VoiceLibrary INSTANCE = Native.load(
- System.getProperty("user.dir")+"\\src\\main\\resources\\voice\\BVCSP_x64.dll", VoiceLibrary.class);
- int BVCSP_Initialize(int bAutoHandle, int iTCPDataPort);
- int BVCSP_Login(PointerByReference phSession, BVCSP_SessionParam pParam);
- }
copycode
登录调用
- public static void main(String[] args){
- int result;
- result= VoiceLibrary.INSTANCE.BVCSP_Initialize(1,0);
- System.out.println(result);
- PointerByReference pHSession=new PointerByReference();
- Pointer hSession = pHSession.getValue();
- BVCSP_SessionParam.ByReference sessionParam = new BVCSP_SessionParam.ByReference();
- sessionParam.iSize = 500;
- sessionParam.iTimeOut = 8000;
- sessionParam.szClientID = "towercloud".getBytes();
- sessionParam.szServerAddr = "192.168.1.173".getBytes();
- sessionParam.szUserName = "admin".getBytes();
- sessionParam.szPassword = "123456".getBytes();
- sessionParam.szUserAgent = "bvcsp_towercloud".getBytes();
- sessionParam.iClientType = 16;
- sessionParam.iServerPort = 9701;
- sessionParam.iCmdProtoType = 0;
- sessionParam.OnEvent = new LoginCallbackFunction.OnEventImpl();
- sessionParam.OnCommand = new LoginCallbackFunction.OnCommandImpl();
- sessionParam.OnNotify = new LoginCallbackFunction.OnNotifyImpl();
- sessionParam.OnDialogCmd = new LoginCallbackFunction.OnDialogCmdImpl();
- sessionParam.stEntityInfo.pPUInfo.szName = "fang_CU".getBytes();
- for (int i = 0; i < 4; ++i){
- sessionParam.stEntityInfo.pChannelList[i] = new BVCU_PUCFG_ChannelInfo.ByReference();
- sessionParam.stEntityInfo.pChannelList[i].iChannelIndex = i;
- sessionParam.stEntityInfo.pChannelList[i].iMediaDir = 10;
- }
- sessionParam.stEntityInfo.iChannelCount = 4;
- result=VoiceLibrary.INSTANCE.BVCSP_Login(pHSession,sessionParam);
- System.out.println(result);
- }
copycode
参数定义
- public class BVCSP_SessionParam extends Structure {
- // 本结构体的大小,分配者应初始化为sizeof(BVCSP_ServerParam)
- public int iSize;
- // 用户自定义数据。通常用于回调通知
- public Pointer pUserData;
- // 用户类型。 见 BVCSP_CLIENT_TYPE_*
- public int iClientType;
- // 一个通道能够同时被打开几路流。 iClientType为PU时有效,0:不限制个数。库内最大支持64
- public int iMaxChannelOpenCount;
- /* 登录实体的具体信息
- 注意: 这里BVCSP_EntityInfo中的指针,库内会根据iClientType类型深拷贝。 */
- public BVCSP_EntityInfo.ByValue stEntityInfo = new BVCSP_EntityInfo.ByValue();
- // Server地址,只支持IP地址,如127.0.0.1,域名需上层转换为IP地址
- public byte[] szServerAddr = new byte[128];
- // Server端口号
- public int iServerPort;
-
- public byte[] szClientID = new byte[32];
- // 应用程序名称。该名称被Server端记录到Log中
- public byte[] szUserAgent = new byte[32];
- // 登录用户名
- public byte[] szUserName = new byte[32];
- // 登录密码
- public byte[] szPassword = new byte[64];
- // Ukey ID。从UKey中获得的UKeyID。登录验证中使用。如果为空,表示没有UKey
- public byte[] szUKeyID = new byte[32];
- // Ukey 授权码。 从UKey中获得的验证授权码。如果为空,表示没有UKey授权码
- public byte[] szUkeyCode = new byte[64];
- /* 与Server之间命令通道使用的传输层协议类型,参见BVCU_PROTOTYPE_*。
- 目前仅支持 UDP 和 TCP */
- public int iCmdProtoType;
- // 命令超过iTimeOut未收到回响则认为失败,单位毫秒。必须>0 默认:30*1000毫秒
- public int iTimeOut;
-
- public LoginCallbackFunction.OnEvent OnEvent;
-
- public LoginCallbackFunction.OnCommand OnCommand;
-
- public LoginCallbackFunction.OnNotify OnNotify;
-
- public LoginCallbackFunction.OnDialogCmd OnDialogCmd;
- // 保留,必须初始化为0
- public int iReserved[] = new int[4];
- @Override
- protected List<String> getFieldOrder() {
- return Arrays.asList("iSize","pUserData","iClientType","iMaxChannelOpenCount","stEntityInfo","szServerAddr",
- "iServerPort","szClientID","szUserAgent","szUserName","szPassword","szUKeyID","szUkeyCode",
- "iCmdProtoType","iTimeOut","OnEvent","OnCommand","OnNotify","OnDialogCmd","iReserved");
- }
- public static class ByReference extends BVCSP_SessionParam implements Structure.ByReference {}
- public static class ByValue extends BVCSP_SessionParam implements Structure.ByValue {}
- }
copycode |
|