Commit bc431e429026d5efb9d404767f76a0724978d40d

Authored by Cloud User
1 parent e073b60c

fix-use-source-ip-as-stream-ip

src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java
... ... @@ -523,6 +523,69 @@ public class StreamInfo implements Serializable, Cloneable{
523 523 StreamInfo instance = null;
524 524 try{
525 525 instance = (StreamInfo)super.clone();
  526 + if (this.flv != null) {
  527 + instance.flv=this.flv.clone();
  528 + }
  529 + if (this.ws_flv != null ){
  530 + instance.ws_flv= this.ws_flv.clone();
  531 + }
  532 + if (this.hls != null ) {
  533 + instance.hls= this.hls.clone();
  534 + }
  535 + if (this.ws_hls != null ) {
  536 + instance.ws_hls= this.ws_hls.clone();
  537 + }
  538 + if (this.ts != null ) {
  539 + instance.ts= this.ts.clone();
  540 + }
  541 + if (this.ws_ts != null ) {
  542 + instance.ws_ts= this.ws_ts.clone();
  543 + }
  544 + if (this.fmp4 != null ) {
  545 + instance.fmp4= this.fmp4.clone();
  546 + }
  547 + if (this.ws_fmp4 != null ) {
  548 + instance.ws_fmp4= this.ws_fmp4.clone();
  549 + }
  550 + if (this.rtc != null ) {
  551 + instance.rtc= this.rtc.clone();
  552 + }
  553 + if (this.https_flv != null) {
  554 + instance.https_flv= this.https_flv.clone();
  555 + }
  556 + if (this.wss_flv != null) {
  557 + instance.wss_flv= this.wss_flv.clone();
  558 + }
  559 + if (this.https_hls != null) {
  560 + instance.https_hls= this.https_hls.clone();
  561 + }
  562 + if (this.wss_hls != null) {
  563 + instance.wss_hls= this.wss_hls.clone();
  564 + }
  565 + if (this.wss_ts != null) {
  566 + instance.wss_ts= this.wss_ts.clone();
  567 + }
  568 + if (this.https_fmp4 != null) {
  569 + instance.https_fmp4= this.https_fmp4.clone();
  570 + }
  571 + if (this.wss_fmp4 != null) {
  572 + instance.wss_fmp4= this.wss_fmp4.clone();
  573 + }
  574 + if (this.rtcs != null) {
  575 + instance.rtcs= this.rtcs.clone();
  576 + }
  577 + if (this.rtsp != null) {
  578 + instance.rtsp= this.rtsp.clone();
  579 + }
  580 + if (this.rtsps != null) {
  581 + instance.rtsps= this.rtsps.clone();
  582 + }
  583 + if (this.rtmp != null) {
  584 + instance.rtmp= this.rtmp.clone();
  585 + }
  586 + if (this.rtmps != null) {
  587 + instance.rtmps= this.rtmps.clone();
  588 + }
526 589 }catch(CloneNotSupportedException e) {
527 590 e.printStackTrace();
528 591 }
... ...
src/main/java/com/genersoft/iot/vmp/common/StreamURL.java
... ... @@ -6,7 +6,7 @@ import java.io.Serializable;
6 6  
7 7  
8 8 @Schema(description = "流地址信息")
9   -public class StreamURL implements Serializable {
  9 +public class StreamURL implements Serializable,Cloneable {
10 10  
11 11 @Schema(description = "协议")
12 12 private String protocol;
... ... @@ -77,4 +77,8 @@ public class StreamURL implements Serializable {
77 77 return null;
78 78 }
79 79 }
  80 + @Override
  81 + public StreamURL clone() throws CloneNotSupportedException {
  82 + return (StreamURL) super.clone();
  83 + }
80 84 }
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
... ... @@ -40,6 +40,8 @@ import org.springframework.web.context.request.async.DeferredResult;
40 40 import javax.servlet.http.HttpServletRequest;
41 41 import javax.sip.InvalidArgumentException;
42 42 import javax.sip.SipException;
  43 +import java.net.MalformedURLException;
  44 +import java.net.URL;
43 45 import java.text.ParseException;
44 46 import java.util.List;
45 47 import java.util.UUID;
... ... @@ -128,7 +130,15 @@ public class PlayController {
128 130 if (data != null) {
129 131 StreamInfo streamInfo = (StreamInfo)data;
130 132 if (userSetting.getUseSourceIpAsStreamIp()) {
131   - streamInfo.channgeStreamIp(request.getLocalAddr());
  133 + streamInfo=streamInfo.clone();//深拷贝
  134 + String host;
  135 + try {
  136 + URL url=new URL(request.getRequestURL().toString());
  137 + host=url.getHost();
  138 + } catch (MalformedURLException e) {
  139 + host=request.getLocalAddr();
  140 + }
  141 + streamInfo.channgeStreamIp(host);
132 142 }
133 143 wvpResult.setData(new StreamContent(streamInfo));
134 144 }
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java
... ... @@ -34,6 +34,8 @@ import org.springframework.web.context.request.async.DeferredResult;
34 34 import javax.servlet.http.HttpServletRequest;
35 35 import javax.sip.InvalidArgumentException;
36 36 import javax.sip.SipException;
  37 +import java.net.MalformedURLException;
  38 +import java.net.URL;
37 39 import java.text.ParseException;
38 40 import java.util.UUID;
39 41  
... ... @@ -99,7 +101,15 @@ public class PlaybackController {
99 101 if (data != null) {
100 102 StreamInfo streamInfo = (StreamInfo)data;
101 103 if (userSetting.getUseSourceIpAsStreamIp()) {
102   - streamInfo.channgeStreamIp(request.getLocalAddr());
  104 + streamInfo=streamInfo.clone();//深拷贝
  105 + String host;
  106 + try {
  107 + URL url=new URL(request.getRequestURL().toString());
  108 + host=url.getHost();
  109 + } catch (MalformedURLException e) {
  110 + host=request.getLocalAddr();
  111 + }
  112 + streamInfo.channgeStreamIp(host);
103 113 }
104 114 wvpResult.setData(new StreamContent(streamInfo));
105 115 }
... ...