struct plugin_handle* plugin_load(const char* filename, const char* config, struct hub_info* hub) { plugin_register_f register_f; plugin_unregister_f unregister_f; int ret; struct plugin_handle* handle = (struct plugin_handle*) hub_malloc_zero(sizeof(struct plugin_handle)); struct uhub_plugin* plugin = plugin_open(filename); struct plugin_hub_internals* internals = (struct plugin_hub_internals*) plugin->internals; if (!plugin) return NULL; if (!handle) { plugin_close(plugin); return NULL; } handle->handle = plugin; register_f = plugin_lookup_symbol(plugin, "plugin_register"); unregister_f = plugin_lookup_symbol(plugin, "plugin_unregister"); // register hub internals internals->unregister = unregister_f; internals->hub = hub; internals->callback_data = plugin_callback_data_create(); // setup callback functions, where the plugin can contact the hub. plugin_register_callback_functions(handle); if (register_f && unregister_f) { ret = register_f(handle, config); if (ret == 0) { if (handle->plugin_api_version == PLUGIN_API_VERSION && handle->plugin_funcs_size == sizeof(struct plugin_funcs)) { LOG_INFO("Loaded plugin: %s: %s, version %s.", filename, handle->name, handle->version); LOG_PLUGIN("Plugin API version: %d (func table size: " PRINTF_SIZE_T ")", handle->plugin_api_version, handle->plugin_funcs_size); return handle; } else { LOG_ERROR("Unable to load plugin: %s - API version mistmatch", filename); } } else { LOG_ERROR("Unable to load plugin: %s - Failed to initialize: %s", filename, handle->error_msg); } } plugin_close(plugin); hub_free(handle); return NULL; }
struct plugin_handle* plugin_load(const char* filename, const char* config) { plugin_register_f register_f; plugin_unregister_f unregister_f; int ret; struct plugin_handle* handle = hub_malloc_zero(sizeof(struct plugin_handle)); struct uhub_plugin* plugin = plugin_open(filename); if (!plugin) return NULL; if (!handle) { plugin_close(plugin); return NULL; } handle->handle = plugin; register_f = plugin_lookup_symbol(plugin, "plugin_register"); unregister_f = plugin_lookup_symbol(plugin, "plugin_unregister"); if (register_f && unregister_f) { ret = register_f(handle, config); if (ret == 0) { if (handle->plugin_api_version == PLUGIN_API_VERSION && handle->plugin_funcs_size == sizeof(struct plugin_funcs)) { LOG_INFO("Loaded plugin: %s: %s, version %s.", filename, handle->name, handle->version); LOG_TRACE("Plugin API version: %d (func table size: " PRINTF_SIZE_T ")", handle->plugin_api_version, handle->plugin_funcs_size); plugin->unregister = unregister_f; return handle; } else { LOG_ERROR("Unable to load plugin: %s - API version mistmatch", filename); } } else { LOG_ERROR("Unable to load plugin: %s - Failed to initialize: %s", filename, handle->error_msg); } } plugin_close(plugin); hub_free(handle); return NULL; }
void plugin_unload(struct plugin_handle* plugin) { struct plugin_hub_internals* internals = get_internals(plugin); internals->unregister(plugin); plugin_unregister_callback_functions(plugin); plugin_close(plugin->handle); hub_free(plugin); }
static void hb_qsv_filter_pre_close( hb_filter_object_t * filter ){ int i = 0; mfxStatus sts = MFX_ERR_NONE; hb_filter_private_t * pv = filter->private_data; if ( !pv ) { return; } sws_freeContext(pv->sws_context_to_nv12); sws_freeContext(pv->sws_context_from_nv12); av_qsv_context* qsv = pv->job->qsv; if(qsv && qsv->vpp_space && av_qsv_list_count(qsv->vpp_space) > 0 ){ if(pv->qsv_user && qsv->mfx_session){ sts=MFXVideoUSER_Unregister(qsv->mfx_session,0); AV_QSV_CHECK_RESULT(sts, MFX_ERR_NONE, sts); for(i=hb_list_count(pv->qsv_user);i>0;i--){ qsv_filter_t *plugin = hb_list_item(pv->qsv_user,i-1); hb_list_rem(pv->qsv_user,plugin); plugin_close(plugin); } hb_list_close(&pv->qsv_user); } // closing local stuff qsv_filter_close(qsv,AV_QSV_VPP_USER); // closing the commong stuff av_qsv_context_clean(qsv); } hb_cond_close(&pv->pre.frame_completed); hb_lock_close(&pv->pre.frame_completed_lock); hb_cond_close(&pv->post.frame_completed); hb_lock_close(&pv->post.frame_completed_lock); hb_cond_close(&pv->pre_busy.frame_completed); hb_lock_close(&pv->pre_busy.frame_completed_lock); hb_cond_close(&pv->post_busy.frame_completed); hb_lock_close(&pv->post_busy.frame_completed_lock); hb_list_close( &pv->list ); free( pv ); filter->private_data = NULL; }
static FILE *plugin_open(const char *path, const char *mode){ int sfd; int ret; struct addrinfo hints,*rp,*result; char *url,*port,*filename; if(open_pipe()) return NULL; if(parse_url(path,&url,&port,&filename)){ return NULL; } memset(&hints,0,sizeof(struct addrinfo)); hints.ai_family=AF_INET; hints.ai_socktype=SOCK_STREAM; hints.ai_protocol=0; if((ret=getaddrinfo(url,port,&hints,&result))){ fprintf(stderr,"error (%s) - getaddrinfo: %s\n",path,gai_strerror(ret)); close_pipe(); free(port); return NULL; } free(url); free(port); for(rp=result;rp;rp=rp->ai_next){ if((sfd=socket(rp->ai_family,rp->ai_socktype,rp->ai_protocol))==-1) continue; if(connect(sfd,rp->ai_addr,rp->ai_addrlen)!=-1){ h.sfd=sfd; h.ffd=fdopen(sfd,mode); break; } close(sfd); } if(!rp){ fprintf(stderr,"Cannot connect to: %s\n",path); close_pipe(); return NULL; } freeaddrinfo(result); h.print_meta=1; if(stream_hello(filename)){ plugin_close(NULL); return NULL; } free(filename); return h.rfd; }
int v4l2_deinit(enc_context_p ctx) { struct v4l2_requestbuffers reqbufs; memset(&reqbufs, 0, sizeof(reqbufs)); reqbufs.count = 0; reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; reqbufs.memory = V4L2_MEMORY_MMAP; IOCTL_OR_LOG_ERROR(VIDIOC_REQBUFS, &reqbufs); memset(&reqbufs, 0, sizeof(reqbufs)); reqbufs.count = 0; reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; reqbufs.memory = V4L2_MEMORY_MMAP; IOCTL_OR_ERROR_RETURN(VIDIOC_REQBUFS, &reqbufs); plugin_close(ctx->enc); close(ctx->fd); free(ctx); return 0; }
void plugin_unload(struct plugin_handle* plugin) { plugin->handle->unregister(plugin); plugin_close(plugin->handle); }