diff --git a/000init.go b/000init.go index f5cf4b9..243cc2a 100644 --- a/000init.go +++ b/000init.go @@ -8,7 +8,7 @@ package pex // #cgo LDFLAGS: -Wl,-rpath,/usr/local/lib // // #define PEX_SDK_MAJOR_VERSION 4 -// #define PEX_SDK_MINOR_VERSION 0 +// #define PEX_SDK_MINOR_VERSION 1 // // #include import "C" diff --git a/pex_search.go b/pex_search.go index ffc2e18..3eef8b3 100644 --- a/pex_search.go +++ b/pex_search.go @@ -13,6 +13,20 @@ import ( "unsafe" ) +// PexSearchType can optionally be specified in the PexSearchRequest and will +// allow to retrieve results that are more relevant to the given use-case. +type PexSearchType int + +const ( + // IdentifyMusic is a type of PexSearch that will return results that will + // help identify the music in the provided media file. + IdentifyMusic = C.Pex_CheckSearchType_IdentifyMusic + + // FindMatches is a type of PexSearch that will return all assets that + // matched against the given media file. + FindMatches = C.Pex_CheckSearchType_FindMatches +) + // Holds all data necessary to perform a pex search. A search can only be // performed using a fingerprint, but additional parameters may be supported in // the future. @@ -20,6 +34,10 @@ type PexSearchRequest struct { // A fingerprint obtained by calling either NewFingerprintFromFile // or NewFingerprintFromBuffer. This field is required. Fingerprint *Fingerprint + + // Type is optional and when specified will allow to retrieve results that + // are more relevant to the given use-case. + Type PexSearchType } // This object is returned from PexSearchFuture.Get upon successful @@ -82,13 +100,14 @@ type PexSearchFuture struct { client *PexSearchClient LookupIDs []string + Type PexSearchType } // Get blocks until the search result is ready and then returns it. It // also releases all the allocated resources, so it will return an // error when called multiple times. func (x *PexSearchFuture) Get() (*PexSearchResult, error) { - return x.client.CheckSearch(x.LookupIDs) + return x.client.CheckSearch(x.LookupIDs, x.Type) } // PexSearchClient serves as an entry point to all operations that @@ -178,10 +197,11 @@ func (x *PexSearchClient) StartSearch(req *PexSearchRequest) (*PexSearchFuture, return &PexSearchFuture{ client: x, LookupIDs: lookupIDs, + Type: req.Type, }, nil } -func (x *PexSearchClient) CheckSearch(lookupIDs []string) (*PexSearchResult, error) { +func (x *PexSearchClient) CheckSearch(lookupIDs []string, searchType PexSearchType) (*PexSearchResult, error) { C.Pex_Lock() defer C.Pex_Unlock() @@ -209,6 +229,8 @@ func (x *PexSearchClient) CheckSearch(lookupIDs []string) (*PexSearchResult, err C.Pex_CheckSearchRequest_AddLookupID(cRequest, cLookupID) } + C.Pex_CheckSearchRequest_SetType(cRequest, C.Pex_CheckSearchType(searchType)) + C.Pex_CheckSearch(x.c, cRequest, cResult, cStatus) if err := statusToError(cStatus); err != nil { return nil, err