| | |
| | | ,scale_w_(0) |
| | | ,scale_h_(0) |
| | | ,scale_f_(SWS_POINT) |
| | | ,encoder_(NULL) |
| | | ,gb_(0) |
| | | ,cpu_(0) |
| | | ,encoder_(nullptr) |
| | | { |
| | | makeTheWorld(); |
| | | } |
| | |
| | | scale_h_ = h; |
| | | } |
| | | |
| | | void Wrapper::UseGB28181(){ |
| | | gb_ = 1; |
| | | } |
| | | |
| | | void Wrapper::UseCPU(){ |
| | | cpu_ = 1; |
| | | } |
| | | |
| | | std::unique_ptr<ffwrapper::FormatIn> Wrapper::init_reader(const char* input){ |
| | | |
| | | VideoProp prop; |
| | | prop.url_ = input; |
| | | prop.rtsp_tcp_ = true; |
| | | prop.gpu_acc_ = !cpu_; |
| | | |
| | | std::unique_ptr<FormatIn> in(new FormatIn(prop.gpuAccl())); |
| | | AVDictionary *avdic = prop.optsFormat(); |
| | |
| | | VideoProp prop; |
| | | prop.url_ = input; |
| | | prop.rtsp_tcp_ = true; |
| | | prop.gpu_acc_ = !cpu_; |
| | | |
| | | // std::unique_ptr<FormatIn> in(new FormatIn(prop.gpuAccl())); |
| | | ffwrapper::FormatIn* in(new FormatIn(prop.gpuAccl())); |
| | | AVDictionary *avdic = prop.optsFormat(); |
| | | int flag = in->openGb28181(input, &avdic); |
| | |
| | | } |
| | | |
| | | void Wrapper::run_stream_thread(){ |
| | | |
| | | std::unique_ptr<FormatIn> fi(nullptr); |
| | | |
| | | while(!stop_stream_.load()){ |
| | | //auto in = init_reader(input_url_.c_str()); |
| | | ffwrapper::FormatIn * in = init_reader_gb28181(input_url_.c_str()); |
| | | FormatIn *in = NULL; |
| | | if (!gb_){ |
| | | fi = init_reader(input_url_.c_str()); |
| | | in = fi.get(); |
| | | }else{ |
| | | in = init_reader_gb28181(input_url_.c_str()); |
| | | } |
| | | if (!in) { |
| | | logIt("ERROR: init_reader_gb28181!\n"); |
| | | |
| | | logIt("ERROR: init_reader!\n"); |
| | | usleep(200000); |
| | | continue; |
| | | } |
| | | init_worker(in.get()); |
| | | init_worker(in); |
| | | |
| | | int64_t id = 0; |
| | | avpacket pkt; |
| | |
| | | } |
| | | pkt.data = data; |
| | | |
| | | run_worker(in.get(), pkt); |
| | | run_worker(in, pkt); |
| | | if(!data){ |
| | | break; |
| | | } |
| | |
| | | if(id % 250 == 0) |
| | | recorder_->FireRecorder(id); |
| | | } |
| | | if (gb_){ |
| | | delete in; |
| | | }else{ |
| | | fi.reset(nullptr); |
| | | } |
| | | } |
| | | } |
| | | |