| | |
| | | * @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); |
| | |
|
| | | /**
|
| | | * 语音广播
|
| | |
| | | }
|
| | |
|
| | | @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) {
|
| | |
| | | } 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) {
|
| | |
| | | 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) {
|