Skip to content

Commit

Permalink
Merge pull request #23 from lunasaw/dev_1.1.4
Browse files Browse the repository at this point in the history
Dev 1.1.4
  • Loading branch information
lunasaw authored Dec 25, 2023
2 parents b68724a + 02cada7 commit e1ff28b
Show file tree
Hide file tree
Showing 146 changed files with 1,518 additions and 603 deletions.
7 changes: 6 additions & 1 deletion gb28181-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.lunasaw</groupId>
<artifactId>sip-proxy</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent>

<version>${gb28181-proxy.version}</version>
Expand All @@ -27,6 +27,11 @@
<groupId>io.github.lunasaw</groupId>
<artifactId>sip-common</artifactId>
</dependency>

<dependency>
<groupId>io.github.lunasaw</groupId>
<artifactId>gb28181-common</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.Map;

import io.github.lunasaw.gbproxy.client.transmit.request.message.MessageClientHandlerAbstract;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
Expand All @@ -11,7 +10,9 @@
import org.springframework.stereotype.Component;

import io.github.lunasaw.gbproxy.client.transmit.request.message.ClientMessageRequestProcessor;
import io.github.lunasaw.sip.common.transmit.event.message.MessageHandler;
import io.github.lunasaw.gbproxy.client.transmit.request.message.MessageClientHandlerAbstract;
import io.github.lunasaw.gbproxy.client.transmit.request.subscribe.ClientSubscribeRequestProcessor;
import io.github.lunasaw.gbproxy.client.transmit.request.subscribe.SubscribeClientHandlerAbstract;
import lombok.extern.slf4j.Slf4j;

/**
Expand All @@ -29,6 +30,10 @@ public class SipProxyClientAutoConfig implements InitializingBean, ApplicationCo
public void afterPropertiesSet() {
Map<String, MessageClientHandlerAbstract> clientMessageHandlerMap = applicationContext.getBeansOfType(MessageClientHandlerAbstract.class);
clientMessageHandlerMap.forEach((k, v) -> ClientMessageRequestProcessor.addHandler(v));

Map<String, SubscribeClientHandlerAbstract> clientSubscribeHandlerMap =
applicationContext.getBeansOfType(SubscribeClientHandlerAbstract.class);
clientSubscribeHandlerMap.forEach((k, v) -> ClientSubscribeRequestProcessor.addHandler(v));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.lunasaw.gbproxy.client.entity;

import io.github.lunasaw.sip.common.enums.InviteSessionNameEnum;
import io.github.lunasaw.gb28181.common.entity.enums.InviteSessionNameEnum;
import lombok.Getter;
import lombok.Setter;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.github.lunasaw.gbproxy.client.eventbus.event.subscribe;

import org.springframework.context.ApplicationEvent;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class CatalogEvent extends ApplicationEvent {
public CatalogEvent(Object source) {
super(source);
}

/**
* 上线
*/
public static final String ON = "ON";

/**
* 离线
*/
public static final String OFF = "OFF";

/**
* 视频丢失
*/
public static final String VIDEO_LOST = "VIDEO_LOST";

/**
* 故障
*/
public static final String DEFECT = "DEFECT";

/**
* 增加
*/
public static final String ADD = "ADD";

/**
* 删除
*/
public static final String DEL = "DEL";

/**
* 更新
*/
public static final String UPDATE = "UPDATE";

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import com.luna.common.check.Assert;
import com.luna.common.text.RandomStrUtil;

import io.github.lunasaw.sip.common.entity.DeviceAlarm;
import io.github.lunasaw.gb28181.common.entity.DeviceAlarm;
import io.github.lunasaw.sip.common.entity.FromDevice;
import io.github.lunasaw.sip.common.entity.ToDevice;
import io.github.lunasaw.sip.common.entity.notify.*;
import io.github.lunasaw.sip.common.entity.response.*;
import io.github.lunasaw.sip.common.enums.CmdTypeEnum;
import io.github.lunasaw.gb28181.common.entity.notify.*;
import io.github.lunasaw.gb28181.common.entity.response.*;
import io.github.lunasaw.gb28181.common.entity.enums.CmdTypeEnum;
import io.github.lunasaw.sip.common.subscribe.SubscribeInfo;
import io.github.lunasaw.sip.common.transmit.SipSender;
import io.github.lunasaw.sip.common.transmit.event.Event;
Expand All @@ -29,7 +29,7 @@ public class ClientSendCmd {
* @return
*/
public static String deviceAlarmNotify(FromDevice fromDevice, ToDevice toDevice, DeviceAlarmNotify deviceAlarmNotify) {
return SipSender.doMessageRequest(fromDevice, toDevice, deviceAlarmNotify);
return SipSender.doMessageRequest(fromDevice, toDevice, deviceAlarmNotify.toString());
}

/**
Expand All @@ -45,7 +45,7 @@ public static String deviceAlarmNotify(FromDevice fromDevice, ToDevice toDevice,

deviceAlarmNotify.setAlarm(deviceAlarm);

return SipSender.doMessageRequest(fromDevice, toDevice, deviceAlarmNotify);
return SipSender.doMessageRequest(fromDevice, toDevice, deviceAlarmNotify.toString());
}

/**
Expand All @@ -70,7 +70,7 @@ public static String deviceKeepLiveNotify(FromDevice fromDevice, ToDevice toDevi

deviceKeepLiveNotify.setStatus(status);

return SipSender.doMessageRequest(fromDevice, toDevice, deviceKeepLiveNotify, errorEvent, okEvent);
return SipSender.doMessageRequest(fromDevice, toDevice, deviceKeepLiveNotify.toString(), errorEvent, okEvent);
}

/**
Expand All @@ -82,7 +82,7 @@ public static String deviceKeepLiveNotify(FromDevice fromDevice, ToDevice toDevi
* @return
*/
public static String deviceChannelCatalogResponse(FromDevice fromDevice, ToDevice toDevice, DeviceResponse deviceResponse) {
return SipSender.doMessageRequest(fromDevice, toDevice, deviceResponse);
return SipSender.doMessageRequest(fromDevice, toDevice, deviceResponse.toString());
}

public static String deviceChannelCatalogResponse(FromDevice fromDevice, ToDevice toDevice, List<DeviceItem> deviceItems, String sn) {
Expand Down Expand Up @@ -120,7 +120,7 @@ public static String deviceInfoResponse(FromDevice fromDevice, ToDevice toDevice

deviceInfo.setCmdType(CmdTypeEnum.DEVICE_INFO.getType());
deviceInfo.setSn(RandomStrUtil.getValidationCode());
return SipSender.doMessageRequest(fromDevice, toDevice, deviceInfo);
return SipSender.doMessageRequest(fromDevice, toDevice, deviceInfo.toString());
}

/**
Expand All @@ -138,7 +138,7 @@ public static String deviceStatusResponse(FromDevice fromDevice, ToDevice toDevi

deviceStatus.setOnline(online);

return SipSender.doMessageRequest(fromDevice, toDevice, deviceStatus);
return SipSender.doMessageRequest(fromDevice, toDevice, deviceStatus.toString());
}

/**
Expand All @@ -154,7 +154,7 @@ public static String MobilePositionNotify(FromDevice fromDevice, ToDevice toDevi
mobilePositionNotify.setCmdType(CmdTypeEnum.DEVICE_INFO.getType());
mobilePositionNotify.setSn(RandomStrUtil.getValidationCode());
mobilePositionNotify.setDeviceId(fromDevice.getUserId());
return SipSender.doNotifyRequest(fromDevice, toDevice, mobilePositionNotify, subscribeInfo);
return SipSender.doNotifyRequest(fromDevice, toDevice, mobilePositionNotify.toString(), subscribeInfo);
}

/**
Expand All @@ -173,7 +173,7 @@ public static String deviceChannelUpdateCatlog(FromDevice fromDevice, ToDevice t
deviceUpdateNotify.setSumNum(deviceItems.size());
deviceUpdateNotify.setDeviceItemList(deviceItems);

return SipSender.doNotifyRequest(fromDevice, toDevice, deviceUpdateNotify, subscribeInfo);
return SipSender.doNotifyRequest(fromDevice, toDevice, deviceUpdateNotify.toString(), subscribeInfo);
}

/**
Expand All @@ -192,7 +192,7 @@ public static String deviceOtherUpdateCatlog(FromDevice fromDevice, ToDevice toD
deviceUpdateNotify.setSumNum(deviceItems.size());
deviceUpdateNotify.setDeviceItemList(deviceItems);

return SipSender.doNotifyRequest(fromDevice, toDevice, deviceUpdateNotify, subscribeInfo);
return SipSender.doNotifyRequest(fromDevice, toDevice, deviceUpdateNotify.toString(), subscribeInfo);
}

/**
Expand All @@ -205,7 +205,7 @@ public static String deviceOtherUpdateCatlog(FromDevice fromDevice, ToDevice toD
*/
public static String deviceRecordResponse(FromDevice fromDevice, ToDevice toDevice, DeviceRecord deviceRecord) {

return SipSender.doMessageRequest(fromDevice, toDevice, deviceRecord);
return SipSender.doMessageRequest(fromDevice, toDevice, deviceRecord.toString());
}

/**
Expand Down Expand Up @@ -235,7 +235,7 @@ public static String deviceRecordResponse(FromDevice fromDevice, ToDevice toDevi
* @return
*/
public static String deviceConfigResponse(FromDevice fromDevice, ToDevice toDevice, DeviceConfigResponse deviceConfigResponse) {
return SipSender.doMessageRequest(fromDevice, toDevice, deviceConfigResponse);
return SipSender.doMessageRequest(fromDevice, toDevice, deviceConfigResponse.toString());
}

public static String deviceConfigResponse(FromDevice fromDevice, ToDevice toDevice, DeviceConfigResponse.BasicParam basicParam) {
Expand All @@ -262,7 +262,7 @@ public static String deviceMediaStatusNotify(FromDevice fromDevice, ToDevice toD

mediaStatusNotify.setNotifyType(notifyType);

return SipSender.doMessageRequest(fromDevice, toDevice, mediaStatusNotify);
return SipSender.doMessageRequest(fromDevice, toDevice, mediaStatusNotify.toString());
}

/**
Expand Down Expand Up @@ -307,6 +307,10 @@ public static String deviceRegister(FromDevice fromDevice, ToDevice toDevice, In
return SipSender.doRegisterRequest(fromDevice, toDevice, expires);
}

public static String deviceRegister(FromDevice fromDevice, ToDevice toDevice, Integer expires, Event event) {
return SipSender.doRegisterRequest(fromDevice, toDevice, expires, event);
}

/**
* 设备注销
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io.github.lunasaw.gbproxy.client.entity.InviteResponseEntity;
import io.github.lunasaw.sip.common.entity.GbSessionDescription;
import io.github.lunasaw.sip.common.entity.SdpSessionDescription;
import io.github.lunasaw.sip.common.enums.InviteSessionNameEnum;
import io.github.lunasaw.gb28181.common.entity.enums.InviteSessionNameEnum;
import io.github.lunasaw.sip.common.service.SipUserGenerate;
import lombok.SneakyThrows;
import org.apache.commons.collections4.CollectionUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
import javax.sip.header.ContentTypeHeader;
import javax.sip.message.Response;

import org.springframework.stereotype.Component;

import gov.nist.javax.sip.message.SIPRequest;
import io.github.lunasaw.sip.common.entity.*;
import io.github.lunasaw.sip.common.entity.GbSessionDescription;
import io.github.lunasaw.sip.common.entity.Device;
import io.github.lunasaw.sip.common.entity.FromDevice;
import io.github.lunasaw.sip.common.enums.ContentTypeEnum;
import io.github.lunasaw.sip.common.transmit.ResponseCmd;
import io.github.lunasaw.sip.common.utils.SipUtils;
import org.springframework.stereotype.Component;

import io.github.lunasaw.sip.common.transmit.event.request.SipRequestProcessorAbstract;
import io.github.lunasaw.sip.common.utils.SipUtils;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import gov.nist.javax.sip.message.SIPRequest;
import io.github.lunasaw.sip.common.entity.FromDevice;
import io.github.lunasaw.sip.common.transmit.event.request.SipMessageRequestProcessorAbstract;
import io.github.lunasaw.sip.common.transmit.event.message.SipMessageRequestProcessorAbstract;
import io.github.lunasaw.sip.common.utils.SipUtils;
import lombok.Getter;
import lombok.Setter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.github.lunasaw.gbproxy.client.transmit.request.message;

import gov.nist.javax.sip.message.SIPRequest;
import io.github.lunasaw.sip.common.entity.base.DeviceSession;
import io.github.lunasaw.gb28181.common.entity.base.DeviceSession;
import io.github.lunasaw.sip.common.transmit.event.message.MessageHandlerAbstract;
import io.github.lunasaw.sip.common.utils.SipUtils;
import lombok.Data;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
Expand All @@ -20,7 +21,7 @@ public abstract class MessageClientHandlerAbstract extends MessageHandlerAbstrac
@Resource
public MessageProcessorClient messageProcessorClient;

public MessageClientHandlerAbstract(MessageProcessorClient messageProcessorClient) {
public MessageClientHandlerAbstract(@Lazy MessageProcessorClient messageProcessorClient) {
this.messageProcessorClient = messageProcessorClient;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package io.github.lunasaw.gbproxy.client.transmit.request.message;

import io.github.lunasaw.gb28181.common.entity.response.*;
import io.github.lunasaw.gbproxy.client.transmit.request.message.handler.notify.BroadcastNotifyMessageHandler;
import io.github.lunasaw.gbproxy.client.transmit.request.message.handler.query.CatalogQueryMessageClientHandler;
import io.github.lunasaw.gbproxy.client.transmit.request.message.handler.query.DeviceInfoQueryMessageClientHandler;
import io.github.lunasaw.gbproxy.client.transmit.request.message.handler.query.DeviceStatusQueryMessageClientHandler;
import io.github.lunasaw.sip.common.entity.control.DeviceControlBase;
import io.github.lunasaw.sip.common.entity.notify.DeviceAlarmNotify;
import io.github.lunasaw.sip.common.entity.notify.DeviceBroadcastNotify;
import io.github.lunasaw.sip.common.entity.query.DeviceAlarmQuery;
import io.github.lunasaw.sip.common.entity.query.DeviceConfigDownload;
import io.github.lunasaw.sip.common.entity.query.DeviceRecordQuery;
import io.github.lunasaw.sip.common.entity.response.*;
import io.github.lunasaw.gb28181.common.entity.notify.DeviceAlarmNotify;
import io.github.lunasaw.gb28181.common.entity.notify.DeviceBroadcastNotify;
import io.github.lunasaw.gb28181.common.entity.query.DeviceAlarmQuery;
import io.github.lunasaw.gb28181.common.entity.query.DeviceConfigDownload;
import io.github.lunasaw.gb28181.common.entity.query.DeviceRecordQuery;
import io.github.lunasaw.sip.common.service.SipUserGenerate;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import io.github.lunasaw.gbproxy.client.transmit.request.message.MessageClientHandlerAbstract;
import io.github.lunasaw.gbproxy.client.transmit.request.message.MessageProcessorClient;
import io.github.lunasaw.sip.common.entity.FromDevice;
import io.github.lunasaw.sip.common.entity.base.DeviceSession;
import io.github.lunasaw.sip.common.enums.DeviceControlType;
import io.github.lunasaw.gb28181.common.entity.enums.DeviceControlType;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import javax.sip.RequestEvent;

import io.github.lunasaw.sip.common.entity.FromDevice;
import io.github.lunasaw.sip.common.entity.base.DeviceSession;
import io.github.lunasaw.sip.common.entity.notify.DeviceBroadcastNotify;
import io.github.lunasaw.gb28181.common.entity.base.DeviceSession;
import io.github.lunasaw.gb28181.common.entity.notify.DeviceBroadcastNotify;
import org.springframework.stereotype.Component;

import io.github.lunasaw.gbproxy.client.transmit.request.message.MessageClientHandlerAbstract;
Expand Down Expand Up @@ -43,6 +43,9 @@ public void handForEvt(RequestEvent event) {

// 设备查询
FromDevice fromDevice = (FromDevice) messageProcessorClient.getFromDevice();
if (fromDevice == null || !fromDevice.getUserId().equals(userId)) {
throw new RuntimeException("查询设备失败");
}

DeviceBroadcastNotify broadcastNotify = parseXml(DeviceBroadcastNotify.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import io.github.lunasaw.gbproxy.client.transmit.request.message.MessageClientHandlerAbstract;
import io.github.lunasaw.sip.common.entity.FromDevice;
import io.github.lunasaw.sip.common.entity.ToDevice;
import io.github.lunasaw.sip.common.entity.base.DeviceSession;
import io.github.lunasaw.sip.common.entity.notify.DeviceAlarmNotify;
import io.github.lunasaw.sip.common.entity.query.DeviceAlarmQuery;
import io.github.lunasaw.gb28181.common.entity.base.DeviceSession;
import io.github.lunasaw.gb28181.common.entity.notify.DeviceAlarmNotify;
import io.github.lunasaw.gb28181.common.entity.query.DeviceAlarmQuery;
import org.springframework.stereotype.Component;

import io.github.lunasaw.gbproxy.client.transmit.request.message.MessageProcessorClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import javax.sip.RequestEvent;

import io.github.lunasaw.sip.common.entity.response.DeviceResponse;
import io.github.lunasaw.gb28181.common.entity.response.DeviceResponse;
import lombok.Setter;
import org.springframework.stereotype.Component;

Expand All @@ -11,8 +11,8 @@
import io.github.lunasaw.gbproxy.client.transmit.request.message.MessageProcessorClient;
import io.github.lunasaw.sip.common.entity.FromDevice;
import io.github.lunasaw.sip.common.entity.ToDevice;
import io.github.lunasaw.sip.common.entity.base.DeviceSession;
import io.github.lunasaw.sip.common.entity.query.DeviceQuery;
import io.github.lunasaw.gb28181.common.entity.base.DeviceSession;
import io.github.lunasaw.gb28181.common.entity.query.DeviceQuery;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

Expand Down
Loading

0 comments on commit e1ff28b

Please sign in to comment.