修复检测字段是否存在带来的停止按钮无法点击
修改错别字
| | |
| | | |
| | | private String streamId; |
| | | private String deviceID; |
| | | private String cahnnelId; |
| | | private String channelId; |
| | | private String flv; |
| | | private String ws_flv; |
| | | private String fmp4; |
| | |
| | | this.deviceID = deviceID; |
| | | } |
| | | |
| | | public String getCahnnelId() { |
| | | return cahnnelId; |
| | | public String getChannelId() { |
| | | return channelId; |
| | | } |
| | | |
| | | public void setCahnnelId(String cahnnelId) { |
| | | this.cahnnelId = cahnnelId; |
| | | public void setChannelId(String channelId) { |
| | | this.channelId = channelId; |
| | | } |
| | | |
| | | public String getFlv() { |
| | |
| | | content.append("s=Play\r\n");
|
| | | content.append("c=IN IP4 "+mediaInfo.getWanIp()+"\r\n");
|
| | | content.append("t=0 0\r\n");
|
| | |
|
| | | if (seniorSdp) {
|
| | | if("TCP-PASSIVE".equals(streamMode)) {
|
| | | content.append("m=video "+ mediaPort +" TCP/RTP/AVP 126 125 99 34 98 97 96\r\n");
|
| | | }else if ("TCP-ACTIVE".equals(streamMode)) {
|
| | |
| | | content.append("a=setup:active\r\n");
|
| | | content.append("a=connection:new\r\n");
|
| | | }
|
| | | }else {
|
| | | if("TCP-PASSIVE".equals(streamMode)) {
|
| | | content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n");
|
| | | }else if ("TCP-ACTIVE".equals(streamMode)) {
|
| | | content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n");
|
| | | }else if("UDP".equals(streamMode)) {
|
| | | content.append("m=video "+ mediaPort +" RTP/AVP 96 98 97\r\n");
|
| | | }
|
| | | content.append("a=recvonly\r\n");
|
| | | content.append("a=rtpmap:96 PS/90000\r\n");
|
| | | content.append("a=rtpmap:98 H264/90000\r\n");
|
| | | content.append("a=rtpmap:97 MPEG4/90000\r\n");
|
| | | if("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式
|
| | | content.append("a=setup:passive\r\n");
|
| | | content.append("a=recvonly\r\n");
|
| | | content.append("a=rtpmap:96 PS/90000\r\n");
|
| | | content.append("a=rtpmap:98 H264/90000\r\n");
|
| | | content.append("a=rtpmap:97 MPEG4/90000\r\n");
|
| | | if ("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式
|
| | | content.append("a=setup:passive\r\n");
|
| | | content.append("a=connection:new\r\n");
|
| | | } else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式
|
| | | } else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式
|
| | | content.append("a=setup:active\r\n");
|
| | | content.append("a=connection:new\r\n");
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | content.append("y="+ssrc+"\r\n");//ssrc
|
| | |
|
| | | // String fromTag = UUID.randomUUID().toString();
|
| | |
| | | if ("rtp".equals(app) && !regist ) {
|
| | | if (streamInfo!=null){
|
| | | redisCatchStorage.stopPlay(streamInfo);
|
| | | storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
|
| | | }else{
|
| | | streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
|
| | | redisCatchStorage.stopPlayback(streamInfo);
|
| | |
| | | StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
|
| | | if (streamInfo!=null){
|
| | | redisCatchStorage.stopPlay(streamInfo);
|
| | | storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
|
| | | }else{
|
| | | streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
|
| | | redisCatchStorage.stopPlayback(streamInfo);
|
| | |
| | | * @param channel 通道
|
| | | */
|
| | | public void updateChannel(String deviceId, DeviceChannel channel);
|
| | |
|
| | | /**
|
| | | * 开始播放
|
| | | * @param deviceId 设备id
|
| | | * @param channelId 通道ID
|
| | | * @param streamId 流地址
|
| | | */
|
| | | public void startPlay(String deviceId, String channelId, String streamId);
|
| | |
|
| | | /**
|
| | | * 停止播放
|
| | | * @param deviceId 设备id
|
| | | * @param channelId 通道ID
|
| | | */
|
| | | public void stopPlay(String deviceId, String channelId);
|
| | |
|
| | | /**
|
| | | * 获取设备
|
| | |
| | | @Delete("DELETE FROM device_channel WHERE deviceId=#{deviceId}") |
| | | int cleanChannelsByDeviceId(String deviceId); |
| | | |
| | | @Update(value = {"UPDATE device_channel SET streamId=null WHERE deviceId=#{deviceId} AND channelId=#{channelId}"}) |
| | | void stopPlay(String deviceId, String channelId); |
| | | |
| | | @Update(value = {"UPDATE device_channel SET streamId=#{streamId} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"}) |
| | | void startPlay(String deviceId, String channelId, String streamId); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public boolean startPlay(StreamInfo stream) { |
| | | return redis.set(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, stream.getStreamId(),stream.getDeviceID(), stream.getCahnnelId()), |
| | | return redis.set(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, stream.getStreamId(),stream.getDeviceID(), stream.getChannelId()), |
| | | stream); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public boolean stopPlay(StreamInfo streamInfo) { |
| | | if (streamInfo == null) return false; |
| | | DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(streamInfo.getDeviceID(), streamInfo.getCahnnelId()); |
| | | if (deviceChannel != null) { |
| | | deviceChannel.setStreamId(null); |
| | | deviceChannel.setDeviceId(streamInfo.getDeviceID()); |
| | | deviceChannelMapper.update(deviceChannel); |
| | | } |
| | | return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, |
| | | streamInfo.getStreamId(), |
| | | streamInfo.getDeviceID(), |
| | | streamInfo.getCahnnelId())); |
| | | streamInfo.getChannelId())); |
| | | } |
| | | |
| | | /** |
| | |
| | | VideoManagerConstants.PLAYER_PREFIX, |
| | | streamInfo.getStreamId(), |
| | | streamInfo.getDeviceID(), |
| | | streamInfo.getCahnnelId())); |
| | | streamInfo.getChannelId())); |
| | | } |
| | | @Override |
| | | public StreamInfo queryPlayByStreamId(String steamId) { |
| | |
| | | for (int i = 0; i < players.size(); i++) { |
| | | String key = (String) players.get(i); |
| | | StreamInfo streamInfo = (StreamInfo)redis.get(key); |
| | | streamInfos.put(streamInfo.getDeviceID() + "_" + streamInfo.getCahnnelId(), streamInfo); |
| | | streamInfos.put(streamInfo.getDeviceID() + "_" + streamInfo.getChannelId(), streamInfo); |
| | | } |
| | | return streamInfos; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public boolean startPlayback(StreamInfo stream) { |
| | | return redis.set(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, stream.getStreamId(),stream.getDeviceID(), stream.getCahnnelId()), |
| | | return redis.set(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, stream.getStreamId(),stream.getDeviceID(), stream.getChannelId()), |
| | | stream); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public boolean stopPlayback(StreamInfo streamInfo) { |
| | | if (streamInfo == null) return false; |
| | | DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(streamInfo.getDeviceID(), streamInfo.getCahnnelId()); |
| | | DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(streamInfo.getDeviceID(), streamInfo.getChannelId()); |
| | | if (deviceChannel != null) { |
| | | deviceChannel.setStreamId(null); |
| | | deviceChannel.setDeviceId(streamInfo.getDeviceID()); |
| | |
| | | return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, |
| | | streamInfo.getStreamId(), |
| | | streamInfo.getDeviceID(), |
| | | streamInfo.getCahnnelId())); |
| | | streamInfo.getChannelId())); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void startPlay(String deviceId, String channelId, String streamId) { |
| | | deviceChannelMapper.startPlay(deviceId, channelId, streamId); |
| | | } |
| | | |
| | | @Override |
| | | public void stopPlay(String deviceId, String channelId) { |
| | | deviceChannelMapper.stopPlay(deviceId, channelId); |
| | | } |
| | | |
| | | /** |
| | | * 获取设备 |
| | | * |
| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.genersoft.iot.vmp.common.StreamInfo; |
| | | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| | | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| | |
| | | resultHolder.invokeResult(msg); |
| | | } else { |
| | | redisCatchStorage.stopPlay(streamInfo); |
| | | storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); |
| | | cmder.playStreamCmd(device, channelId, (JSONObject response) -> { |
| | | logger.info("收到订阅消息: " + response.toJSONString()); |
| | | playService.onPublishHandlerForPlay(response, deviceId, channelId, uuid.toString()); |
| | |
| | | msg.setId(DeferredResultHolder.CALLBACK_CMD_PlAY + uuid); |
| | | msg.setData("streamId not found"); |
| | | resultHolder.invokeResult(msg); |
| | | }else { |
| | | redisCatchStorage.stopPlay(streamInfo); |
| | | } |
| | | |
| | | storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); |
| | | RequestMessage msg = new RequestMessage(); |
| | | msg.setId(DeferredResultHolder.CALLBACK_CMD_STOP + uuid); |
| | | Response response = event.getResponse(); |
| | | msg.setData(String.format("success")); |
| | | resultHolder.invokeResult(msg); |
| | | } |
| | | }); |
| | | |
| | | |
| | | |
| | | if (streamId != null) { |
| | | JSONObject json = new JSONObject(); |
| | |
| | | // 超时处理 |
| | | result.onTimeout(()->{ |
| | | logger.warn(String.format("设备预览/回放停止超时,streamId:%s ", streamId)); |
| | | |
| | | RequestMessage msg = new RequestMessage(); |
| | | msg.setId(DeferredResultHolder.CALLBACK_CMD_STOP + uuid); |
| | | msg.setData("Timeout"); |
| | |
| | | DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); |
| | | if (deviceChannel != null) { |
| | | deviceChannel.setStreamId(streamInfo.getStreamId()); |
| | | storager.updateChannel(deviceId, deviceChannel); |
| | | storager.startPlay(deviceId, channelId, streamInfo.getStreamId()); |
| | | } |
| | | |
| | | redisCatchStorage.startPlay(streamInfo); |
| | |
| | | StreamInfo streamInfo = new StreamInfo(); |
| | | streamInfo.setStreamId(streamId); |
| | | streamInfo.setDeviceID(deviceId); |
| | | streamInfo.setCahnnelId(channelId); |
| | | streamInfo.setChannelId(channelId); |
| | | MediaServerConfig mediaServerConfig = redisCatchStorage.getMediaInfo(); |
| | | |
| | | streamInfo.setFlv(String.format("http://%s:%s/rtp/%s.flv", mediaServerConfig.getWanIp(), mediaServerConfig.getHttpPort(), streamId)); |
| | |
| | | } |
| | | cmder.streamByeCmd(streamInfo.getStreamId()); |
| | | redisCatchStorage.stopPlay(streamInfo); |
| | | storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); |
| | | return null; |
| | | } |
| | | |