4670101279
2 years ago
12 changed files with 2950 additions and 0 deletions
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>ruoyi</artifactId> |
||||
<groupId>com.ruoyi</groupId> |
||||
<version>3.8.1</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>ruoyi-code</artifactId> |
||||
|
||||
<description> |
||||
ruoyi-code |
||||
</description> |
||||
|
||||
<dependencies> |
||||
|
||||
<!-- 通用工具--> |
||||
<dependency> |
||||
<groupId>com.ruoyi</groupId> |
||||
<artifactId>ruoyi-common</artifactId> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
</project> |
@ -0,0 +1,136 @@
@@ -0,0 +1,136 @@
|
||||
package com.ruoyi.code.camera.controller; |
||||
|
||||
import com.ruoyi.common.annotation.Log; |
||||
import com.ruoyi.common.core.controller.BaseController; |
||||
import com.ruoyi.common.core.page.R; |
||||
import com.ruoyi.common.enums.BusinessType; |
||||
import com.ruoyi.common.utils.StringUtils; |
||||
import com.ruoyi.common.utils.poi.ExcelUtil; |
||||
import com.ruoyi.code.camera.domain.Camera; |
||||
import com.ruoyi.code.camera.service.ICameraService; |
||||
import com.sun.jna.NativeLong; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import utils.CameraUtil; |
||||
import utils.RegisterUtil; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 摄像机Controller |
||||
* |
||||
* @author ruoyi |
||||
* @date 2022-06-21 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/web/camera") |
||||
public class CameraController extends BaseController |
||||
{ |
||||
@Resource |
||||
private ICameraService cameraService; |
||||
|
||||
/** |
||||
* 查询列表 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('web:camera:list')") |
||||
@RequestMapping("/list") |
||||
public R list(@RequestParam Map<String, Object> params){ |
||||
return cameraService.queryPage(params); |
||||
} |
||||
|
||||
/** |
||||
* 获取详细信息 |
||||
*/ |
||||
@RequestMapping("/info/{id}") |
||||
@PreAuthorize("@ss.hasPermi('web:camera:query')") |
||||
public R info(@PathVariable("id") Long id){ |
||||
Camera camera = cameraService.getById(id); |
||||
|
||||
return R.ok().put("data", camera); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 导出列表 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('web:camera:export')") |
||||
@Log(title = "列表", businessType = BusinessType.EXPORT) |
||||
@PostMapping("/export") |
||||
public void export(HttpServletResponse response, Camera camera) |
||||
{ |
||||
List<Camera> list = cameraService.list(); |
||||
ExcelUtil<Camera> util = new ExcelUtil<Camera>(Camera.class); |
||||
util.exportExcel(response, list, "列表数据"); |
||||
} |
||||
|
||||
/** |
||||
* 新增 |
||||
*/ |
||||
@RequestMapping("/add") |
||||
@Log(title = "Camera", businessType = BusinessType.INSERT) |
||||
@PreAuthorize("@ss.hasPermi('web:camera:add')") |
||||
public R add(@RequestBody Camera camera){ |
||||
cameraService.save(camera); |
||||
return R.ok(); |
||||
} |
||||
|
||||
/** |
||||
* 修改 |
||||
*/ |
||||
@RequestMapping("/edit") |
||||
@PreAuthorize("@ss.hasPermi('web:camera:edit')") |
||||
@Log(title = "Camera", businessType = BusinessType.UPDATE) |
||||
public R edit(@RequestBody Camera camera){ |
||||
cameraService.updateById(camera); |
||||
return R.ok(); |
||||
} |
||||
|
||||
/** |
||||
* 删除 |
||||
*/ |
||||
@RequestMapping("/delete/{ids}") |
||||
@PreAuthorize("@ss.hasPermi('web:camera:remove')") |
||||
@Log(title = "Camera", businessType = BusinessType.DELETE) |
||||
public R delete(@PathVariable Long[] ids){ |
||||
cameraService.removeByIds(Arrays.asList(ids)); |
||||
return R.ok(); |
||||
} |
||||
|
||||
|
||||
@RequestMapping("register") |
||||
public R register(){ |
||||
return cameraService.register(); |
||||
} |
||||
|
||||
@RequestMapping("reboot/{id}") |
||||
public R reboot(@PathVariable Long id){ |
||||
Camera c = cameraService.getById(id); |
||||
if(StringUtils.isNotBlank(c.getLoginId())) { |
||||
System.out.println("reboot loginID:"+c.getLoginId()); |
||||
NativeLong nl = new NativeLong(Long.parseLong(c.getLoginId())); |
||||
boolean result = CameraUtil.deal(nl); |
||||
if(result){ |
||||
c.setLoginId(""); |
||||
c.setStatus(0); |
||||
cameraService.updateById(c); |
||||
return R.ok("设备重启成功,请等待几分钟后重新使用"); |
||||
} |
||||
} |
||||
return R.error("设备重启失败"); |
||||
} |
||||
|
||||
|
||||
@RequestMapping("showVideo/{id}") |
||||
public void showVideo(@PathVariable Long id){ |
||||
Camera c = cameraService.getById(id); |
||||
System.out.println("show loginID:"+c.getLoginId()); |
||||
RegisterUtil window = new RegisterUtil(); |
||||
window.m_frame.setVisible(true); |
||||
window.showVideo(new NativeLong(Long.parseLong(c.getLoginId()))); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
package com.ruoyi.code.camera.domain; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Data; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
|
||||
|
||||
/** |
||||
* 摄像机对象 camera |
||||
* |
||||
* @author ruoyi |
||||
* @date 2022-06-21 |
||||
*/ |
||||
@Data |
||||
@TableName("camera") |
||||
public class Camera implements Serializable |
||||
{ |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** $column.columnComment */ |
||||
@TableId(type = IdType.INPUT) |
||||
private Long id; |
||||
|
||||
/** 设备名 */ |
||||
private String name; |
||||
|
||||
/** 设备ip */ |
||||
private String ip; |
||||
|
||||
/** 设备端口 */ |
||||
private Integer port; |
||||
|
||||
/** 设备登录账号 */ |
||||
private String username; |
||||
|
||||
/** 设备登录密码 */ |
||||
private String password; |
||||
|
||||
/** 设备序列号 */ |
||||
private String devsn; |
||||
|
||||
/** 状态 */ |
||||
private Integer status; |
||||
|
||||
private String loginId; |
||||
|
||||
/** 首次注册时间 */ |
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date firstTime; |
||||
|
||||
/** 注册更新时间 */ |
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date updateTime; |
||||
|
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
package com.ruoyi.code.camera.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.ruoyi.code.camera.domain.Camera; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* Mapper接口 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2022-06-21 |
||||
*/ |
||||
@Mapper |
||||
public interface CameraMapper extends BaseMapper<Camera> |
||||
{ |
||||
|
||||
} |
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
package com.ruoyi.code.camera.scheduled; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.ruoyi.code.camera.domain.Camera; |
||||
import com.ruoyi.code.camera.service.ICameraService; |
||||
import com.ruoyi.common.core.page.R; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.scheduling.annotation.EnableScheduling; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import javax.annotation.PostConstruct; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/*@Author: tongw |
||||
*@CreateDate: 2020/8/11 8:58 |
||||
*@Description: |
||||
**/ |
||||
|
||||
@Component |
||||
@Configuration |
||||
@EnableScheduling |
||||
public class RegisterServer { |
||||
@Autowired |
||||
private ICameraService cameraService; |
||||
|
||||
@PostConstruct |
||||
public void synStart(){ |
||||
start(); |
||||
} |
||||
|
||||
private void start(){ |
||||
R result = cameraService.register(); |
||||
if("0".equals(result.get("code").toString())){ |
||||
System.out.println("主动注册服务已启动"); |
||||
}else{ |
||||
System.out.println("主动注册服务启动失败"); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
package com.ruoyi.code.camera.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.ruoyi.common.core.page.R; |
||||
import com.ruoyi.code.camera.domain.Camera; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Service接口 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2022-06-21 |
||||
*/ |
||||
public interface ICameraService extends IService<Camera> |
||||
{ |
||||
/** |
||||
* 查询 |
||||
*/ |
||||
R queryPage(Map<String, Object> params); |
||||
|
||||
R register(); |
||||
|
||||
void online(String ip,int port,String username,String password,String devsn,String loginID); |
||||
|
||||
void outline(String loginID); |
||||
} |
@ -0,0 +1,92 @@
@@ -0,0 +1,92 @@
|
||||
package com.ruoyi.code.camera.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.ruoyi.common.core.page.R; |
||||
import com.ruoyi.common.utils.Query; |
||||
import com.ruoyi.code.camera.domain.Camera; |
||||
import com.ruoyi.code.camera.mapper.CameraMapper; |
||||
import com.ruoyi.code.camera.service.ICameraService; |
||||
import org.springframework.stereotype.Service; |
||||
import utils.RegisterUtil; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Service业务层处理 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2022-06-21 |
||||
*/ |
||||
@Service("cameraService") |
||||
public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> implements ICameraService |
||||
{ |
||||
@Override |
||||
public R queryPage(Map<String, Object> params) { |
||||
IPage<Camera> page = this.page( |
||||
new Query<Camera>().getPage(params), |
||||
new QueryWrapper<Camera>() |
||||
); |
||||
|
||||
return R.ok().put("count", page.getTotal()).put("data", page.getRecords()); |
||||
} |
||||
|
||||
@Override |
||||
public R register(){ |
||||
//清空所有摄像机状态
|
||||
List<Camera> list = list(); |
||||
list.forEach(d -> { |
||||
d.setLoginId(""); |
||||
d.setStatus(0); |
||||
}); |
||||
updateBatchById(list); |
||||
|
||||
RegisterUtil window = new RegisterUtil(); |
||||
//先停
|
||||
window.onBtnStopRegServer(); |
||||
//再开
|
||||
boolean result = window.onBtnStartRegServer(); |
||||
if(result){ |
||||
return R.ok("服务启动成功,请等待几分钟后重新使用"); |
||||
} |
||||
return R.error("服务启动失败"); |
||||
} |
||||
|
||||
@Override |
||||
public void online(String ip,int port,String username,String password,String devsn,String loginID){ |
||||
Date now = new Date(); |
||||
Camera c = getOne(new QueryWrapper<Camera>().eq("devsn",devsn)); |
||||
if(c == null){ |
||||
c = new Camera(); |
||||
c.setIp(ip); |
||||
c.setPort(port); |
||||
c.setUsername(username); |
||||
c.setPassword(password); |
||||
c.setDevsn(devsn); |
||||
c.setStatus(1); |
||||
c.setLoginId(loginID); |
||||
c.setFirstTime(now); |
||||
c.setUpdateTime(now); |
||||
save(c); |
||||
}else{ |
||||
c.setIp(ip); |
||||
c.setPort(port); |
||||
c.setLoginId(loginID); |
||||
c.setStatus(1); |
||||
c.setUpdateTime(now); |
||||
updateById(c); |
||||
} |
||||
} |
||||
@Override |
||||
public void outline(String loginID){ |
||||
Camera c = getOne(new QueryWrapper<Camera>().eq("login_id",loginID)); |
||||
if(c != null){ |
||||
c.setLoginId(""); |
||||
c.setStatus(0); |
||||
updateById(c); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,87 @@
@@ -0,0 +1,87 @@
|
||||
package utils; |
||||
|
||||
import com.ruoyi.common.utils.DateUtils; |
||||
import com.sun.jna.NativeLong; |
||||
import com.sun.jna.ptr.IntByReference; |
||||
import sdk.java.lib.netmanager.NetLib; |
||||
import sdk.java.lib.netmanager.NetStructs; |
||||
|
||||
import java.util.Date; |
||||
|
||||
public class CameraUtil { |
||||
public static void main(String[] args) { |
||||
|
||||
NetLib.instance.Net_Init(null, null); |
||||
String strIp="36.133.93.214"; |
||||
int nPort= 27778; |
||||
String strUsername="admin"; |
||||
String strPassword="admin123"; |
||||
IntByReference error = null; |
||||
NativeLong loginID = NetLib.instance.Net_LoginDevice(strIp, nPort, strUsername, strPassword, null, error); |
||||
System.out.println(loginID); |
||||
|
||||
//重启设备
|
||||
// boolean bResult = NetLib.instance.Net_RebootDevice(loginID);
|
||||
// System.out.println("Net_RebootDevice = " + bResult);
|
||||
|
||||
// boolean r2 = NetLib.instance.Net_LogoutDevice(loginID);
|
||||
// System.out.println("r2 = " + r2);
|
||||
// NetLib.instance.Net_Exit();
|
||||
} |
||||
|
||||
public static boolean deal(NativeLong loginID){ |
||||
boolean res = NetLib.instance.Net_RebootDevice(loginID); |
||||
int error = NetLib.instance.Net_LastError(); |
||||
System.out.println("reboot errorCode = "+ error); |
||||
return res; |
||||
} |
||||
|
||||
private static void sleep(int nTime) |
||||
{ |
||||
try { |
||||
Thread.sleep(nTime * 1000); |
||||
} catch (InterruptedException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设置当前时间 |
||||
* @param loginID |
||||
*/ |
||||
public static void setNowTime(NativeLong loginID){ |
||||
NetStructs.STU_TIME.ByReference stuTimeRef = new NetStructs.STU_TIME.ByReference(); |
||||
boolean bGet = NetLib.instance.Net_GetDeviceTime(loginID, stuTimeRef, 6000); |
||||
|
||||
System.out.printf("Get time = %b, time = %04d-%02d-%02d %02d:%02d:%02d\n", |
||||
bGet, stuTimeRef.nYear, stuTimeRef.nMonth, stuTimeRef.nDay, |
||||
stuTimeRef.nHour, stuTimeRef.nMinute, stuTimeRef.nSecond); |
||||
|
||||
try { |
||||
Thread.sleep(3000); |
||||
} catch (InterruptedException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
String time = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",new Date()); |
||||
// 修改时间
|
||||
stuTimeRef.nYear = Integer.parseInt(time.substring(0,4)); |
||||
stuTimeRef.nMonth = Integer.parseInt(time.substring(5,7)); |
||||
stuTimeRef.nDay = Integer.parseInt(time.substring(8,10)); |
||||
stuTimeRef.nHour = Integer.parseInt(time.substring(11,13)); |
||||
stuTimeRef.nMinute = Integer.parseInt(time.substring(14,16)); |
||||
stuTimeRef.nSecond = Integer.parseInt(time.substring(17,19)); |
||||
|
||||
System.out.println("Set time, time"+ |
||||
stuTimeRef.nYear+"-"+ stuTimeRef.nMonth+"-"+ stuTimeRef.nDay+" "+ |
||||
stuTimeRef.nHour+":"+ stuTimeRef.nMinute+":"+stuTimeRef.nSecond); |
||||
|
||||
NetLib.instance.Net_SetDeviceTime(loginID, stuTimeRef, 2000); |
||||
|
||||
// 再获取时间
|
||||
bGet = NetLib.instance.Net_GetDeviceTime(loginID, stuTimeRef, 2000); |
||||
System.out.println("Get time = %b, time =" + |
||||
stuTimeRef.nYear+"-"+ stuTimeRef.nMonth+"-"+ stuTimeRef.nDay+" "+ |
||||
stuTimeRef.nHour+":"+ stuTimeRef.nMinute+":"+stuTimeRef.nSecond); |
||||
} |
||||
} |
@ -0,0 +1,278 @@
@@ -0,0 +1,278 @@
|
||||
package utils; |
||||
|
||||
import com.sun.jna.Native; |
||||
import com.sun.jna.NativeLong; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.ptr.IntByReference; |
||||
import sdk.java.lib.DataUtils; |
||||
import sdk.java.lib.netmanager.NetDelegates; |
||||
import sdk.java.lib.netmanager.NetEnums; |
||||
import sdk.java.lib.netmanager.NetLib; |
||||
import sdk.java.lib.playmanager.*; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
public class Play { |
||||
|
||||
private IntByReference m_nPlayPort = new IntByReference(0); // 当前设备的播放端口
|
||||
|
||||
|
||||
public static class DecodeCallBack implements PlayDelegates.fDecodeCallBack |
||||
{ |
||||
@Override |
||||
public void invoke(int nPort, Pointer pFrameDecodeInfo, Pointer pFrameInfo, Pointer pUserData) |
||||
{ |
||||
// pFrameDecodeInfo, pFrameInfo 均可获取帧类型、子帧类型
|
||||
// 如果是视频帧,子帧类型则为 I 帧、P 帧...,以枚举值 ENUM_SUB_FRAME_TYPE 为准
|
||||
|
||||
// pFrameDecodeInfo 解码帧内容
|
||||
// 如果是音频帧,有音频帧数据
|
||||
// 如果是视频帧,有视频帧 YUV 数据
|
||||
|
||||
// pFrameInfo 解码帧属性信息
|
||||
// 其中帧数据/裸数据可以自定义处理
|
||||
PlayStructs.FRAME_ATTRI_INFO_EX frameInfo = new PlayStructs.FRAME_ATTRI_INFO_EX(); |
||||
DataUtils.sdk_data_ptrToStructure(pFrameInfo, frameInfo); |
||||
|
||||
if(frameInfo.nFrameType == PlayEnums.ENUM_MEDIA_FRAME_TYPE.MEDIA_FRAME_TYPE_VIDEO) |
||||
{ |
||||
if(frameInfo.nSubFrameType == PlayEnums.ENUM_SUB_FRAME_TYPE.SUB_FRAME_TYPE_VIDEO_I) |
||||
{ |
||||
//System.out.println("Video Frame I");
|
||||
} |
||||
else if(frameInfo.nSubFrameType == PlayEnums.ENUM_SUB_FRAME_TYPE.SUB_FRAME_TYPE_VIDEO_P) |
||||
{ |
||||
//System.out.println("Video Frame P");
|
||||
} |
||||
else if(frameInfo.nSubFrameType == PlayEnums.ENUM_SUB_FRAME_TYPE.SUB_FRAME_TYPE_VIDEO_B) |
||||
{ |
||||
//System.out.println("Video Frame B");
|
||||
} |
||||
else if(frameInfo.nSubFrameType == PlayEnums.ENUM_SUB_FRAME_TYPE.SUB_FRAME_TYPE_VIDEO_S) |
||||
{ |
||||
//System.out.println("Video Frame S");
|
||||
} |
||||
else if(frameInfo.nSubFrameType == PlayEnums.ENUM_SUB_FRAME_TYPE.SUB_FRAME_TYPE_VIDEO_MJPEG) |
||||
{ |
||||
//System.out.println("Video Frame MJPEG");
|
||||
} |
||||
else |
||||
{ |
||||
//System.out.println("Video Frame Unknown");
|
||||
} |
||||
} |
||||
else if(frameInfo.nFrameType == PlayEnums.ENUM_MEDIA_FRAME_TYPE.MEDIA_FRAME_TYPE_AUDIO) |
||||
{ |
||||
//System.out.print("Audio Frame\n");
|
||||
} |
||||
} |
||||
} |
||||
|
||||
DecodeCallBack _cbDecodeCallBack = new DecodeCallBack(); |
||||
public static class GetIVSInfoCallBackFunc implements PlayDelegates.fGetIVSInfoCallBack |
||||
{ |
||||
@Override |
||||
public void invoke(Pointer pBuf, int nType, int nLen, int nRealLen, Pointer pReserved, Pointer pUserData) |
||||
{ |
||||
// 智能帧物体类型
|
||||
if(nType == PlayEnums.SA_DD_PARSE_TYPE.DD_PARSE_TYPE_INTL) |
||||
{ |
||||
int nObjNum = nLen / new PlayStructs.SA_DD_INTL_OBJECT().size(); |
||||
System.out.printf("nObjNum = %d\n", nObjNum); |
||||
PlayStructs.SA_DD_INTL_OBJECT[]pObjArr = new PlayStructs.SA_DD_INTL_OBJECT[nObjNum]; |
||||
for(int i = 0; i < nObjNum; i++) |
||||
{ |
||||
pObjArr[i] = new PlayStructs.SA_DD_INTL_OBJECT(); |
||||
} |
||||
DataUtils.sdk_data_ptrToStructureArray(pBuf, pObjArr); |
||||
|
||||
for (int i = 0; i < nObjNum; i++) |
||||
{ |
||||
// 人脸物体
|
||||
if(PlayEnums.SA_DD_INTL_OBJECT_TYPE.DD_INITL_OBJECT_FACE == pObjArr[i].nAttriType) |
||||
{ |
||||
PlayStructs.SA_DD_OBJECT_FACE pFaceObj = new PlayStructs.SA_DD_OBJECT_FACE(); |
||||
DataUtils.sdk_data_ptrToStructure(pObjArr[i].pData, pFaceObj); |
||||
|
||||
System.out.printf("left = %d, top = %d, right = %d, bottom = %d\n", pFaceObj.shape_rect.x - pFaceObj.shape_rect.xSize, |
||||
pFaceObj.shape_rect.y - pFaceObj.shape_rect.ySize, pFaceObj.shape_rect.x + pFaceObj.shape_rect.xSize, |
||||
pFaceObj.shape_rect.y + pFaceObj.shape_rect.ySize); |
||||
} |
||||
else |
||||
{ |
||||
// ...
|
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
GetIVSInfoCallBackFunc _cbGetIVSInfoCallBackFunc = new GetIVSInfoCallBackFunc(); |
||||
|
||||
// 播放回调
|
||||
private static class RealPlayDataCallBack implements NetDelegates.fRealPlayDataCallBack |
||||
{ |
||||
@Override |
||||
public void invoke(NativeLong realHandle, int dataType, Pointer ptrBuffer, int bufferSize, NativeLong userdata) |
||||
{ |
||||
if(0 != userdata.longValue()) |
||||
{ |
||||
int nPort = (int) userdata.longValue(); |
||||
// 将码流数据传给play库来播放
|
||||
PlayLib.instance.PlayMS_InputData(nPort, ptrBuffer, bufferSize); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private NativeLong m_realPlayHandle = new NativeLong(0); |
||||
RealPlayDataCallBack _realPlayDataCallBack = new RealPlayDataCallBack(); |
||||
|
||||
private Panel m_panel_video = null; |
||||
private NativeLong m_loginHandle = new NativeLong(0); |
||||
|
||||
public boolean startPlay() |
||||
{ |
||||
if(0 == m_loginHandle.longValue()) |
||||
{ |
||||
JOptionPane.showMessageDialog(null, "还未登录!", "提示", JOptionPane.ERROR_MESSAGE); |
||||
return false; |
||||
} |
||||
|
||||
Pointer ptrWnd = Native.getComponentPointer(m_panel_video); |
||||
|
||||
boolean bResult = PlayLib.instance.PlayMS_GetFreePort(m_nPlayPort); |
||||
|
||||
if(!bResult) |
||||
{ |
||||
JOptionPane.showMessageDialog(null, "设备繁忙,不能网络播放!", "提示", JOptionPane.ERROR_MESSAGE); |
||||
return false; |
||||
} |
||||
|
||||
// 设置实时流模式
|
||||
PlayLib.instance.PlayMS_SetLogOption(3); |
||||
bResult = PlayLib.instance.PlayMS_SetStreamOpenMode(m_nPlayPort.getValue(), PlayDefs.STREAM_TYPE_REALTIME); |
||||
// 打开流,并初始化缓存池(大小 MIN_SOURCE_BUF_SIZE - MAX_SOURCE_BUF_SIZE)
|
||||
bResult &= PlayLib.instance.PlayMS_OpenStream(m_nPlayPort.getValue(), 1024 * 1024 * 20); |
||||
// 在窗口 hwnd 播放流数据
|
||||
bResult &= PlayLib.instance.PlayMS_Play(m_nPlayPort.getValue(), ptrWnd); |
||||
// 设置解码回调函数,解码回调中获取帧内容和帧信息
|
||||
bResult &= PlayLib.instance.PlayMS_SetVisibleDecodeCallBack(m_nPlayPort.getValue(), _cbDecodeCallBack, null); |
||||
// 设置智能帧数据回调
|
||||
bResult &= PlayLib.instance.PlayMS_SetIVSCallBack(m_nPlayPort.getValue(), _cbGetIVSInfoCallBackFunc, null); |
||||
|
||||
if(!bResult) |
||||
{ |
||||
JOptionPane.showMessageDialog(null, "播放视频失败!", "提示", JOptionPane.ERROR_MESSAGE); |
||||
return false; |
||||
} |
||||
|
||||
int channel = 0; // 目前通道号常用为 0
|
||||
int nType = NetEnums.EM_REALPLAY_STREAM_TYPE.REALPLAY_STREAM_TYPE_REAL; // 实时播放流
|
||||
m_realPlayHandle = NetLib.instance.Net_RealPlay(m_loginHandle, channel, null, nType); |
||||
|
||||
if(0 == m_realPlayHandle.longValue()) |
||||
{ |
||||
JOptionPane.showMessageDialog(null, "实时播放失败!", "提示", JOptionPane.ERROR_MESSAGE); |
||||
return false; |
||||
} |
||||
|
||||
NetLib.instance.Net_SetRealDataCallBack(m_realPlayHandle, _realPlayDataCallBack, new NativeLong(this.m_nPlayPort.getValue())); |
||||
|
||||
/* |
||||
IntByReference nBrightness = new IntByReference(0); |
||||
IntByReference nContrast = new IntByReference(0); |
||||
IntByReference nHue = new IntByReference(0); |
||||
IntByReference nSaturation = new IntByReference(0); |
||||
if(getVideoBasicEffect(nBrightness, nContrast, nHue, nSaturation)) |
||||
{ |
||||
// 最大为128,转换为0-100显示
|
||||
this.m_slider_brighness.setValue(calEffectValue(nBrightness.getValue())); |
||||
this.m_slider_contrast.setValue(calEffectValue(nContrast.getValue())); |
||||
this.m_slider_hue.setValue(calEffectValue(nHue.getValue())); |
||||
this.m_slider_saturation.setValue(calEffectValue(nSaturation.getValue())); |
||||
} |
||||
*/ |
||||
|
||||
|
||||
System.out.println("播放实时视频成功!"); |
||||
return true; |
||||
} |
||||
|
||||
public boolean stopPlay() |
||||
{ |
||||
if(0 < this.m_nPlayPort.getValue()) |
||||
{ |
||||
PlayLib.instance.PlayMS_SetLogOption(3); |
||||
PlayLib.instance.PlayMS_Stop(this.m_nPlayPort.getValue()); |
||||
PlayLib.instance.PlayMS_ResetSourceBuffer(this.m_nPlayPort.getValue()); |
||||
PlayLib.instance.PlayMS_CloseStream(this.m_nPlayPort.getValue()); |
||||
} |
||||
|
||||
if(0 != m_loginHandle.longValue()) |
||||
{ |
||||
boolean bRet = NetLib.instance.Net_StopRealPlay(m_realPlayHandle); |
||||
if(!bRet) |
||||
{ |
||||
System.out.println("停止播放实时视频失败!"); |
||||
} |
||||
else |
||||
{ |
||||
System.out.println("停止播放实时视频成功!"); |
||||
} |
||||
|
||||
this.m_panel_video.repaint(); |
||||
this.m_nPlayPort.setValue(0); |
||||
this.m_realPlayHandle = new NativeLong(0); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
|
||||
|
||||
public boolean logout() |
||||
{ |
||||
if(0 == m_loginHandle.longValue()) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
boolean bRet = NetLib.instance.Net_LogoutDevice(m_loginHandle); |
||||
if(!bRet) |
||||
{ |
||||
System.out.println("设备登出失败!"); |
||||
} |
||||
else |
||||
{ |
||||
System.out.println("设备登出成功!"); |
||||
} |
||||
|
||||
m_loginHandle = new NativeLong(0); |
||||
|
||||
return bRet; |
||||
} |
||||
|
||||
public boolean login() |
||||
{ |
||||
String m_ip="192.168.1.64"; |
||||
int m_port= 27778; |
||||
String m_username="tongw"; |
||||
String m_password="tongw123"; |
||||
IntByReference m_error = null; |
||||
// 登录设备
|
||||
m_loginHandle = NetLib.instance.Net_LoginDevice(m_ip, m_port, m_username, m_password, null, m_error); |
||||
if(0 == m_loginHandle.longValue()) |
||||
{ |
||||
JOptionPane.showMessageDialog(null, "登录失败!", "提示", JOptionPane.ERROR_MESSAGE); |
||||
return false; |
||||
} |
||||
|
||||
System.out.println("设备登录成功!"); |
||||
return true; |
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
|
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!DOCTYPE mapper |
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.ruoyi.code.camera.mapper.CameraMapper"> |
||||
|
||||
</mapper> |
Loading…
Reference in new issue