| | |
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.concurrent.ConcurrentHashMap;
|
| | |
|
| | | import javax.sip.ClientTransaction;
|
| | | import javax.sip.Dialog;
|
| | | import javax.sip.message.Request;
|
| | |
|
| | | import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
| | | import com.genersoft.iot.vmp.conf.UserSetup;
|
| | | import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
|
| | | import com.genersoft.iot.vmp.service.IMediaServerService;
|
| | | import com.genersoft.iot.vmp.utils.SerializeUtils;
|
| | | import com.genersoft.iot.vmp.utils.redis.JedisUtil;
|
| | | import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
| | | import gov.nist.javax.sip.stack.SIPDialog;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.data.redis.core.RedisTemplate;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | /**
|
| | | * @Description:视频流session管理器,管理视频预览、预览回放的通信句柄 |
| | | * @description:视频流session管理器,管理视频预览、预览回放的通信句柄 |
| | | * @author: swwheihei
|
| | | * @date: 2020年5月13日 下午4:03:02
|
| | | */
|
| | |
| | |
|
| | | @Autowired
|
| | | private RedisUtil redisUtil;
|
| | |
|
| | | @Autowired
|
| | | private UserSetup userSetup;
|
| | |
|
| | | public void put(String deviceId, String channelId ,String ssrc, String streamId, String mediaServerId, ClientTransaction transaction){
|
| | | SsrcTransaction ssrcTransaction = new SsrcTransaction();
|
| | |
| | | ssrcTransaction.setSsrc(ssrc);
|
| | | ssrcTransaction.setMediaServerId(mediaServerId);
|
| | |
|
| | | redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + deviceId + "_" + channelId, ssrcTransaction);
|
| | | redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_" + deviceId + "_" + channelId, ssrcTransaction);
|
| | | }
|
| | |
|
| | | public void put(String deviceId, String channelId , Dialog dialog){
|
| | |
| | | byte[] dialogByteArray = SerializeUtils.serialize(dialog);
|
| | | ssrcTransaction.setDialog(dialogByteArray);
|
| | | }
|
| | | redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + deviceId + "_" + channelId, ssrcTransaction);
|
| | | redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_" + deviceId + "_" + channelId, ssrcTransaction);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | }
|
| | |
|
| | | public SsrcTransaction getSsrcTransaction(String deviceId, String channelId){
|
| | | SsrcTransaction ssrcTransaction = (SsrcTransaction)redisUtil.get(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + deviceId + "_" + channelId);
|
| | | SsrcTransaction ssrcTransaction = (SsrcTransaction)redisUtil.get(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_" + deviceId + "_" + channelId);
|
| | | return ssrcTransaction;
|
| | | }
|
| | |
|
| | |
| | | public void remove(String deviceId, String channelId) {
|
| | | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId);
|
| | | if (ssrcTransaction == null) return;
|
| | | redisUtil.del(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + deviceId + "_" + channelId);
|
| | | redisUtil.del(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_" + deviceId + "_" + channelId);
|
| | | }
|
| | |
|
| | | public List<SsrcTransaction> getAllSsrc() {
|
| | | List<Object> ssrcTransactionKeys = redisUtil.scan(String.format("%s_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX));
|
| | | List<Object> ssrcTransactionKeys = redisUtil.scan(String.format("%s_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetup.getServerId() + "_" ));
|
| | | List<SsrcTransaction> result= new ArrayList<>();
|
| | | for (int i = 0; i < ssrcTransactionKeys.size(); i++) {
|
| | | String key = (String)ssrcTransactionKeys.get(i);
|