Merge remote-tracking branch 'origin/master' into wvp-28181-2.0

# Conflicts:
#	src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
This commit is contained in:
panlinlin
2021-01-08 17:31:49 +08:00
10 changed files with 110 additions and 53 deletions

View File

@@ -47,6 +47,21 @@ public interface IVideoManagerStorager {
* @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);
/**
* 获取设备

View File

@@ -1,7 +1,6 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import org.apache.ibatis.annotations.*;
import java.util.List;
@@ -78,6 +77,9 @@ public interface DeviceChannelMapper {
@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);
}

View File

@@ -35,7 +35,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
*/
@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);
}
@@ -47,16 +47,10 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@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()));
}
/**
@@ -69,7 +63,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
VideoManagerConstants.PLAYER_PREFIX,
streamInfo.getStreamId(),
streamInfo.getDeviceID(),
streamInfo.getCahnnelId()));
streamInfo.getChannelId()));
}
@Override
public StreamInfo queryPlayByStreamId(String steamId) {
@@ -123,7 +117,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
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;
}
@@ -131,7 +125,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@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);
}
@@ -139,7 +133,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@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());
@@ -148,7 +142,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
streamInfo.getStreamId(),
streamInfo.getDeviceID(),
streamInfo.getCahnnelId()));
streamInfo.getChannelId()));
}
@Override

View File

@@ -93,6 +93,16 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
}
}
@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);
}
/**
* 获取设备
*