统计代理结果返回
parent
b902a659dc
commit
df0b530ce4
|
@ -2,10 +2,11 @@ package com.genersoft.iot.vmp.conf;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||||
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
import org.apache.http.HttpRequest;
|
import org.apache.http.HttpRequest;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.json.JSONObject;
|
||||||
import org.mitre.dsmiley.httpproxy.ProxyServlet;
|
import org.mitre.dsmiley.httpproxy.ProxyServlet;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -14,13 +15,20 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author lin
|
* @author lin
|
||||||
|
@ -73,10 +81,39 @@ public class ProxyServletConfig {
|
||||||
response.removeHeaders("Access-Control-Allow-Origin");
|
response.removeHeaders("Access-Control-Allow-Origin");
|
||||||
response.setHeader("Access-Control-Allow-Credentials","true");
|
response.setHeader("Access-Control-Allow-Credentials","true");
|
||||||
response.removeHeaders("Access-Control-Allow-Credentials");
|
response.removeHeaders("Access-Control-Allow-Credentials");
|
||||||
|
if (servletResponse.getStatus() == HttpServletResponse.SC_OK) {
|
||||||
|
HttpEntity entity = response.getEntity();
|
||||||
|
if (entity != null) {
|
||||||
|
if (entity.isChunked()) {
|
||||||
|
List<Byte> byteList = new ArrayList<>();
|
||||||
|
InputStream is = entity.getContent();
|
||||||
|
OutputStream os = servletResponse.getOutputStream();
|
||||||
|
byte[] buffer = new byte[10240];
|
||||||
|
ByteBuffer byteBuffer = new ByteBuffer()
|
||||||
|
while(true) {
|
||||||
|
do {
|
||||||
|
int read;
|
||||||
|
if ((read = is.read(buffer)) == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
buffer
|
||||||
|
byteList.addAll(buffer.)
|
||||||
|
os.write(buffer, 0, read);
|
||||||
|
} while(!this.doHandleCompression && is.available() != 0);
|
||||||
|
|
||||||
|
os.flush();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
OutputStream servletOutputStream = servletResponse.getOutputStream();
|
||||||
|
entity.writeTo(servletOutputStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 异常处理
|
* 异常处理
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -120,17 +120,17 @@ public class OnStreamChangedHookParam extends HookParam{
|
||||||
/**
|
/**
|
||||||
* H264 = 0, H265 = 1, AAC = 2, G711A = 3, G711U = 4
|
* H264 = 0, H265 = 1, AAC = 2, G711A = 3, G711U = 4
|
||||||
*/
|
*/
|
||||||
private int codecId;
|
private int codec_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编码类型名称 CodecAAC CodecH264
|
* 编码类型名称 CodecAAC CodecH264
|
||||||
*/
|
*/
|
||||||
private String codecIdName;
|
private String codec_id_name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Video = 0, Audio = 1
|
* Video = 0, Audio = 1
|
||||||
*/
|
*/
|
||||||
private int codecType;
|
private int codec_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 轨道是否准备就绪
|
* 轨道是否准备就绪
|
||||||
|
@ -145,7 +145,7 @@ public class OnStreamChangedHookParam extends HookParam{
|
||||||
/**
|
/**
|
||||||
* 音频采样率
|
* 音频采样率
|
||||||
*/
|
*/
|
||||||
private int sampleRate;
|
private int sample_rate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 视频fps
|
* 视频fps
|
||||||
|
@ -170,28 +170,28 @@ public class OnStreamChangedHookParam extends HookParam{
|
||||||
this.channels = channels;
|
this.channels = channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCodecId() {
|
public int getCodec_id() {
|
||||||
return codecId;
|
return codec_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCodecId(int codecId) {
|
public void setCodec_id(int codec_id) {
|
||||||
this.codecId = codecId;
|
this.codec_id = codec_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCodecIdName() {
|
public String getCodec_id_name() {
|
||||||
return codecIdName;
|
return codec_id_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCodecIdName(String codecIdName) {
|
public void setCodec_id_name(String codec_id_name) {
|
||||||
this.codecIdName = codecIdName;
|
this.codec_id_name = codec_id_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCodecType() {
|
public int getCodec_type() {
|
||||||
return codecType;
|
return codec_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCodecType(int codecType) {
|
public void setCodec_type(int codec_type) {
|
||||||
this.codecType = codecType;
|
this.codec_type = codec_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReady() {
|
public boolean isReady() {
|
||||||
|
@ -210,12 +210,12 @@ public class OnStreamChangedHookParam extends HookParam{
|
||||||
this.sampleBit = sampleBit;
|
this.sampleBit = sampleBit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSampleRate() {
|
public int getSample_rate() {
|
||||||
return sampleRate;
|
return sample_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSampleRate(int sampleRate) {
|
public void setSample_rate(int sample_rate) {
|
||||||
this.sampleRate = sampleRate;
|
this.sample_rate = sample_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFps() {
|
public int getFps() {
|
||||||
|
|
Loading…
Reference in New Issue