还原
This commit is contained in:
parent
facf67d256
commit
967b3c43fb
@ -1,8 +1,6 @@
|
||||
package com.gc.easy.flv.factories;
|
||||
|
||||
import com.alibaba.fastjson.util.IOUtils;
|
||||
import com.gc.easy.flv.factories.state.OutputImage;
|
||||
import com.gc.easy.flv.service.IOutputStreamService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bytedeco.ffmpeg.avcodec.AVPacket;
|
||||
import org.bytedeco.ffmpeg.global.avcodec;
|
||||
@ -12,7 +10,6 @@ import org.bytedeco.javacv.FFmpegFrameRecorder;
|
||||
import javax.servlet.AsyncContext;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -63,16 +60,12 @@ public class ConverterFactories extends Thread implements Converter {
|
||||
*/
|
||||
private Map<String, Converter> factories;
|
||||
|
||||
private IOutputStreamService iOutputStreamService;
|
||||
private Integer channel;
|
||||
|
||||
public ConverterFactories(String url, String key, Map<String, Converter> factories, List<AsyncContext> outEntitys, IOutputStreamService iOutputStreamService,Integer channel) {
|
||||
public ConverterFactories(String url, String key, Map<String, Converter> factories, List<AsyncContext> outEntitys) {
|
||||
this.url = url;
|
||||
this.key = key;
|
||||
this.factories = factories;
|
||||
this.outEntitys = outEntitys;
|
||||
this.iOutputStreamService=iOutputStreamService;
|
||||
this.channel=channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -124,13 +117,6 @@ public class ConverterFactories extends Thread implements Converter {
|
||||
if (stream.size() > 0) {
|
||||
byte[] b = stream.toByteArray();
|
||||
stream.reset();
|
||||
if(iOutputStreamService!=null){
|
||||
OutputImage image = OutputImage.builder().image(b).recordTime(new Date()).channel(channel).build();
|
||||
byte[] handler = iOutputStreamService.handler(image);
|
||||
if(iOutputStreamService.write()){
|
||||
b=handler;
|
||||
}
|
||||
}
|
||||
writeResponse(b);
|
||||
if (outEntitys.isEmpty()) {
|
||||
log.info("没有输出退出");
|
||||
@ -149,7 +135,7 @@ public class ConverterFactories extends Thread implements Converter {
|
||||
} else {
|
||||
isCloseGrabberAndResponse = false;
|
||||
// 需要转码为视频H264格式,音频AAC格式
|
||||
ConverterTranFactories c = new ConverterTranFactories(url, key, factories, outEntitys, grabber,iOutputStreamService,channel);
|
||||
ConverterTranFactories c = new ConverterTranFactories(url, key, factories, outEntitys, grabber);
|
||||
factories.put(key, c);
|
||||
c.start();
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.gc.easy.flv.factories;
|
||||
|
||||
import com.alibaba.fastjson.util.IOUtils;
|
||||
import com.gc.easy.flv.factories.state.OutputImage;
|
||||
import com.gc.easy.flv.service.IOutputStreamService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bytedeco.ffmpeg.global.avcodec;
|
||||
import org.bytedeco.javacv.FFmpegFrameGrabber;
|
||||
@ -12,7 +10,6 @@ import org.bytedeco.javacv.Frame;
|
||||
import javax.servlet.AsyncContext;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -62,19 +59,13 @@ public class ConverterTranFactories extends Thread implements Converter {
|
||||
*/
|
||||
private Map<String, Converter> factories;
|
||||
|
||||
private IOutputStreamService iOutputStreamService;
|
||||
private Integer channel;
|
||||
|
||||
public ConverterTranFactories(String url, String key, Map<String, Converter> factories,
|
||||
List<AsyncContext> outEntitys, FFmpegFrameGrabber grabber, IOutputStreamService iOutputStreamService,Integer channel) {
|
||||
List<AsyncContext> outEntitys, FFmpegFrameGrabber grabber) {
|
||||
this.url = url;
|
||||
this.key = key;
|
||||
this.factories = factories;
|
||||
this.outEntitys = outEntitys;
|
||||
this.grabber = grabber;
|
||||
this.iOutputStreamService=iOutputStreamService;
|
||||
this.channel=channel;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -125,13 +116,6 @@ public class ConverterTranFactories extends Thread implements Converter {
|
||||
if (stream.size() > 0) {
|
||||
byte[] b = stream.toByteArray();
|
||||
stream.reset();
|
||||
if(iOutputStreamService!=null){
|
||||
OutputImage image = OutputImage.builder().image(b).recordTime(new Date()).channel(channel).build();
|
||||
byte[] handler = iOutputStreamService.handler(image);
|
||||
if(iOutputStreamService.write()){
|
||||
b=handler;
|
||||
}
|
||||
}
|
||||
writeResponse(b);
|
||||
if (outEntitys.isEmpty()) {
|
||||
log.info("没有输出退出");
|
||||
|
@ -4,9 +4,7 @@ package com.gc.easy.flv.service.impl;
|
||||
import com.gc.easy.flv.factories.Converter;
|
||||
import com.gc.easy.flv.factories.ConverterFactories;
|
||||
import com.gc.easy.flv.service.IFLVService;
|
||||
import com.gc.easy.flv.service.IOutputStreamService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
@ -29,8 +27,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class FLVService implements IFLVService {
|
||||
|
||||
private ConcurrentHashMap<String, Converter> converters = new ConcurrentHashMap<>();
|
||||
@Autowired(required = false)
|
||||
private IOutputStreamService iOutputStreamService;
|
||||
|
||||
@Override
|
||||
public void open(Integer channel,String url, HttpServletResponse response, HttpServletRequest request) {
|
||||
@ -48,7 +44,7 @@ public class FLVService implements IFLVService {
|
||||
} else {
|
||||
List<AsyncContext> outs = new ArrayList<>();
|
||||
outs.add(async);
|
||||
ConverterFactories c = new ConverterFactories(url, key, converters, outs,iOutputStreamService,channel);
|
||||
ConverterFactories c = new ConverterFactories(url, key, converters, outs);
|
||||
c.start();
|
||||
converters.put(key, c);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user