From fc901e8c65b6a2ec3c19e60534202114970fccbe Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期五, 25 九月 2020 17:41:02 +0800
Subject: [PATCH] 更新readme
---
src/main/java/com/genersoft/iot/vmp/web/ApiStreamController.java | 168 ++++++++++++++++
src/main/java/com/genersoft/iot/vmp/web/ApiController.java | 109 ++++++++++
src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java | 169 ++++++++++++++++
src/main/java/com/genersoft/iot/vmp/web/ApiControlController.java | 96 +++++++++
README.md | 5
5 files changed, 547 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
index 2109bb3..1f1dbc9 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,8 @@
娴佸獟浣撴湇鍔″熀浜嶼LMediaKit-https://github.com/xiongziliang/ZLMediaKit
鍓嶇灞曠ず鍩轰簬MediaServerUI-https://gitee.com/kkkkk5G/MediaServerUI/tree/gb28181/
+### fork鑷� [swwheihei/wvp-GB28181](https://github.com/swwheihei/wvp-GB28181)
+
# 搴旂敤鍦烘櫙锛�
涓昏搴旂敤鍦↖PC绛夎澶囨病鏈夊浐瀹欼P鍦板潃锛屼絾闇�瑕佸湪浜掕仈缃戜腑瑙傜湅鐨勫満鏅��
瑕佹眰IPC璁惧鍙互璁块棶浜掕仈缃戯紝鏈変簯鏈嶅姟鍣ㄧ敤浜庨儴缃叉湰鏈嶅姟銆�
@@ -36,3 +38,6 @@
# 鑷磋阿
鎰熻阿浣滆�匸澶忔](https://github.com/xiongziliang) 鎻愪緵杩欎箞妫掔殑寮�婧愭祦濯掍綋鏈嶅姟妗嗘灦
鎰熻阿浣滆�匸kkkkk5G](https://gitee.com/kkkkk5G) 鎻愪緵杩欎箞妫掔殑鍓嶇UI
+
+
+[]: https://github.com/swwheihei/wvp-GB28181
\ No newline at end of file
diff --git a/src/main/java/com/genersoft/iot/vmp/web/ApiControlController.java b/src/main/java/com/genersoft/iot/vmp/web/ApiControlController.java
new file mode 100644
index 0000000..c9a68bf
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/web/ApiControlController.java
@@ -0,0 +1,96 @@
+package com.genersoft.iot.vmp.web;
+
+import com.alibaba.fastjson.JSONObject;
+import com.genersoft.iot.vmp.gb28181.bean.Device;
+import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.vmanager.ptz.PtzController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 鍏煎LiveGBS鐨凙PI锛氳澶囨帶鍒�
+ */
+@CrossOrigin
+@RestController
+@RequestMapping(value = "/api/v1/control")
+public class ApiControlController {
+
+ private final static Logger logger = LoggerFactory.getLogger(ApiControlController.class);
+
+ @Autowired
+ private SIPCommander cmder;
+
+ @Autowired
+ private IVideoManagerStorager storager;
+
+ /**
+ * 璁惧鎺у埗 - 浜戝彴鎺у埗
+ * @param serial 璁惧缂栧彿
+ * @param command 鎺у埗鎸囦护 鍏佽鍊�: left, right, up, down, upleft, upright, downleft, downright, zoomin, zoomout, stop
+ * @param channel 閫氶亾搴忓彿
+ * @param code 閫氶亾缂栧彿
+ * @param speed 閫熷害(0~255) 榛樿鍊�: 129
+ * @return
+ */
+ @RequestMapping(value = "/ptz")
+ private JSONObject list(String serial,String command,
+ @RequestParam(required = false)Integer channel,
+ @RequestParam(required = false)String code,
+ @RequestParam(required = false)Integer speed){
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("妯℃嫙鎺ュ彛> 璁惧浜戝彴鎺у埗 API璋冪敤锛宒eviceId锛�%s 锛宑hannelId锛�%s 锛宑ommand锛�%d 锛宻peed锛�%d ",
+ serial, code, command, speed));
+ }
+ Device device = storager.queryVideoDevice(serial);
+ int leftRight = 0;
+ int upDown = 0;
+ int inOut = 0;
+ switch (command) {
+ case "left":
+ leftRight = 1;
+ break;
+ case "right":
+ leftRight = 2;
+ break;
+ case "up":
+ upDown = 1;
+ break;
+ case "down":
+ upDown = 2;
+ break;
+ case "upleft":
+ upDown = 1;
+ leftRight = 1;
+ case "upright":
+ upDown = 1;
+ leftRight = 2;
+ break;
+ case "downleft":
+ upDown = 2;
+ leftRight = 1;
+ break;
+ case "downright":
+ upDown = 2;
+ leftRight = 2;
+ break;
+ case "zoomin":
+ inOut = 2;
+ break;
+ case "zoomout":
+ inOut = 1;
+ break;
+ case "stop":
+ break;
+
+ }
+ // 榛樿鍊� 50
+ cmder.ptzCmd(device, code, leftRight, upDown, inOut, speed==0 ? 129 : speed, 50);
+ return null;
+ }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/web/ApiController.java b/src/main/java/com/genersoft/iot/vmp/web/ApiController.java
new file mode 100644
index 0000000..002b2cc
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/web/ApiController.java
@@ -0,0 +1,109 @@
+package com.genersoft.iot.vmp.web;
+
+import com.alibaba.fastjson.JSONObject;
+import com.genersoft.iot.vmp.conf.SipConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * 鍏煎LiveGBS鐨凙PI锛氱郴缁熸帴鍙�
+ */
+@Controller
+@CrossOrigin
+@RequestMapping(value = "/api/v1")
+public class ApiController {
+
+ private final static Logger logger = LoggerFactory.getLogger(ApiController.class);
+
+ @Autowired
+ private SipConfig sipConfig;
+
+
+ @RequestMapping("/getserverinfo")
+ private JSONObject getserverinfo(){
+ JSONObject result = new JSONObject();
+ result.put("Authorization","ceshi");
+ result.put("Hardware","");
+ result.put("InterfaceVersion","2.5.5");
+ result.put("IsDemo","");
+ result.put("Hardware","false");
+ result.put("APIAuth","false");
+ result.put("RemainDays","姘镐箙");
+ result.put("RunningTime","");
+ result.put("ServerTime","2020-09-02 17锛�11");
+ result.put("StartUpTime","2020-09-02 17锛�11");
+ result.put("Server","");
+ result.put("SIPSerial", sipConfig.getSipId());
+ result.put("SIPRealm", sipConfig.getSipDomain());
+ result.put("SIPHost", sipConfig.getSipIp());
+ result.put("SIPPort", sipConfig.getSipPort());
+ result.put("ChannelCount","1000");
+ result.put("VersionType","");
+ result.put("LogoMiniText","");
+ result.put("LogoText","");
+ result.put("CopyrightText","");
+
+ return result;
+ }
+
+ @RequestMapping(value = "/userinfo")
+ private JSONObject userinfo(){
+// JSONObject result = new JSONObject();
+// result.put("ID","ceshi");
+// result.put("Hardware","");
+// result.put("InterfaceVersion","2.5.5");
+// result.put("IsDemo","");
+// result.put("Hardware","false");
+// result.put("APIAuth","false");
+// result.put("RemainDays","姘镐箙");
+// result.put("RunningTime","");
+// result.put("ServerTime","2020-09-02 17锛�11");
+// result.put("StartUpTime","2020-09-02 17锛�11");
+// result.put("Server","");
+// result.put("SIPSerial", sipConfig.getSipId());
+// result.put("SIPRealm", sipConfig.getSipDomain());
+// result.put("SIPHost", sipConfig.getSipIp());
+// result.put("SIPPort", sipConfig.getSipPort());
+// result.put("ChannelCount","1000");
+// result.put("VersionType","");
+// result.put("LogoMiniText","");
+// result.put("LogoText","");
+// result.put("CopyrightText","");
+
+ return null;
+ }
+
+ /**
+ * 绯荤粺鎺ュ彛 - 鐧诲綍
+ * @param username 鐢ㄦ埛鍚�
+ * @param password 瀵嗙爜(缁忚繃md5鍔犲瘑,32浣嶉暱搴�,涓嶅甫涓垝绾�,涓嶅尯鍒嗗ぇ灏忓啓)
+ * @return
+ */
+ @RequestMapping(value = "/login")
+ @ResponseBody
+ private JSONObject login(String username,String password ){
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("妯℃嫙鎺ュ彛> 鐧诲綍 API璋冪敤锛寀sername锛�%s 锛宲assword锛�%s ",
+ username, password));
+ }
+
+ JSONObject result = new JSONObject();
+ result.put("CookieToken","ynBDDiKMg");
+ result.put("URLToken","MOBkORkqnrnoVGcKIAHXppgfkNWRdV7utZSkDrI448Q.oxNjAxNTM4NDk3LCJwIjoiZGJjODg5NzliNzVj" +
+ "Nzc2YmU5MzBjM2JjNjg1ZWFiNGI5ZjhhN2Y0N2RlZjg3NWUyOTJkY2VkYjkwYmEwMTA0NyIsInQiOjE2MDA5MzM2OTcsInUiOiI" +
+ "4ODlkZDYyM2ViIn0eyJlIj.GciOiJIUzI1NiIsInR5cCI6IkpXVCJ9eyJhb");
+ result.put("TokenTimeout",604800);
+ result.put("AuthToken","MOBkORkqnrnoVGcKIAHXppgfkNWRdV7utZSkDrI448Q.oxNjAxNTM4NDk3LCJwIjoiZGJjODg5NzliNzVj" +
+ "Nzc2YmU5MzBjM2JjNjg1ZWFiNGI5ZjhhN2Y0N2RlZjg3NWUyOTJkY2VkYjkwYmEwMTA0NyIsInQiOjE2MDA5MzM2OTcsInUiOiI" +
+ "4ODlkZDYyM2ViIn0eyJlIj.GciOiJIUzI1NiIsInR5cCI6IkpXVCJ9eyJhb");
+ result.put("Token","ynBDDiKMg");
+ return result;
+ }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java b/src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java
new file mode 100644
index 0000000..57b102c
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java
@@ -0,0 +1,169 @@
+package com.genersoft.iot.vmp.web;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.genersoft.iot.vmp.common.PageResult;
+import com.genersoft.iot.vmp.gb28181.bean.Device;
+import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
+import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
+import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
+import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.vmanager.device.DeviceController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 鍏煎LiveGBS鐨凙PI锛氳澶囦俊鎭�
+ */
+@CrossOrigin
+@RestController
+@RequestMapping(value = "/api/v1/device")
+public class ApiDeviceController {
+
+ private final static Logger logger = LoggerFactory.getLogger(ApiDeviceController.class);
+
+ @Autowired
+ private IVideoManagerStorager storager;
+
+ @Autowired
+ private SIPCommander cmder;
+
+ @Autowired
+ private DeferredResultHolder resultHolder;
+
+ @Autowired
+ private DeviceOffLineDetector offLineDetector;
+
+ /**
+ * 鍒嗛〉鑾峰彇璁惧鍒楄〃 TODO 鐜板湪鐩存帴杩斿洖锛屽皻鏈疄鐜板垎椤�
+ * @param start
+ * @param limit
+ * @param q
+ * @param online
+ * @return
+ */
+ @RequestMapping(value = "/list")
+ public JSONObject list( @RequestParam(required = false)Integer start,
+ @RequestParam(required = false)Integer limit,
+ @RequestParam(required = false)String q,
+ @RequestParam(required = false)Boolean online ){
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("鏌ヨ鎵�鏈夎棰戣澶嘇PI璋冪敤");
+ }
+
+ logger.debug("鏌ヨ鎵�鏈夎棰戣澶嘇PI璋冪敤");
+ JSONObject result = new JSONObject();
+ List<Device> devices;
+ if (start == null || limit ==null) {
+ devices = storager.queryVideoDeviceList(null);
+ result.put("DeviceCount", devices.size());
+ }else {
+ PageResult<Device> deviceList = storager.queryVideoDeviceList(null, start, limit);
+ result.put("DeviceCount", deviceList.getTotal());
+ devices = deviceList.getData();
+ }
+
+ JSONArray deviceJSONList = new JSONArray();
+ for (Device device : devices) {
+ JSONObject deviceJsonObject = new JSONObject();
+ deviceJsonObject.put("ID", device.getDeviceId());
+ deviceJsonObject.put("Name", device.getName());
+ deviceJsonObject.put("Type", "GB");
+ deviceJsonObject.put("ChannelCount", device.getChannelCount());
+ deviceJsonObject.put("RecvStreamIP", "");
+ deviceJsonObject.put("CatalogInterval", 3600); // 閫氶亾鐩綍鎶撳彇鍛ㄦ湡
+ deviceJsonObject.put("SubscribeInterval", 0); // 璁㈤槄鍛ㄦ湡(绉�), 0 琛ㄧず鍚庡彴涓嶅懆鏈熻闃�
+ deviceJsonObject.put("Online", device.getOnline() == 1);
+ deviceJsonObject.put("Password", "");
+ deviceJsonObject.put("MediaTransport", device.getTransport());
+ deviceJsonObject.put("RemoteIP", device.getHost().getIp());
+ deviceJsonObject.put("RemotePort", device.getHost().getPort());
+ deviceJsonObject.put("LastRegisterAt", "");
+ deviceJsonObject.put("LastKeepaliveAt", "");
+ deviceJsonObject.put("UpdatedAt", "");
+ deviceJsonObject.put("CreatedAt", "");
+ deviceJSONList.add(deviceJsonObject);
+ }
+ result.put("DeviceList",deviceJSONList);
+ return result;
+ }
+
+ @RequestMapping(value = "/channellist")
+ public JSONObject channellist( String serial,
+ @RequestParam(required = false)String channel_type,
+ @RequestParam(required = false)String dir_serial ,
+ @RequestParam(required = false)Integer start,
+ @RequestParam(required = false)Integer limit,
+ @RequestParam(required = false)String q,
+ @RequestParam(required = false)Boolean online ){
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("鏌ヨ鎵�鏈夎棰戣澶嘇PI璋冪敤");
+ }
+ JSONObject result = new JSONObject();
+ // 鏌ヨ璁惧鏄惁瀛樺湪
+ Device device = storager.queryVideoDevice(serial);
+ if (device == null) {
+ result.put("ChannelCount", 0);
+ result.put("ChannelList", "[]");
+ return result;
+ }
+ List<DeviceChannel> deviceChannels;
+ if (start == null || limit ==null) {
+ deviceChannels = storager.queryChannelsByDeviceId(serial);
+ result.put("ChannelCount", deviceChannels.size());
+ }else {
+ PageResult<DeviceChannel> pageResult = storager.queryChannelsByDeviceId(serial, start, limit);
+ result.put("ChannelCount", pageResult.getTotal());
+ deviceChannels = pageResult.getData();
+ }
+
+ JSONArray channleJSONList = new JSONArray();
+ for (DeviceChannel deviceChannel : deviceChannels) {
+ JSONObject deviceJOSNChannel = new JSONObject();
+ deviceJOSNChannel.put("ID", deviceChannel.getChannelId());
+ deviceJOSNChannel.put("DeviceID", device.getDeviceId());
+ deviceJOSNChannel.put("DeviceName", device.getName());
+ deviceJOSNChannel.put("DeviceOnline", device.getOnline() == 1);
+ deviceJOSNChannel.put("Channel", 0); // TODO 鑷畾涔夊簭鍙�
+ deviceJOSNChannel.put("Name", deviceChannel.getName());
+ deviceJOSNChannel.put("Custom", false);
+ deviceJOSNChannel.put("CustomName", "");
+ deviceJOSNChannel.put("SubCount", 0); // TODO ? 瀛愯妭鐐规暟, SubCount > 0 琛ㄧず璇ラ�氶亾涓哄瓙鐩綍
+ deviceJOSNChannel.put("SnapURL", "");
+ deviceJOSNChannel.put("Manufacturer ", deviceChannel.getManufacture());
+ deviceJOSNChannel.put("Model", deviceChannel.getModel());
+ deviceJOSNChannel.put("Owner", deviceChannel.getOwner());
+ deviceJOSNChannel.put("CivilCode", deviceChannel.getCivilCode());
+ deviceJOSNChannel.put("Address", deviceChannel.getAddress());
+ deviceJOSNChannel.put("Parental", deviceChannel.getParental()); // 褰撲负閫氶亾璁惧鏃�, 鏄惁鏈夐�氶亾瀛愯澶�, 1-鏈�,0-娌℃湁
+ deviceJOSNChannel.put("ParentID", deviceChannel.getParentId()); // 鐩存帴涓婄骇缂栧彿
+ deviceJOSNChannel.put("Secrecy", deviceChannel.getSecrecy());
+ deviceJOSNChannel.put("RegisterWay", 1); // 娉ㄥ唽鏂瑰紡, 缂虹渷涓�1, 鍏佽鍊�: 1, 2, 3
+ // 1-IETF RFC3261,
+ // 2-鍩轰簬鍙d护鐨勫弻鍚戣璇�,
+ // 3-鍩轰簬鏁板瓧璇佷功鐨勫弻鍚戣璇�
+ deviceJOSNChannel.put("Status", deviceChannel.getStatus());
+ deviceJOSNChannel.put("Longitude", deviceChannel.getLongitude());
+ deviceJOSNChannel.put("Latitude", deviceChannel.getLatitude());
+ deviceJOSNChannel.put("PTZType ", deviceChannel.getPTZType()); // 浜戝彴绫诲瀷, 0 - 鏈煡, 1 - 鐞冩満, 2 - 鍗婄悆,
+ // 3 - 鍥哄畾鏋満, 4 - 閬ユ帶鏋満
+ deviceJOSNChannel.put("CustomPTZType", "");
+ deviceJOSNChannel.put("StreamID", deviceChannel.getSsrc()); // StreamID 鐩存挱娴両D, 鏈夊�艰〃绀烘鍦ㄧ洿鎾�
+ deviceJOSNChannel.put("NumOutputs ", -1); // 鐩存挱鍦ㄧ嚎浜烘暟
+ channleJSONList.add(deviceJOSNChannel);
+ }
+ result.put("ChannelList", channleJSONList);
+ return result;
+ }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/web/ApiStreamController.java b/src/main/java/com/genersoft/iot/vmp/web/ApiStreamController.java
new file mode 100644
index 0000000..d2644f3
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/web/ApiStreamController.java
@@ -0,0 +1,168 @@
+package com.genersoft.iot.vmp.web;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.genersoft.iot.vmp.common.StreamInfo;
+import com.genersoft.iot.vmp.gb28181.bean.Device;
+import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
+import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.vmanager.play.PlayController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 鍏煎LiveGBS鐨凙PI锛氬疄鏃剁洿鎾�
+ */
+@CrossOrigin
+@RestController
+@RequestMapping(value = "/api/v1/stream")
+public class ApiStreamController {
+
+ private final static Logger logger = LoggerFactory.getLogger(ApiStreamController.class);
+
+ @Autowired
+ private SIPCommander cmder;
+
+ @Autowired
+ private IVideoManagerStorager storager;
+
+ /**
+ * 瀹炴椂鐩存挱 - 寮�濮嬬洿鎾�
+ * @param serial 璁惧缂栧彿
+ * @param channel 閫氶亾搴忓彿 榛樿鍊�: 1
+ * @param code 閫氶亾缂栧彿,閫氳繃 /api/v1/device/channellist 鑾峰彇鐨� ChannelList.ID, 璇ュ弬鏁板拰 channel 浜岄�変竴浼犻�掑嵆鍙�
+ * @param cdn TODO 杞帹 CDN 鍦板潃, 褰㈠: [rtmp|rtsp]://xxx, encodeURIComponent
+ * @param audio TODO 鏄惁寮�鍚煶棰�, 榛樿 寮�鍚�
+ * @param transport 娴佷紶杈撴ā寮忥紝 榛樿 UDP
+ * @param checkchannelstatus TODO 鏄惁妫�鏌ラ�氶亾鐘舵��, 榛樿 false, 琛ㄧず 鎷夋祦鍓嶄笉妫�鏌ラ�氶亾鐘舵�佹槸鍚﹀湪绾�
+ * @param transportmode TODO 褰� transport=TCP 鏃舵湁鏁�, 鎸囩ず娴佷紶杈撲富琚姩妯″紡, 榛樿琚姩
+ * @param timeout TODO 鎷夋祦瓒呮椂(绉�),
+ * @return
+ */
+ @RequestMapping(value = "/start")
+ private JSONObject start(String serial ,
+ @RequestParam(required = false)Integer channel ,
+ @RequestParam(required = false)String code,
+ @RequestParam(required = false)String cdn,
+ @RequestParam(required = false)String audio,
+ @RequestParam(required = false)String transport,
+ @RequestParam(required = false)String checkchannelstatus ,
+ @RequestParam(required = false)String transportmode,
+ @RequestParam(required = false)String timeout
+
+ ){
+
+ Device device = storager.queryVideoDevice(serial);
+ if (device == null ) {
+ JSONObject result = new JSONObject();
+ result.put("error","device[ " + serial + " ]鏈壘鍒�");
+ return result;
+ }
+ DeviceChannel deviceChannel = storager.queryChannel(serial, code);
+ if (deviceChannel == null) {
+ JSONObject result = new JSONObject();
+ result.put("error","channel[ " + code + " ]鏈壘鍒�");
+ return result;
+ }
+ // 鏌ヨ鏄惁宸茬粡鍦ㄦ挱鏀�
+ StreamInfo streamInfo = storager.queryPlay(device.getDeviceId(), code);
+ if (streamInfo == null) streamInfo = cmder.playStreamCmd(device, code);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("璁惧棰勮 API璋冪敤锛宒eviceId锛�%s 锛宑hannelId锛�%s",serial, code));
+ logger.debug("璁惧棰勮 API璋冪敤锛宻src锛�"+streamInfo.getSsrc()+",ZLMedia streamId:"+Integer.toHexString(Integer.parseInt(streamInfo.getSsrc())));
+ }
+
+ if(streamInfo!=null) {
+ JSONObject result = new JSONObject();
+ result.put("StreamID", streamInfo.getSsrc());
+ result.put("DeviceID", device.getDeviceId());
+ result.put("ChannelID", code);
+ result.put("ChannelName", deviceChannel.getName());
+ result.put("ChannelCustomName ", "");
+ result.put("FLV ", streamInfo.getFlv());
+ result.put("WS_FLV ", streamInfo.getWS_FLV());
+ result.put("RTMP", streamInfo.getRTMP());
+ result.put("HLS", streamInfo.getHLS());
+ result.put("RTSP", streamInfo.getRTSP());
+ result.put("CDN", "");
+ result.put("SnapURL", "");
+ result.put("Transport", device.getTransport());
+ result.put("StartAt", "");
+ result.put("Duration", "");
+ result.put("SourceVideoCodecName", "");
+ result.put("SourceVideoWidth", "");
+ result.put("SourceVideoHeight", "");
+ result.put("SourceVideoFrameRate", "");
+ result.put("SourceAudioCodecName", "");
+ result.put("SourceAudioSampleRate", "");
+ result.put("AudioEnable", "");
+ result.put("Ondemand", "");
+ result.put("InBytes", "");
+ result.put("InBitRate", "");
+ result.put("OutBytes", "");
+ result.put("NumOutputs", "");
+ result.put("CascadeSize", "");
+ result.put("RelaySize", "");
+ result.put("ChannelPTZType", 0);
+ return result;
+ } else {
+ logger.warn("璁惧棰勮API璋冪敤澶辫触锛�");
+ JSONObject result = new JSONObject();
+ result.put("error","璋冪敤澶辫触");
+ return result;
+ }
+ }
+
+ /**
+ * 瀹炴椂鐩存挱 - 鐩存挱娴佸仠姝�
+ * @param serial 璁惧缂栧彿
+ * @param channel 閫氶亾搴忓彿
+ * @param code 閫氶亾鍥芥爣缂栧彿
+ * @param check_outputs
+ * @return
+ */
+ @RequestMapping(value = "/stop")
+ @ResponseBody
+ private JSONObject stop(String serial ,
+ @RequestParam(required = false)Integer channel ,
+ @RequestParam(required = false)String code,
+ @RequestParam(required = false)String check_outputs
+
+ ){
+ StreamInfo streamInfo = storager.queryPlay(serial, code);
+ if (streamInfo == null) {
+ JSONObject result = new JSONObject();
+ result.put("error","鏈壘鍒版祦淇℃伅");
+ return result;
+ }
+ cmder.streamByeCmd(streamInfo.getSsrc());
+ storager.stopPlay(serial, code);
+ return null;
+ }
+
+ /**
+ * 瀹炴椂鐩存挱 - 鐩存挱娴佷繚娲�
+ * @param serial 璁惧缂栧彿
+ * @param channel 閫氶亾搴忓彿
+ * @param code 閫氶亾鍥芥爣缂栧彿
+ * @param check_outputs
+ * @return
+ */
+ @RequestMapping(value = "/touch")
+ @ResponseBody
+ private JSONObject touch(String serial ,String t,
+ @RequestParam(required = false)Integer channel ,
+ @RequestParam(required = false)String code,
+ @RequestParam(required = false)String autorestart,
+ @RequestParam(required = false)String audio,
+ @RequestParam(required = false)String cdn
+ ){
+ return null;
+ }
+}
--
Gitblit v1.8.0