1078-支持控制是否要音频
This commit is contained in:
@@ -32,7 +32,7 @@ public class JTChannel {
|
||||
* 是否含有音频
|
||||
*/
|
||||
@Schema(description = "是否含有音频")
|
||||
private Boolean hasAudio;
|
||||
private boolean hasAudio;
|
||||
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@@ -92,11 +92,11 @@ public class JTChannel {
|
||||
this.channelId = channelId;
|
||||
}
|
||||
|
||||
public Boolean getHasAudio() {
|
||||
public boolean getHasAudio() {
|
||||
return hasAudio;
|
||||
}
|
||||
|
||||
public void setHasAudio(Boolean hasAudio) {
|
||||
public void setHasAudio(boolean hasAudio) {
|
||||
this.hasAudio = hasAudio;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class JT1078Controller {
|
||||
@GetMapping("/live/start")
|
||||
public DeferredResult<WVPResult<StreamContent>> startLive(HttpServletRequest request,
|
||||
@Parameter(required = true) String phoneNumber,
|
||||
@Parameter(required = true) String channelId,
|
||||
@Parameter(required = true) Integer channelId,
|
||||
@Parameter(required = false) Integer type) {
|
||||
if (type == null || (type != 0 && type != 1 && type != 3)) {
|
||||
type = 0;
|
||||
@@ -131,7 +131,7 @@ public class JT1078Controller {
|
||||
@GetMapping("/live/stop")
|
||||
public void stopLive(HttpServletRequest request,
|
||||
@Parameter(required = true) String phoneNumber,
|
||||
@Parameter(required = true) String channelId) {
|
||||
@Parameter(required = true) Integer channelId) {
|
||||
service.stopPlay(phoneNumber, channelId);
|
||||
}
|
||||
|
||||
@@ -145,24 +145,20 @@ public class JT1078Controller {
|
||||
@GetMapping("/talk/start")
|
||||
public DeferredResult<WVPResult<StreamContent>> startTalk(HttpServletRequest request,
|
||||
@Parameter(required = true) String phoneNumber,
|
||||
@Parameter(required = true) String channelId,
|
||||
@Parameter(required = true) Integer channelId,
|
||||
@Parameter(required = true) String app,
|
||||
@Parameter(required = true) String stream,
|
||||
@Parameter(required = true) String mediaServerId,
|
||||
@Parameter(required = false) Boolean onlySend) {
|
||||
DeferredResult<WVPResult<StreamContent>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId = "1";
|
||||
}
|
||||
String finalChannelId = channelId;
|
||||
result.onTimeout(()->{
|
||||
logger.info("[1078-语音对讲超时] phoneNumber:{}, channelId:{}, ", phoneNumber, finalChannelId);
|
||||
logger.info("[1078-语音对讲超时] phoneNumber:{}, channelId:{}, ", phoneNumber, channelId);
|
||||
// 释放rtpserver
|
||||
WVPResult<StreamContent> wvpResult = new WVPResult<>();
|
||||
wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
||||
wvpResult.setMsg("超时");
|
||||
result.setResult(wvpResult);
|
||||
service.stopPlay(phoneNumber, finalChannelId);
|
||||
service.stopPlay(phoneNumber, channelId);
|
||||
});
|
||||
|
||||
service.startTalk(phoneNumber, channelId, app, stream, mediaServerId, onlySend, (code, msg, streamInfo) -> {
|
||||
@@ -204,7 +200,7 @@ public class JT1078Controller {
|
||||
@GetMapping("/talk/stop")
|
||||
public void stopTalk(HttpServletRequest request,
|
||||
@Parameter(required = true) String phoneNumber,
|
||||
@Parameter(required = true) String channelId) {
|
||||
@Parameter(required = true) Integer channelId) {
|
||||
service.stopTalk(phoneNumber, channelId);
|
||||
}
|
||||
|
||||
@@ -215,7 +211,7 @@ public class JT1078Controller {
|
||||
@GetMapping("/live/pause")
|
||||
public void pauseLive(HttpServletRequest request,
|
||||
@Parameter(required = true) String phoneNumber,
|
||||
@Parameter(required = true) String channelId) {
|
||||
@Parameter(required = true) Integer channelId) {
|
||||
service.pausePlay(phoneNumber, channelId);
|
||||
}
|
||||
|
||||
@@ -225,7 +221,7 @@ public class JT1078Controller {
|
||||
@GetMapping("/live/continue")
|
||||
public void continueLive(HttpServletRequest request,
|
||||
@Parameter(required = true) String phoneNumber,
|
||||
@Parameter(required = true) String channelId) {
|
||||
@Parameter(required = true) Integer channelId) {
|
||||
|
||||
service.continueLivePlay(phoneNumber, channelId);
|
||||
}
|
||||
@@ -237,7 +233,7 @@ public class JT1078Controller {
|
||||
@GetMapping("/live/switch")
|
||||
public void changeStreamType(HttpServletRequest request,
|
||||
@Parameter(required = true) String phoneNumber,
|
||||
@Parameter(required = true) String channelId,
|
||||
@Parameter(required = true) Integer channelId,
|
||||
@Parameter(required = true) Integer streamType) {
|
||||
service.changeStreamType(phoneNumber, channelId, streamType);
|
||||
}
|
||||
@@ -250,13 +246,10 @@ public class JT1078Controller {
|
||||
@GetMapping("/record/list")
|
||||
public WVPResult<List<J1205.JRecordItem>> playbackList(HttpServletRequest request,
|
||||
@Parameter(required = true) String phoneNumber,
|
||||
@Parameter(required = false) String channelId,
|
||||
@Parameter(required = true) Integer channelId,
|
||||
@Parameter(required = true) String startTime,
|
||||
@Parameter(required = true) String endTime
|
||||
) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId = "1";
|
||||
}
|
||||
List<J1205.JRecordItem> recordList = service.getRecordList(phoneNumber, channelId, startTime, endTime);
|
||||
if (recordList == null) {
|
||||
return WVPResult.fail(ErrorCode.ERROR100);
|
||||
@@ -276,7 +269,7 @@ public class JT1078Controller {
|
||||
@GetMapping("/playback/start")
|
||||
public DeferredResult<WVPResult<StreamContent>> recordLive(HttpServletRequest request,
|
||||
@Parameter(required = true) String phoneNumber,
|
||||
@Parameter(required = false) String channelId,
|
||||
@Parameter(required = true) Integer channelId,
|
||||
@Parameter(required = true) String startTime,
|
||||
@Parameter(required = true) String endTime,
|
||||
@Parameter(required = false) Integer type,
|
||||
@@ -286,18 +279,14 @@ public class JT1078Controller {
|
||||
|
||||
) {
|
||||
DeferredResult<WVPResult<StreamContent>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId = "1";
|
||||
}
|
||||
String finalChannelId = channelId;
|
||||
result.onTimeout(()->{
|
||||
logger.info("[1078-回放-等待超时] phoneNumber:{}, channelId:{}, ", phoneNumber, finalChannelId);
|
||||
logger.info("[1078-回放-等待超时] phoneNumber:{}, channelId:{}, ", phoneNumber, channelId);
|
||||
// 释放rtpserver
|
||||
WVPResult<StreamContent> wvpResult = new WVPResult<>();
|
||||
wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
||||
wvpResult.setMsg("回放超时");
|
||||
result.setResult(wvpResult);
|
||||
service.stopPlay(phoneNumber, finalChannelId);
|
||||
service.stopPlay(phoneNumber, channelId);
|
||||
});
|
||||
|
||||
service.playback(phoneNumber, channelId, startTime, endTime,type, rate, playbackType, playbackSpeed, (code, msg, streamInfo) -> {
|
||||
@@ -341,7 +330,7 @@ public class JT1078Controller {
|
||||
@Parameter(name = "time", description = "拖动回放位置(时间)", required = true)
|
||||
@GetMapping("/playback/control")
|
||||
public void recordControl(@Parameter(required = true) String phoneNumber,
|
||||
@Parameter(required = true) String channelId,
|
||||
@Parameter(required = true) Integer channelId,
|
||||
@Parameter(required = false) Integer command,
|
||||
@Parameter(required = false) String time,
|
||||
@Parameter(required = false) Integer playbackSpeed
|
||||
@@ -356,10 +345,7 @@ public class JT1078Controller {
|
||||
@GetMapping("/playback/stop")
|
||||
public void stopPlayback(HttpServletRequest request,
|
||||
@Parameter(required = true) String phoneNumber,
|
||||
@Parameter(required = false) String channelId) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId = "1";
|
||||
}
|
||||
@Parameter(required = true) Integer channelId) {
|
||||
service.stopPlayback(phoneNumber, channelId);
|
||||
}
|
||||
|
||||
@@ -374,7 +360,7 @@ public class JT1078Controller {
|
||||
public DeferredResult<Void> recordDownload(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
@Parameter(required = true) String phoneNumber,
|
||||
@Parameter(required = false) String channelId,
|
||||
@Parameter(required = true) Integer channelId,
|
||||
@Parameter(required = true) String startTime,
|
||||
@Parameter(required = true) String endTime,
|
||||
@Parameter(required = false) Integer type,
|
||||
@@ -423,11 +409,8 @@ public class JT1078Controller {
|
||||
@Parameter(name = "command", description = "控制指令,允许值: left, right, up, down, zoomin, zoomout, irisin, irisout, focusnear, focusfar, stop", required = true)
|
||||
@Parameter(name = "speed", description = "速度(0-255), command,值 left, right, up, down时有效", required = true)
|
||||
@PostMapping("/ptz")
|
||||
public void ptz(String phoneNumber, String channelId, String command, int speed){
|
||||
public void ptz(String phoneNumber, Integer channelId, String command, int speed){
|
||||
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId = "1";
|
||||
}
|
||||
logger.info("[1078-云台控制] phoneNumber:{}, channelId:{}, command: {}, speed: {}", phoneNumber, channelId, command, speed);
|
||||
service.ptzControl(phoneNumber, channelId, command, speed);
|
||||
}
|
||||
@@ -437,11 +420,8 @@ public class JT1078Controller {
|
||||
@Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true)
|
||||
@Parameter(name = "command", description = "控制指令,允许值: on off", required = true)
|
||||
@PostMapping("/fill-light")
|
||||
public void fillLight(String phoneNumber, String channelId, String command){
|
||||
public void fillLight(String phoneNumber, Integer channelId, String command){
|
||||
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId = "1";
|
||||
}
|
||||
logger.info("[1078-补光灯开关] phoneNumber:{}, channelId:{}, command: {}", phoneNumber, channelId, command);
|
||||
service.supplementaryLight(phoneNumber, channelId, command);
|
||||
}
|
||||
@@ -451,11 +431,8 @@ public class JT1078Controller {
|
||||
@Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true)
|
||||
@Parameter(name = "command", description = "控制指令,允许值: on off", required = true)
|
||||
@PostMapping("/wiper")
|
||||
public void wiper(String phoneNumber, String channelId, String command){
|
||||
public void wiper(String phoneNumber, Integer channelId, String command){
|
||||
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId = "1";
|
||||
}
|
||||
logger.info("[1078-雨刷开关] phoneNumber:{}, channelId:{}, command: {}", phoneNumber, channelId, command);
|
||||
service.wiper(phoneNumber, channelId, command);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import java.util.List;
|
||||
public interface Ijt1078Service {
|
||||
JTDevice getDevice(String phoneNumber);
|
||||
|
||||
JTChannel getChannel(Integer terminalDbId, Integer channelId);
|
||||
|
||||
void updateDevice(JTDevice deviceInDb);
|
||||
|
||||
PageInfo<JTDevice> getDeviceList(int page, int count, String query, Boolean online);
|
||||
@@ -21,26 +23,26 @@ public interface Ijt1078Service {
|
||||
|
||||
void updateDeviceStatus(boolean connected, String phoneNumber);
|
||||
|
||||
void play(String phoneNumber, String channelId, int type, GeneralCallback<StreamInfo> callback);
|
||||
void play(String phoneNumber, Integer channelId, int type, GeneralCallback<StreamInfo> callback);
|
||||
|
||||
void playback(String phoneNumber, String channelId, String startTime, String endTime, Integer type,
|
||||
void playback(String phoneNumber, Integer channelId, String startTime, String endTime, Integer type,
|
||||
Integer rate, Integer playbackType, Integer playbackSpeed, GeneralCallback<StreamInfo> callback);
|
||||
|
||||
void stopPlay(String phoneNumber, String channelId);
|
||||
void stopPlay(String phoneNumber, Integer channelId);
|
||||
|
||||
void pausePlay(String phoneNumber, String channelId);
|
||||
void pausePlay(String phoneNumber, Integer channelId);
|
||||
|
||||
void continueLivePlay(String phoneNumber, String channelId);
|
||||
void continueLivePlay(String phoneNumber, Integer channelId);
|
||||
|
||||
List<J1205.JRecordItem> getRecordList(String phoneNumber, String channelId, String startTime, String endTime);
|
||||
List<J1205.JRecordItem> getRecordList(String phoneNumber, Integer channelId, String startTime, String endTime);
|
||||
|
||||
void stopPlayback(String phoneNumber, String channelId);
|
||||
void stopPlayback(String phoneNumber, Integer channelId);
|
||||
|
||||
void ptzControl(String phoneNumber, String channelId, String command, int speed);
|
||||
void ptzControl(String phoneNumber, Integer channelId, String command, int speed);
|
||||
|
||||
void supplementaryLight(String phoneNumber, String channelId, String command);
|
||||
void supplementaryLight(String phoneNumber, Integer channelId, String command);
|
||||
|
||||
void wiper(String phoneNumber, String channelId, String command);
|
||||
void wiper(String phoneNumber, Integer channelId, String command);
|
||||
|
||||
JTDeviceConfig queryConfig(String phoneNumber, String[] params, GeneralCallback<StreamInfo> callback);
|
||||
|
||||
@@ -108,15 +110,15 @@ public interface Ijt1078Service {
|
||||
|
||||
JTMediaAttribute queryMediaAttribute(String phoneNumber);
|
||||
|
||||
void startTalk(String phoneNumber, String channelId, String app, String stream, String mediaServerId, Boolean onlySend, GeneralCallback<StreamInfo> callback);
|
||||
void startTalk(String phoneNumber, Integer channelId, String app, String stream, String mediaServerId, Boolean onlySend, GeneralCallback<StreamInfo> callback);
|
||||
|
||||
void stopTalk(String phoneNumber, String channelId);
|
||||
void stopTalk(String phoneNumber, Integer channelId);
|
||||
|
||||
void changeStreamType(String phoneNumber, String channelId, Integer streamType);
|
||||
void changeStreamType(String phoneNumber, Integer channelId, Integer streamType);
|
||||
|
||||
void playbackControl(String phoneNumber, String channelId, Integer command, Integer playbackSpeed, String time);
|
||||
void playbackControl(String phoneNumber, Integer channelId, Integer command, Integer playbackSpeed, String time);
|
||||
|
||||
void recordDownload(String phoneNumber, String channelId, String startTime, String endTime, Integer type, Integer rate, GeneralCallback<String> fileCallback);
|
||||
void recordDownload(String phoneNumber, Integer channelId, String startTime, String endTime, Integer type, Integer rate, GeneralCallback<String> fileCallback);
|
||||
|
||||
PageInfo<JTChannel> getChannelList(int page, int count, int deviceId, String query);
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.genersoft.iot.vmp.jt1078.event.FtpUploadEvent;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.request.J1205;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.*;
|
||||
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
||||
import com.genersoft.iot.vmp.jt1078.session.SessionManager;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaInfo;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||
import com.genersoft.iot.vmp.media.event.hook.Hook;
|
||||
@@ -99,6 +98,11 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
return jtDeviceMapper.getDevice(phoneNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JTChannel getChannel(Integer terminalDbId, Integer channelId) {
|
||||
return jtChannelMapper.getChannel(terminalDbId, channelId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDevice(JTDevice device) {
|
||||
device.setUpdateTime(DateUtil.getNow());
|
||||
@@ -136,11 +140,16 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
private final Map<String, List<GeneralCallback<StreamInfo>>> inviteErrorCallbackMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public void play(String phoneNumber, String channelId, int type, GeneralCallback<StreamInfo> callback) {
|
||||
public void play(String phoneNumber, Integer channelId, int type, GeneralCallback<StreamInfo> callback) {
|
||||
JTDevice device = getDevice(phoneNumber);
|
||||
if (device == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备不存在");
|
||||
}
|
||||
jt1078Template.checkTerminalStatus(phoneNumber);
|
||||
JTChannel channel = getChannel(device.getId(), channelId);
|
||||
if (channel == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道不存在");
|
||||
}
|
||||
// 检查流是否已经存在,存在则返回
|
||||
String playKey = VideoManagerConstants.INVITE_INFO_1078_PLAY + phoneNumber + ":" + channelId;
|
||||
List<GeneralCallback<StreamInfo>> errorCallbacks = inviteErrorCallbackMap.computeIfAbsent(playKey, k -> new ArrayList<>());
|
||||
@@ -151,8 +160,8 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
MediaServer mediaServer = mediaServerService.getOne(mediaServerId);
|
||||
if (mediaServer != null) {
|
||||
// 查询流是否存在,不存在则删除缓存数据
|
||||
JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServer, "rtp", "rtsp", streamInfo.getStream());
|
||||
if (mediaInfo != null && mediaInfo.getInteger("code") == 0) {
|
||||
MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServer, "rtp", streamInfo.getStream());
|
||||
if (mediaInfo != null) {
|
||||
logger.info("[1078-点播] 点播已经存在,直接返回, phoneNumber: {}, channelId: {}", phoneNumber, channelId);
|
||||
for (GeneralCallback<StreamInfo> errorCallback : errorCallbacks) {
|
||||
errorCallback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo);
|
||||
@@ -186,7 +195,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
redisTemplate.opsForValue().set(playKey, info);
|
||||
});
|
||||
// 开启收流端口
|
||||
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServer, stream, "000", false, false, 0, false, false, false, 1);
|
||||
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServer, stream, "000", false, false, 0, false, !channel.getHasAudio(), false, 1);
|
||||
// 设置超时监听
|
||||
dynamicTask.startDelay(playKey, () -> {
|
||||
logger.info("[1078-点播] 超时, phoneNumber: {}, channelId: {}", phoneNumber, channelId);
|
||||
@@ -209,15 +218,15 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
jt1078Template.startLive(phoneNumber, j9101, 6);
|
||||
}
|
||||
|
||||
public StreamInfo onPublishHandler(MediaServer mediaServerItem, HookData hookData, String phoneNumber, String channelId) {
|
||||
public StreamInfo onPublishHandler(MediaServer mediaServerItem, HookData hookData, String phoneNumber, Integer channelId) {
|
||||
StreamInfo streamInfo = mediaServerService.getStreamInfoByAppAndStream(mediaServerItem, "rtp", hookData.getStream(), hookData.getMediaInfo(), null);
|
||||
streamInfo.setDeviceID(phoneNumber);
|
||||
streamInfo.setChannelId(channelId);
|
||||
streamInfo.setChannelId(channelId + "");
|
||||
return streamInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopPlay(String phoneNumber, String channelId) {
|
||||
public void stopPlay(String phoneNumber, Integer channelId) {
|
||||
String playKey = VideoManagerConstants.INVITE_INFO_1078_PLAY + phoneNumber + ":" + channelId;
|
||||
dynamicTask.stop(playKey);
|
||||
StreamInfo streamInfo = (StreamInfo) redisTemplate.opsForValue().get(playKey);
|
||||
@@ -245,7 +254,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pausePlay(String phoneNumber, String channelId) {
|
||||
public void pausePlay(String phoneNumber, Integer channelId) {
|
||||
String playKey = VideoManagerConstants.INVITE_INFO_1078_PLAY + phoneNumber + ":" + channelId;
|
||||
dynamicTask.stop(playKey);
|
||||
StreamInfo streamInfo = (StreamInfo) redisTemplate.opsForValue().get(playKey);
|
||||
@@ -263,7 +272,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void continueLivePlay(String phoneNumber, String channelId) {
|
||||
public void continueLivePlay(String phoneNumber, Integer channelId) {
|
||||
String playKey = VideoManagerConstants.INVITE_INFO_1078_PLAY + phoneNumber + ":" + channelId;
|
||||
dynamicTask.stop(playKey);
|
||||
StreamInfo streamInfo = (StreamInfo) redisTemplate.opsForValue().get(playKey);
|
||||
@@ -281,12 +290,12 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<J1205.JRecordItem> getRecordList(String phoneNumber, String channelId, String startTime, String endTime) {
|
||||
public List<J1205.JRecordItem> getRecordList(String phoneNumber, Integer channelId, String startTime, String endTime) {
|
||||
logger.info("[1078-查询录像列表] phoneNumber: {}, channelId: {}, startTime: {}, endTime: {}"
|
||||
, phoneNumber, channelId, startTime, endTime);
|
||||
// 发送请求录像列表命令
|
||||
J9205 j9205 = new J9205();
|
||||
j9205.setChannelId(Integer.parseInt(channelId));
|
||||
j9205.setChannelId(channelId);
|
||||
j9205.setStartTime(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime));
|
||||
j9205.setEndTime(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime));
|
||||
j9205.setMediaType(0);
|
||||
@@ -302,7 +311,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playback(String phoneNumber, String channelId, String startTime, String endTime, Integer type,
|
||||
public void playback(String phoneNumber, Integer channelId, String startTime, String endTime, Integer type,
|
||||
Integer rate, Integer playbackType, Integer playbackSpeed, GeneralCallback<StreamInfo> callback) {
|
||||
logger.info("[1078-回放] 回放,设备:{}, 通道: {}, 开始时间: {}, 结束时间: {}, 音视频类型: {}, 码流类型: {}, " +
|
||||
"回放方式: {}, 快进或快退倍数: {}", phoneNumber, channelId, startTime, endTime, type, rate, playbackType, playbackSpeed);
|
||||
@@ -317,16 +326,13 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
MediaServer mediaServer = mediaServerService.getOne(mediaServerId);
|
||||
if (mediaServer != null) {
|
||||
// 查询流是否存在,不存在则删除缓存数据
|
||||
JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServer, "rtp", "rtsp", streamInfo.getStream());
|
||||
if (mediaInfo != null && mediaInfo.getInteger("code") == 0) {
|
||||
Boolean online = mediaInfo.getBoolean("online");
|
||||
if (online != null && online) {
|
||||
logger.info("[1078-回放] 回放已经存在,直接返回, logInfo: {}", logInfo);
|
||||
for (GeneralCallback<StreamInfo> errorCallback : errorCallbacks) {
|
||||
errorCallback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo);
|
||||
}
|
||||
return;
|
||||
MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServer, "rtp", streamInfo.getStream());
|
||||
if (mediaInfo != null) {
|
||||
logger.info("[1078-回放] 回放已经存在,直接返回, logInfo: {}", logInfo);
|
||||
for (GeneralCallback<StreamInfo> errorCallback : errorCallbacks) {
|
||||
errorCallback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 清理数据
|
||||
@@ -369,7 +375,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServer, stream, null, false, false, 0, false, false, false, 1);
|
||||
logger.info("[1078-回放] logInfo: {}, 端口: {}", logInfo, ssrcInfo.getPort());
|
||||
J9201 j9201 = new J9201();
|
||||
j9201.setChannel(Integer.parseInt(channelId));
|
||||
j9201.setChannel(channelId);
|
||||
j9201.setIp(mediaServer.getSdpIp());
|
||||
if (rate != null) {
|
||||
j9201.setRate(rate);
|
||||
@@ -391,7 +397,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playbackControl(String phoneNumber, String channelId, Integer command, Integer playbackSpeed, String time) {
|
||||
public void playbackControl(String phoneNumber, Integer channelId, Integer command, Integer playbackSpeed, String time) {
|
||||
logger.info("[1078-回放控制] phoneNumber: {}, channelId: {}, command: {}, playbackSpeed: {}, time: {}",
|
||||
phoneNumber, channelId, command, playbackSpeed, time);
|
||||
String playKey = VideoManagerConstants.INVITE_INFO_1078_PLAYBACK + phoneNumber + ":" + channelId;
|
||||
@@ -414,7 +420,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
// 发送停止命令
|
||||
J9202 j9202 = new J9202();
|
||||
j9202.setChannel(Integer.parseInt(channelId));
|
||||
j9202.setChannel(channelId);
|
||||
j9202.setPlaybackType(command);
|
||||
if (playbackSpeed != null) {
|
||||
j9202.setPlaybackSpeed(playbackSpeed);
|
||||
@@ -426,7 +432,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopPlayback(String phoneNumber, String channelId) {
|
||||
public void stopPlayback(String phoneNumber, Integer channelId) {
|
||||
playbackControl(phoneNumber, channelId, 2, null, String.valueOf(0));
|
||||
}
|
||||
|
||||
@@ -450,7 +456,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordDownload(String phoneNumber, String channelId, String startTime, String endTime, Integer type, Integer rate, GeneralCallback<String> fileCallback) {
|
||||
public void recordDownload(String phoneNumber, Integer channelId, String startTime, String endTime, Integer type, Integer rate, GeneralCallback<String> fileCallback) {
|
||||
String filePath = UUID.randomUUID().toString();
|
||||
fileUploadMap.put(filePath, fileCallback);
|
||||
dynamicTask.startDelay(filePath, ()->{
|
||||
@@ -460,7 +466,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
phoneNumber, channelId, startTime, endTime, filePath);
|
||||
// 发送停止命令
|
||||
J9206 j92026 = new J9206();
|
||||
j92026.setChannelId(Integer.parseInt(channelId));
|
||||
j92026.setChannelId(channelId);
|
||||
j92026.setStartTime(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime));
|
||||
j92026.setEndTime(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime));
|
||||
j92026.setServerIp(ftpSetting.getIp());
|
||||
@@ -479,7 +485,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ptzControl(String phoneNumber, String channelId, String command, int speed) {
|
||||
public void ptzControl(String phoneNumber, Integer channelId, String command, int speed) {
|
||||
// 发送停止命令
|
||||
|
||||
switch (command) {
|
||||
@@ -489,7 +495,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
case "down":
|
||||
case "stop":
|
||||
J9301 j9301 = new J9301();
|
||||
j9301.setChannel(Integer.parseInt(channelId));
|
||||
j9301.setChannel(channelId);
|
||||
switch (command) {
|
||||
case "left":
|
||||
j9301.setDirection(3);
|
||||
@@ -518,7 +524,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
case "zoomin":
|
||||
case "zoomout":
|
||||
J9306 j9306 = new J9306();
|
||||
j9306.setChannel(Integer.parseInt(channelId));
|
||||
j9306.setChannel(channelId);
|
||||
if (command.equals("zoomin")) {
|
||||
j9306.setZoom(0);
|
||||
} else {
|
||||
@@ -529,7 +535,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
case "irisin":
|
||||
case "irisout":
|
||||
J9303 j9303 = new J9303();
|
||||
j9303.setChannel(Integer.parseInt(channelId));
|
||||
j9303.setChannel(channelId);
|
||||
if (command.equals("irisin")) {
|
||||
j9303.setIris(0);
|
||||
} else {
|
||||
@@ -540,7 +546,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
case "focusnear":
|
||||
case "focusfar":
|
||||
J9302 j9302 = new J9302();
|
||||
j9302.setChannel(Integer.parseInt(channelId));
|
||||
j9302.setChannel(channelId);
|
||||
if (command.equals("focusfar")) {
|
||||
j9302.setFocalDirection(0);
|
||||
} else {
|
||||
@@ -553,9 +559,9 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void supplementaryLight(String phoneNumber, String channelId, String command) {
|
||||
public void supplementaryLight(String phoneNumber, Integer channelId, String command) {
|
||||
J9305 j9305 = new J9305();
|
||||
j9305.setChannel(Integer.parseInt(channelId));
|
||||
j9305.setChannel(channelId);
|
||||
if (command.equalsIgnoreCase("on")) {
|
||||
j9305.setOn(1);
|
||||
} else {
|
||||
@@ -565,9 +571,9 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wiper(String phoneNumber, String channelId, String command) {
|
||||
public void wiper(String phoneNumber, Integer channelId, String command) {
|
||||
J9304 j9304 = new J9304();
|
||||
j9304.setChannel(Integer.parseInt(channelId));
|
||||
j9304.setChannel(channelId);
|
||||
if (command.equalsIgnoreCase("on")) {
|
||||
j9304.setOn(1);
|
||||
} else {
|
||||
@@ -867,7 +873,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startTalk(String phoneNumber, String channelId, String app, String stream, String mediaServerId, Boolean onlySend,
|
||||
public void startTalk(String phoneNumber, Integer channelId, String app, String stream, String mediaServerId, Boolean onlySend,
|
||||
GeneralCallback<StreamInfo> callback) {
|
||||
// 检查流是否已经存在,存在则返回
|
||||
String playKey = VideoManagerConstants.INVITE_INFO_1078_TALK + phoneNumber + ":" + channelId;
|
||||
@@ -898,7 +904,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
sendRtpItem.setPort(0);
|
||||
sendRtpItem.setSsrc(ssrc);
|
||||
sendRtpItem.setDeviceId(phoneNumber);
|
||||
sendRtpItem.setChannelId(channelId);
|
||||
sendRtpItem.setChannelId(channelId + "");
|
||||
sendRtpItem.setRtcp(false);
|
||||
sendRtpItem.setApp(app);
|
||||
sendRtpItem.setStream(stream);
|
||||
@@ -965,7 +971,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopTalk(String phoneNumber, String channelId) {
|
||||
public void stopTalk(String phoneNumber, Integer channelId) {
|
||||
String playKey = VideoManagerConstants.INVITE_INFO_1078_TALK + phoneNumber + ":" + channelId;
|
||||
dynamicTask.stop(playKey);
|
||||
StreamInfo streamInfo = (StreamInfo) redisTemplate.opsForValue().get(playKey);
|
||||
@@ -993,7 +999,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeStreamType(String phoneNumber, String channelId, Integer streamType) {
|
||||
public void changeStreamType(String phoneNumber, Integer channelId, Integer streamType) {
|
||||
String playKey = VideoManagerConstants.INVITE_INFO_1078_PLAY + phoneNumber + ":" + channelId;
|
||||
dynamicTask.stop(playKey);
|
||||
StreamInfo streamInfo = (StreamInfo) redisTemplate.opsForValue().get(playKey);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||
|
||||
@Override
|
||||
public int createRTPServer(MediaServer mediaServer, String streamId, long ssrc, Integer port, Boolean onlyAuto, Boolean disableAudio, Boolean reUsePort, Integer tcpMode) {
|
||||
return zlmServerFactory.createRTPServer(mediaServer, streamId, ssrc, port, onlyAuto, reUsePort, tcpMode);
|
||||
return zlmServerFactory.createRTPServer(mediaServer, streamId, ssrc, port, onlyAuto, disableAudio, reUsePort, tcpMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ZLMServerFactory {
|
||||
* @param tcpMode 0/null udp 模式,1 tcp 被动模式, 2 tcp 主动模式。
|
||||
* @return
|
||||
*/
|
||||
public int createRTPServer(MediaServer mediaServerItem, String streamId, long ssrc, Integer port, Boolean onlyAuto, Boolean reUsePort, Integer tcpMode) {
|
||||
public int createRTPServer(MediaServer mediaServerItem, String streamId, long ssrc, Integer port, Boolean onlyAuto, Boolean disableAudio, Boolean reUsePort, Integer tcpMode) {
|
||||
int result = -1;
|
||||
// 查询此rtp server 是否已经存在
|
||||
JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaServerItem, streamId);
|
||||
@@ -55,7 +55,7 @@ public class ZLMServerFactory {
|
||||
JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(mediaServerItem, param);
|
||||
if (jsonObject != null ) {
|
||||
if (jsonObject.getInteger("code") == 0) {
|
||||
return createRTPServer(mediaServerItem, streamId, ssrc, port,onlyAuto, reUsePort, tcpMode);
|
||||
return createRTPServer(mediaServerItem, streamId, ssrc, port,onlyAuto, reUsePort,disableAudio, tcpMode);
|
||||
}else {
|
||||
logger.warn("[开启rtpServer], 重启RtpServer错误");
|
||||
}
|
||||
@@ -74,6 +74,10 @@ public class ZLMServerFactory {
|
||||
}
|
||||
param.put("tcp_mode", tcpMode);
|
||||
param.put("stream_id", streamId);
|
||||
if (disableAudio != null) {
|
||||
param.put("only_track", disableAudio?2:0);
|
||||
}
|
||||
|
||||
if (reUsePort != null) {
|
||||
param.put("re_use_port", reUsePort?"1":"0");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user