mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-20 12:27:49 +08:00
根据应用名和流id获取播放地址 接口增加参数:使用请求ip作为返回的流IP
This commit is contained in:
parent
0cf52c375f
commit
80f6897976
@ -6,6 +6,8 @@ public class StreamInfo {
|
||||
|
||||
private String app;
|
||||
private String stream;
|
||||
|
||||
private String ip;
|
||||
private String deviceID;
|
||||
private String channelId;
|
||||
private String flv;
|
||||
@ -52,6 +54,14 @@ public class StreamInfo {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getDeviceID() {
|
||||
return deviceID;
|
||||
}
|
||||
|
||||
@ -78,6 +78,7 @@ public class MediaServiceImpl implements IMediaService {
|
||||
if (addr == null) {
|
||||
addr = mediaInfo.getStreamIp();
|
||||
}
|
||||
streamInfoResult.setIp(addr);
|
||||
streamInfoResult.setMediaServerId(mediaInfo.getId());
|
||||
streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s", addr, mediaInfo.getRtmpPort(), app, stream));
|
||||
if (mediaInfo.getRtmpSSlPort() != 0) {
|
||||
|
||||
@ -16,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
||||
@Api(tags = "媒体流相关")
|
||||
@Controller
|
||||
@ -49,16 +51,90 @@ public class MediaController {
|
||||
@ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "stream", value = "流id", dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "mediaServerId", value = "媒体服务器id", dataTypeClass = String.class, required = false),
|
||||
@ApiImplicitParam(name = "useSourceIpAsStreamIp", value = "使用请求ip作为返回的流IP", dataTypeClass = Boolean.class, required = false),
|
||||
})
|
||||
@GetMapping(value = "/stream_info_by_app_and_stream")
|
||||
@ResponseBody
|
||||
public WVPResult<StreamInfo> getStreamInfoByAppAndStream(@RequestParam String app, @RequestParam String stream, @RequestParam(required = false) String mediaServerId){
|
||||
StreamInfo streamInfoByAppAndStreamWithCheck = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId);
|
||||
public WVPResult<StreamInfo> getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app,
|
||||
@RequestParam String stream,
|
||||
@RequestParam(required = false) String mediaServerId,
|
||||
@RequestParam(required = false) Boolean useSourceIpAsStreamIp){
|
||||
|
||||
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId);
|
||||
|
||||
WVPResult<StreamInfo> result = new WVPResult<>();
|
||||
if (streamInfoByAppAndStreamWithCheck != null){
|
||||
if (streamInfo != null){
|
||||
if (useSourceIpAsStreamIp != null && useSourceIpAsStreamIp) {
|
||||
String localAddr = request.getLocalAddr();
|
||||
streamInfo.setIp(localAddr);
|
||||
if (streamInfo.getRtsp() != null) {
|
||||
streamInfo.setRtsp(streamInfo.getRtsp().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getRtsps() != null) {
|
||||
streamInfo.setRtsps(streamInfo.getRtsps().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getRtmp() != null) {
|
||||
streamInfo.setRtmp(streamInfo.getRtmp().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getRtmps() != null) {
|
||||
streamInfo.setRtmps(streamInfo.getRtmps().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getFlv() != null) {
|
||||
streamInfo.setFlv(streamInfo.getFlv().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getHttps_flv() != null) {
|
||||
streamInfo.setHttps_flv(streamInfo.getHttps_flv().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getWs_flv() != null) {
|
||||
streamInfo.setWs_flv(streamInfo.getWs_flv().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getWss_flv() != null) {
|
||||
streamInfo.setWss_flv(streamInfo.getWss_flv().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getFmp4() != null) {
|
||||
streamInfo.setFmp4(streamInfo.getFmp4().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getHttps_fmp4() != null) {
|
||||
streamInfo.setHttps_fmp4(streamInfo.getHttps_fmp4().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getWs_fmp4() != null) {
|
||||
streamInfo.setWs_fmp4(streamInfo.getWs_fmp4().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getWss_fmp4() != null) {
|
||||
streamInfo.setWss_fmp4(streamInfo.getWss_fmp4().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getTs() != null) {
|
||||
streamInfo.setTs(streamInfo.getTs().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getHttps_ts() != null) {
|
||||
streamInfo.setHttps_ts(streamInfo.getHttps_ts().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getWs_ts() != null) {
|
||||
streamInfo.setWs_ts(streamInfo.getWs_ts().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getWss_ts() != null) {
|
||||
streamInfo.setWss_ts(streamInfo.getWss_ts().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getHls() != null) {
|
||||
streamInfo.setHls(streamInfo.getHls().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getHttps_hls() != null) {
|
||||
streamInfo.setHttps_hls(streamInfo.getHttps_hls().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getWs_hls() != null) {
|
||||
streamInfo.setWs_hls(streamInfo.getWs_hls().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getWss_hls() != null) {
|
||||
streamInfo.setWss_hls(streamInfo.getWss_hls().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
if (streamInfo.getRtc() != null) {
|
||||
streamInfo.setRtc(streamInfo.getRtc().replace(streamInfo.getIp(), localAddr));
|
||||
}
|
||||
}
|
||||
|
||||
result.setCode(0);
|
||||
result.setMsg("scccess");
|
||||
result.setData(streamInfoByAppAndStreamWithCheck);
|
||||
result.setData(streamInfo);
|
||||
}else {
|
||||
result.setCode(-1);
|
||||
result.setMsg("fail");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user