|
import java.io.UnsupportedEncodingException;
|
import java.util.Arrays;
|
import java.util.Calendar;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.HashMap;
|
|
import LSDataStruct.LSExecTime;
|
|
import bean.Constant;
|
import com.sun.jna.Library;
|
import com.sun.jna.Memory;
|
import com.sun.jna.Native;
|
import com.sun.jna.Pointer;
|
import com.sun.jna.Structure;
|
import com.sun.jna.ptr.ByteByReference;
|
import com.sun.jna.ptr.IntByReference;
|
import com.sun.jna.win32.StdCallLibrary.StdCallCallback;
|
|
import javax.swing.*;
|
|
|
/**
|
* Simple example of native library declaration and usage.
|
*/
|
|
public class API_DEMO_MIC {
|
|
|
//??????????????
|
public static class Get_Task_Data implements Fnote_CallbackFun.GET_Terminal_List_Callback {
|
public void Data(Pointer data, int count) {
|
|
int Task_Structure_Size = 496;
|
for (int i = 0; i < count; i++) {
|
LSDataStruct.LSTask task = new LSDataStruct.LSTask();
|
task.fID = data.getInt(0 + i * Task_Structure_Size);
|
task.fType = data.getInt(4 + i * Task_Structure_Size);
|
task.fName = new byte[32];
|
data.read(8 + i * Task_Structure_Size, task.fName, 0, 32);
|
task.fBroadcastMode = data.getByte(40 + i * Task_Structure_Size);
|
task.fDuration = data.getLong(48 + i * Task_Structure_Size);
|
task.fAdvancedPowerOn = data.getLong(56 + i * Task_Structure_Size);
|
task.fPlayNum = data.getInt(64 + i * Task_Structure_Size);
|
task.fLevel = data.getInt(68 + i * Task_Structure_Size);
|
task.fUserName = new byte[255];
|
data.read(72 + i * Task_Structure_Size, task.fUserName, 0, 255);
|
task.fExecRule = data.getByte(327 + i * Task_Structure_Size);
|
task.fBeginDate = data.getLong(328 + i * Task_Structure_Size);
|
task.fEndDate = data.getLong(336 + i * Task_Structure_Size);
|
task.fWeekRule = data.getByte(344 + i * Task_Structure_Size);
|
task.fAudioSourceType = data.getByte(364 + i * Task_Structure_Size);
|
task.fExternalSrc = data.getInt(368 + i * Task_Structure_Size);
|
task.fExternalMute = data.getByte(372 + i * Task_Structure_Size);
|
task.fExternalVolumn = data.getByte(373 + i * Task_Structure_Size);
|
task.fExternalMicMute = data.getByte(374 + i * Task_Structure_Size);
|
task.fExternalMicVolumn = data.getByte(375 + i * Task_Structure_Size);
|
task.fExternalLineInMute = data.getByte(376 + i * Task_Structure_Size);
|
task.fExternalLineInVolumn = data.getByte(377 + i * Task_Structure_Size);
|
task.fSampleRate = data.getShort(378 + i * Task_Structure_Size);
|
task.fChannel = data.getByte(380 + i * Task_Structure_Size);
|
task.fQuality = data.getByte(381 + i * Task_Structure_Size);
|
task.fFileSrc = data.getInt(384 + i * Task_Structure_Size);
|
task.fFileSrcChannel = data.getInt(388 + i * Task_Structure_Size);
|
task.fPlayFilePos = data.getShort(404 + i * Task_Structure_Size);
|
task.fVoice = data.getShort(436 + i * Task_Structure_Size);
|
task.fInsertTime = data.getShort(438 + i * Task_Structure_Size);
|
task.fIsInsertPlay = data.getByte(440 + i * Task_Structure_Size);
|
task.fMicID = data.getInt(444 + i * Task_Structure_Size);
|
task.fPlayStatus = data.getShort(448 + i * Task_Structure_Size);
|
task.fManagerType = data.getShort(450 + i * Task_Structure_Size);
|
task.fEn = data.getByte(452 + i * Task_Structure_Size);
|
task.fExe = data.getByte(453 + i * Task_Structure_Size);
|
task.fBeginExeTime = data.getLong(456 + i * Task_Structure_Size);
|
task.fComplete = data.getByte(464 + i * Task_Structure_Size);
|
task.fDefaultVol = data.getShort(484 + i * Task_Structure_Size);
|
task.fPRule = data.getByte(486 + i * Task_Structure_Size);
|
task.fSchemeID = data.getShort(488 + i * Task_Structure_Size);
|
task.fUserID = data.getInt(492 + i * Task_Structure_Size);
|
Pointer contextP = data.getPointer(424 + i * Task_Structure_Size);
|
task.fContextLen = data.getInt(432 + i * Task_Structure_Size);
|
if (task.fContextLen > 0) {
|
try {
|
String contextStr = "";
|
byte[] context = new byte[task.fContextLen];
|
contextP.read(0, context, 0, task.fContextLen);
|
contextStr = new String(context, "GBK");
|
ByteByReference intr = new ByteByReference();
|
Pointer mymem = new Memory(task.fContextLen);
|
intr.setPointer(mymem);
|
mymem.setString(0, context.toString());
|
task.fContext = intr;
|
|
System.out.printf("context:%s\r\n", contextStr);
|
|
|
} catch (UnsupportedEncodingException e) {
|
// TODO ???????? catch ??
|
e.printStackTrace();
|
}
|
|
|
}
|
|
task.fExecTimeListLen = data.getInt(360 + i * Task_Structure_Size);
|
Pointer exec_time_list = data.getPointer(352 + i * Task_Structure_Size);
|
if (task.fExecTimeListLen > 0) {
|
/*
|
LSDataStruct.LSExecTime[] exec_times = (LSDataStruct.LSExecTime[])new LSDataStruct.LSExecTime().toArray(task.fExecTimeListLen);
|
int ExecTime_Structure_Size = 48;
|
for(int j = 0; j < task.fExecTimeListLen; j++){
|
exec_times[j].fBeginTime = exec_time_list.getLong(0 + j * ExecTime_Structure_Size);
|
exec_times[j].fEndTime = exec_time_list.getLong(8 + j * ExecTime_Structure_Size);
|
exec_times[j].fName = new byte[31];
|
data.read(16 + j * ExecTime_Structure_Size, exec_times[j].fName, 0, 31);
|
exec_times[j].fOperation = exec_time_list.getByte(47 + j * ExecTime_Structure_Size);
|
|
}
|
task.fExecTimeList = exec_times[0].getPointer();
|
*/
|
LSDataStruct.LSExecTime.ByReference exec_times_p = new LSDataStruct.LSExecTime.ByReference();
|
LSDataStruct.LSExecTime[] exec_times = (LSDataStruct.LSExecTime[]) exec_times_p.toArray(task.fExecTimeListLen);
|
int ExecTime_Structure_Size = 48;
|
for (int j = 0; j < task.fExecTimeListLen; j++) {
|
exec_times[j].fBeginTime = exec_time_list.getLong(0 + j * ExecTime_Structure_Size);
|
exec_times[j].fEndTime = exec_time_list.getLong(8 + j * ExecTime_Structure_Size);
|
exec_times[j].fName = new byte[31];
|
data.read(16 + j * ExecTime_Structure_Size, exec_times[j].fName, 0, 31);
|
exec_times[j].fOperation = exec_time_list.getByte(47 + j * ExecTime_Structure_Size);
|
}
|
task.fExecTimeList = exec_times_p;
|
}
|
|
Pointer file_list = data.getPointer(392 + i * Task_Structure_Size);
|
task.fFileListLen = data.getInt(400 + i * Task_Structure_Size);
|
if (task.fFileListLen > 0) {
|
LSDataStruct.LSFile.ByReference files_p = new LSDataStruct.LSFile.ByReference();
|
LSDataStruct.LSFile[] files = (LSDataStruct.LSFile[]) files_p.toArray(task.fFileListLen);
|
int File_Structure_Size = 528;
|
for (int j = 0; j < task.fFileListLen; j++) {
|
files[j].fId = file_list.getShort(0 + j * File_Structure_Size);
|
files[j].fIsDir = file_list.getByte(2 + j * File_Structure_Size);
|
file_list.read(3 + j * File_Structure_Size, files[j].fName, 0, 257);
|
files[j].fSize = file_list.getInt(260 + j * File_Structure_Size);
|
files[j].fLength = file_list.getInt(264 + j * File_Structure_Size);
|
file_list.read(268 + j * File_Structure_Size, files[j].fPath, 0, 257);
|
}
|
task.fFileList = files_p;
|
}
|
Pointer term_list = data.getPointer(408 + i * Task_Structure_Size);
|
task.fTerminalListLen = data.getInt(416 + i * Task_Structure_Size);
|
if (task.fTerminalListLen > 0) {
|
IntByReference intr = new IntByReference();
|
|
Pointer term_mem = new Memory(4 * task.fTerminalListLen);
|
intr.setPointer(term_mem);
|
for (int j = 0; j < task.fTerminalListLen; j++) {
|
term_mem.setInt(4 * j, term_list.getInt(4 * j));
|
}
|
task.fTerminalList = intr;
|
}
|
|
Pointer term_vol_list = data.getPointer(472 + i * Task_Structure_Size);
|
task.fTerminalVolListLen = data.getByte(480 + i * Task_Structure_Size);
|
if (task.fTerminalVolListLen > 0) {
|
IntByReference intr = new IntByReference();
|
|
Pointer term_vol_mem = new Memory(4 * task.fTerminalVolListLen);
|
intr.setPointer(term_vol_mem);
|
for (int j = 0; j < task.fTerminalVolListLen; j++) {
|
term_vol_mem.setInt(4 * j, term_vol_list.getInt(4 * j));
|
}
|
task.fTerminalVolList = intr;
|
}
|
String taskName = "";
|
try {
|
taskName = new String(task.fName, "GBK");
|
} catch (UnsupportedEncodingException e) {
|
// TODO ???????? catch ??
|
e.printStackTrace();
|
}
|
System.out.printf("task ID:%d,Name:%s\r\n", task.fID, taskName);
|
}
|
}
|
}
|
|
|
//??¨°???????????
|
public static class Get_Terminal_Data implements Fnote_CallbackFun.GET_Terminal_List_Callback {
|
public void Data(Pointer data, int count) {
|
|
int Terminal_Structure_Size = 460;
|
for (int i = 0; i < count; i++) {
|
|
LSDataStruct.LSTerminal term = new LSDataStruct.LSTerminal();
|
byte[] ip = new byte[33];
|
byte[] name = new byte[129];
|
int[] context = new int[256];
|
term.fID = data.getInt(0 + i * Terminal_Structure_Size);
|
data.read(4 + i * Terminal_Structure_Size, ip, 0, 33);
|
term.fIP = PtrToString(ip);
|
data.read(37 + i * Terminal_Structure_Size, name, 0, 129);
|
term.fName = PtrToString(name);
|
term.fStatus = data.getInt(168 + i * Terminal_Structure_Size);
|
term.fType = data.getInt(172 + i * Terminal_Structure_Size);
|
|
data.read(176 + i * Terminal_Structure_Size, context, 0, 256);
|
|
term.fVolumn = data.getInt(432 + i * Terminal_Structure_Size);
|
term.fPower = data.getByte(436 + i * Terminal_Structure_Size);
|
term.fLastOnlineTime = data.getInt(440 + i * Terminal_Structure_Size);
|
term.fDefaultVolumn = data.getInt(444 + i * Terminal_Structure_Size);
|
term.fDefaultPower = data.getByte(448 + i * Terminal_Structure_Size);
|
term.fIsDefault = data.getByte(450 + i * Terminal_Structure_Size);
|
term.fTaskID = data.getInt(452 + i * Terminal_Structure_Size);
|
term.fTaskType = data.getInt(456 + i * Terminal_Structure_Size);
|
|
System.out.printf("term ID:%d,Name:%s,IP:%s,Status:%d,Volumn:%d,Power:%d,Time:%d\r\n", term.fID, term.fName,
|
term.fIP, term.fStatus, term.fVolumn, term.fPower, term.fLastOnlineTime);
|
}
|
}
|
}
|
|
//?????????????????????
|
public static String server_media_dir = "";
|
|
public static class Get_Server_Media_Dir implements Fnote_CallbackFun.GET_Server_MediaDir_Callback {
|
public void Data(String dir) {
|
|
|
server_media_dir = dir;
|
|
}
|
}
|
|
|
//??????´Â???????
|
public static class Get_Mic_Data implements Fnote_CallbackFun.GET_Terminal_List_Callback {
|
public void Data(Pointer data, int count) {
|
|
int mic_Structure_Size = 224;
|
for (int i = 0; i < count; i++) {
|
LSDataStruct.LSMic mic = new LSDataStruct.LSMic();
|
byte[] ip = new byte[33];
|
byte[] name = new byte[129];
|
mic.fID = data.getInt(0 + i * mic_Structure_Size);
|
data.read(4 + i * mic_Structure_Size, ip, 0, 33);
|
mic.fIP = PtrToString(ip);
|
data.read(37 + i * mic_Structure_Size, name, 0, 129);
|
mic.fName = PtrToString(name);
|
mic.fStatus = data.getInt(168 + i * mic_Structure_Size);
|
mic.fType = data.getInt(172 + i * mic_Structure_Size);
|
mic.fCode = data.getInt(176 + i * mic_Structure_Size);
|
mic.fComplete = data.getByte(189 + i * mic_Structure_Size);
|
mic.fLevel = data.getInt(180 + i * mic_Structure_Size);
|
mic.fVolume = data.getInt(184 + i * mic_Structure_Size);
|
mic.fTerminalLen = data.getInt(216 + i * mic_Structure_Size);
|
Pointer term_list = data.getPointer(208 + i * mic_Structure_Size);
|
if (mic.fTerminalLen > 0) {
|
IntByReference intr = new IntByReference();
|
|
Pointer term_mem = new Memory(4 * mic.fTerminalLen);
|
intr.setPointer(term_mem);
|
for (int j = 0; j < mic.fTerminalLen; j++) {
|
term_mem.setInt(4 * j, term_list.getInt(4 * j));
|
}
|
mic.fTerminalList = intr;
|
}
|
|
Pointer region_list = data.getPointer(200 + i * mic_Structure_Size);
|
mic.fRegionListLen = data.getInt(192 + i * mic_Structure_Size);
|
if (mic.fRegionListLen > 0) {
|
|
LSDataStruct.LSMicMapRegion.ByReference regions_p = new LSDataStruct.LSMicMapRegion.ByReference();
|
LSDataStruct.LSMicMapRegion[] regions = (LSDataStruct.LSMicMapRegion[]) regions_p.toArray(mic.fRegionListLen);
|
int micmapregion_Structure_Size = 416;
|
for (int j = 0; j < mic.fRegionListLen; j++) {
|
byte[] region_name = new byte[129];
|
byte[] memo = new byte[257];
|
regions[j].key = region_list.getInt(0 + j * micmapregion_Structure_Size);
|
regions[j].region.fId = region_list.getInt(8 + j * micmapregion_Structure_Size);
|
data.read(12 + i * micmapregion_Structure_Size, region_name, 0, 129);
|
regions[j].region.fName = PtrToString(region_name);
|
data.read(141 + i * micmapregion_Structure_Size, memo, 0, 257);
|
regions[j].region.fMemo = PtrToString(memo);
|
regions[j].region.fTerminalLen = region_list.getInt(400 + j * micmapregion_Structure_Size);
|
Pointer region_term_list = region_list.getPointer(408 + j * micmapregion_Structure_Size);
|
if (regions[j].region.fTerminalLen > 0) {
|
IntByReference intr = new IntByReference();
|
|
Pointer term_mem = new Memory(4 * regions[j].region.fTerminalLen);
|
intr.setPointer(term_mem);
|
for (int k = 0; k < regions[j].region.fTerminalLen; k++) {
|
term_mem.setInt(4 * k, region_term_list.getInt(4 * k));
|
}
|
regions[j].region.fTerminalList = intr;
|
}
|
|
}
|
mic.regionList = regions_p;
|
}
|
//mic.fTerminalList = data.getInt(208 + i * mic_Structure_Size);
|
}
|
}
|
}
|
|
|
//??????´Â??????
|
public static class Update_Mic_Data implements Fnote_CallbackFun.Update_Terminal_Callback {
|
public void Data(Pointer data) {
|
LSDataStruct.LSMic mic = new LSDataStruct.LSMic();
|
byte[] ip = new byte[33];
|
byte[] name = new byte[129];
|
mic.fID = data.getInt(0);
|
data.read(4, ip, 0, 33);
|
mic.fIP = PtrToString(ip);
|
data.read(37, name, 0, 129);
|
mic.fName = PtrToString(name);
|
mic.fStatus = data.getInt(168);
|
mic.fType = data.getInt(172);
|
mic.fCode = data.getInt(176);
|
mic.fComplete = data.getByte(189);
|
mic.fLevel = data.getInt(180);
|
mic.fVolume = data.getInt(184);
|
mic.fTerminalLen = data.getInt(216);
|
Pointer term_list = data.getPointer(208);
|
if (mic.fTerminalLen > 0) {
|
IntByReference intr = new IntByReference();
|
|
Pointer term_mem = new Memory(4 * mic.fTerminalLen);
|
intr.setPointer(term_mem);
|
for (int j = 0; j < mic.fTerminalLen; j++) {
|
term_mem.setInt(4 * j, term_list.getInt(4 * j));
|
}
|
mic.fTerminalList = intr;
|
}
|
|
Pointer region_list = data.getPointer(200);
|
mic.fRegionListLen = data.getInt(192);
|
if (mic.fRegionListLen > 0) {
|
|
LSDataStruct.LSMicMapRegion.ByReference regions_p = new LSDataStruct.LSMicMapRegion.ByReference();
|
LSDataStruct.LSMicMapRegion[] regions = (LSDataStruct.LSMicMapRegion[]) regions_p.toArray(mic.fRegionListLen);
|
int micmapregion_Structure_Size = 416;
|
for (int j = 0; j < mic.fRegionListLen; j++) {
|
byte[] region_name = new byte[129];
|
byte[] memo = new byte[257];
|
regions[j].key = region_list.getInt(0 + j * micmapregion_Structure_Size);
|
regions[j].region.fId = region_list.getInt(8 + j * micmapregion_Structure_Size);
|
region_list.read(12 + j * micmapregion_Structure_Size, region_name, 0, 129);
|
regions[j].region.fName = PtrToString(region_name);
|
region_list.read(141 + j * micmapregion_Structure_Size, memo, 0, 257);
|
regions[j].region.fMemo = PtrToString(memo);
|
regions[j].region.fTerminalLen = region_list.getInt(400 + j * micmapregion_Structure_Size);
|
Pointer region_term_list = region_list.getPointer(408 + j * micmapregion_Structure_Size);
|
if (regions[j].region.fTerminalLen > 0) {
|
IntByReference intr = new IntByReference();
|
|
Pointer term_mem = new Memory(4 * regions[j].region.fTerminalLen);
|
intr.setPointer(term_mem);
|
for (int k = 0; k < regions[j].region.fTerminalLen; k++) {
|
term_mem.setInt(4 * k, region_term_list.getInt(4 * k));
|
}
|
regions[j].region.fTerminalList = intr;
|
}
|
String regionName = "";
|
try {
|
regionName = new String(region_name, "GBK");
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
}
|
System.out.printf("Mic Region Name:%s\r\n", regionName);
|
}
|
mic.regionList = regions_p;
|
}
|
}
|
}
|
//public static CLibrary.GET_Terminal_Callback get_terminal = new CLibrary.Get_Terminal_Data();
|
|
//public static CLibrary.GET_Server_MediaDir_Callback get_media_dir = new Get_Server_Media_Dir();
|
public static Fnote_CallbackFun.GET_Terminal_List_Callback get_terminal = new Get_Terminal_Data();
|
public static Fnote_CallbackFun.GET_Server_MediaDir_Callback get_media_dir = new Get_Server_Media_Dir();
|
public static Fnote_CallbackFun.GET_Terminal_List_Callback get_task = new Get_Task_Data();
|
public static Fnote_CallbackFun.GET_Terminal_List_Callback get_mic_list = new Get_Mic_Data();
|
public static Fnote_CallbackFun.Update_Terminal_Callback update_mic = new Update_Mic_Data();
|
|
public static String PtrToString(byte[] ptr) {
|
String str = "";
|
for (byte b : ptr) {
|
if (b != 0) {
|
str += (char) b;
|
} else
|
break;
|
}
|
return str;
|
}
|
|
|
public static int runMicTask(Pointer handle) {
|
|
LSDataStruct.LSTask.ByReference data = new LSDataStruct.LSTask.ByReference();
|
|
data.fID = 1;
|
data.fType = 27;
|
data.fAudioSourceType = 1;
|
data.fDefaultVol = 50;
|
data.fBeginDate = 0;
|
data.fEndDate = -1;
|
data.fLevel = 99;
|
data.fEn = 1;
|
data.fSampleRate = 16000;
|
data.fName = Arrays.copyOf("task_1".getBytes(), 32);
|
data.fUserName = new byte[255];
|
data.fExternalLineInMute = 0;
|
|
int len = 5;
|
//????????
|
|
data.fFileListLen = 0;
|
data.fTerminalListLen = 2;
|
|
IntByReference intr = new IntByReference();
|
|
Pointer mymem = new Memory(4);
|
intr.setPointer(mymem);
|
mymem.setInt(0, 9999);
|
// mymem.setInt(4, 90);
|
|
data.fTerminalList = intr;
|
|
data.fExecTimeListLen = 0;
|
int size = data.size();
|
int ret = FnoteLibrary.INSTANCE.updateData(handle, FnoteLibrary.DataListType.kRunClientTaskType.ordinal(), data);
|
if (ret == 0) {
|
System.out.println("Ö´Ðгɹ¦");
|
} else {
|
System.out.println("Ö´ÐÐʧ°Ü");
|
}
|
return ret;
|
}
|
|
|
public static int endClientTask(Pointer handle, LSDataStruct.LSTask.ByReference data) {
|
|
int size = data.size();
|
int ret = FnoteLibrary.INSTANCE.updateData(handle, FnoteLibrary.DataListType.kEndClientTaskType.ordinal(), data);
|
if (ret == 0) {
|
System.out.println("ÖÕÖ¹³É¹¦");
|
} else {
|
System.out.println("ÖÕֹʧ°Ü");
|
}
|
return ret;
|
}
|
|
//???????
|
public static int addTask(Pointer handle, LSDataStruct.FtpFileListStruct.ByReference ftpFileList) {
|
LSDataStruct.LSTask.ByReference data = new LSDataStruct.LSTask.ByReference();
|
|
data.fID = 1;
|
data.fType = 1;
|
data.fAudioSourceType = 0;
|
data.fDefaultVol = 50;
|
Calendar c = Calendar.getInstance();
|
c.set(Calendar.YEAR, 2019);
|
c.set(Calendar.MONTH, 7);
|
c.set(Calendar.DATE, 4);
|
c.set(Calendar.HOUR_OF_DAY, 0);
|
c.set(Calendar.MINUTE, 0);
|
c.set(Calendar.SECOND, 0);
|
data.fBeginDate = c.getTimeInMillis() / 1000;//2019/8/4 00:00:00
|
data.fEndDate = -1;
|
data.fLevel = 99;
|
data.fEn = 1;
|
data.fName = Arrays.copyOf("task_1".getBytes(), 32);
|
data.fUserName = new byte[255];
|
data.fSchemeID = 1;
|
int len = 5;
|
//????????
|
LSDataStruct.FtpFileStruct ftpFile = ftpFileList.fileList[0];
|
LSDataStruct.LSFile.ByReference files_p = new LSDataStruct.LSFile.ByReference();
|
LSDataStruct.LSFile[] files = (LSDataStruct.LSFile[]) files_p.toArray(2);
|
String fileName = "";
|
try {
|
fileName = new String(ftpFile.fName, "GBK");
|
} catch (UnsupportedEncodingException e) {
|
// TODO ???????? catch ??
|
e.printStackTrace();
|
}
|
files[0].fName = Arrays.copyOf(fileName.getBytes(), 257);
|
files[0].fPath = Arrays.copyOf((server_media_dir + "/BroadMedia/" + fileName).getBytes(), 257);
|
files[0].fSize = ftpFile.fSize;
|
files[0].fLength = ftpFile.fDuration;
|
files[1].fName = Arrays.copyOf(fileName.getBytes(), 257);
|
files[1].fPath = Arrays.copyOf((server_media_dir + "/BroadMedia/" + fileName).getBytes(), 257);
|
files[1].fSize = ftpFile.fSize;
|
files[1].fLength = ftpFile.fDuration;
|
data.fFileList = files_p;
|
data.fFileListLen = 2;
|
data.fTerminalListLen = 2;
|
|
IntByReference intr = new IntByReference();
|
|
Pointer mymem = new Memory(8);
|
intr.setPointer(mymem);
|
mymem.setInt(0, 218);
|
mymem.setInt(4, 230);
|
|
data.fTerminalList = intr;
|
|
LSDataStruct.LSExecTime.ByReference exec_times_p = new LSDataStruct.LSExecTime.ByReference();
|
LSDataStruct.LSExecTime[] exeTimes = (LSDataStruct.LSExecTime[]) exec_times_p.toArray(1);
|
String name = "dfdf";
|
exeTimes[0].fName = Arrays.copyOf(name.getBytes(), 31);
|
exeTimes[0].fBeginTime = 39279;
|
exeTimes[0].fEndTime = 86399;
|
data.fExecTimeList = exec_times_p;
|
data.fExecTimeListLen = 1;
|
files[0].write();
|
files[1].write();
|
int ret = FnoteLibrary.INSTANCE.addData(handle, FnoteLibrary.DataListType.kFileTaskListType.ordinal(), data);
|
if (ret == 0) {
|
System.out.println("???????????");
|
} else {
|
System.out.println("???????????");
|
}
|
return ret;
|
}
|
|
public static void play (IntByReference intr, JLabel loadText, short volume) {
|
|
if (FnoteLibrary.INSTANCE != null) {
|
System.out.println("Fnote DLL????????");
|
} else {
|
System.out.println("Fonte DLL????????");
|
}
|
if (FtpClientLibrary.INSTANCE != null) {
|
System.out.println("Ftp DLL????????");
|
} else {
|
System.out.println("Ftp DLL????????");
|
}
|
|
//?????????
|
FnoteLibrary.INSTANCE.initWSAStartup();
|
String ip = new String("47.106.172.9");
|
//?????????????????
|
Pointer handle = FnoteLibrary.INSTANCE.initNetSystem();
|
//???FTP???
|
Pointer ftp_handle = FtpClientLibrary.INSTANCE.getCFtpClient();
|
//???FTP
|
System.out.println(FtpClientLibrary.INSTANCE.login(ftp_handle, ip, 2121, "gadmin", "gadmin"));
|
//???????????§Ò?
|
LSDataStruct.FtpFileListStruct.ByReference ftpFileList = new LSDataStruct.FtpFileListStruct.ByReference();
|
FtpClientLibrary.INSTANCE.Noop(ftp_handle);
|
//??¡Â?????"BroadMedia"???????????
|
ftpFileList.fNum = FtpClientLibrary.INSTANCE.getFtpFileList(ftp_handle, "BroadMedia", ftpFileList);
|
for (int i = 0; i < ftpFileList.fNum; i++) {
|
LSDataStruct.FtpFileStruct ftpFile = ftpFileList.fileList[i];
|
try {
|
System.out.println(new String(ftpFile.fName, "GBK"));
|
} catch (UnsupportedEncodingException e) {
|
|
}
|
System.out.println(ftpFile.fSize);
|
System.out.println(ftpFile.fDuration);
|
}
|
|
|
String user = new String(Constant.username);
|
String passwd = new String(Constant.password);
|
FnoteLibrary.INSTANCE.setServerIpAndPort(handle, ip, 6900);
|
FnoteLibrary.INSTANCE.setServerUserAndPassWord(handle, user, passwd);
|
|
int Callback_Event_Type = FnoteLibrary.CallbackEventType.kGetTerminalListEventType.ordinal();
|
int Data_List_Type = FnoteLibrary.DataListType.kMediaInfoType.ordinal();
|
|
FnoteLibrary.INSTANCE.setCallbackHandle(handle, Callback_Event_Type, get_terminal);
|
FnoteLibrary.INSTANCE.setCallbackHandle(handle, FnoteLibrary.CallbackEventType.kGetMediaInfoEventType.ordinal(), get_media_dir);
|
FnoteLibrary.INSTANCE.setCallbackHandle(handle, FnoteLibrary.CallbackEventType.kGetFileTaskListEventType.ordinal(), get_task);
|
FnoteLibrary.INSTANCE.setCallbackHandle(handle, FnoteLibrary.CallbackEventType.kGetMicInfoListEventType.ordinal(), get_mic_list);
|
FnoteLibrary.INSTANCE.setCallbackHandle(handle, FnoteLibrary.CallbackEventType.kGetMicInfoEventType.ordinal(), update_mic);
|
int i = FnoteLibrary.INSTANCE.runSystem(handle);
|
|
if(i >= 0){
|
loadText.setText("Á¬½Óϵͳ³É¹¦£¡");
|
} else {
|
int loginCode = FnoteLibrary.INSTANCE.getLoginCode(handle);
|
loadText.setText("µÇ¼ϵͳʧ°Ü, code: "+loginCode);
|
System.out.println("µÇ¼ϵͳʧ°Ü, code: "+loginCode);
|
}
|
|
boolean isGetTerm = false;
|
|
|
LSDataStruct.LSTask.ByReference data = new LSDataStruct.LSTask.ByReference();
|
|
data.fID = 1;
|
data.fType = 27;
|
data.fAudioSourceType = 1;
|
data.fDefaultVol = 100;
|
data.fBeginDate = 0;
|
data.fEndDate = -1;
|
data.fLevel = 99;
|
data.fEn = 1;
|
data.fSampleRate = 32000;
|
data.fName = Arrays.copyOf("task_1".getBytes(), 32);
|
data.fUserName = new byte[255];
|
data.fExternalLineInMute = 1;
|
|
int len = 5;
|
|
LSDataStruct.LSFile.ByReference files_p = new LSDataStruct.LSFile.ByReference();
|
LSDataStruct.LSFile[] files = (LSDataStruct.LSFile[]) files_p.toArray(2);
|
LSDataStruct.LSExecTime[] exec_times = (LSDataStruct.LSExecTime[]) new LSDataStruct.LSExecTime().toArray(1);
|
|
files[0].fName = Arrays.copyOf("love.mp3".getBytes(), 257);
|
files[0].fPath = Arrays.copyOf("C:/Program Files/DBBSystem/DBBServer/love.mp3".getBytes(), 257);
|
files[1].fName = Arrays.copyOf("love.mp3".getBytes(), 257);
|
files[1].fPath = Arrays.copyOf("C:/Program Files/DBBSystem/DBBServer/mp3Root/BroadMedia/test/08????.mp3".getBytes(), 257);
|
|
data.fFileList = files_p;
|
data.fFileListLen = 2;
|
data.fTerminalListLen = 2;
|
|
// IntByReference intr = new IntByReference();
|
//
|
// Pointer mymem = new Memory(4);
|
// intr.setPointer(mymem);
|
// mymem.setInt(0, 9999);
|
|
data.fTerminalList = intr;
|
|
data.fExecTimeListLen = 0;
|
files[0].write();
|
files[1].write();
|
|
while (true) {
|
try {
|
|
Thread.sleep(1000);
|
int stauts = FnoteLibrary.INSTANCE.getSystemStauts(handle);
|
if (stauts == -1)
|
break;
|
if (stauts == 5)
|
break;
|
int code = FnoteLibrary.INSTANCE.getLoginCode(handle);
|
if (code == 6)
|
break;
|
if (!isGetTerm) {
|
int ret = runMicTask(handle);
|
|
if (ret == 0)
|
isGetTerm = true;
|
}
|
if(Constant.stopFlag){
|
// ֹͣʵʱÈÎÎñ
|
endClientTask(handle, data);
|
}
|
|
} catch (InterruptedException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
|
}
|