| | |
| | | ,rec_(new rec) |
| | | ,logit_(false) |
| | | ,fps_(25) |
| | | ,file_finished_(false) |
| | | { |
| | | makeTheWorld(); |
| | | } |
| | |
| | | ,decoder_(nullptr) |
| | | ,rec_(new rec) |
| | | ,logit_(true) |
| | | ,fps_(25) |
| | | ,file_finished_(false) |
| | | { |
| | | makeTheWorld(); |
| | | logif::CreateLogger(logfile, true); |
| | |
| | | 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"); |
| | |
| | | |
| | | fps_ = in->getFPS(); |
| | | |
| | | int wTime = 1000000.0 / in->getFPS() ; |
| | | if (fps_ < 1 || fps_ > 200){ |
| | | fps_ = 25; |
| | | } |
| | | |
| | | int wTime = 1000000.0 / fps_ ; |
| | | wTime >>= 1; |
| | | logIt("WAIT TIME PER FRAME: %d", wTime); |
| | | |
| | | init_worker(in.get()); |
| | | |
| | |
| | | int64_t a_id = id; |
| | | |
| | | bool exist = access(input_url_.c_str(), 0) == 0; |
| | | if (exist){ |
| | | wTime <<= 1; |
| | | } |
| | | |
| | | logIt("WAIT TIME PER FRAME: %d", wTime); |
| | | |
| | | while(!stop_stream_.load()){ |
| | | auto data(std::make_shared<CodedData>()); |
| | |
| | | } |
| | | |
| | | deinit_worker(); |
| | | if (exist) break; |
| | | if (exist) { |
| | | logIt("local file exist"); |
| | | file_finished_ = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | void Wrapper::GetPicDecoder(unsigned char **data, int *w, int *h, int *format, int *length, int64_t *id){ |
| | | if (file_finished_){ |
| | | *data = (unsigned char*)this; |
| | | *w = 1080; |
| | | *h = 720; |
| | | *format = 23; |
| | | *length = 12; |
| | | *id = -10802020; |
| | | return; |
| | | } |
| | | if (decoder_){ |
| | | decoder_->GetFrame(data, w, h, format, length, id); |
| | | } |
| | |
| | | |
| | | 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; |
| | | } |
| | | } |
| | | |