| | |
| | | void c_ffmpeg_run_gb28181(const cffmpeg h); |
| | | void c_ffmepg_use_cpu(const cffmpeg h); |
| | | /////////passive api |
| | | void c_ffmpeg_open_recorder(const cffmpeg h); |
| | | void c_ffmpeg_set_record_duration(const cffmpeg h, const int min, const int max); |
| | | void c_ffmpeg_build_recorder(const cffmpeg h, const char*id, const char *dir, const int64_t fid, int mind, int maxd, int audio); |
| | | void c_ffmpeg_fire_recorder(const cffmpeg h, const char*sid, const int64_t id); |
| | |
| | | |
| | | |
| | | //////passive api |
| | | void c_ffmpeg_open_recorder(const cffmpeg h){ |
| | | Wrapper *s = (Wrapper*)h; |
| | | s->OpenRecorder(); |
| | | } |
| | | void c_ffmpeg_set_record_duration(const cffmpeg h, const int min, const int max){ |
| | | Wrapper *s = (Wrapper*)h; |
| | | s->SetRecMinCacheTime(min); |
| | |
| | | |
| | | void c_ffmpeg_build_decoder(const cffmpeg h){ |
| | | Wrapper *s = (Wrapper*)h; |
| | | s->BuildDecoder(); |
| | | s->OpenDecoder(); |
| | | } |
| | | |
| | | void* c_ffmpeg_get_pic_decoder(const cffmpeg h, int *wid, int *hei, int *format, int *length, int64_t *id){ |
| | |
| | | ,cpu_(0) |
| | | ,run_dec_(false) |
| | | ,run_stream_(true) |
| | | ,run_rec_(false) |
| | | ,thread_(nullptr) |
| | | ,stop_stream_(false) |
| | | ,stream_(nullptr) |
| | |
| | | ,cpu_(0) |
| | | ,run_dec_(false) |
| | | ,run_stream_(true) |
| | | ,run_rec_(false) |
| | | ,thread_(nullptr) |
| | | ,stop_stream_(false) |
| | | ,stream_(nullptr) |
| | |
| | | int flag = 0; |
| | | if (run_stream_ && stream_) stream_->SetPacket(pkt); |
| | | if (run_dec_ && decoder_) flag = decoder_->SetFrame(pkt); |
| | | if (rec_->Loaded()) rec_->SetPacket(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; |
| | |
| | | } |
| | | } |
| | | ////////decoder |
| | | void Wrapper::BuildDecoder(){ |
| | | void Wrapper::OpenDecoder(){ |
| | | run_dec_ = true; |
| | | } |
| | | |
| | |
| | | |
| | | int GetFPS(){return fps_;} |
| | | public: //decoder |
| | | void BuildDecoder(); |
| | | void OpenDecoder(); |
| | | void GetPicDecoder(unsigned char **data, int *w, int *h, int *format, int *length, int64_t *id); |
| | | public: // push stream |
| | | void CloseStream(); |
| | | void GetPacket(unsigned char **pktData, int *size, int *key); |
| | | public: // recorder |
| | | void OpenRecorder(); |
| | | private: |
| | | // stream 参数 |
| | | std::string input_url_; |
| | |
| | | int gb_, cpu_; |
| | | bool run_dec_; |
| | | bool run_stream_; |
| | | bool run_rec_; |
| | | // decoder 参数 |
| | | std::unique_ptr<std::thread> thread_; |
| | | std::atomic_bool stop_stream_; |
| | |
| | | |
| | | import "unsafe" |
| | | |
| | | // OpenRecorder rec func open |
| | | func (h *GoFFMPEG) OpenRecorder() { |
| | | C.wrap_fn_open_rec(unsafe.Pointer(libcffmpeg), h.ffmpeg) |
| | | } |
| | | |
| | | // FireRecorder fire recorder |
| | | func (h *GoFFMPEG) FireRecorder(sid string, id int64) { |
| | | csid := C.CString(sid) |
| | |
| | | fn_cpu(h); |
| | | } |
| | | |
| | | void wrap_fn_open_rec(void *lib, const cffmpeg h){ |
| | | if (!fn_open_recorder){ |
| | | fn_open_recorder = (lib_cffmpeg_open_recorder)dlsym(lib, "c_ffmpeg_open_recorder"); |
| | | if (!fn_open_recorder) return; |
| | | } |
| | | fn_open_recorder(h); |
| | | } |
| | | |
| | | void wrap_fn_recorder(void *lib, const cffmpeg h, const char* id, const char* dir, const int64_t fid, int mind, int maxd, int audio){ |
| | | if (!fn_recorder){ |
| | | fn_recorder = (lib_cffmpeg_recorder)dlsym(lib, "c_ffmpeg_build_recorder"); |
| | |
| | | typedef int (*lib_cffmpeg_fps)(const cffmpeg); |
| | | typedef void (*lib_cffmpeg_gb28181)(const cffmpeg); |
| | | typedef void (*lib_cffmpeg_cpu)(const cffmpeg); |
| | | typedef void (*lib_cffmpeg_open_recorder)(const cffmpeg); |
| | | typedef void (*lib_cffmpeg_rec_duration)(const cffmpeg, const int, const int); |
| | | typedef void (*lib_cffmpeg_recorder)(const cffmpeg, const char*, const char*, const int64_t, int, int, int); |
| | | typedef void (*lib_cffmpeg_fire_recorder)(const cffmpeg, const char*, const int64_t); |
| | |
| | | static lib_cffmpeg_fps fn_fps = NULL; |
| | | static lib_cffmpeg_gb28181 fn_gb28181 = NULL; |
| | | static lib_cffmpeg_cpu fn_cpu = NULL; |
| | | static lib_cffmpeg_open_recorder fn_open_recorder = NULL; |
| | | static lib_cffmpeg_rec_duration fn_rec_duration = NULL; |
| | | static lib_cffmpeg_recorder fn_recorder = NULL; |
| | | static lib_cffmpeg_fire_recorder fn_fire_recorder = NULL; |
| | |
| | | int wrap_fn_fps(void *lib, const cffmpeg h); |
| | | void wrap_fn_run_gb28181(void *lib, const cffmpeg h); |
| | | void wrap_fn_use_cpu(void *lib, const cffmpeg h); |
| | | void wrap_fn_open_rec(void *lib, const cffmpeg h); |
| | | void wrap_fn_rec_duration(void *lib, const cffmpeg h, const int min, const int max); |
| | | void wrap_fn_recorder(void *lib, const cffmpeg h, const char* id, const char* dir, const int64_t fid, int mind, int maxd, int audio); |
| | | void wrap_fn_fire_recorder(void *lib, const cffmpeg h, const char *sid, const int64_t id); |