添加国标级联录像控制功能

This commit is contained in:
mk1990 2022-06-22 16:26:41 +08:00
parent 7643c7f18d
commit b9aca76599
3 changed files with 2465 additions and 2428 deletions

View File

@ -150,7 +150,7 @@ public interface ISIPCommander {
* @param streamInfo
* @param content
*/
void playbackControlCmd(Device device, StreamInfo streamInfo, String content);
void playbackControlCmd(Device device, StreamInfo streamInfo, String content,SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent);
/**
* 语音广播

View File

@ -1830,7 +1830,7 @@ public class SIPCommander implements ISIPCommander {
}
@Override
public void playbackControlCmd(Device device, StreamInfo streamInfo, String content) {
public void playbackControlCmd(Device device, StreamInfo streamInfo, String content,SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) {
try {
Request request = headerProvider.createInfoRequest(device, streamInfo, content);
if (request == null) {
@ -1843,7 +1843,22 @@ public class SIPCommander implements ISIPCommander {
} else if ("UDP".equals(device.getTransport())) {
clientTransaction = udpSipProvider.getNewClientTransaction(request);
}
CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME);
if(errorEvent != null) {
sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (eventResult -> {
errorEvent.response(eventResult);
sipSubscribe.removeErrorSubscribe(eventResult.callId);
sipSubscribe.removeOkSubscribe(eventResult.callId);
}));
}
if(okEvent != null) {
sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), eventResult -> {
okEvent.response(eventResult);
sipSubscribe.removeOkSubscribe(eventResult.callId);
sipSubscribe.removeErrorSubscribe(eventResult.callId);
});
}
clientTransaction.sendRequest();
} catch (SipException | ParseException | InvalidArgumentException e) {

View File

@ -105,7 +105,29 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I
return;
}
Device device1 = storager.queryVideoDevice(streamInfo.getDeviceID());
cmder.playbackControlCmd(device1,streamInfo,new String(evt.getRequest().getRawContent()));
cmder.playbackControlCmd(device1,streamInfo,new String(evt.getRequest().getRawContent()),eventResult -> {
// 失败的回复
try {
responseAck(evt, eventResult.statusCode, eventResult.msg);
} catch (SipException e) {
e.printStackTrace();
} catch (InvalidArgumentException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
}, eventResult -> {
// 成功的回复
try {
responseAck(evt, eventResult.statusCode);
} catch (SipException e) {
e.printStackTrace();
} catch (InvalidArgumentException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
});
}
}
} catch (SipException e) {