|
@@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.service.impl;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
|
|
+import java.time.Instant;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
import javax.sip.InvalidArgumentException;
|
|
import javax.sip.InvalidArgumentException;
|
|
@@ -21,6 +22,8 @@ import com.genersoft.iot.vmp.service.IDeviceService;
|
|
import com.genersoft.iot.vmp.service.bean.*;
|
|
import com.genersoft.iot.vmp.service.bean.*;
|
|
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
|
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
|
|
|
+import gov.nist.javax.sdp.TimeDescriptionImpl;
|
|
|
|
+import gov.nist.javax.sdp.fields.TimeField;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -380,7 +383,7 @@ public class PlayServiceImpl implements IPlayService {
|
|
|
|
|
|
public PlayResult openBroadcast(MediaServerItem mediaServerItem,String deviceId,String audioStreamId,ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
|
|
public PlayResult openBroadcast(MediaServerItem mediaServerItem,String deviceId,String audioStreamId,ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
|
|
Runnable timeoutCallback){
|
|
Runnable timeoutCallback){
|
|
-
|
|
|
|
|
|
+ logger.warn("[语音广播] 开语音广播");
|
|
PlayResult playResult = new PlayResult();
|
|
PlayResult playResult = new PlayResult();
|
|
RequestMessage msg = new RequestMessage();
|
|
RequestMessage msg = new RequestMessage();
|
|
String key = DeferredResultHolder.CALLBACK_CMD_BROADCAST + deviceId;
|
|
String key = DeferredResultHolder.CALLBACK_CMD_BROADCAST + deviceId;
|
|
@@ -407,7 +410,8 @@ public class PlayServiceImpl implements IPlayService {
|
|
// 此段为录像查询...
|
|
// 此段为录像查询...
|
|
Device device = redisCatchStorage.getDevice(deviceId);
|
|
Device device = redisCatchStorage.getDevice(deviceId);
|
|
StreamInfo streamInfo = redisCatchStorage.queryRecordByDevice(deviceId);
|
|
StreamInfo streamInfo = redisCatchStorage.queryRecordByDevice(deviceId);
|
|
- playResult.setDevice(device);
|
|
|
|
|
|
+// playResult.setDevice(device);
|
|
|
|
+
|
|
result.onCompletion(()->{
|
|
result.onCompletion(()->{
|
|
// 通道结束
|
|
// 通道结束
|
|
logger.info("[语音广播] broadcast流程结束....");
|
|
logger.info("[语音广播] broadcast流程结束....");
|
|
@@ -483,46 +487,68 @@ public class PlayServiceImpl implements IPlayService {
|
|
streamInfo = null;
|
|
streamInfo = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(streamInfo == null){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- // rtp语音通道创建完成,开始发送broadcast
|
|
|
|
- broadcastEventHandle(
|
|
|
|
- device,
|
|
|
|
- audioStreamId,
|
|
|
|
- (int code,String tipMsg)->{
|
|
|
|
- if(code == 1){
|
|
|
|
- WVPResult wvpResult = new WVPResult();
|
|
|
|
- wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
|
|
|
- wvpResult.setMsg(tipMsg);
|
|
|
|
- msg.setData(wvpResult);
|
|
|
|
- // 回复之前所有的点播请求
|
|
|
|
- resultHolder.invokeAllResult(msg);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ // rtp语音通道创建完成,开始发送broadcast
|
|
|
|
+ broadcastEventHandle(
|
|
|
|
+ device,
|
|
|
|
+ audioStreamId,
|
|
|
|
+ (int code,String tipMsg)->{
|
|
|
|
+ if(code == 1){
|
|
|
|
+ WVPResult wvpResult = new WVPResult();
|
|
|
|
+ wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
|
|
|
+ wvpResult.setMsg(tipMsg);
|
|
|
|
+ msg.setData(wvpResult);
|
|
|
|
+ // 回复之前所有的点播请求
|
|
|
|
+ resultHolder.invokeAllResult(msg);
|
|
}
|
|
}
|
|
- );
|
|
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
|
|
- // 开始创建 rtp/tcp 推流通道
|
|
|
|
|
|
+ // 开始创建 rtp/tcp 推流通道
|
|
|
|
|
|
|
|
|
|
- // 注册subScript事件
|
|
|
|
- GBHookSubscribe.addSubscribe(broadcastForInviteHook,(int code,JSONObject json)->{
|
|
|
|
- logger.info("[语音广播] 接收到设备invite信息___订阅事件触发 JSONDATA: {}",json.toJSONString());
|
|
|
|
- String streamId = null;
|
|
|
|
- SSRCInfo ssrcInfo;
|
|
|
|
- if (mediaServerItem.isRtpEnable()) {
|
|
|
|
- streamId = String.format("broadcast_%s", device.getDeviceId());
|
|
|
|
- }
|
|
|
|
- logger.info("[语音广播] 尝试创建rtp语音推流通道");
|
|
|
|
|
|
+ // 注册subScript事件
|
|
|
|
+ GBHookSubscribe.addSubscribe(broadcastForInviteHook,(int code,JSONObject json)->{
|
|
|
|
+ logger.info("[语音广播] 接收到设备invite信息___订阅事件触发 JSONDATA: {}",json.toJSONString());
|
|
|
|
+ String streamId = null;
|
|
|
|
+ String ssrcStr = json.getString("ssrc");
|
|
|
|
+ ssrcStr = ssrcStr.replaceAll("\\s*|\r|\n|\t","");
|
|
|
|
+ SSRCInfo ssrcInfo = new SSRCInfo(31234,ssrcStr,audioStreamId);
|
|
|
|
+ if (mediaServerItem.isRtpEnable()) {
|
|
|
|
+ streamId = String.format("broadcast_%s", device.getDeviceId());
|
|
|
|
+ }
|
|
|
|
+ logger.info("[语音广播] 尝试创建rtp语音推流通道");
|
|
|
|
+// ssrcInfo = mediaServerService.startSendRtpServer(mediaServerItem, streamId, audioStreamId,
|
|
|
|
+// json.getString("addr"),
|
|
|
|
+// json.getString("port"),
|
|
|
|
+// json.getString("ssrc")
|
|
|
|
+// );
|
|
|
|
+// logger.info(JSONObject.toJSONString(ssrcInfo));
|
|
|
|
+// TimeDescriptionImpl timeDescription = (TimeDescriptionImpl) (sdp.getTimeDescriptions(false).get(0));
|
|
|
|
+// TimeField startTimeFiled = (TimeField) timeDescription.getTime();
|
|
|
|
+// startTime = startTimeFiled.getStartTime();
|
|
|
|
+// stopTime = startTimeFiled.getStopTime();
|
|
|
|
+//
|
|
|
|
+// start = Instant.ofEpochSecond(startTime);
|
|
|
|
+// end = Instant.ofEpochSecond(stopTime);
|
|
|
|
+
|
|
|
|
+ // TODO: 2023/3/7 开始下发invite信息给设备
|
|
|
|
+ try {
|
|
|
|
+ cmder.sendBoradcastInviteCmd(mediaServerItem, ssrcInfo, device, null, null,
|
|
|
|
+ null,
|
|
|
|
+ (_event) -> {
|
|
|
|
+ },
|
|
|
|
+ (_errorEvent) -> {
|
|
|
|
+
|
|
|
|
+ });
|
|
ssrcInfo = mediaServerService.startSendRtpServer(mediaServerItem, streamId, audioStreamId,
|
|
ssrcInfo = mediaServerService.startSendRtpServer(mediaServerItem, streamId, audioStreamId,
|
|
json.getString("addr"),
|
|
json.getString("addr"),
|
|
json.getString("port"),
|
|
json.getString("port"),
|
|
- json.getString("ssrc")
|
|
|
|
|
|
+ ssrcStr
|
|
);
|
|
);
|
|
- logger.info(JSONObject.toJSONString(ssrcInfo));
|
|
|
|
-
|
|
|
|
-
|
|
|
|
resultHolder.invokeAllResult(msg);
|
|
resultHolder.invokeAllResult(msg);
|
|
WVPResult wvpResult = new WVPResult();
|
|
WVPResult wvpResult = new WVPResult();
|
|
wvpResult.setCode(ErrorCode.SUCCESS.getCode());
|
|
wvpResult.setCode(ErrorCode.SUCCESS.getCode());
|
|
@@ -531,23 +557,14 @@ public class PlayServiceImpl implements IPlayService {
|
|
|
|
|
|
msg.setData(wvpResult);
|
|
msg.setData(wvpResult);
|
|
resultHolder.invokeAllResult(msg);
|
|
resultHolder.invokeAllResult(msg);
|
|
- // TODO: 2023/3/7 开始下发invite信息给设备
|
|
|
|
- try {
|
|
|
|
- cmder.sendBoradcastInviteCmd(mediaServerItem, ssrcInfo, device, null, null,
|
|
|
|
- null,
|
|
|
|
- (_event) -> {
|
|
|
|
- },
|
|
|
|
- (_errorEvent) -> {
|
|
|
|
-
|
|
|
|
- });
|
|
|
|
- }catch(InvalidArgumentException | SipException | ParseException e){
|
|
|
|
- logger.error("[下发audio拉流invite失败]",e);
|
|
|
|
|
|
+ }catch(InvalidArgumentException | SipException | ParseException e){
|
|
|
|
+ logger.error("[下发audio拉流invite失败]",e);
|
|
// SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(new CmdSendFailEvent(null));
|
|
// SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(new CmdSendFailEvent(null));
|
|
// eventResult.msg = "命令发送失败";
|
|
// eventResult.msg = "命令发送失败";
|
|
// errorEvent.response(eventResult);
|
|
// errorEvent.response(eventResult);
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
return playResult;
|
|
return playResult;
|