From 6b74d3200087df398d9d266e61ae07dd1f81d39d Mon Sep 17 00:00:00 2001 From: Stepan Bujnak Date: Mon, 17 Oct 2022 21:11:31 +0200 Subject: [PATCH] Added ingestion into the private search catalog (#24) --- private_search.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/private_search.go b/private_search.go index 34e633e..bab127a 100644 --- a/private_search.go +++ b/private_search.go @@ -181,3 +181,37 @@ func (x *Client) StartPrivateSearch(req *PrivateSearchRequest) (*PrivateSearchFu LookupID: C.GoString(C.AE_PrivateSearchStartResult_GetLookupID(cResult)), }, nil } + +// IngestPrivateSearchAsset ingests a fingerprint into the private search +// catalog. The catalog is determined from the authentication credentials used +// when initializing the client. If you want to ingest into multiple catalogs +// within one application, you need to use multiple clients. The id parameter +// identifies the fingerprint and will be returned during search to identify +// the matched asset. +func (x *Client) IngestPrivateSearchAsset(id string, ft *Fingerprint) error { + C.AE_Lock() + defer C.AE_Unlock() + + cStatus := C.AE_Status_New() + if cStatus == nil { + panic("out of memory") + } + defer C.AE_Status_Delete(&cStatus) + + cID := C.CString(id) + defer C.free(unsafe.Pointer(cID)) + + cBuffer := C.AE_Buffer_New() + if cBuffer == nil { + panic("out of memory") + } + defer C.AE_Buffer_Delete(&cBuffer) + + ftData := unsafe.Pointer(&ft.b[0]) + ftSize := C.size_t(len(ft.b)) + + C.AE_Buffer_Set(cBuffer, ftData, ftSize) + + C.AE_PrivateSearch_Ingest(x.c, cID, cBuffer, cStatus) + return statusToError(cStatus) +}