|
@ -1,9 +1,11 @@ |
|
|
package com.storeroom.modules.storeroom3d.config.common; |
|
|
package com.storeroom.modules.storeroom3d.config.common; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.storeroom.exception.BaseException; |
|
|
import com.storeroom.modules.storeroom3d.config.common.NVSSDK.DOWNLOAD_TIMESPAN; |
|
|
import com.storeroom.modules.storeroom3d.config.common.NVSSDK.DOWNLOAD_TIMESPAN; |
|
|
import com.storeroom.modules.storeroom3d.config.common.NVSSDK.RAWFRAME_INFO; |
|
|
import com.storeroom.modules.storeroom3d.config.common.NVSSDK.RAWFRAME_INFO; |
|
|
import com.storeroom.modules.storeroom3d.config.common.NVSSDK.*; |
|
|
import com.storeroom.modules.storeroom3d.config.common.NVSSDK.*; |
|
|
|
|
|
import com.storeroom.utils.DateUtils; |
|
|
import com.sun.jna.Pointer; |
|
|
import com.sun.jna.Pointer; |
|
|
import com.sun.jna.ptr.IntByReference; |
|
|
import com.sun.jna.ptr.IntByReference; |
|
|
|
|
|
|
|
@ -17,7 +19,7 @@ public class VideoClient { |
|
|
int m_iConnectID = -1; |
|
|
int m_iConnectID = -1; |
|
|
int m_iTotalCount = 0; |
|
|
int m_iTotalCount = 0; |
|
|
int m_iCurrentCount = 0; |
|
|
int m_iCurrentCount = 0; |
|
|
String[] suffix = {".sdv", ".mp4", "", ".ps", "", "", ".ts"}; |
|
|
|
|
|
|
|
|
String[] suffix = {".sdv", "", "", ".ps", "", "", ".ts"}; |
|
|
|
|
|
|
|
|
public void LogonNotify(String strIP, String strID, int iLogonID, int iLogonState) { |
|
|
public void LogonNotify(String strIP, String strID, int iLogonID, int iLogonState) { |
|
|
String strMsg = new String(); |
|
|
String strMsg = new String(); |
|
@ -55,7 +57,6 @@ public class VideoClient { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NVSSDK.ALARM_NOTIFY cbkAlarm = new NVSSDK.ALARM_NOTIFY() { |
|
|
NVSSDK.ALARM_NOTIFY cbkAlarm = new NVSSDK.ALARM_NOTIFY() { |
|
|
public void AlarmNotify(int _iLogonID, int _iChannel, |
|
|
public void AlarmNotify(int _iLogonID, int _iChannel, |
|
|
int _iAlarmState, int _iAlarmType, Pointer _pUserData) { |
|
|
int _iAlarmState, int _iAlarmType, Pointer _pUserData) { |
|
@ -123,24 +124,25 @@ public class VideoClient { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
case NVSSDK.WCM_DWONLOAD_FAULT: { |
|
|
case NVSSDK.WCM_DWONLOAD_FAULT: { |
|
|
System.out.println("MainNotify:WCM_DWONLOAD_FAULT!下载失败!"); |
|
|
|
|
|
|
|
|
// System.out.println("MainNotify:WCM_DWONLOAD_FAULT!下载失败!"); |
|
|
if (null == lParam) { |
|
|
if (null == lParam) { |
|
|
m_iConnectID = 0; |
|
|
m_iConnectID = 0; |
|
|
} else { |
|
|
} else { |
|
|
m_iConnectID = (int) lParam.nativeValue(lParam); |
|
|
m_iConnectID = (int) lParam.nativeValue(lParam); |
|
|
} |
|
|
} |
|
|
NetClient.NetFileStopDownloadFile(m_iConnectID); |
|
|
NetClient.NetFileStopDownloadFile(m_iConnectID); |
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new BaseException("MainNotify:WCM_DWONLOAD_FAULT!下载失败!"); |
|
|
} |
|
|
} |
|
|
case NVSSDK.WCM_DOWNLOAD_INTERRUPT: { |
|
|
case NVSSDK.WCM_DOWNLOAD_INTERRUPT: { |
|
|
System.out.println("MainNotify:WCM_DOWNLOAD_INTERRUPT!下载中断!"); |
|
|
|
|
|
if (null == lParam) { |
|
|
if (null == lParam) { |
|
|
m_iConnectID = 0; |
|
|
m_iConnectID = 0; |
|
|
} else { |
|
|
} else { |
|
|
m_iConnectID = (int) lParam.nativeValue(lParam); |
|
|
m_iConnectID = (int) lParam.nativeValue(lParam); |
|
|
} |
|
|
} |
|
|
NetClient.NetFileStopDownloadFile(m_iConnectID); |
|
|
NetClient.NetFileStopDownloadFile(m_iConnectID); |
|
|
break; |
|
|
|
|
|
|
|
|
throw new BaseException("MainNotify:WCM_DOWNLOAD_INTERRUPT!下载中断!"); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
default: |
|
|
default: |
|
|
break; |
|
|
break; |
|
@ -177,7 +179,6 @@ public class VideoClient { |
|
|
|
|
|
|
|
|
VideoClient tPlayback = new VideoClient(); |
|
|
VideoClient tPlayback = new VideoClient(); |
|
|
tPlayback.SDKInit(); //初始化SDK |
|
|
tPlayback.SDKInit(); //初始化SDK |
|
|
// Scanner scanInput = new Scanner(System.in); |
|
|
|
|
|
System.out.println("Logon" + strIP + ":" + iPort + "-" + strUserName + "-" + strUserPwd); |
|
|
System.out.println("Logon" + strIP + ":" + iPort + "-" + strUserName + "-" + strUserPwd); |
|
|
while (true) { |
|
|
while (true) { |
|
|
m_iLogonID = NetClient.Logon("", strIP, strUserName, strUserPwd, "", iPort); |
|
|
m_iLogonID = NetClient.Logon("", strIP, strUserName, strUserPwd, "", iPort); |
|
@ -185,15 +186,15 @@ public class VideoClient { |
|
|
if (iLogonStatus == NVSSDK.LOGON_SUCCESS) { |
|
|
if (iLogonStatus == NVSSDK.LOGON_SUCCESS) { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
tPlayback.PlaybackByTimespanMode(); |
|
|
|
|
|
|
|
|
// tPlayback.PlaybackByTimespanMode(startTime, endTime); |
|
|
try { |
|
|
try { |
|
|
Thread.currentThread(); |
|
|
Thread.currentThread(); |
|
|
Thread.sleep(1000); |
|
|
Thread.sleep(1000); |
|
|
} catch (InterruptedException e) { |
|
|
} catch (InterruptedException e) { |
|
|
System.err.println("Interrupted"); |
|
|
System.err.println("Interrupted"); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -270,33 +271,39 @@ public class VideoClient { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int PlaybackByTimespanMode() { |
|
|
|
|
|
|
|
|
public int PlaybackByTimespanMode(String startTime, String endTime, int iChannelNO) { |
|
|
DOWNLOAD_TIMESPAN tDownloadTimeSpan = new DOWNLOAD_TIMESPAN(); |
|
|
DOWNLOAD_TIMESPAN tDownloadTimeSpan = new DOWNLOAD_TIMESPAN(); |
|
|
tDownloadTimeSpan.m_iSize = tDownloadTimeSpan.size(); |
|
|
tDownloadTimeSpan.m_iSize = tDownloadTimeSpan.size(); |
|
|
//Scanner scanInput = new Scanner(System.in); |
|
|
//Scanner scanInput = new Scanner(System.in); |
|
|
System.out.print("请输入录像文件类型(sdv=0;PS=3;TS=6):"); |
|
|
|
|
|
int iSaveFileType = 1; //scanInput.nextInt(); |
|
|
|
|
|
|
|
|
//System.out.print("请输入录像文件类型(sdv=0;PS=3;TS=6):"); |
|
|
|
|
|
int iSaveFileType = 6; |
|
|
tDownloadTimeSpan.m_iSaveFileType = iSaveFileType; |
|
|
tDownloadTimeSpan.m_iSaveFileType = iSaveFileType; |
|
|
tDownloadTimeSpan.m_iFileFlag = 0; //0:Download multiple files 1:Download into a single file |
|
|
tDownloadTimeSpan.m_iFileFlag = 0; //0:Download multiple files 1:Download into a single file |
|
|
|
|
|
|
|
|
String strLocalSaveFileName = new String("myTimespanDownload" + suffix[iSaveFileType]); |
|
|
|
|
|
|
|
|
//判断文件夹是否存在 |
|
|
|
|
|
File file = new File("videos/"); |
|
|
|
|
|
if (!file.exists() && !file.isDirectory()) { |
|
|
|
|
|
file.mkdirs(); |
|
|
|
|
|
} |
|
|
|
|
|
String strLocalSaveFileName = new String(file + "/" + DateUtils.getNowTimeInMillis() + "" + suffix[iSaveFileType]); |
|
|
tDownloadTimeSpan.m_cLocalFilename = strLocalSaveFileName.getBytes(); |
|
|
tDownloadTimeSpan.m_cLocalFilename = strLocalSaveFileName.getBytes(); |
|
|
tDownloadTimeSpan.m_iChannelNO = 0; //通道号按实际下载的设备通道号赋值 |
|
|
|
|
|
|
|
|
tDownloadTimeSpan.m_iChannelNO = iChannelNO; //通道号按实际下载的设备通道号赋值 |
|
|
tDownloadTimeSpan.m_iStreamNo = 0; //码流号:0-主码流,1-副码流 |
|
|
tDownloadTimeSpan.m_iStreamNo = 0; //码流号:0-主码流,1-副码流 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//按时间段下载开始时间 |
|
|
//按时间段下载开始时间 |
|
|
tDownloadTimeSpan.m_tTimeBegin.iYear = 2022; |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeBegin.iMonth = 8; |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeBegin.iDay = 24; |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeBegin.iHour = 0; |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeBegin.iMinute = 0; |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeBegin.iSecond = 0; |
|
|
|
|
|
|
|
|
tDownloadTimeSpan.m_tTimeBegin.iYear = DateUtils.getYear(startTime); |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeBegin.iMonth = DateUtils.getMonth(startTime); |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeBegin.iDay = DateUtils.getDay(startTime); |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeBegin.iHour = DateUtils.getHour(startTime); |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeBegin.iMinute = DateUtils.getMinute(startTime); |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeBegin.iSecond = DateUtils.getSecond(startTime); |
|
|
//按时间段下载结束时间 |
|
|
//按时间段下载结束时间 |
|
|
tDownloadTimeSpan.m_tTimeEnd.iYear = 2022; |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeEnd.iMonth = 8; |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeEnd.iDay = 24; |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeEnd.iHour = 0; |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeEnd.iMinute = 5; |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeEnd.iSecond = 0; |
|
|
|
|
|
|
|
|
tDownloadTimeSpan.m_tTimeEnd.iYear = DateUtils.getYear(endTime); |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeEnd.iMonth = DateUtils.getMonth(endTime); |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeEnd.iDay = DateUtils.getDay(endTime); |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeEnd.iHour = DateUtils.getHour(endTime); |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeEnd.iMinute = DateUtils.getMinute(endTime); |
|
|
|
|
|
tDownloadTimeSpan.m_tTimeEnd.iSecond = DateUtils.getSecond(endTime); |
|
|
|
|
|
|
|
|
tDownloadTimeSpan.m_iPosition = -1; //定位功能使用 |
|
|
tDownloadTimeSpan.m_iPosition = -1; //定位功能使用 |
|
|
tDownloadTimeSpan.m_iSpeed = 32; //下载速度,最大32,老设备按最大速度下载容易出现中断,因此下载成功后可将速度调成16倍速 |
|
|
tDownloadTimeSpan.m_iSpeed = 32; //下载速度,最大32,老设备按最大速度下载容易出现中断,因此下载成功后可将速度调成16倍速 |
|
@ -307,7 +314,8 @@ public class VideoClient { |
|
|
if (0 == iRet) { |
|
|
if (0 == iRet) { |
|
|
//设置裸流回调,在回调里接收音视频裸流数据 |
|
|
//设置裸流回调,在回调里接收音视频裸流数据 |
|
|
m_iConnectID = iConnID.getValue(); |
|
|
m_iConnectID = iConnID.getValue(); |
|
|
NetClient.SetRawFrameCallBack(m_iConnectID, cbkRawFrame, null); |
|
|
|
|
|
|
|
|
//屏蔽下载无损格式视频 |
|
|
|
|
|
//NetClient.SetRawFrameCallBack(m_iConnectID, cbkRawFrame, null); |
|
|
//调整速度 |
|
|
//调整速度 |
|
|
NVSSDK.DOWNLOAD_CONTROL tControl = new NVSSDK.DOWNLOAD_CONTROL(); |
|
|
NVSSDK.DOWNLOAD_CONTROL tControl = new NVSSDK.DOWNLOAD_CONTROL(); |
|
|
tControl.m_iSize = tControl.size(); |
|
|
tControl.m_iSize = tControl.size(); |
|
|