From f9ab13a14590d310937de7d78a36ee599dce750b Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期二, 13 十月 2020 17:16:38 +0800 Subject: [PATCH] 添加通道音频设置 添加media配置 --- src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java | 51 +++++++++++++++++++++++++++++++++------------------ 1 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java index a036fd0..38a6476 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java @@ -80,11 +80,10 @@ String channelId = channel.getChannelId(); HashMap<String, HashSet<String>> channelMap = deviceMap.get(deviceId); if (channelMap == null) return; - // 浣滀负鐖惰澶�, 纭畾鑷繁鐨勫瓙鑺傜偣鏁� if (channelMap.get(channelId) == null) { channelMap.put(channelId, new HashSet<String>()); - }else if (channelMap.get(channelId).size()> 0) { + }else if (channelMap.get(channelId).size() > 0) { channel.setSubCount(channelMap.get(channelId).size()); } @@ -107,7 +106,7 @@ if (!StringUtils.isEmpty(parentId)) { if (channelMap.get(parentId) == null) { - channelMap.put(parentId, new HashSet<>()); + channelMap.put(parentId, new HashSet<String>()); } channelMap.get(parentId).add(channelId); @@ -330,40 +329,54 @@ /** * 寮�濮嬫挱鏀炬椂灏嗘祦瀛樺叆redis * - * @param deviceId 璁惧ID - * @param channelId 閫氶亾ID * @return */ @Override - public boolean startPlay(String deviceId, String channelId, StreamInfo stream) { - return redis.set(String.format("%S_%s_%s", VideoManagerConstants.PLAYER_PREFIX, deviceId, channelId), + public boolean startPlay(StreamInfo stream) { + return redis.set(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, stream.getSsrc(),stream.getDeviceID(), stream.getCahnnelId()), stream); } /** * 鍋滄鎾斁鏃朵粠redis鍒犻櫎 * - * @param deviceId 璁惧ID - * @param channelId 閫氶亾ID * @return */ @Override - public boolean stopPlay(String deviceId, String channelId) { - return redis.del(String.format("%S_%s_%s", VideoManagerConstants.PLAYER_PREFIX, deviceId, channelId)); + public boolean stopPlay(StreamInfo streamInfo) { + if (streamInfo == null) return false; + return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, + streamInfo.getSsrc(), + streamInfo.getDeviceID(), + streamInfo.getCahnnelId())); } /** * 鏌ヨ鎾斁鍒楄〃 - * @param deviceId 璁惧ID - * @param channelId 閫氶亾ID * @return */ @Override - public StreamInfo queryPlay(String deviceId, String channelId) { - return (StreamInfo)redis.get(String.format("%S_%s_%s", VideoManagerConstants.PLAYER_PREFIX, deviceId, channelId)); + public StreamInfo queryPlay(StreamInfo streamInfo) { + return (StreamInfo)redis.get(String.format("%S_%s_%s_%s", + VideoManagerConstants.PLAYER_PREFIX, + streamInfo.getSsrc(), + streamInfo.getDeviceID(), + streamInfo.getCahnnelId())); + } + @Override + public StreamInfo queryPlayBySSRC(String ssrc) { + List<Object> playLeys = redis.keys(String.format("%S_%s_*", VideoManagerConstants.PLAYER_PREFIX, ssrc)); + if (playLeys.size() == 0) return null; + return (StreamInfo)redis.get(playLeys.get(0).toString()); } - + @Override + public StreamInfo queryPlayByDevice(String deviceId, String code) { + List<Object> playLeys = redis.keys(String.format("%S_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX, + deviceId, + code)); + return (StreamInfo)redis.get(playLeys.get(0).toString()); + } /** * 鏇存柊娴佸獟浣撲俊鎭� @@ -404,11 +417,10 @@ if (subChannel == null) { subChannel = new HashSet<>(); } - if ("null".equals(s[6])) { + if (!"null".equals(s[6])) { subChannel.add(s[6]); } channelMap.put(channelId, subChannel); - System.out.println(); } } deviceMap.put(device.getDeviceId(),channelMap); @@ -425,4 +437,7 @@ } } } + + + } -- Gitblit v1.8.0