Commit 7e581e9d3a0e32be5e90e453f4283d70d895a634
Merge remote-tracking branch 'origin/master' into wvp-28181-2.0
# Conflicts: # src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
Showing
10 changed files
with
110 additions
and
53 deletions
src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java
| @@ -6,7 +6,7 @@ public class StreamInfo { | @@ -6,7 +6,7 @@ public class StreamInfo { | ||
| 6 | 6 | ||
| 7 | private String streamId; | 7 | private String streamId; |
| 8 | private String deviceID; | 8 | private String deviceID; |
| 9 | - private String cahnnelId; | 9 | + private String channelId; |
| 10 | private String flv; | 10 | private String flv; |
| 11 | private String ws_flv; | 11 | private String ws_flv; |
| 12 | private String fmp4; | 12 | private String fmp4; |
| @@ -27,12 +27,12 @@ public class StreamInfo { | @@ -27,12 +27,12 @@ public class StreamInfo { | ||
| 27 | this.deviceID = deviceID; | 27 | this.deviceID = deviceID; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | - public String getCahnnelId() { | ||
| 31 | - return cahnnelId; | 30 | + public String getChannelId() { |
| 31 | + return channelId; | ||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | - public void setCahnnelId(String cahnnelId) { | ||
| 35 | - this.cahnnelId = cahnnelId; | 34 | + public void setChannelId(String channelId) { |
| 35 | + this.channelId = channelId; | ||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | public String getFlv() { | 38 | public String getFlv() { |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -323,30 +323,61 @@ public class SIPCommander implements ISIPCommander { | @@ -323,30 +323,61 @@ public class SIPCommander implements ISIPCommander { | ||
| 323 | content.append("s=Play\r\n"); | 323 | content.append("s=Play\r\n"); |
| 324 | content.append("c=IN IP4 "+mediaInfo.getWanIp()+"\r\n"); | 324 | content.append("c=IN IP4 "+mediaInfo.getWanIp()+"\r\n"); |
| 325 | content.append("t=0 0\r\n"); | 325 | content.append("t=0 0\r\n"); |
| 326 | - if("TCP-PASSIVE".equals(streamMode)) { | ||
| 327 | - content.append("m=video "+ mediaPort +" TCP/RTP/AVP 126 125 99 34 98 97 96\r\n"); | ||
| 328 | - }else if ("TCP-ACTIVE".equals(streamMode)) { | ||
| 329 | - content.append("m=video "+ mediaPort +" TCP/RTP/AVP 126 125 99 34 98 97 96\r\n"); | ||
| 330 | - }else if("UDP".equals(streamMode)) { | ||
| 331 | - content.append("m=video "+ mediaPort +" RTP/AVP 126 125 99 34 98 97 96\r\n"); | ||
| 332 | - } | ||
| 333 | - content.append("a=recvonly\r\n"); | ||
| 334 | - content.append("a=fmtp:126 profile-level-id=42e01e\r\n"); | ||
| 335 | - content.append("a=rtpmap:126 H264/90000\r\n"); | ||
| 336 | - content.append("a=rtpmap:125 H264S/90000\r\n"); | ||
| 337 | - content.append("a=fmtp:125 profile-level-id=42e01e\r\n"); | ||
| 338 | - content.append("a=rtpmap:99 MP4V-ES/90000\r\n"); | ||
| 339 | - content.append("a=fmtp:99 profile-level-id=3\r\n"); | ||
| 340 | - content.append("a=rtpmap:98 H264/90000\r\n"); | ||
| 341 | - content.append("a=rtpmap:97 MPEG4/90000\r\n"); | ||
| 342 | - content.append("a=rtpmap:96 PS/90000\r\n"); | ||
| 343 | - if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 | ||
| 344 | - content.append("a=setup:passive\r\n"); | ||
| 345 | - content.append("a=connection:new\r\n"); | ||
| 346 | - }else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 | ||
| 347 | - content.append("a=setup:active\r\n"); | ||
| 348 | - content.append("a=connection:new\r\n"); | 326 | + |
| 327 | + if (seniorSdp) { | ||
| 328 | + if("TCP-PASSIVE".equals(streamMode)) { | ||
| 329 | + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 126 125 99 34 98 97 96\r\n"); | ||
| 330 | + }else if ("TCP-ACTIVE".equals(streamMode)) { | ||
| 331 | + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 126 125 99 34 98 97 96\r\n"); | ||
| 332 | + }else if("UDP".equals(streamMode)) { | ||
| 333 | + content.append("m=video "+ mediaPort +" RTP/AVP 126 125 99 34 98 97 96\r\n"); | ||
| 334 | + } | ||
| 335 | + content.append("a=recvonly\r\n"); | ||
| 336 | + content.append("a=fmtp:126 profile-level-id=42e01e\r\n"); | ||
| 337 | + content.append("a=rtpmap:126 H264/90000\r\n"); | ||
| 338 | + content.append("a=rtpmap:125 H264S/90000\r\n"); | ||
| 339 | + content.append("a=fmtp:125 profile-level-id=42e01e\r\n"); | ||
| 340 | + content.append("a=rtpmap:99 MP4V-ES/90000\r\n"); | ||
| 341 | + content.append("a=fmtp:99 profile-level-id=3\r\n"); | ||
| 342 | + content.append("a=rtpmap:98 H264/90000\r\n"); | ||
| 343 | + content.append("a=rtpmap:97 MPEG4/90000\r\n"); | ||
| 344 | + content.append("a=rtpmap:96 PS/90000\r\n"); | ||
| 345 | + if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 | ||
| 346 | + content.append("a=setup:passive\r\n"); | ||
| 347 | + content.append("a=connection:new\r\n"); | ||
| 348 | + }else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 | ||
| 349 | + content.append("a=setup:active\r\n"); | ||
| 350 | + content.append("a=connection:new\r\n"); | ||
| 351 | + } | ||
| 352 | + }else { | ||
| 353 | + if("TCP-PASSIVE".equals(streamMode)) { | ||
| 354 | + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n"); | ||
| 355 | + }else if ("TCP-ACTIVE".equals(streamMode)) { | ||
| 356 | + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n"); | ||
| 357 | + }else if("UDP".equals(streamMode)) { | ||
| 358 | + content.append("m=video "+ mediaPort +" RTP/AVP 96 98 97\r\n"); | ||
| 359 | + } | ||
| 360 | + content.append("a=recvonly\r\n"); | ||
| 361 | + content.append("a=rtpmap:96 PS/90000\r\n"); | ||
| 362 | + content.append("a=rtpmap:98 H264/90000\r\n"); | ||
| 363 | + content.append("a=rtpmap:97 MPEG4/90000\r\n"); | ||
| 364 | + if("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式 | ||
| 365 | + content.append("a=setup:passive\r\n"); | ||
| 366 | + content.append("a=recvonly\r\n"); | ||
| 367 | + content.append("a=rtpmap:96 PS/90000\r\n"); | ||
| 368 | + content.append("a=rtpmap:98 H264/90000\r\n"); | ||
| 369 | + content.append("a=rtpmap:97 MPEG4/90000\r\n"); | ||
| 370 | + if ("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式 | ||
| 371 | + content.append("a=setup:passive\r\n"); | ||
| 372 | + content.append("a=connection:new\r\n"); | ||
| 373 | + } else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 | ||
| 374 | + } else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 | ||
| 375 | + content.append("a=setup:active\r\n"); | ||
| 376 | + content.append("a=connection:new\r\n"); | ||
| 377 | + } | ||
| 378 | + } | ||
| 349 | } | 379 | } |
| 380 | + | ||
| 350 | content.append("y="+ssrc+"\r\n");//ssrc | 381 | content.append("y="+ssrc+"\r\n");//ssrc |
| 351 | 382 | ||
| 352 | // String fromTag = UUID.randomUUID().toString(); | 383 | // String fromTag = UUID.randomUUID().toString(); |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| @@ -261,6 +261,7 @@ public class ZLMHttpHookListener { | @@ -261,6 +261,7 @@ public class ZLMHttpHookListener { | ||
| 261 | if ("rtp".equals(app) && !regist ) { | 261 | if ("rtp".equals(app) && !regist ) { |
| 262 | if (streamInfo!=null){ | 262 | if (streamInfo!=null){ |
| 263 | redisCatchStorage.stopPlay(streamInfo); | 263 | redisCatchStorage.stopPlay(streamInfo); |
| 264 | + storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); | ||
| 264 | }else{ | 265 | }else{ |
| 265 | streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId); | 266 | streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId); |
| 266 | redisCatchStorage.stopPlayback(streamInfo); | 267 | redisCatchStorage.stopPlayback(streamInfo); |
| @@ -292,6 +293,7 @@ public class ZLMHttpHookListener { | @@ -292,6 +293,7 @@ public class ZLMHttpHookListener { | ||
| 292 | StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId); | 293 | StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId); |
| 293 | if (streamInfo!=null){ | 294 | if (streamInfo!=null){ |
| 294 | redisCatchStorage.stopPlay(streamInfo); | 295 | redisCatchStorage.stopPlay(streamInfo); |
| 296 | + storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); | ||
| 295 | }else{ | 297 | }else{ |
| 296 | streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId); | 298 | streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId); |
| 297 | redisCatchStorage.stopPlayback(streamInfo); | 299 | redisCatchStorage.stopPlayback(streamInfo); |
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
| @@ -47,6 +47,21 @@ public interface IVideoManagerStorager { | @@ -47,6 +47,21 @@ public interface IVideoManagerStorager { | ||
| 47 | * @param channel 通道 | 47 | * @param channel 通道 |
| 48 | */ | 48 | */ |
| 49 | public void updateChannel(String deviceId, DeviceChannel channel); | 49 | public void updateChannel(String deviceId, DeviceChannel channel); |
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 开始播放 | ||
| 53 | + * @param deviceId 设备id | ||
| 54 | + * @param channelId 通道ID | ||
| 55 | + * @param streamId 流地址 | ||
| 56 | + */ | ||
| 57 | + public void startPlay(String deviceId, String channelId, String streamId); | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 停止播放 | ||
| 61 | + * @param deviceId 设备id | ||
| 62 | + * @param channelId 通道ID | ||
| 63 | + */ | ||
| 64 | + public void stopPlay(String deviceId, String channelId); | ||
| 50 | 65 | ||
| 51 | /** | 66 | /** |
| 52 | * 获取设备 | 67 | * 获取设备 |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
| 1 | package com.genersoft.iot.vmp.storager.dao; | 1 | package com.genersoft.iot.vmp.storager.dao; |
| 2 | 2 | ||
| 3 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | 3 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 4 | -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | ||
| 5 | import org.apache.ibatis.annotations.*; | 4 | import org.apache.ibatis.annotations.*; |
| 6 | 5 | ||
| 7 | import java.util.List; | 6 | import java.util.List; |
| @@ -78,6 +77,9 @@ public interface DeviceChannelMapper { | @@ -78,6 +77,9 @@ public interface DeviceChannelMapper { | ||
| 78 | @Delete("DELETE FROM device_channel WHERE deviceId=#{deviceId}") | 77 | @Delete("DELETE FROM device_channel WHERE deviceId=#{deviceId}") |
| 79 | int cleanChannelsByDeviceId(String deviceId); | 78 | int cleanChannelsByDeviceId(String deviceId); |
| 80 | 79 | ||
| 80 | + @Update(value = {"UPDATE device_channel SET streamId=null WHERE deviceId=#{deviceId} AND channelId=#{channelId}"}) | ||
| 81 | + void stopPlay(String deviceId, String channelId); | ||
| 81 | 82 | ||
| 82 | - | 83 | + @Update(value = {"UPDATE device_channel SET streamId=#{streamId} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"}) |
| 84 | + void startPlay(String deviceId, String channelId, String streamId); | ||
| 83 | } | 85 | } |
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
| @@ -35,7 +35,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -35,7 +35,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 35 | */ | 35 | */ |
| 36 | @Override | 36 | @Override |
| 37 | public boolean startPlay(StreamInfo stream) { | 37 | public boolean startPlay(StreamInfo stream) { |
| 38 | - return redis.set(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, stream.getStreamId(),stream.getDeviceID(), stream.getCahnnelId()), | 38 | + return redis.set(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, stream.getStreamId(),stream.getDeviceID(), stream.getChannelId()), |
| 39 | stream); | 39 | stream); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| @@ -47,16 +47,10 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -47,16 +47,10 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 47 | @Override | 47 | @Override |
| 48 | public boolean stopPlay(StreamInfo streamInfo) { | 48 | public boolean stopPlay(StreamInfo streamInfo) { |
| 49 | if (streamInfo == null) return false; | 49 | if (streamInfo == null) return false; |
| 50 | - DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(streamInfo.getDeviceID(), streamInfo.getCahnnelId()); | ||
| 51 | - if (deviceChannel != null) { | ||
| 52 | - deviceChannel.setStreamId(null); | ||
| 53 | - deviceChannel.setDeviceId(streamInfo.getDeviceID()); | ||
| 54 | - deviceChannelMapper.update(deviceChannel); | ||
| 55 | - } | ||
| 56 | return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, | 50 | return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, |
| 57 | streamInfo.getStreamId(), | 51 | streamInfo.getStreamId(), |
| 58 | streamInfo.getDeviceID(), | 52 | streamInfo.getDeviceID(), |
| 59 | - streamInfo.getCahnnelId())); | 53 | + streamInfo.getChannelId())); |
| 60 | } | 54 | } |
| 61 | 55 | ||
| 62 | /** | 56 | /** |
| @@ -69,7 +63,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -69,7 +63,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 69 | VideoManagerConstants.PLAYER_PREFIX, | 63 | VideoManagerConstants.PLAYER_PREFIX, |
| 70 | streamInfo.getStreamId(), | 64 | streamInfo.getStreamId(), |
| 71 | streamInfo.getDeviceID(), | 65 | streamInfo.getDeviceID(), |
| 72 | - streamInfo.getCahnnelId())); | 66 | + streamInfo.getChannelId())); |
| 73 | } | 67 | } |
| 74 | @Override | 68 | @Override |
| 75 | public StreamInfo queryPlayByStreamId(String steamId) { | 69 | public StreamInfo queryPlayByStreamId(String steamId) { |
| @@ -123,7 +117,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -123,7 +117,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 123 | for (int i = 0; i < players.size(); i++) { | 117 | for (int i = 0; i < players.size(); i++) { |
| 124 | String key = (String) players.get(i); | 118 | String key = (String) players.get(i); |
| 125 | StreamInfo streamInfo = (StreamInfo)redis.get(key); | 119 | StreamInfo streamInfo = (StreamInfo)redis.get(key); |
| 126 | - streamInfos.put(streamInfo.getDeviceID() + "_" + streamInfo.getCahnnelId(), streamInfo); | 120 | + streamInfos.put(streamInfo.getDeviceID() + "_" + streamInfo.getChannelId(), streamInfo); |
| 127 | } | 121 | } |
| 128 | return streamInfos; | 122 | return streamInfos; |
| 129 | } | 123 | } |
| @@ -131,7 +125,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -131,7 +125,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 131 | 125 | ||
| 132 | @Override | 126 | @Override |
| 133 | public boolean startPlayback(StreamInfo stream) { | 127 | public boolean startPlayback(StreamInfo stream) { |
| 134 | - return redis.set(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, stream.getStreamId(),stream.getDeviceID(), stream.getCahnnelId()), | 128 | + return redis.set(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, stream.getStreamId(),stream.getDeviceID(), stream.getChannelId()), |
| 135 | stream); | 129 | stream); |
| 136 | } | 130 | } |
| 137 | 131 | ||
| @@ -139,7 +133,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -139,7 +133,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 139 | @Override | 133 | @Override |
| 140 | public boolean stopPlayback(StreamInfo streamInfo) { | 134 | public boolean stopPlayback(StreamInfo streamInfo) { |
| 141 | if (streamInfo == null) return false; | 135 | if (streamInfo == null) return false; |
| 142 | - DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(streamInfo.getDeviceID(), streamInfo.getCahnnelId()); | 136 | + DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(streamInfo.getDeviceID(), streamInfo.getChannelId()); |
| 143 | if (deviceChannel != null) { | 137 | if (deviceChannel != null) { |
| 144 | deviceChannel.setStreamId(null); | 138 | deviceChannel.setStreamId(null); |
| 145 | deviceChannel.setDeviceId(streamInfo.getDeviceID()); | 139 | deviceChannel.setDeviceId(streamInfo.getDeviceID()); |
| @@ -148,7 +142,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -148,7 +142,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 148 | return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, | 142 | return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, |
| 149 | streamInfo.getStreamId(), | 143 | streamInfo.getStreamId(), |
| 150 | streamInfo.getDeviceID(), | 144 | streamInfo.getDeviceID(), |
| 151 | - streamInfo.getCahnnelId())); | 145 | + streamInfo.getChannelId())); |
| 152 | } | 146 | } |
| 153 | 147 | ||
| 154 | @Override | 148 | @Override |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
| @@ -93,6 +93,16 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { | @@ -93,6 +93,16 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { | ||
| 93 | } | 93 | } |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | + @Override | ||
| 97 | + public void startPlay(String deviceId, String channelId, String streamId) { | ||
| 98 | + deviceChannelMapper.startPlay(deviceId, channelId, streamId); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + @Override | ||
| 102 | + public void stopPlay(String deviceId, String channelId) { | ||
| 103 | + deviceChannelMapper.stopPlay(deviceId, channelId); | ||
| 104 | + } | ||
| 105 | + | ||
| 96 | /** | 106 | /** |
| 97 | * 获取设备 | 107 | * 获取设备 |
| 98 | * | 108 | * |
src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
| @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; | @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; | ||
| 4 | import com.alibaba.fastjson.JSONArray; | 4 | import com.alibaba.fastjson.JSONArray; |
| 5 | import com.genersoft.iot.vmp.common.StreamInfo; | 5 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 6 | import com.genersoft.iot.vmp.conf.MediaServerConfig; | 6 | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| 7 | +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | ||
| 7 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | 8 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 8 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | 9 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| 9 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | 10 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| @@ -94,6 +95,7 @@ public class PlayController { | @@ -94,6 +95,7 @@ public class PlayController { | ||
| 94 | resultHolder.invokeResult(msg); | 95 | resultHolder.invokeResult(msg); |
| 95 | } else { | 96 | } else { |
| 96 | redisCatchStorage.stopPlay(streamInfo); | 97 | redisCatchStorage.stopPlay(streamInfo); |
| 98 | + storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); | ||
| 97 | cmder.playStreamCmd(device, channelId, (JSONObject response) -> { | 99 | cmder.playStreamCmd(device, channelId, (JSONObject response) -> { |
| 98 | logger.info("收到订阅消息: " + response.toJSONString()); | 100 | logger.info("收到订阅消息: " + response.toJSONString()); |
| 99 | playService.onPublishHandlerForPlay(response, deviceId, channelId, uuid.toString()); | 101 | playService.onPublishHandlerForPlay(response, deviceId, channelId, uuid.toString()); |
| @@ -138,18 +140,17 @@ public class PlayController { | @@ -138,18 +140,17 @@ public class PlayController { | ||
| 138 | msg.setId(DeferredResultHolder.CALLBACK_CMD_PlAY + uuid); | 140 | msg.setId(DeferredResultHolder.CALLBACK_CMD_PlAY + uuid); |
| 139 | msg.setData("streamId not found"); | 141 | msg.setData("streamId not found"); |
| 140 | resultHolder.invokeResult(msg); | 142 | resultHolder.invokeResult(msg); |
| 143 | + }else { | ||
| 141 | redisCatchStorage.stopPlay(streamInfo); | 144 | redisCatchStorage.stopPlay(streamInfo); |
| 145 | + storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); | ||
| 146 | + RequestMessage msg = new RequestMessage(); | ||
| 147 | + msg.setId(DeferredResultHolder.CALLBACK_CMD_STOP + uuid); | ||
| 148 | + Response response = event.getResponse(); | ||
| 149 | + msg.setData(String.format("success")); | ||
| 150 | + resultHolder.invokeResult(msg); | ||
| 142 | } | 151 | } |
| 143 | - | ||
| 144 | - RequestMessage msg = new RequestMessage(); | ||
| 145 | - msg.setId(DeferredResultHolder.CALLBACK_CMD_STOP + uuid); | ||
| 146 | - Response response = event.getResponse(); | ||
| 147 | - msg.setData(String.format("success")); | ||
| 148 | - resultHolder.invokeResult(msg); | ||
| 149 | }); | 152 | }); |
| 150 | 153 | ||
| 151 | - | ||
| 152 | - | ||
| 153 | if (streamId != null) { | 154 | if (streamId != null) { |
| 154 | JSONObject json = new JSONObject(); | 155 | JSONObject json = new JSONObject(); |
| 155 | json.put("streamId", streamId); | 156 | json.put("streamId", streamId); |
| @@ -168,6 +169,7 @@ public class PlayController { | @@ -168,6 +169,7 @@ public class PlayController { | ||
| 168 | // 超时处理 | 169 | // 超时处理 |
| 169 | result.onTimeout(()->{ | 170 | result.onTimeout(()->{ |
| 170 | logger.warn(String.format("设备预览/回放停止超时,streamId:%s ", streamId)); | 171 | logger.warn(String.format("设备预览/回放停止超时,streamId:%s ", streamId)); |
| 172 | + | ||
| 171 | RequestMessage msg = new RequestMessage(); | 173 | RequestMessage msg = new RequestMessage(); |
| 172 | msg.setId(DeferredResultHolder.CALLBACK_CMD_STOP + uuid); | 174 | msg.setId(DeferredResultHolder.CALLBACK_CMD_STOP + uuid); |
| 173 | msg.setData("Timeout"); | 175 | msg.setData("Timeout"); |
src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/PlayServiceImpl.java
| @@ -41,7 +41,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -41,7 +41,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 41 | DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); | 41 | DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); |
| 42 | if (deviceChannel != null) { | 42 | if (deviceChannel != null) { |
| 43 | deviceChannel.setStreamId(streamInfo.getStreamId()); | 43 | deviceChannel.setStreamId(streamInfo.getStreamId()); |
| 44 | - storager.updateChannel(deviceId, deviceChannel); | 44 | + storager.startPlay(deviceId, channelId, streamInfo.getStreamId()); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | redisCatchStorage.startPlay(streamInfo); | 47 | redisCatchStorage.startPlay(streamInfo); |
| @@ -75,7 +75,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -75,7 +75,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 75 | StreamInfo streamInfo = new StreamInfo(); | 75 | StreamInfo streamInfo = new StreamInfo(); |
| 76 | streamInfo.setStreamId(streamId); | 76 | streamInfo.setStreamId(streamId); |
| 77 | streamInfo.setDeviceID(deviceId); | 77 | streamInfo.setDeviceID(deviceId); |
| 78 | - streamInfo.setCahnnelId(channelId); | 78 | + streamInfo.setChannelId(channelId); |
| 79 | MediaServerConfig mediaServerConfig = redisCatchStorage.getMediaInfo(); | 79 | MediaServerConfig mediaServerConfig = redisCatchStorage.getMediaInfo(); |
| 80 | 80 | ||
| 81 | streamInfo.setFlv(String.format("http://%s:%s/rtp/%s.flv", mediaServerConfig.getWanIp(), mediaServerConfig.getHttpPort(), streamId)); | 81 | streamInfo.setFlv(String.format("http://%s:%s/rtp/%s.flv", mediaServerConfig.getWanIp(), mediaServerConfig.getHttpPort(), streamId)); |
src/main/java/com/genersoft/iot/vmp/web/ApiStreamController.java
| @@ -168,6 +168,7 @@ public class ApiStreamController { | @@ -168,6 +168,7 @@ public class ApiStreamController { | ||
| 168 | } | 168 | } |
| 169 | cmder.streamByeCmd(streamInfo.getStreamId()); | 169 | cmder.streamByeCmd(streamInfo.getStreamId()); |
| 170 | redisCatchStorage.stopPlay(streamInfo); | 170 | redisCatchStorage.stopPlay(streamInfo); |
| 171 | + storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); | ||
| 171 | return null; | 172 | return null; |
| 172 | } | 173 | } |
| 173 | 174 |