mirror of https://github.com/swwheihei/wvp.git
添加播放 ssrc缓存
parent
956fd47ed6
commit
2246ffa187
|
@ -1,5 +1,6 @@
|
||||||
package com.genersoft.iot.vmp.gb28181.session;
|
package com.genersoft.iot.vmp.gb28181.session;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import javax.sip.ClientTransaction;
|
import javax.sip.ClientTransaction;
|
||||||
|
@ -16,6 +17,8 @@ public class VideoStreamSessionManager {
|
||||||
|
|
||||||
private ConcurrentHashMap<String, ClientTransaction> sessionMap = new ConcurrentHashMap<>();
|
private ConcurrentHashMap<String, ClientTransaction> sessionMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
private ConcurrentHashMap<String, String> deviceSessionMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public String createPlaySsrc(){
|
public String createPlaySsrc(){
|
||||||
String ssrc = SsrcUtil.getPlaySsrc();
|
String ssrc = SsrcUtil.getPlaySsrc();
|
||||||
return ssrc;
|
return ssrc;
|
||||||
|
@ -33,9 +36,29 @@ public class VideoStreamSessionManager {
|
||||||
public ClientTransaction get(String ssrc){
|
public ClientTransaction get(String ssrc){
|
||||||
return sessionMap.get(ssrc);
|
return sessionMap.get(ssrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(String ssrc) {
|
public void remove(String ssrc) {
|
||||||
sessionMap.remove(ssrc);
|
sessionMap.remove(ssrc);
|
||||||
SsrcUtil.releaseSsrc(ssrc);
|
SsrcUtil.releaseSsrc(ssrc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止播放 删除device-ssr关联
|
||||||
|
*/
|
||||||
|
Collection<String> col = deviceSessionMap.values();
|
||||||
|
while (true == col.contains(ssrc)) {
|
||||||
|
col.remove(ssrc);
|
||||||
|
}
|
||||||
|
System.out.println(deviceSessionMap);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void putDevice(String deviceAndChannel,String ssrc){
|
||||||
|
deviceSessionMap.put(deviceAndChannel, ssrc);
|
||||||
|
}
|
||||||
|
public String getSsrcByDevice(String deviceAndChannel){
|
||||||
|
return deviceSessionMap.get(deviceAndChannel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeDevice(String deviceAndChannel) {
|
||||||
|
deviceSessionMap.remove(deviceAndChannel);
|
||||||
|
}
|
||||||
|
}
|
|
@ -223,7 +223,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
ClientTransaction transaction = transmitRequest(device, request);
|
ClientTransaction transaction = transmitRequest(device, request);
|
||||||
streamSession.put(ssrc, transaction);
|
streamSession.put(ssrc, transaction);
|
||||||
return ssrc;
|
streamSession.putDevice("0"+device.getDeviceId()+channelId,ssrc); return ssrc;
|
||||||
} catch ( SipException | ParseException | InvalidArgumentException e) {
|
} catch ( SipException | ParseException | InvalidArgumentException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
|
@ -271,6 +271,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
ClientTransaction transaction = transmitRequest(device, request);
|
ClientTransaction transaction = transmitRequest(device, request);
|
||||||
streamSession.put(ssrc, transaction);
|
streamSession.put(ssrc, transaction);
|
||||||
|
streamSession.putDevice("1"+device.getDeviceId()+channelId,ssrc);
|
||||||
return ssrc;
|
return ssrc;
|
||||||
} catch ( SipException | ParseException | InvalidArgumentException e) {
|
} catch ( SipException | ParseException | InvalidArgumentException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -553,4 +554,19 @@ public class SIPCommander implements ISIPCommander {
|
||||||
return clientTransaction;
|
return clientTransaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除缓存的ssrc
|
||||||
|
* @param ssrc
|
||||||
|
*/
|
||||||
|
public void remove(String ssrc){
|
||||||
|
streamSession.remove(ssrc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getPlaySsrcByDevice(String deviceId,String channelId){
|
||||||
|
return streamSession.getSsrcByDevice("0"+deviceId+channelId);
|
||||||
|
}
|
||||||
|
/*public String getPlaybackSsrcByDevice(String deviceId,String channelId){
|
||||||
|
return streamSession.getSsrcByDevice("1"+deviceId+channelId);
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue