From 6282c81bc5d3da22eaa304ad564d15014bcc4a79 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 23 十一月 2021 11:35:23 +0800
Subject: [PATCH] 移除onvif实现

---
 /dev/null                              |  123 -----------------------------------------
 src/main/resources/all-application.yml |    2 
 pom.xml                                |   11 ---
 3 files changed, 2 insertions(+), 134 deletions(-)

diff --git a/libs/onvif-java-1.0.2.jar b/libs/onvif-java-1.0.2.jar
deleted file mode 100644
index dd62a23..0000000
--- a/libs/onvif-java-1.0.2.jar
+++ /dev/null
Binary files differ
diff --git a/pom.xml b/pom.xml
index 5cd5f04..7a04892 100644
--- a/pom.xml
+++ b/pom.xml
@@ -212,17 +212,6 @@
 <!--			<version>1.0.8</version>-->
 <!--		</dependency>-->
 
-
-
-		<!-- onvif鍗忚鏍� -->
-		<dependency>
-			<groupId>be.teletask</groupId>
-			<artifactId>onvif-java</artifactId>
-			<version>1.0.2</version>
-			<scope>system</scope>
-			<systemPath>${project.basedir}/libs/onvif-java-1.0.2.jar</systemPath>
-		</dependency>
-
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-test</artifactId>
diff --git a/src/main/java/com/genersoft/iot/vmp/onvif/IONVIFServer.java b/src/main/java/com/genersoft/iot/vmp/onvif/IONVIFServer.java
deleted file mode 100644
index eb81a36..0000000
--- a/src/main/java/com/genersoft/iot/vmp/onvif/IONVIFServer.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.genersoft.iot.vmp.onvif;
-
-import be.teletask.onvif.models.OnvifDevice;
-import com.genersoft.iot.vmp.onvif.dto.ONVIFCallBack;
-
-import java.util.List;
-
-public interface IONVIFServer {
-
-    void search(int timeout, ONVIFCallBack<List<String>> callBack);
-
-    void getRTSPUrl(int timeout, OnvifDevice device, ONVIFCallBack<String> callBack);
-}
diff --git a/src/main/java/com/genersoft/iot/vmp/onvif/dto/ONVIFCallBack.java b/src/main/java/com/genersoft/iot/vmp/onvif/dto/ONVIFCallBack.java
deleted file mode 100644
index 3fdbde5..0000000
--- a/src/main/java/com/genersoft/iot/vmp/onvif/dto/ONVIFCallBack.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.genersoft.iot.vmp.onvif.dto;
-
-public interface ONVIFCallBack<T> {
-    void run(int errorCode, T t);
-}
diff --git a/src/main/java/com/genersoft/iot/vmp/onvif/impl/ONVIFServerIMpl.java b/src/main/java/com/genersoft/iot/vmp/onvif/impl/ONVIFServerIMpl.java
deleted file mode 100644
index d952cc8..0000000
--- a/src/main/java/com/genersoft/iot/vmp/onvif/impl/ONVIFServerIMpl.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package com.genersoft.iot.vmp.onvif.impl;
-
-
-import be.teletask.onvif.DiscoveryManager;
-import be.teletask.onvif.OnvifManager;
-import be.teletask.onvif.listeners.*;
-import be.teletask.onvif.models.*;
-import be.teletask.onvif.responses.OnvifResponse;
-import com.genersoft.iot.vmp.onvif.IONVIFServer;
-import com.genersoft.iot.vmp.onvif.dto.ONVIFCallBack;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@SuppressWarnings("rawtypes")
-/**
- * 澶勭悊onvif鐨勫悇绉嶆搷浣�
- */
-@Service
-public class ONVIFServerIMpl implements IONVIFServer {
-
-    private final static Logger logger = LoggerFactory.getLogger(ONVIFServerIMpl.class);
-
-    @Override
-    public void search(int timeout, ONVIFCallBack<List<String>> callBack) {
-        DiscoveryManager manager = new DiscoveryManager();
-        manager.setDiscoveryTimeout(timeout);
-        Map<String, Device> deviceMap = new HashMap<>();
-        // 鎼滅储璁惧
-        manager.discover(new DiscoveryListener() {
-            @Override
-            public void onDiscoveryStarted() {
-                logger.info("Discovery started");
-            }
-
-            @Override
-            public void onDevicesFound(List<Device> devices) {
-                if (devices == null || devices.size() == 0) return;
-                for (Device device : devices){
-                    logger.info(device.getHostName());
-                    deviceMap.put(device.getHostName(),  device);
-                }
-            }
-
-            // 鎼滅储缁撴潫
-            @Override
-            public void onDiscoveryFinished() {
-                ArrayList<String> result = new ArrayList<>();
-                for (Device device : deviceMap.values()) {
-                    logger.info(device.getHostName());
-                    result.add(device.getHostName());
-                }
-                callBack.run(0, result);
-            }
-        });
-    }
-
-    @Override
-    public void getRTSPUrl(int timeout, OnvifDevice device, ONVIFCallBack<String> callBack) {
-        if (device.getHostName() == null ){
-            callBack.run(400, null);
-        }
-        OnvifManager onvifManager = new OnvifManager();
-        onvifManager.setOnvifResponseListener(new OnvifResponseListener(){
-
-            @Override
-            public void onResponse(OnvifDevice onvifDevice, OnvifResponse response) {
-                logger.info("[RESPONSE] " + onvifDevice.getHostName()
-                        + "======" + response.getErrorCode()
-                        + "======" + response.getErrorMessage());
-            }
-
-            @Override
-            public void onError(OnvifDevice onvifDevice, int errorCode, String errorMessage) {
-                logger.info("[ERROR] " + onvifDevice.getHostName() + "======" + errorCode + "=======" + errorMessage);
-                callBack.run(errorCode, errorMessage);
-            }
-        });
-
-        try {
-            onvifManager.getServices(device, (OnvifDevice onvifDevice, OnvifServices services) -> {
-                if (services.getProfilesPath().equals("/onvif/Media")) {
-                    onvifDevice.setPath(services);
-                    onvifManager.getMediaProfiles(onvifDevice, new OnvifMediaProfilesListener() {
-                        @Override
-                        public void onMediaProfilesReceived(OnvifDevice device, List<OnvifMediaProfile> mediaProfiles) {
-                            for (OnvifMediaProfile mediaProfile : mediaProfiles) {
-                                logger.info(mediaProfile.getName());
-                                logger.info(mediaProfile.getToken());
-                                if (mediaProfile.getName().equals("mainStream")) {
-                                    onvifManager.getMediaStreamURI(device, mediaProfile, (OnvifDevice onvifDevice,
-                                                                                          OnvifMediaProfile profile, String uri) -> {
-
-                                        uri = uri.replace("rtsp://", "rtsp://"+ device.getUsername() + ":"+ device.getPassword() + "@");
-                                        logger.info(onvifDevice.getHostName() + "鐨勫湴鍧�" + uri);
-                                        callBack.run(0, uri);
-                                    });
-                                }
-                            }
-                        }
-                    });
-                }
-            });
-        }catch (Exception e) {
-            callBack.run(400, e.getMessage());
-        }
-
-
-    }
-}
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/onvif/ONVIFController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/onvif/ONVIFController.java
deleted file mode 100644
index 0fa2f6b..0000000
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/onvif/ONVIFController.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package com.genersoft.iot.vmp.vmanager.onvif;
-
-import be.teletask.onvif.models.OnvifDevice;
-import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
-import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
-import com.genersoft.iot.vmp.onvif.IONVIFServer;
-import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.context.request.async.DeferredResult;
-
-import java.util.List;
-import java.util.UUID;
-
-@SuppressWarnings(value = {"rawtypes", "unchecked"})
-@Api(tags = "onvif璁惧")
-@CrossOrigin
-@RestController
-@RequestMapping("/api/onvif")
-public class ONVIFController {
-
-
-    @Autowired
-    private DeferredResultHolder resultHolder;
-
-    @Autowired
-    private IONVIFServer onvifServer;
-
-
-    @ApiOperation("鎼滅储")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name="timeout", value = "瓒呮椂鏃堕棿", required = true, dataTypeClass = Integer.class),
-    })
-    @GetMapping(value = "/search")
-    @ResponseBody
-    public DeferredResult<ResponseEntity<WVPResult>> search(@RequestParam(required = false)Integer timeout){
-        DeferredResult<ResponseEntity<WVPResult>> result = new DeferredResult<>(timeout + 10L);
-        String uuid = UUID.randomUUID().toString();
-        result.onTimeout(()->{
-            RequestMessage msg = new RequestMessage();
-            msg.setKey(DeferredResultHolder.CALLBACK_ONVIF );
-            msg.setId(uuid);
-            WVPResult<String> wvpResult = new WVPResult();
-            wvpResult.setCode(0);
-            wvpResult.setMsg("鎼滅储瓒呮椂");
-            msg.setData(wvpResult);
-            resultHolder.invokeResult(msg);
-        });
-        resultHolder.put(DeferredResultHolder.CALLBACK_ONVIF, uuid, result);
-
-        onvifServer.search(timeout, (errorCode, onvifDevices) ->{
-            RequestMessage msg = new RequestMessage();
-            msg.setId(DeferredResultHolder.CALLBACK_ONVIF + uuid);
-            WVPResult<List<String>> resultData = new WVPResult();
-            resultData.setCode(errorCode);
-            if (errorCode == 0) {
-                resultData.setMsg("success");
-                resultData.setData(onvifDevices);
-            }else {
-                resultData.setMsg("fail");
-            }
-            msg.setData(resultData);
-            msg.setData(resultData);
-            resultHolder.invokeResult(msg);
-        });
-
-        return result;
-    }
-
-    @ApiOperation("鑾峰彇onvif鐨剅tsp鍦板潃")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name="timeout", value = "瓒呮椂鏃堕棿", required = true, dataTypeClass = Integer.class),
-            @ApiImplicitParam(name="hostname", value = "onvif鍦板潃", required = true, dataTypeClass = String.class),
-            @ApiImplicitParam(name="username", value = "鐢ㄦ埛鍚�", required = true, dataTypeClass = String.class),
-            @ApiImplicitParam(name="password", value = "瀵嗙爜", required = true, dataTypeClass = String.class),
-    })
-    @GetMapping(value = "/rtsp")
-    @ResponseBody
-    public DeferredResult<ResponseEntity<WVPResult>> getRTSPUrl(@RequestParam(value="timeout", required=false, defaultValue="3000") Integer timeout,
-                                                                @RequestParam(required = true) String hostname,
-                                                                @RequestParam(required = false) String username,
-                                                                @RequestParam(required = false) String password
-                                                                ){
-
-        DeferredResult<ResponseEntity<WVPResult>> result = new DeferredResult<>(timeout + 10L);
-        String uuid = UUID.randomUUID().toString();
-        result.onTimeout(()->{
-            RequestMessage msg = new RequestMessage();
-            msg.setId(uuid);
-            msg.setKey(DeferredResultHolder.CALLBACK_ONVIF);
-            WVPResult<String> wvpResult = new WVPResult();
-            wvpResult.setCode(0);
-            wvpResult.setMsg("鑾峰彇onvif鐨剅tsp鍦板潃瓒呮椂");
-            msg.setData(wvpResult);
-            resultHolder.invokeResult(msg);
-        });
-        resultHolder.put(DeferredResultHolder.CALLBACK_ONVIF, uuid, result);
-        OnvifDevice onvifDevice = new OnvifDevice(hostname, username, password);
-        onvifServer.getRTSPUrl(timeout, onvifDevice,  (errorCode, url) ->{
-            RequestMessage msg = new RequestMessage();
-            msg.setId(DeferredResultHolder.CALLBACK_ONVIF + uuid);
-            WVPResult<String> resultData = new WVPResult();
-            resultData.setCode(errorCode);
-            if (errorCode == 0) {
-                resultData.setMsg("success");
-                resultData.setData(url);
-            }else {
-                resultData.setMsg(url);
-            }
-            msg.setData(resultData);
-
-            resultHolder.invokeResult(msg);
-        });
-
-        return result;
-    }
-
-}
diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml
index e7d6810..6328bc3 100644
--- a/src/main/resources/all-application.yml
+++ b/src/main/resources/all-application.yml
@@ -137,6 +137,8 @@
         com.genersoft.iot.vmp.gb28181: info
 # [鏍规嵁涓氬姟闇�姹傞厤缃甝
 user-settings:
+    # [鍙�塢 鏈嶅姟ID锛屼笉鍐欏垯涓�000000
+    server-id:
     # [鍙�塢 鑷姩鐐规挱锛� 浣跨敤鍥哄畾娴佸湴鍧�杩涜鎾斁鏃讹紝濡傛灉鏈偣鎾垯鑷姩杩涜鐐规挱, 闇�瑕乺tp.enable=true
     auto-apply-play: false
     # [鍙�塢 閮ㄥ垎璁惧闇�瑕佹墿灞昐DP锛岄渶瑕佹墦寮�姝よ缃�

--
Gitblit v1.8.0