增加RPC调用停止实时流播放
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.genersoft.iot.vmp.service.redisMsg;
|
||||
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||
|
||||
@@ -7,4 +8,6 @@ public interface IRedisRpcPlayService {
|
||||
|
||||
|
||||
void play(String serverId, Integer channelId, ErrorCallback<StreamInfo> callback);
|
||||
|
||||
void stop(String serverId, InviteSessionType type, int channelId, String stream);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.genersoft.iot.vmp.service.redisMsg.control;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage;
|
||||
@@ -79,4 +81,42 @@ public class RedisRpcChannelPlayController extends RpcController {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 停止点播国标设备
|
||||
*/
|
||||
@RedisRpcMapping("stop")
|
||||
public RedisRpcResponse stop(RedisRpcRequest request) {
|
||||
System.out.println(request.getParam().toString());
|
||||
JSONObject jsonObject = JSONObject.parseObject(request.getParam().toString());
|
||||
|
||||
RedisRpcResponse response = request.getResponse();
|
||||
|
||||
Integer channelId = jsonObject.getIntValue("channelId");
|
||||
if (channelId == null || channelId <= 0) {
|
||||
response.setStatusCode(Response.BAD_REQUEST);
|
||||
response.setBody("param error");
|
||||
return response;
|
||||
}
|
||||
|
||||
String stream = jsonObject.getString("stream");
|
||||
InviteSessionType type = jsonObject.getObject("inviteSessionType", InviteSessionType.class);
|
||||
|
||||
// 获取对应的设备和通道信息
|
||||
CommonGBChannel channel = channelService.getOne(channelId);
|
||||
if (channel == null) {
|
||||
response.setStatusCode(Response.BAD_REQUEST);
|
||||
response.setBody("param error");
|
||||
return response;
|
||||
}
|
||||
try {
|
||||
channelPlayService.stopPlay(type, channel, stream);
|
||||
response.setStatusCode(Response.OK);
|
||||
}catch (Exception e){
|
||||
response.setStatusCode(Response.SERVER_INTERNAL_ERROR);
|
||||
response.setBody(e.getMessage());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.genersoft.iot.vmp.service.redisMsg.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse;
|
||||
@@ -51,5 +54,23 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(String serverId, InviteSessionType type, int channelId, String stream) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("channelId", channelId);
|
||||
jsonObject.put("stream", stream);
|
||||
jsonObject.put("inviteSessionType", type);
|
||||
RedisRpcRequest request = buildRequest("channel/stop", jsonObject.toJSONString());
|
||||
request.setToId(serverId);
|
||||
RedisRpcResponse response = redisRpcConfig.request(request, 50);
|
||||
if (response == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg());
|
||||
}else {
|
||||
if (response.getStatusCode() != Response.OK) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user