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

pull/530/head
mk1990 2022-06-22 16:26:41 +08:00
parent 6c919937bd
commit 4b4afa4ef7
3 changed files with 2465 additions and 2428 deletions

View File

@ -150,7 +150,7 @@ public interface ISIPCommander {
* @param streamInfo * @param streamInfo
* @param content * @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 @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 { try {
Request request = headerProvider.createInfoRequest(device, streamInfo, content); Request request = headerProvider.createInfoRequest(device, streamInfo, content);
if (request == null) { if (request == null) {
@ -1843,7 +1843,22 @@ public class SIPCommander implements ISIPCommander {
} else if ("UDP".equals(device.getTransport())) { } else if ("UDP".equals(device.getTransport())) {
clientTransaction = udpSipProvider.getNewClientTransaction(request); 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(); clientTransaction.sendRequest();
} catch (SipException | ParseException | InvalidArgumentException e) { } catch (SipException | ParseException | InvalidArgumentException e) {

View File

@ -105,7 +105,29 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I
return; return;
} }
Device device1 = storager.queryVideoDevice(streamInfo.getDeviceID()); 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) { } catch (SipException e) {