|
|
@@ -28,7 +28,10 @@ import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.context.request.async.DeferredResult;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.sip.message.Response;
|
|
|
+import java.net.MalformedURLException;
|
|
|
+import java.net.URL;
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@@ -200,16 +203,39 @@ public class CommonChannelController {
|
|
|
|
|
|
@Operation(summary = "播放通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
|
|
@GetMapping("/play")
|
|
|
- public DeferredResult<WVPResult<StreamContent>> deleteChannelToGroupByGbDevice(Integer channelId){
|
|
|
+ public DeferredResult<WVPResult<StreamContent>> deleteChannelToGroupByGbDevice(HttpServletRequest request, Integer channelId){
|
|
|
Assert.notNull(channelId,"参数异常");
|
|
|
CommonGBChannel channel = channelService.getOne(channelId);
|
|
|
Assert.notNull(channel, "通道不存在");
|
|
|
|
|
|
DeferredResult<WVPResult<StreamContent>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
|
|
|
|
|
|
- ErrorCallback<StreamInfo> callback = (code, msg, data) -> {
|
|
|
+ ErrorCallback<StreamInfo> callback = (code, msg, streamInfo) -> {
|
|
|
if (code == InviteErrorCode.SUCCESS.getCode()) {
|
|
|
- result.setResult(WVPResult.success(new StreamContent(data)));
|
|
|
+ WVPResult<StreamContent> wvpResult = WVPResult.success();
|
|
|
+ if (streamInfo != null) {
|
|
|
+ if (userSetting.getUseSourceIpAsStreamIp()) {
|
|
|
+ streamInfo=streamInfo.clone();//深拷贝
|
|
|
+ String host;
|
|
|
+ try {
|
|
|
+ URL url=new URL(request.getRequestURL().toString());
|
|
|
+ host=url.getHost();
|
|
|
+ } catch (MalformedURLException e) {
|
|
|
+ host=request.getLocalAddr();
|
|
|
+ }
|
|
|
+ streamInfo.channgeStreamIp(host);
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(streamInfo.getMediaServer().getTranscodeSuffix())
|
|
|
+ && !"null".equalsIgnoreCase(streamInfo.getMediaServer().getTranscodeSuffix())) {
|
|
|
+ streamInfo.setStream(streamInfo.getStream() + "_" + streamInfo.getMediaServer().getTranscodeSuffix());
|
|
|
+ }
|
|
|
+ wvpResult.setData(new StreamContent(streamInfo));
|
|
|
+ }else {
|
|
|
+ wvpResult.setCode(code);
|
|
|
+ wvpResult.setMsg(msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ result.setResult(wvpResult);
|
|
|
}else {
|
|
|
result.setResult(WVPResult.fail(code, msg));
|
|
|
}
|