Indexer¶
-
class
Indexer
¶ Interface to access the engine’s indexing functionality.
The Indexer is responsible for the initiation, maintenance and finalization of an indexing session. Its job is that of extracting the fingerprints from the given audio recordings, transform them into a format that is suitable for fast searches and emitting the data necessary to build the required data structures for storage.
Public Functions
-
virtual void
Start
() = 0¶ Start an indexing session. This method must be called prior to calling any of the Index() methods.
-
virtual void
Index
(uint32_t FID) = 0¶ Do indexing of audio recordings. The client shall call this method for every audio recording to be fingerprinted by passing its unique fingerprint identifier (FID). Fingerprint Identifiers must be strict increasing positive integral numbers. Upon calling this method, the engine will call the client’s registered audio provider in order to get the recording’s audio data. This is accomplished by repeatedly calling AudioProvider::OnAudioData() until there is no more audio for the recording identified by FID. The fingerprint for the current audio recording is emitted by calling DataStore::OnIndexerFingerprint() and is indexed according to the currently set match type.
- Note
An indexing session must be started by calling Indexer::Start() prior to using this method.
- Parameters
[in] FID
: The fingerprint’s unique identifier. Must be a positive strictly monotonic increasing integer.
-
virtual void
Index
(uint32_t FID, const uint8_t *fpdata, size_t fpsize) = 0¶ Do indexing of the given fingerprint. This method may be used to reindex the fingerprints database, for example in order to change the match type or other parameters. An indexing session must be started by calling Indexer::Start() prior to using this method. Note that using different Index() methods within the same session is not allowed.
- Parameters
[in] FID
: The fingerprint’s unique identifier.[in] fpdata
: A pointer to the memory location containing the fingerprint data. The engine does not take ownership of the pointer.[in] fpsize
: The size in bytes of the fingerprint data.
-
virtual void
Flush
() = 0¶ This method flushes the indexer’s cache starting the processing and emission of list chunks. Normally the cache is automatically flushed by the indexer whenever the set memory limit is reached, but you may want to do it manually based on circumnstances. In such a case you can use this method in conjunction with GetCacheUsed().
-
virtual void
End
(bool flush = true) = 0¶ End an indexing session. This method must be called when there is nothing more to index. Failing to end an indexing session may result in data loss and/or undefined behaviour. The method also flushes any remaining data in the cache, unless otherwise specified.
- Parameters
[in] flush
: Flag specifying whether to flush the indexer’s cache.
-
virtual void
SetMatchType
(eMatchType type) = 0¶ Set the match type to be used with the index. This determines the type and size of the index.
- Note
Once the index has been created with a specific match type it can only be used to perform identifications using that type of matching strategy. To set the match type for the identification use the Recognizer::SetMatchType() method passing the same value used to build the index. Mixing match types (that is trying to identify audio using an index built with a different match type) will produce incorrect results.
- Parameters
[in] type
: The match type. This must be one of the supported values in Audioneex::eMatchType.
-
virtual eMatchType
GetMatchType
() const = 0¶ Get the currently set match type.
-
virtual void
SetCacheLimit
(size_t limit) = 0¶ Set the cache size (in MB). The indexer will flush the cache once this limit is reached.
- Parameters
[in] limit
: The memory limit in MB.
-
virtual size_t
GetCacheLimit
() const = 0¶ Get the currently set cache limit.
- Return
The currently set limit in MB
-
virtual size_t
GetCacheUsed
() const = 0¶ Get the amount of memory currently used by the cache.
- Return
The current cache size in bytes.
-
virtual void
SetAudioProvider
(AudioProvider *aprovider) = 0¶ Set the audio provider.
-
virtual AudioProvider *
GetAudioProvider
() const = 0¶ Get the currently set audio provider.
-
virtual void