添加界面优化接口
parent
1d1f174852
commit
07956b48df
|
@ -28,6 +28,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
|
||||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||||
|
import com.genersoft.iot.vmp.service.IMediaService;
|
||||||
import com.genersoft.iot.vmp.service.IPlayService;
|
import com.genersoft.iot.vmp.service.IPlayService;
|
||||||
import com.genersoft.iot.vmp.service.IStreamPushService;
|
import com.genersoft.iot.vmp.service.IStreamPushService;
|
||||||
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
|
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
|
||||||
|
@ -103,6 +104,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
@Autowired
|
@Autowired
|
||||||
private IMediaServerService mediaServerService;
|
private IMediaServerService mediaServerService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMediaService mediaService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ZLMRESTfulUtils zlmresTfulUtils;
|
private ZLMRESTfulUtils zlmresTfulUtils;
|
||||||
|
|
||||||
|
@ -1016,7 +1020,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult();
|
AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult();
|
||||||
audioBroadcastResult.setApp(app);
|
audioBroadcastResult.setApp(app);
|
||||||
audioBroadcastResult.setStream(stream);
|
audioBroadcastResult.setStream(stream);
|
||||||
audioBroadcastResult.setMediaServerItem(new MediaServerItemLite(mediaServerItem));
|
audioBroadcastResult.setStreamInfo(mediaService.getStreamInfoByAppAndStream(mediaServerItem, app, stream, null, null, false));
|
||||||
audioBroadcastResult.setCodec("G.711");
|
audioBroadcastResult.setCodec("G.711");
|
||||||
wvpResult.setData(audioBroadcastResult);
|
wvpResult.setData(audioBroadcastResult);
|
||||||
RequestMessage requestMessage = new RequestMessage();
|
RequestMessage requestMessage = new RequestMessage();
|
||||||
|
|
|
@ -41,4 +41,5 @@ public interface IMediaService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr);
|
StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr);
|
||||||
|
StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr, boolean isPlay);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,11 @@ public class MediaServiceImpl implements IMediaService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr) {
|
public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr) {
|
||||||
|
return getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr, boolean isPlay) {
|
||||||
StreamInfo streamInfoResult = new StreamInfo();
|
StreamInfo streamInfoResult = new StreamInfo();
|
||||||
streamInfoResult.setStream(stream);
|
streamInfoResult.setStream(stream);
|
||||||
streamInfoResult.setApp(app);
|
streamInfoResult.setApp(app);
|
||||||
|
@ -107,11 +112,10 @@ public class MediaServiceImpl implements IMediaService {
|
||||||
streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream));
|
streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream));
|
||||||
streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream));
|
streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream));
|
||||||
streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream));
|
streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream));
|
||||||
streamInfoResult.setRtc(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream));
|
streamInfoResult.setRtc(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=%s", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream, isPlay?"play":"push"));
|
||||||
}
|
}
|
||||||
|
|
||||||
streamInfoResult.setTracks(tracks);
|
streamInfoResult.setTracks(tracks);
|
||||||
return streamInfoResult;
|
return streamInfoResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,10 +190,7 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
redisCatchStorage.stopPlay(streamInfo);
|
redisCatchStorage.stopPlay(streamInfo);
|
||||||
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
|
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
|
||||||
streamInfo = null;
|
streamInfo = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (streamInfo == null) {
|
if (streamInfo == null) {
|
||||||
String streamId = null;
|
String streamId = null;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.genersoft.iot.vmp.vmanager.bean;
|
package com.genersoft.iot.vmp.vmanager.bean;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite;
|
||||||
|
|
||||||
|
@ -8,9 +9,9 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite;
|
||||||
*/
|
*/
|
||||||
public class AudioBroadcastResult {
|
public class AudioBroadcastResult {
|
||||||
/**
|
/**
|
||||||
* 推流的媒体节点信息
|
* 推流的各个方式流地址
|
||||||
*/
|
*/
|
||||||
private MediaServerItemLite mediaServerItem;
|
private StreamInfo streamInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编码格式
|
* 编码格式
|
||||||
|
@ -28,12 +29,12 @@ public class AudioBroadcastResult {
|
||||||
private String stream;
|
private String stream;
|
||||||
|
|
||||||
|
|
||||||
public MediaServerItemLite getMediaServerItem() {
|
public StreamInfo getStreamInfo() {
|
||||||
return mediaServerItem;
|
return streamInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMediaServerItem(MediaServerItemLite mediaServerItem) {
|
public void setStreamInfo(StreamInfo streamInfo) {
|
||||||
this.mediaServerItem = mediaServerItem;
|
this.streamInfo = streamInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCodec() {
|
public String getCodec() {
|
||||||
|
|
Binary file not shown.
|
@ -276,6 +276,17 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="语音对讲" name="broadcast" >
|
||||||
|
<div class="trank" style="text-align: center;">
|
||||||
|
<el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" circle icon="el-icon-microphone" style="font-size: 32px; padding: 24px;margin-top: 24px;"/>
|
||||||
|
<p>
|
||||||
|
<span v-if="broadcastStatus === -1">点击开始对讲</span>
|
||||||
|
<span v-if="broadcastStatus === 0">等待接通中...</span>
|
||||||
|
<span v-if="broadcastStatus === 1">请说话</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</div>
|
</div>
|
||||||
|
@ -359,6 +370,8 @@ export default {
|
||||||
recordStartTime: 0,
|
recordStartTime: 0,
|
||||||
showTimeText: "00:00:00",
|
showTimeText: "00:00:00",
|
||||||
streamInfo: null,
|
streamInfo: null,
|
||||||
|
broadcastRtc: null,
|
||||||
|
broadcastStatus: -1, // -1 默认状态 0 等待接通 1 接通成功
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -804,8 +817,111 @@ export default {
|
||||||
}, 600)
|
}, 600)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getBroadcastStatus() {
|
||||||
|
if (this.broadcastStatus == -1) {
|
||||||
|
return "primary"
|
||||||
|
}
|
||||||
|
if (this.broadcastStatus == 0) {
|
||||||
|
return "warning"
|
||||||
|
}
|
||||||
|
if (this.broadcastStatus == 1) {
|
||||||
|
return "danger"
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
broadcastStatusClick() {
|
||||||
|
if (this.broadcastStatus == -1) {
|
||||||
|
// 默认状态, 开始
|
||||||
|
// 发起语音对讲
|
||||||
|
this.$axios({
|
||||||
|
method: 'get',
|
||||||
|
url: '/api/play/broadcast/' + this.deviceId + '/' + this.channelId + "?timeout=30"
|
||||||
|
}).then( (res)=> {
|
||||||
|
if (res.data.code == 0) {
|
||||||
|
let streamInfo = res.data.data.streamInfo;
|
||||||
|
this.startBroadcast(streamInfo.rtc)
|
||||||
|
}else {
|
||||||
|
this.$message({
|
||||||
|
showClose: true,
|
||||||
|
message: res.data.msg,
|
||||||
|
type: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else if (this.broadcastStatus === 1) {
|
||||||
|
this.broadcastRtc.close()
|
||||||
|
this.broadcastRtc = null;
|
||||||
|
this.broadcastStatus = -1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
startBroadcast(url){
|
||||||
|
console.log("开始语音对讲: " + url)
|
||||||
|
this.broadcastRtc = new ZLMRTCClient.Endpoint({
|
||||||
|
debug: true, // 是否打印日志
|
||||||
|
zlmsdpUrl: url, //流地址
|
||||||
|
simulecast: false,
|
||||||
|
useCamera: false,
|
||||||
|
audioEnable: true,
|
||||||
|
videoEnable: false,
|
||||||
|
recvOnly: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
// webrtcPlayer.on(ZLMRTCClient.Events.WEBRTC_ON_REMOTE_STREAMS,(e)=>{//获取到了远端流,可以播放
|
||||||
|
// console.error('播放成功',e.streams)
|
||||||
|
// this.broadcastStatus = 1;
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// webrtcPlayer.on(ZLMRTCClient.Events.WEBRTC_ON_LOCAL_STREAM,(s)=>{// 获取到了本地流
|
||||||
|
// this.broadcastStatus = 1;
|
||||||
|
// // document.getElementById('selfVideo').srcObject=s;
|
||||||
|
// // this.eventcallbacK("LOCAL STREAM", "获取到了本地流")
|
||||||
|
// });
|
||||||
|
|
||||||
|
this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_NOT_SUPPORT,(e)=>{// 获取到了本地流
|
||||||
|
console.error('不支持webrtc',e)
|
||||||
|
this.$message({
|
||||||
|
showClose: true,
|
||||||
|
message: '不支持webrtc, 无法进行语音对讲',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ICE_CANDIDATE_ERROR,(e)=>{// ICE 协商出错
|
||||||
|
console.error('ICE 协商出错')
|
||||||
|
this.$message({
|
||||||
|
showClose: true,
|
||||||
|
message: 'ICE 协商出错',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED,(e)=>{// offer anwser 交换失败
|
||||||
|
console.error('offer anwser 交换失败',e)
|
||||||
|
this.$message({
|
||||||
|
showClose: true,
|
||||||
|
message: 'offer anwser 交换失败' + e,
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ON_CONNECTION_STATE_CHANGE,(e)=>{// offer anwser 交换失败
|
||||||
|
console.log('状态改变',e)
|
||||||
|
if (e === "failed") {
|
||||||
|
this.broadcastStatus = -1;
|
||||||
|
}else if (e === "connecting") {
|
||||||
|
this.broadcastStatus = 0;
|
||||||
|
}else{
|
||||||
|
this.broadcastStatus = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.broadcastRtc.on(ZLMRTCClient.Events.CAPTURE_STREAM_FAILED,(e)=>{// offer anwser 交换失败
|
||||||
|
console.log('捕获流失败',e)
|
||||||
|
this.$message({
|
||||||
|
showClose: true,
|
||||||
|
message: '捕获流失败' + e,
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue