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