| | |
| | | ,gb_(0) |
| | | ,cpu_(0) |
| | | ,run_dec_(false) |
| | | ,run_stream_(true) |
| | | ,run_rec_(false) |
| | | ,thread_(nullptr) |
| | | ,stop_stream_(false) |
| | | ,stream_(nullptr) |
| | |
| | | ,gb_(0) |
| | | ,cpu_(0) |
| | | ,run_dec_(false) |
| | | ,run_stream_(true) |
| | | ,run_rec_(false) |
| | | ,thread_(nullptr) |
| | | ,stop_stream_(false) |
| | | ,stream_(nullptr) |
| | |
| | | prop.gpu_acc_ = !cpu_; |
| | | |
| | | std::unique_ptr<FormatIn> in(new FormatIn(prop.gpuAccl())); |
| | | AVDictionary *avdic = prop.optsFormat(); |
| | | int flag = -1; |
| | | if (gb_){ |
| | | flag = in->openGb28181(input, NULL); |
| | | }else{ |
| | | flag = in->open(input, &avdic); |
| | | AVDictionary *avdic = prop.optsFormat(); |
| | | if(avdic){ |
| | | flag = in->open(input, &avdic); |
| | | av_dict_free(&avdic); |
| | | }else{ |
| | | flag = in->open(input, NULL); |
| | | } |
| | | } |
| | | if(avdic){ |
| | | av_dict_free(&avdic); |
| | | } |
| | | |
| | | if(flag == 0){ |
| | | if(!in->findStreamInfo(NULL)){ |
| | | logIt("can't find video stream\n"); |
| | |
| | | |
| | | stream_ = new stream(in, 3 * in->getFPS()); |
| | | // stream_->AudioSwitch(audio_); |
| | | |
| | | |
| | | decoder_ = new decoder(in); |
| | | |
| | | rec_->Load(in); |
| | |
| | | p.pts = p.dts = AV_NOPTS_VALUE; |
| | | } |
| | | int flag = 0; |
| | | if (stream_) stream_->SetPacket(pkt); |
| | | if (decoder_ && run_dec_) flag = decoder_->SetFrame(pkt); |
| | | if (rec_->Loaded()) rec_->SetPacket(pkt); |
| | | if (run_stream_ && stream_) stream_->SetPacket(pkt); |
| | | if (run_dec_ && decoder_) flag = decoder_->SetFrame(pkt); |
| | | if (run_rec_ && rec_->Loaded()) rec_->SetPacket(pkt); |
| | | |
| | | return flag; |
| | | } |
| | |
| | | rec_->SetRecMinCacheTime(mind); |
| | | } |
| | | |
| | | void Wrapper::OpenRecorder(){ |
| | | run_rec_ = true; |
| | | } |
| | | |
| | | void Wrapper::BuildRecorder(const char* id, const char *output, const int64_t &fid, const int mindur, const int maxdur, const bool audio){ |
| | | bool a = audio; |
| | | if (gb_) a = false; |
| | |
| | | [=]{rec_->NewRec(rid.c_str(), dir.c_str(), fid, mindur, maxdur, a);}; |
| | | } |
| | | } |
| | | |
| | | int Wrapper::FireRecorder(const char* sid,const int64_t &id){ |
| | | if (rec_->Loaded()){ |
| | | rec_->FireRecSignal(sid, id); |
| | |
| | | } |
| | | } |
| | | ////////decoder |
| | | void Wrapper::BuildDecoder(){ |
| | | void Wrapper::OpenDecoder(){ |
| | | run_dec_ = true; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | void Wrapper::CloseStream(){ |
| | | run_stream_ = false; |
| | | } |
| | | |
| | | void Wrapper::GetPacket(unsigned char **pktData, int *size, int *key){ |
| | | if (stream_){ |
| | | stream_->GetPacket(pktData, size, key); |
| | |
| | | |
| | | return flag; |
| | | } |
| | | |
| | | int GetGb28181Pic(const char *rtspUrl, char *retData, int *retDataLen){ |
| | | int ret = 0; |
| | | std::string fn = rtspUrl; |
| | | |
| | | auto handle_gb28181 = new GB28181API; |
| | | if(handle_gb28181->addCamera(fn) == -1){ |
| | | delete(handle_gb28181); |
| | | logIt("do addCamera Error\n"); |
| | | return -1; |
| | | } |
| | | |
| | | int retLen = handle_gb28181->capturePic(handle_gb28181, retData, retDataLen); |
| | | if(retLen == 0){ |
| | | logIt("do capturePic failed:%d"); |
| | | ret = -1; |
| | | } |
| | | |
| | | handle_gb28181->deleteCamera(); |
| | | return ret; |
| | | } |
| | | } |
| | | |