调整通用点播RPC调用
parent
ca9b5c2054
commit
541726a43c
|
@ -0,0 +1,101 @@
|
||||||
|
package com.genersoft.iot.vmp.service.redisMsg.control;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||||
|
import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig;
|
||||||
|
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage;
|
||||||
|
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest;
|
||||||
|
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.session.SSRCFactory;
|
||||||
|
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||||
|
import com.genersoft.iot.vmp.media.event.hook.Hook;
|
||||||
|
import com.genersoft.iot.vmp.media.event.hook.HookSubscribe;
|
||||||
|
import com.genersoft.iot.vmp.media.event.hook.HookType;
|
||||||
|
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||||
|
import com.genersoft.iot.vmp.service.ISendRtpServerService;
|
||||||
|
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
|
||||||
|
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController;
|
||||||
|
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
|
||||||
|
import javax.sip.message.Response;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RedisRpcController("chanel")
|
||||||
|
public class RedisRpcChannelPlayController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SSRCFactory ssrcFactory;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMediaServerService mediaServerService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISendRtpServerService sendRtpServerService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserSetting userSetting;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HookSubscribe hookSubscribe;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<Object, Object> redisTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IGbChannelService channelService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IGbChannelPlayService channelPlayService;
|
||||||
|
|
||||||
|
private void sendResponse(RedisRpcResponse response){
|
||||||
|
log.info("[redis-rpc] >> {}", response);
|
||||||
|
response.setToId(userSetting.getServerId());
|
||||||
|
RedisRpcMessage message = new RedisRpcMessage();
|
||||||
|
message.setResponse(response);
|
||||||
|
redisTemplate.convertAndSend(RedisRpcConfig.REDIS_REQUEST_CHANNEL_KEY, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点播国标设备
|
||||||
|
*/
|
||||||
|
@RedisRpcMapping("play")
|
||||||
|
public RedisRpcResponse playChannel(RedisRpcRequest request) {
|
||||||
|
int channelId = Integer.parseInt(request.getParam().toString());
|
||||||
|
RedisRpcResponse response = request.getResponse();
|
||||||
|
|
||||||
|
if (channelId <= 0) {
|
||||||
|
response.setStatusCode(Response.BAD_REQUEST);
|
||||||
|
response.setBody("param error");
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
// 获取对应的设备和通道信息
|
||||||
|
CommonGBChannel channel = channelService.getOne(channelId);
|
||||||
|
if (channel == null) {
|
||||||
|
response.setStatusCode(Response.BAD_REQUEST);
|
||||||
|
response.setBody("param error");
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
channelPlayService.play(channel, null, (code, msg, data) ->{
|
||||||
|
if (code == InviteErrorCode.SUCCESS.getCode()) {
|
||||||
|
response.setStatusCode(Response.OK);
|
||||||
|
response.setBody(data);
|
||||||
|
}else {
|
||||||
|
response.setStatusCode(code);
|
||||||
|
}
|
||||||
|
// 手动发送结果
|
||||||
|
sendResponse(response);
|
||||||
|
});
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -37,7 +37,7 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void play(String serverId, Integer channelId, ErrorCallback<StreamInfo> callback) {
|
public void play(String serverId, Integer channelId, ErrorCallback<StreamInfo> callback) {
|
||||||
RedisRpcRequest request = buildRequest("playChannel", channelId);
|
RedisRpcRequest request = buildRequest("channel/play", channelId);
|
||||||
request.setToId(serverId);
|
request.setToId(serverId);
|
||||||
RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getPlayTimeout());
|
RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getPlayTimeout());
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
|
|
|
@ -34,6 +34,7 @@ create table wvp_device
|
||||||
as_message_channel bool default false,
|
as_message_channel bool default false,
|
||||||
keepalive_interval_time integer,
|
keepalive_interval_time integer,
|
||||||
broadcast_push_after_ack bool default false,
|
broadcast_push_after_ack bool default false,
|
||||||
|
server_id character varying(50),
|
||||||
constraint uk_device_device unique (device_id)
|
constraint uk_device_device unique (device_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ create table wvp_device
|
||||||
as_message_channel bool default false,
|
as_message_channel bool default false,
|
||||||
keepalive_interval_time integer,
|
keepalive_interval_time integer,
|
||||||
broadcast_push_after_ack bool default false,
|
broadcast_push_after_ack bool default false,
|
||||||
|
server_id character varying(50),
|
||||||
constraint uk_device_device unique (device_id)
|
constraint uk_device_device unique (device_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue