| | |
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.beans.factory.annotation.Qualifier;
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.context.annotation.ComponentScan;
|
| | | import org.springframework.context.annotation.DependsOn;
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.stereotype.Component;
|
| | |
| | | public class SIPCommander implements ISIPCommander {
|
| | |
|
| | | private final Logger logger = LoggerFactory.getLogger(SIPCommander.class);
|
| | |
|
| | |
|
| | | |
| | | @Autowired
|
| | | private SipConfig sipConfig;
|
| | |
|
| | |
| | | @Autowired
|
| | | private SipSubscribe sipSubscribe;
|
| | |
|
| | |
|
| | | public SipConfig getSipConfig() {
|
| | | return sipConfig;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 云台方向放控制,使用配置文件中的默认镜头移动速度
|
| | |
| | | @Override
|
| | | public void playStreamCmd(Device device, String channelId, ZLMHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent) {
|
| | | try {
|
| | |
|
| | | if (device == null) return;
|
| | | String ssrc = streamSession.createPlaySsrc();
|
| | | String streamId = null;
|
| | | if (rtpEnable) {
|
| | |
| | | */
|
| | | @Override
|
| | | public boolean audioBroadcastCmd(Device device, String channelId) {
|
| | | // TODO Auto-generated method stub
|
| | | // 改为新的实现
|
| | | return false;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 语音广播
|
| | | * |
| | | * @param device 视频设备
|
| | | * @param channelId 预览通道
|
| | | */
|
| | | @Override
|
| | | public boolean audioBroadcastCmd(Device device) {
|
| | | try {
|
| | | StringBuffer broadcastXml = new StringBuffer(200);
|
| | | broadcastXml.append("<?xml version=\"1.0\" ?>\r\n");
|
| | | broadcastXml.append("<Notify>\r\n");
|
| | | broadcastXml.append("<CmdType>Broadcast</CmdType>\r\n");
|
| | | broadcastXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
|
| | | broadcastXml.append("<SourceID>" + sipConfig.getSipId() + "</SourceID>\r\n");
|
| | | broadcastXml.append("<TargetID>" + device.getDeviceId() + "</TargetID>\r\n");
|
| | | broadcastXml.append("</Notify>\r\n");
|
| | | |
| | | String tm = Long.toString(System.currentTimeMillis());
|
| | | |
| | | CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
|
| | | : udpSipProvider.getNewCallId();
|
| | | |
| | | Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), "z9hG4bK-ViaBcst-" + tm, "FromBcst" + tm, null, callIdHeader);
|
| | | transmitRequest(device, request);
|
| | | return true;
|
| | | } catch (SipException | ParseException | InvalidArgumentException e) {
|
| | | e.printStackTrace();
|
| | | } |
| | | return false;
|
| | | }
|
| | | @Override
|
| | | public void audioBroadcastCmd(Device device, SipSubscribe.Event errorEvent) {
|
| | | try {
|
| | | StringBuffer broadcastXml = new StringBuffer(200);
|
| | | broadcastXml.append("<?xml version=\"1.0\" ?>\r\n");
|
| | | broadcastXml.append("<Notify>\r\n");
|
| | | broadcastXml.append("<CmdType>Broadcast</CmdType>\r\n");
|
| | | broadcastXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
|
| | | broadcastXml.append("<SourceID>" + sipConfig.getSipId() + "</SourceID>\r\n");
|
| | | broadcastXml.append("<TargetID>" + device.getDeviceId() + "</TargetID>\r\n");
|
| | | broadcastXml.append("</Notify>\r\n");
|
| | | |
| | | String tm = Long.toString(System.currentTimeMillis());
|
| | |
|
| | | CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
|
| | | : udpSipProvider.getNewCallId();
|
| | | |
| | | Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), "z9hG4bK-ViaBcst-" + tm, "FromBcst" + tm, null, callIdHeader);
|
| | | transmitRequest(device, request, errorEvent);
|
| | | } catch (SipException | ParseException | InvalidArgumentException e) {
|
| | | e.printStackTrace();
|
| | | } |
| | | } |
| | | |
| | | |
| | | /**
|
| | | * 音视频录像控制
|
| | | *
|
| | | * @param device 视频设备
|