Browse Source

修复回放、停止预览bug,增加ZLM hook监听,长时间无人观看,停止摄像头推流。需开启ZLM的hook并配置url

pull/1/head
songww 5 years ago
parent
commit
805fa42a2c
  1. 1
      pom.xml
  2. 2
      src/main/java/com/genersoft/iot/vmp/gb28181/session/SsrcUtil.java
  3. 92
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
  4. 21
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
  5. 2
      src/main/java/com/genersoft/iot/vmp/gb28181/utils/DateUtil.java
  6. 199
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
  7. 36
      src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java

1
pom.xml

@ -123,7 +123,6 @@
<groupId>javax.sip</groupId>
<artifactId>jain-sip-ri</artifactId>
<version>1.3.0-91</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>

2
src/main/java/com/genersoft/iot/vmp/gb28181/session/SsrcUtil.java

@ -22,7 +22,7 @@ public class SsrcUtil {
private static void init() {
SipConfig sipConfig = (SipConfig) SpringBeanFactory.getBean("sipConfig");
ssrcPrefix = sipConfig.getSipDomain().substring(4, 9);
ssrcPrefix = sipConfig.getSipDomain().substring(3, 8);
isUsed = new ArrayList<String>();
notUsed = new ArrayList<String>();
for (int i = 1; i < 10000; i++) {

92
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java

@ -24,7 +24,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.Host;
/**
* @Description:TODO(这里用一句话描述这个类的作用)
* @Description:摄像头命令request创造器 TODO 冗余代码太多待优化
* @author: songww
* @date: 2020年5月6日 上午9:29:02
*/
@ -72,50 +72,50 @@ public class SIPRequestHeaderProvider {
return request;
}
// public Request createInviteRequest(Device device, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException {
// Request request = null;
// Host host = device.getHost();
// //请求行
// SipURI requestLine = layer.getAddressFactory().createSipURI(device.getDeviceId(), host.getAddress());
// //via
// ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
// ViaHeader viaHeader = layer.getHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), device.getTransport(), viaTag);
// viaHeader.setRPort();
// viaHeaders.add(viaHeader);
// //from
// SipURI fromSipURI = layer.getAddressFactory().createSipURI(device.getDeviceId(),sipConfig.getSipIp()+":"+sipConfig.getSipPort());
// Address fromAddress = layer.getAddressFactory().createAddress(fromSipURI);
// FromHeader fromHeader = layer.getHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
// //to
// SipURI toSipURI = layer.getAddressFactory().createSipURI(device.getDeviceId(),host.getAddress());
// Address toAddress = layer.getAddressFactory().createAddress(toSipURI);
// ToHeader toHeader = layer.getHeaderFactory().createToHeader(toAddress,null);
//
// //callid
// CallIdHeader callIdHeader = null;
// if(device.getTransport().equals("TCP")) {
// callIdHeader = layer.getTcpSipProvider().getNewCallId();
// }
// if(device.getTransport().equals("UDP")) {
// callIdHeader = layer.getUdpSipProvider().getNewCallId();
// }
//
// //Forwards
// MaxForwardsHeader maxForwards = layer.getHeaderFactory().createMaxForwardsHeader(70);
//
// //ceq
// CSeqHeader cSeqHeader = layer.getHeaderFactory().createCSeqHeader(1L, Request.INVITE);
// request = layer.getMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
//
// Address concatAddress = layer.getAddressFactory().createAddress(layer.getAddressFactory().createSipURI(sipConfig.getSipId(), sipConfig.getSipIp()+":"+sipConfig.getSipPort()));
// request.addHeader(layer.getHeaderFactory().createContactHeader(concatAddress));
//
// ContentTypeHeader contentTypeHeader = layer.getHeaderFactory().createContentTypeHeader("Application", "SDP");
// request.setContent(content, contentTypeHeader);
// return request;
// }
public Request createInviteRequest(Device device, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException {
public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException {
Request request = null;
Host host = device.getHost();
//请求行
SipURI requestLine = layer.getAddressFactory().createSipURI(channelId, host.getAddress());
//via
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
ViaHeader viaHeader = layer.getHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), device.getTransport(), viaTag);
viaHeader.setRPort();
viaHeaders.add(viaHeader);
//from
SipURI fromSipURI = layer.getAddressFactory().createSipURI(sipConfig.getSipId(),sipConfig.getSipDomain());
Address fromAddress = layer.getAddressFactory().createAddress(fromSipURI);
FromHeader fromHeader = layer.getHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
//to
SipURI toSipURI = layer.getAddressFactory().createSipURI(channelId,sipConfig.getSipDomain());
Address toAddress = layer.getAddressFactory().createAddress(toSipURI);
ToHeader toHeader = layer.getHeaderFactory().createToHeader(toAddress,null);
//callid
CallIdHeader callIdHeader = null;
if(device.getTransport().equals("TCP")) {
callIdHeader = layer.getTcpSipProvider().getNewCallId();
}
if(device.getTransport().equals("UDP")) {
callIdHeader = layer.getUdpSipProvider().getNewCallId();
}
//Forwards
MaxForwardsHeader maxForwards = layer.getHeaderFactory().createMaxForwardsHeader(70);
//ceq
CSeqHeader cSeqHeader = layer.getHeaderFactory().createCSeqHeader(1L, Request.INVITE);
request = layer.getMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
Address concatAddress = layer.getAddressFactory().createAddress(layer.getAddressFactory().createSipURI(sipConfig.getSipId(), sipConfig.getSipIp()+":"+sipConfig.getSipPort()));
request.addHeader(layer.getHeaderFactory().createContactHeader(concatAddress));
ContentTypeHeader contentTypeHeader = layer.getHeaderFactory().createContentTypeHeader("Application", "SDP");
request.setContent(content, contentTypeHeader);
return request;
}
public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException {
Request request = null;
Host host = device.getHost();
//请求行
@ -130,7 +130,7 @@ public class SIPRequestHeaderProvider {
Address fromAddress = layer.getAddressFactory().createAddress(fromSipURI);
FromHeader fromHeader = layer.getHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
//to
SipURI toSipURI = layer.getAddressFactory().createSipURI(device.getDeviceId(),sipConfig.getSipDomain());
SipURI toSipURI = layer.getAddressFactory().createSipURI(channelId,sipConfig.getSipDomain());
Address toAddress = layer.getAddressFactory().createAddress(toSipURI);
ToHeader toHeader = layer.getHeaderFactory().createToHeader(toAddress,null);

21
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java

@ -142,30 +142,31 @@ public class SIPCommander implements ISIPCommander {
try {
String ssrc = streamSession.createPlaySsrc();
String transport = device.getTransport();
//
StringBuffer content = new StringBuffer(200);
content.append("v=0\r\n");
content.append("o="+channelId+" 0 0 IN IP4 "+sipConfig.getMediaIp()+"\r\n");
content.append("o="+channelId+" 0 0 IN IP4 "+sipConfig.getSipIp()+"\r\n");
content.append("s=Play\r\n");
content.append("c=IN IP4 "+sipConfig.getMediaIp()+"\r\n");
content.append("t=0 0\r\n");
if(device.getTransport().equals("TCP")) {
if("TCP".equals(transport)) {
content.append("m=video "+sipConfig.getMediaPort()+" TCP/RTP/AVP 96 98 97\r\n");
}
if(device.getTransport().equals("UDP")) {
if("UDP".equals(transport)) {
content.append("m=video "+sipConfig.getMediaPort()+" RTP/AVP 96 98 97\r\n");
}
content.append("a=sendrecv\r\n");
content.append("a=recvonly\r\n");
content.append("a=rtpmap:96 PS/90000\r\n");
content.append("a=rtpmap:98 H264/90000\r\n");
content.append("a=rtpmap:97 MPEG4/90000\r\n");
if(device.getTransport().equals("TCP")){
if("TCP".equals(transport)){
content.append("a=setup:passive\r\n");
content.append("a=connection:new\r\n");
}
content.append("y="+ssrc+"\r\n");//ssrc
Request request = headerProvider.createInviteRequest(device, content.toString(), null, "live", null);
Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, "live", null);
ClientTransaction transaction = transmitRequest(device, request);
streamSession.put(ssrc, transaction);
@ -192,9 +193,9 @@ public class SIPCommander implements ISIPCommander {
//
StringBuffer content = new StringBuffer(200);
content.append("v=0\r\n");
content.append("o="+device.getDeviceId()+" 0 0 IN IP4 "+sipConfig.getMediaIp()+"\r\n");
content.append("o="+sipConfig.getSipId()+" 0 0 IN IP4 "+sipConfig.getSipIp()+"\r\n");
content.append("s=Playback\r\n");
content.append("u="+channelId+":3\r\n");
content.append("u="+channelId+":0\r\n");
content.append("c=IN IP4 "+sipConfig.getMediaIp()+"\r\n");
content.append("t="+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)+" "+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n");
if(device.getTransport().equals("TCP")) {
@ -213,7 +214,7 @@ public class SIPCommander implements ISIPCommander {
}
content.append("y="+ssrc+"\r\n");//ssrc
Request request = headerProvider.createInviteRequest(device, content.toString(), null, "live", null);
Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "playback", null);
ClientTransaction transaction = transmitRequest(device, request);
streamSession.put(ssrc, transaction);
@ -245,7 +246,7 @@ public class SIPCommander implements ISIPCommander {
}
Request byeRequest = dialog.createRequest(Request.BYE);
ViaHeader viaHeader = (ViaHeader) byeRequest.getHeader(ViaHeader.NAME);
String protocol = viaHeader.getTransport();
String protocol = viaHeader.getTransport().toUpperCase();
ClientTransaction clientTransaction = null;
if("TCP".equals(protocol)) {
clientTransaction = sipLayer.getTcpSipProvider().getNewClientTransaction(byeRequest);

2
src/main/java/com/genersoft/iot/vmp/gb28181/utils/DateUtil.java

@ -46,7 +46,7 @@ public class DateUtil {
Date date;
try {
date = format.parse(formatTime);
Long timestamp=date.getTime();
Long timestamp=date.getTime()/1000;
//转换为Date类
return timestamp;
} catch (ParseException e) {

199
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java

@ -1,12 +1,21 @@
package com.genersoft.iot.vmp.media.zlm;
import java.math.BigInteger;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
/**
* @Description:针对 ZLMediaServer的hook事件监听
* @author: songww
@ -18,135 +27,247 @@ public class ZLMHttpHookListener {
private final static Logger logger = LoggerFactory.getLogger(ZLMHttpHookListener.class);
@Autowired
private SIPCommander cmder;
/**
* 流量统计事件播放器或推流器断开时并且耗用流量超过特定阈值时会触发此事件阈值通过配置文件general.flowThreshold配置此事件对回复不敏感
*
*/
@PostMapping("/on_flow_report")
public ResponseEntity onFlowReport(){
@ResponseBody
@PostMapping(value = "/on_flow_report", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onFlowReport(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_flow_report API调用,参数:" + json.toString());
}
// TODO Auto-generated method stub
return null;
JSONObject ret = new JSONObject();
json.put("code", 0);
json.put("msg", "success");
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
}
/**
* 访问http文件服务器上hls之外的文件时触发
*
*/
@PostMapping("/on_http_access")
public ResponseEntity onHttpAccess(){
@ResponseBody
@PostMapping(value = "/on_http_access", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onHttpAccess(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_http_access API 调用,参数:" + json.toString());
}
// TODO Auto-generated method stub
return null;
JSONObject ret = new JSONObject();
json.put("code", 0);
json.put("err", "");
json.put("path", "");
json.put("second", 600);
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
}
/**
* 播放器鉴权事件rtsp/rtmp/http-flv/ws-flv/hls的播放都将触发此鉴权事件
*
*/
@PostMapping("/on_play")
public ResponseEntity onPlay(){
@ResponseBody
@PostMapping(value = "/on_play", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onPlay(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_play API调用,参数:" + json.toString());
}
// TODO Auto-generated method stub
return null;
JSONObject ret = new JSONObject();
json.put("code", 0);
json.put("msg", "success");
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
}
/**
* rtsp/rtmp/rtp推流鉴权事件
*
*/
@PostMapping("/on_publish")
public ResponseEntity onPublish(){
@ResponseBody
@PostMapping(value = "/on_publish", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onPublish(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_publish API调用,参数:" + json.toString());
}
// TODO Auto-generated method stub
return null;
JSONObject ret = new JSONObject();
json.put("code", 0);
json.put("msg", "success");
json.put("enableHls", true);
json.put("enableMP4", false);
json.put("enableRtxp", true);
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
}
/**
* 录制mp4完成后通知事件此事件对回复不敏感
*
*/
@PostMapping("/on_record_mp4")
public ResponseEntity onRecordMp4(){
@ResponseBody
@PostMapping(value = "/on_record_mp4", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onRecordMp4(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_record_mp4 API调用,参数:" + json.toString());
}
// TODO Auto-generated method stub
return null;
JSONObject ret = new JSONObject();
json.put("code", 0);
json.put("msg", "success");
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
}
/**
* 该rtsp流是否开启rtsp专用方式的鉴权事件开启后才会触发on_rtsp_auth事件需要指出的是rtsp也支持url参数鉴权它支持两种方式鉴权
* rtsp专用的鉴权事件先触发on_rtsp_realm事件然后才会触发on_rtsp_auth事件
*
*/
@PostMapping("/on_rtsp_auth")
public ResponseEntity onRtspAuth(){
@ResponseBody
@PostMapping(value = "/on_rtsp_realm", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onRtspRealm(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_rtsp_realm API调用,参数:" + json.toString());
}
// TODO Auto-generated method stub
return null;
JSONObject ret = new JSONObject();
json.put("code", 0);
json.put("realm", "");
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
}
/**
* rtsp专用的鉴权事件先触发on_rtsp_realm事件然后才会触发on_rtsp_auth事件
* 该rtsp流是否开启rtsp专用方式的鉴权事件开启后才会触发on_rtsp_auth事件需要指出的是rtsp也支持url参数鉴权它支持两种方式鉴权
*
*/
@PostMapping("/on_rtsp_realm")
public ResponseEntity onRtspRealm(){
@ResponseBody
@PostMapping(value = "/on_rtsp_auth", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onRtspAuth(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_rtsp_auth API调用,参数:" + json.toString());
}
// TODO Auto-generated method stub
return null;
JSONObject ret = new JSONObject();
json.put("code", 0);
json.put("encrypted", false);
json.put("passwd", "test");
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
}
/**
* shell登录鉴权ZLMediaKit提供简单的telnet调试方式使用telnet 127.0.0.1 9000能进入MediaServer进程的shell界面
*
*/
@PostMapping("/on_shell_login")
public ResponseEntity onShellLogin(){
@ResponseBody
@PostMapping(value = "/on_shell_login", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onShellLogin(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_shell_login API调用,参数:" + json.toString());
}
// TODO Auto-generated method stub
return null;
JSONObject ret = new JSONObject();
json.put("code", 0);
json.put("msg", "success");
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
}
/**
* rtsp/rtmp流注册或注销时触发此事件此事件对回复不敏感
*
*/
@PostMapping("/on_stream_changed")
public ResponseEntity onStreamChanged(){
@ResponseBody
@PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onStreamChanged(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_stream_changed API调用,参数:" + json.toString());
}
// TODO Auto-generated method stub
return null;
JSONObject ret = new JSONObject();
json.put("code", 0);
json.put("msg", "success");
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
}
/**
* 流无人观看时事件用户可以通过此事件选择是否关闭无人看的流
*
*/
@PostMapping("/on_stream_none_reader")
public ResponseEntity onStreamNoneReader(){
// TODO Auto-generated method stub
@ResponseBody
@PostMapping(value = "/on_stream_none_reader", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onStreamNoneReader(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_stream_none_reader API调用,参数:" + json.toString());
}
BigInteger bigint=new BigInteger(json.getString("stream"), 16);
int numb=bigint.intValue();
String ssrc = String.format("%010d", numb);
return null;
cmder.streamByeCmd(ssrc);
JSONObject ret = new JSONObject();
json.put("code", 0);
json.put("close", true);
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
}
/**
* 流未找到事件用户可以在此事件触发时立即去拉流这样可以实现按需拉流此事件对回复不敏感
*
*/
@PostMapping("/on_stream_not_found")
public ResponseEntity onStreamNotFound(){
@ResponseBody
@PostMapping(value = "/on_stream_not_found", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onStreamNotFound(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_stream_not_found API调用,参数:" + json.toString());
}
// TODO Auto-generated method stub
return null;
JSONObject ret = new JSONObject();
json.put("code", 0);
json.put("msg", "success");
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
}
/**
* 服务器启动事件可以用于监听服务器崩溃重启此事件对回复不敏感
*
*/
@PostMapping("/on_server_started")
public ResponseEntity onServerStarted(){
@ResponseBody
@PostMapping(value = "/on_server_started", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onServerStarted(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_server_started API调用,参数:" + json.toString());
}
// TODO Auto-generated method stub
return null;
JSONObject ret = new JSONObject();
json.put("code", 0);
json.put("msg", "success");
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
}
}

36
src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java

@ -5,8 +5,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -30,12 +32,40 @@ public class PlaybackController {
@GetMapping("/playback/{deviceId}/{channelId}")
public ResponseEntity<String> play(@PathVariable String deviceId,@PathVariable String channelId, String startTime, String endTime){
if (logger.isDebugEnabled()) {
logger.debug(String.format("设备回放 API调用,deviceId:%s ,channelId:%s",deviceId, channelId));
}
if (StringUtils.isEmpty(deviceId) || StringUtils.isEmpty(channelId)) {
String log = String.format("设备回放 API调用失败,deviceId:%s ,channelId:%s",deviceId, channelId);
logger.warn(log);
return new ResponseEntity<String>(log,HttpStatus.BAD_REQUEST);
}
Device device = storager.queryVideoDevice(deviceId);
String ssrc = cmder.playbackStreamCmd(device, channelId, startTime, endTime);
if (logger.isDebugEnabled()) {
logger.debug(String.format("设备预览 API调用,deviceId:%s ,channelId:%s",deviceId, channelId));
logger.debug("设备预览 API调用,ssrc:"+ssrc+",ZLMedia streamId:"+Integer.toHexString(Integer.parseInt(ssrc)));
logger.debug("设备回放 API调用,ssrc:"+ssrc+",ZLMedia streamId:"+Integer.toHexString(Integer.parseInt(ssrc)));
}
if(ssrc!=null) {
JSONObject json = new JSONObject();
json.put("ssrc", ssrc);
return new ResponseEntity<String>(json.toString(),HttpStatus.OK);
} else {
logger.warn("设备回放API调用失败!");
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@PostMapping("/playback/{ssrc}/stop")
public ResponseEntity<String> playStop(@PathVariable String ssrc){
cmder.streamByeCmd(ssrc);
if (logger.isDebugEnabled()) {
logger.debug(String.format("设备录像回放停止 API调用,ssrc:%s", ssrc));
}
if(ssrc!=null) {
@ -43,7 +73,7 @@ public class PlaybackController {
json.put("ssrc", ssrc);
return new ResponseEntity<String>(json.toString(),HttpStatus.OK);
} else {
logger.warn("设备预览API调用失败!");
logger.warn("设备录像回放停止API调用失败!");
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}

Loading…
Cancel
Save