完善talk模式
parent
663130df45
commit
a000ed6062
|
@ -8,6 +8,7 @@ import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.listener.PatternTopic;
|
import org.springframework.data.redis.listener.PatternTopic;
|
||||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||||
|
@ -48,6 +49,8 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||||
|
LettuceConnectionFactory lettuceConnectionFactory = (LettuceConnectionFactory) redisConnectionFactory;
|
||||||
|
lettuceConnectionFactory.afterPropertiesSet();
|
||||||
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
|
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
|
||||||
// 使用fastJson序列化
|
// 使用fastJson序列化
|
||||||
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
|
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
|
||||||
|
@ -58,7 +61,7 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||||
// key的序列化采用StringRedisSerializer
|
// key的序列化采用StringRedisSerializer
|
||||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||||
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||||
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
redisTemplate.setConnectionFactory(lettuceConnectionFactory);
|
||||||
return redisTemplate;
|
return redisTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -641,7 +641,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
// 这里为例避免一个通道的点播只有一个callID这个参数使用一个固定值
|
// 这里为例避免一个通道的点播只有一个callID这个参数使用一个固定值
|
||||||
ResponseEvent responseEvent = (ResponseEvent) e.event;
|
ResponseEvent responseEvent = (ResponseEvent) e.event;
|
||||||
SIPResponse response = (SIPResponse) responseEvent.getResponse();
|
SIPResponse response = (SIPResponse) responseEvent.getResponse();
|
||||||
streamSession.put(device.getDeviceId(), channelId, "talk", stream, sendRtpItem.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.play);
|
streamSession.put(device.getDeviceId(), channelId, "talk", stream, sendRtpItem.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.talk);
|
||||||
okEvent.response(e);
|
okEvent.response(e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,6 +249,7 @@ public class ZLMHttpHookListener {
|
||||||
String channelId = ssrcTransactionForAll.get(0).getChannelId();
|
String channelId = ssrcTransactionForAll.get(0).getChannelId();
|
||||||
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
|
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
|
||||||
if (deviceChannel != null) {
|
if (deviceChannel != null) {
|
||||||
|
|
||||||
result.setEnable_audio(deviceChannel.isHasAudio());
|
result.setEnable_audio(deviceChannel.isHasAudio());
|
||||||
}
|
}
|
||||||
// 如果是录像下载就设置视频间隔十秒
|
// 如果是录像下载就设置视频间隔十秒
|
||||||
|
@ -257,6 +258,11 @@ public class ZLMHttpHookListener {
|
||||||
result.setEnable_audio(true);
|
result.setEnable_audio(true);
|
||||||
result.setEnable_mp4(true);
|
result.setEnable_mp4(true);
|
||||||
}
|
}
|
||||||
|
// 如果是talk对讲,则默认获取声音
|
||||||
|
if (ssrcTransactionForAll.get(0).getType() == VideoStreamSessionManager.SessionType.talk) {
|
||||||
|
result.setEnable_audio(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public interface IPlayService {
|
||||||
|
|
||||||
void zlmServerOnline(String mediaServerId);
|
void zlmServerOnline(String mediaServerId);
|
||||||
|
|
||||||
AudioBroadcastResult audioBroadcast(Device device, String channelId);
|
AudioBroadcastResult audioBroadcast(Device device, String channelId, Boolean broadcastMode);
|
||||||
void stopAudioBroadcast(String deviceId, String channelId);
|
void stopAudioBroadcast(String deviceId, String channelId);
|
||||||
|
|
||||||
void audioBroadcastCmd(Device device, String channelId, MediaServerItem mediaServerItem, int timeout, AudioEvent event) throws InvalidArgumentException, ParseException, SipException;
|
void audioBroadcastCmd(Device device, String channelId, MediaServerItem mediaServerItem, int timeout, AudioEvent event) throws InvalidArgumentException, ParseException, SipException;
|
||||||
|
|
|
@ -268,7 +268,7 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
sendRtpItem.setTcpActive(false);
|
sendRtpItem.setTcpActive(false);
|
||||||
sendRtpItem.setTcp(true);
|
sendRtpItem.setTcp(true);
|
||||||
sendRtpItem.setUsePs(false);
|
sendRtpItem.setUsePs(false);
|
||||||
sendRtpItem.setReceiveStream(stream);
|
sendRtpItem.setReceiveStream(stream + "_talk");
|
||||||
|
|
||||||
|
|
||||||
int port = zlmrtpServerFactory.keepPort(mediaServerItem, playSsrc);
|
int port = zlmrtpServerFactory.keepPort(mediaServerItem, playSsrc);
|
||||||
|
@ -348,7 +348,7 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
sendRtpItem.setCallId(response.getCallIdHeader().getCallId());
|
sendRtpItem.setCallId(response.getCallIdHeader().getCallId());
|
||||||
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
||||||
|
|
||||||
streamSession.put(device.getDeviceId(), channelId, response.getCallIdHeader().getCallId(),
|
streamSession.put(device.getDeviceId(), channelId, "talk",
|
||||||
sendRtpItem.getStream(), sendRtpItem.getSsrc(), sendRtpItem.getMediaServerId(),
|
sendRtpItem.getStream(), sendRtpItem.getSsrc(), sendRtpItem.getMediaServerId(),
|
||||||
response, VideoStreamSessionManager.SessionType.talk);
|
response, VideoStreamSessionManager.SessionType.talk);
|
||||||
} else {
|
} else {
|
||||||
|
@ -940,7 +940,7 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AudioBroadcastResult audioBroadcast(Device device, String channelId) {
|
public AudioBroadcastResult audioBroadcast(Device device, String channelId, Boolean broadcastMode) {
|
||||||
// TODO 必须多端口模式才支持语音喊话鹤语音对讲
|
// TODO 必须多端口模式才支持语音喊话鹤语音对讲
|
||||||
if (device == null || channelId == null) {
|
if (device == null || channelId == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -952,11 +952,11 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
MediaServerItem mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null);
|
MediaServerItem mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null);
|
||||||
String app = "broadcast";
|
if (broadcastMode == null) {
|
||||||
// TODO 从sip user agent中判断是什么品牌设备,大华默认使用talk模式,其他使用broadcast模式
|
broadcastMode = true;
|
||||||
// String app = "talk";
|
}
|
||||||
|
String app = broadcastMode?"broadcast":"talk";
|
||||||
String stream = device.getDeviceId() + "_" + channelId;
|
String stream = device.getDeviceId() + "_" + channelId;
|
||||||
StreamInfo broadcast = mediaService.getStreamInfoByAppAndStream(mediaServerItem, "broadcast", stream, null, null, null, false);
|
|
||||||
AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult();
|
AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult();
|
||||||
audioBroadcastResult.setApp(app);
|
audioBroadcastResult.setApp(app);
|
||||||
audioBroadcastResult.setStream(stream);
|
audioBroadcastResult.setStream(stream);
|
||||||
|
|
|
@ -249,7 +249,7 @@ public class PlayController {
|
||||||
@Parameter(name = "timeout", description = "推流超时时间(秒)", required = true)
|
@Parameter(name = "timeout", description = "推流超时时间(秒)", required = true)
|
||||||
@GetMapping("/broadcast/{deviceId}/{channelId}")
|
@GetMapping("/broadcast/{deviceId}/{channelId}")
|
||||||
@PostMapping("/broadcast/{deviceId}/{channelId}")
|
@PostMapping("/broadcast/{deviceId}/{channelId}")
|
||||||
public AudioBroadcastResult broadcastApi(@PathVariable String deviceId, @PathVariable String channelId, Integer timeout) {
|
public AudioBroadcastResult broadcastApi(@PathVariable String deviceId, @PathVariable String channelId, Integer timeout, Boolean broadcastMode) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("语音广播API调用");
|
logger.debug("语音广播API调用");
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ public class PlayController {
|
||||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到通道: " + channelId);
|
throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到通道: " + channelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return playService.audioBroadcast(device, channelId);
|
return playService.audioBroadcast(device, channelId, broadcastMode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ module.exports = {
|
||||||
assetsPublicPath: './',
|
assetsPublicPath: './',
|
||||||
proxyTable: {
|
proxyTable: {
|
||||||
'/debug': {
|
'/debug': {
|
||||||
target: 'https://default.wvp-pro.cn:18080',
|
target: 'https://default.wvp-pro.cn:18082',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
pathRewrite: {
|
pathRewrite: {
|
||||||
'^/debug': '/'
|
'^/debug': '/'
|
||||||
|
|
|
@ -299,6 +299,10 @@
|
||||||
|
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="语音对讲" name="broadcast">
|
<el-tab-pane label="语音对讲" name="broadcast">
|
||||||
|
<div style="padding: 0 10px">
|
||||||
|
<el-switch v-model="broadcastMode" :disabled="broadcastStatus !== -1" active-color="#409EFF" active-text="喊话"
|
||||||
|
inactive-text="对讲"></el-switch>
|
||||||
|
</div>
|
||||||
<div class="trank" style="text-align: center;">
|
<div class="trank" style="text-align: center;">
|
||||||
<el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" :disabled="broadcastStatus === -2"
|
<el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" :disabled="broadcastStatus === -2"
|
||||||
circle icon="el-icon-microphone" style="font-size: 32px; padding: 24px;margin-top: 24px;"/>
|
circle icon="el-icon-microphone" style="font-size: 32px; padding: 24px;margin-top: 24px;"/>
|
||||||
|
@ -390,6 +394,7 @@ export default {
|
||||||
recordStartTime: 0,
|
recordStartTime: 0,
|
||||||
showTimeText: "00:00:00",
|
showTimeText: "00:00:00",
|
||||||
streamInfo: null,
|
streamInfo: null,
|
||||||
|
broadcastMode: true,
|
||||||
broadcastRtc: null,
|
broadcastRtc: null,
|
||||||
broadcastStatus: -1, // -2 正在释放资源 -1 默认状态 0 等待接通 1 接通成功
|
broadcastStatus: -1, // -2 正在释放资源 -1 默认状态 0 等待接通 1 接通成功
|
||||||
};
|
};
|
||||||
|
@ -648,7 +653,7 @@ export default {
|
||||||
// 发起语音对讲
|
// 发起语音对讲
|
||||||
this.$axios({
|
this.$axios({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: '/api/play/broadcast/' + this.deviceId + '/' + this.channelId + "?timeout=30"
|
url: '/api/play/broadcast/' + this.deviceId + '/' + this.channelId + "?timeout=30&broadcastMode=" + this.broadcastMode
|
||||||
}).then( (res)=> {
|
}).then( (res)=> {
|
||||||
if (res.data.code == 0) {
|
if (res.data.code == 0) {
|
||||||
let streamInfo = res.data.data.streamInfo;
|
let streamInfo = res.data.data.streamInfo;
|
||||||
|
|
Loading…
Reference in New Issue