有哈u云台控制接口
parent
df0b530ce4
commit
074dbd69a2
|
@ -1,12 +1,14 @@
|
||||||
package com.genersoft.iot.vmp.conf;
|
package com.genersoft.iot.vmp.conf;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||||
|
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
import org.apache.http.HttpRequest;
|
import org.apache.http.HttpRequest;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.mitre.dsmiley.httpproxy.ProxyServlet;
|
import org.mitre.dsmiley.httpproxy.ProxyServlet;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -26,11 +28,13 @@ import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 系统代理,用来代理zlm和assist服务的接口
|
||||||
* @author lin
|
* @author lin
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings(value = {"rawtypes", "unchecked"})
|
@SuppressWarnings(value = {"rawtypes", "unchecked"})
|
||||||
|
@ -84,28 +88,15 @@ public class ProxyServletConfig {
|
||||||
if (servletResponse.getStatus() == HttpServletResponse.SC_OK) {
|
if (servletResponse.getStatus() == HttpServletResponse.SC_OK) {
|
||||||
HttpEntity entity = response.getEntity();
|
HttpEntity entity = response.getEntity();
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
if (entity.isChunked()) {
|
|
||||||
List<Byte> byteList = new ArrayList<>();
|
|
||||||
InputStream is = entity.getContent();
|
InputStream is = entity.getContent();
|
||||||
OutputStream os = servletResponse.getOutputStream();
|
byte[] allBuffer = new byte[(int) entity.getContentLength()];
|
||||||
byte[] buffer = new byte[10240];
|
if (is.read(allBuffer) > -1) {
|
||||||
ByteBuffer byteBuffer = new ByteBuffer()
|
JSONObject jsonObject = JSON.parseObject(allBuffer);
|
||||||
while(true) {
|
WVPResult<JSONObject> result = WVPResult.success(jsonObject);
|
||||||
do {
|
byte[] jsonBytes = JSON.toJSONBytes(result);
|
||||||
int read;
|
|
||||||
if ((read = is.read(buffer)) == -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
buffer
|
|
||||||
byteList.addAll(buffer.)
|
|
||||||
os.write(buffer, 0, read);
|
|
||||||
} while(!this.doHandleCompression && is.available() != 0);
|
|
||||||
|
|
||||||
os.flush();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
OutputStream servletOutputStream = servletResponse.getOutputStream();
|
OutputStream servletOutputStream = servletResponse.getOutputStream();
|
||||||
entity.writeTo(servletOutputStream);
|
servletResponse.setContentLength(jsonBytes.length);
|
||||||
|
servletOutputStream.write(jsonBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class PtzController {
|
||||||
@Parameter(name = "horizonSpeed", description = "水平速度", required = true)
|
@Parameter(name = "horizonSpeed", description = "水平速度", required = true)
|
||||||
@Parameter(name = "verticalSpeed", description = "垂直速度", required = true)
|
@Parameter(name = "verticalSpeed", description = "垂直速度", required = true)
|
||||||
@Parameter(name = "zoomSpeed", description = "缩放速度", required = true)
|
@Parameter(name = "zoomSpeed", description = "缩放速度", required = true)
|
||||||
@PostMapping("/control/{deviceId}/{channelId}")
|
@RequestMapping(value = "/control/{deviceId}/{channelId}", method = {RequestMethod.GET, RequestMethod.POST})
|
||||||
public void ptz(@PathVariable String deviceId,@PathVariable String channelId, String command, int horizonSpeed, int verticalSpeed, int zoomSpeed){
|
public void ptz(@PathVariable String deviceId,@PathVariable String channelId, String command, int horizonSpeed, int verticalSpeed, int zoomSpeed){
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
|
|
Loading…
Reference in New Issue