From 545cdb3860212fdd6b1f71b179f47b928209bb65 Mon Sep 17 00:00:00 2001 From: Sergiu Ciumac Date: Wed, 5 Jun 2024 15:23:25 +0300 Subject: [PATCH 1/3] Adding new field to AVQueryMatch, MetaFields, to be able to associate more information with the match. Unifying interfaces, IAVQueryMatchRegistry will be implemented by IEmyModelService, to be able to register matches directly from QueryCommand. --- .../Properties/AssemblyInfo.cs | 4 ++-- .../Command/IUsingQueryServices.cs | 6 +++--- .../Command/QueryCommand.cs | 14 +++++++------- .../IAVQueryMatchRegistry.cs | 18 ++++++++++++++++++ src/SoundFingerprinting/IQueryMatchRegistry.cs | 14 -------------- .../Properties/AssemblyInfo.cs | 4 ++-- src/SoundFingerprinting/Query/AVQueryMatch.cs | 11 ++++++++++- src/SoundFingerprinting/Query/AVResultEntry.cs | 2 +- .../SoundFingerprinting.csproj | 4 +++- 9 files changed, 46 insertions(+), 31 deletions(-) create mode 100644 src/SoundFingerprinting/IAVQueryMatchRegistry.cs delete mode 100644 src/SoundFingerprinting/IQueryMatchRegistry.cs diff --git a/src/SoundFingerprinting.Tests/Properties/AssemblyInfo.cs b/src/SoundFingerprinting.Tests/Properties/AssemblyInfo.cs index 6506e776..0ecd7ddb 100644 --- a/src/SoundFingerprinting.Tests/Properties/AssemblyInfo.cs +++ b/src/SoundFingerprinting.Tests/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("4cac962e-ebc5-4006-a1e0-7ffb3e2483c2")] -[assembly: AssemblyVersion("10.3.1.100")] -[assembly: AssemblyInformationalVersion("10.3.1.100")] +[assembly: AssemblyVersion("10.4.0.100")] +[assembly: AssemblyInformationalVersion("10.4.0.100")] diff --git a/src/SoundFingerprinting/Command/IUsingQueryServices.cs b/src/SoundFingerprinting/Command/IUsingQueryServices.cs index 04c8e4b7..e596a357 100644 --- a/src/SoundFingerprinting/Command/IUsingQueryServices.cs +++ b/src/SoundFingerprinting/Command/IUsingQueryServices.cs @@ -32,7 +32,7 @@ public interface IUsingQueryServices : IQueryCommand /// Audio service used in building the fingerprints from the source. /// Match registry used to store the results in a separate storage. /// Query command. - IQueryCommand UsingServices(IQueryService queryService, IAudioService audioService, IQueryMatchRegistry queryMatchRegistry); + IQueryCommand UsingServices(IQueryService queryService, IAudioService audioService, IAVQueryMatchRegistry queryMatchRegistry); /// /// Sets model service as well as video service. @@ -55,7 +55,7 @@ public interface IUsingQueryServices : IQueryCommand /// /// Set video service in case you want to generate video fingerprints only by setting MediaType.Video on the overloads. /// - IQueryCommand UsingServices(IQueryService queryService, IVideoService videoService, IQueryMatchRegistry queryMatchRegistry); + IQueryCommand UsingServices(IQueryService queryService, IVideoService videoService, IAVQueryMatchRegistry queryMatchRegistry); /// /// Sets model service as well as media service. @@ -78,6 +78,6 @@ public interface IUsingQueryServices : IQueryCommand /// /// Media service can be used to read both and from a media file, and generate that will be used to query the underlying source. /// - IQueryCommand UsingServices(IQueryService queryService, IMediaService mediaService, IQueryMatchRegistry queryMatchRegistry); + IQueryCommand UsingServices(IQueryService queryService, IMediaService mediaService, IAVQueryMatchRegistry queryMatchRegistry); } } \ No newline at end of file diff --git a/src/SoundFingerprinting/Command/QueryCommand.cs b/src/SoundFingerprinting/Command/QueryCommand.cs index 028ff3fa..3b4636ec 100644 --- a/src/SoundFingerprinting/Command/QueryCommand.cs +++ b/src/SoundFingerprinting/Command/QueryCommand.cs @@ -26,7 +26,7 @@ public sealed class QueryCommand : IQuerySource, IWithQueryConfiguration private IAudioService audioService; private IVideoService? videoService; private IMediaService? mediaService; - private IQueryMatchRegistry? queryMatchRegistry; + private IAVQueryMatchRegistry? queryMatchRegistry; private Func hashesInterceptor; private Func? createFingerprintCommand; @@ -115,8 +115,8 @@ public IQueryCommand UsingServices(IQueryService queryService, IAudioService aud return this; } - /// - public IQueryCommand UsingServices(IQueryService queryService, IAudioService audioService, IQueryMatchRegistry queryMatchRegistry) + /// + public IQueryCommand UsingServices(IQueryService queryService, IAudioService audioService, IAVQueryMatchRegistry queryMatchRegistry) { this.queryService = queryService; this.audioService = audioService; @@ -132,8 +132,8 @@ public IQueryCommand UsingServices(IQueryService queryService, IVideoService vid return this; } - /// - public IQueryCommand UsingServices(IQueryService queryService, IVideoService videoService, IQueryMatchRegistry queryMatchRegistry) + /// + public IQueryCommand UsingServices(IQueryService queryService, IVideoService videoService, IAVQueryMatchRegistry queryMatchRegistry) { this.queryService = queryService; this.videoService = videoService; @@ -149,8 +149,8 @@ public IQueryCommand UsingServices(IQueryService queryService, IMediaService med return this; } - /// - public IQueryCommand UsingServices(IQueryService queryService, IMediaService mediaService, IQueryMatchRegistry queryMatchRegistry) + /// + public IQueryCommand UsingServices(IQueryService queryService, IMediaService mediaService, IAVQueryMatchRegistry queryMatchRegistry) { this.queryService = queryService; this.mediaService = mediaService; diff --git a/src/SoundFingerprinting/IAVQueryMatchRegistry.cs b/src/SoundFingerprinting/IAVQueryMatchRegistry.cs new file mode 100644 index 00000000..74e8e317 --- /dev/null +++ b/src/SoundFingerprinting/IAVQueryMatchRegistry.cs @@ -0,0 +1,18 @@ +namespace SoundFingerprinting +{ + using System.Collections.Generic; + using SoundFingerprinting.Query; + + /// + /// Register query matches with associated metadata. + /// + public interface IAVQueryMatchRegistry + { + /// + /// Register query matches with associated metadata. + /// + /// AV query matches to register. + /// A flag indicating whether we should publish the query matches to downstream components. + void RegisterMatches(IEnumerable avQueryMatches, bool? publishToDownstreamSubscribers = true); + } +} \ No newline at end of file diff --git a/src/SoundFingerprinting/IQueryMatchRegistry.cs b/src/SoundFingerprinting/IQueryMatchRegistry.cs deleted file mode 100644 index 573af5fc..00000000 --- a/src/SoundFingerprinting/IQueryMatchRegistry.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace SoundFingerprinting -{ - using System.Collections.Generic; - using SoundFingerprinting.Query; - - public interface IQueryMatchRegistry - { - /// - /// Register successful matches. - /// - /// Query matches to register as successful matches. - void RegisterMatches(IEnumerable queryMatches); - } -} \ No newline at end of file diff --git a/src/SoundFingerprinting/Properties/AssemblyInfo.cs b/src/SoundFingerprinting/Properties/AssemblyInfo.cs index f4a37924..14a03d5b 100644 --- a/src/SoundFingerprinting/Properties/AssemblyInfo.cs +++ b/src/SoundFingerprinting/Properties/AssemblyInfo.cs @@ -19,5 +19,5 @@ [assembly: InternalsVisibleTo("SoundFingerprinting.FFT.FFTW")] [assembly: InternalsVisibleTo("SoundFingerprinting.FFT.FFTW.Tests")] -[assembly: AssemblyVersion("10.3.1.100")] -[assembly: AssemblyInformationalVersion("10.3.1.100")] +[assembly: AssemblyVersion("10.4.0.100")] +[assembly: AssemblyInformationalVersion("10.4.0.100")] diff --git a/src/SoundFingerprinting/Query/AVQueryMatch.cs b/src/SoundFingerprinting/Query/AVQueryMatch.cs index 73c16878..04b7df08 100644 --- a/src/SoundFingerprinting/Query/AVQueryMatch.cs +++ b/src/SoundFingerprinting/Query/AVQueryMatch.cs @@ -1,6 +1,7 @@ namespace SoundFingerprinting.Query { using System; + using System.Collections.Generic; using ProtoBuf; using SoundFingerprinting.Data; using SoundFingerprinting.LCS; @@ -19,7 +20,8 @@ public class AVQueryMatch /// Video match information. /// Stream ID information. /// Review status. - public AVQueryMatch(string id, QueryMatch? audio, QueryMatch? video, string? streamId, ReviewStatus reviewStatus = ReviewStatus.None) + /// Meta fields associated with the match. + public AVQueryMatch(string id, QueryMatch? audio, QueryMatch? video, string? streamId, ReviewStatus reviewStatus = ReviewStatus.None, IDictionary? metaFields = null) { if (audio == null && video == null) { @@ -31,6 +33,7 @@ public AVQueryMatch(string id, QueryMatch? audio, QueryMatch? video, string? str Audio = audio; Video = video; ReviewStatus = reviewStatus; + MetaFields = metaFields; } /// @@ -101,6 +104,12 @@ public DateTime MatchedAt } } + /// + /// Gets meta fields associated with the query match. + /// + [ProtoMember(6)] + public IDictionary? MetaFields { get; } + /// /// Deconstructs instance of class. /// diff --git a/src/SoundFingerprinting/Query/AVResultEntry.cs b/src/SoundFingerprinting/Query/AVResultEntry.cs index 66701f31..905bb44a 100644 --- a/src/SoundFingerprinting/Query/AVResultEntry.cs +++ b/src/SoundFingerprinting/Query/AVResultEntry.cs @@ -61,7 +61,7 @@ public DateTime MatchedAt } /// - /// Converts to audio video query match object that you can register in the registry service . + /// Converts to audio video query match object that you can register in the registry service . /// /// Query match identifier. /// Stream identifier. diff --git a/src/SoundFingerprinting/SoundFingerprinting.csproj b/src/SoundFingerprinting/SoundFingerprinting.csproj index 442fa038..21523fb4 100644 --- a/src/SoundFingerprinting/SoundFingerprinting.csproj +++ b/src/SoundFingerprinting/SoundFingerprinting.csproj @@ -4,13 +4,15 @@ true false enable - 10.3.1 + 10.4.0-beta Sergiu Ciumac SoundFingerprinting is a C# framework that implements an efficient algorithm of audio fingerprinting and identification. Designed for developers, enthusiasts, researchers in the fields of audio processing, data mining, digital signal processing. https://github.com/addictedcs/soundfingerprinting https://github.com/AddictedCS/soundfingerprinting git + Version 10.4.0 + - Added new property MetaFields to AVQueryMatch, to be able to store additional metadata about the match. Version 10.3.0 - Improved the ability to reconstruct coverage from tone signal matches (silence can be treated as a tone signal). - Added a fingerprinting flag that allows including silence fingerprints in the generated result set. From b175aac99d1c9d869e84397e9e88d000e890dff7 Mon Sep 17 00:00:00 2001 From: Sergiu Ciumac Date: Wed, 5 Jun 2024 15:40:06 +0300 Subject: [PATCH 2/3] Adding the ability to set meta-fields on AVResultEntry converter. --- src/SoundFingerprinting/Query/AVResultEntry.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SoundFingerprinting/Query/AVResultEntry.cs b/src/SoundFingerprinting/Query/AVResultEntry.cs index 905bb44a..715f0c7d 100644 --- a/src/SoundFingerprinting/Query/AVResultEntry.cs +++ b/src/SoundFingerprinting/Query/AVResultEntry.cs @@ -1,6 +1,7 @@ namespace SoundFingerprinting.Query { using System; + using System.Collections.Generic; using SoundFingerprinting.DAO.Data; using SoundFingerprinting.Data; @@ -66,11 +67,12 @@ public DateTime MatchedAt /// Query match identifier. /// Stream identifier. /// review status. + /// Meta fields. /// An instance of . - public AVQueryMatch ConvertToAvQueryMatch(string avQueryMatchId = "", string streamId = "", ReviewStatus reviewStatus = ReviewStatus.None) + public AVQueryMatch ConvertToAvQueryMatch(string avQueryMatchId = "", string streamId = "", ReviewStatus reviewStatus = ReviewStatus.None, IDictionary? metaFields = null) { string id = string.IsNullOrEmpty(avQueryMatchId) ? Guid.NewGuid().ToString() : avQueryMatchId; - return new AVQueryMatch(id, ToQueryMatch(Audio), ToQueryMatch(Video), streamId, reviewStatus); + return new AVQueryMatch(id, ToQueryMatch(Audio), ToQueryMatch(Video), streamId, reviewStatus, metaFields); } /// From e9fe63cc222ae01fa617c5d8d384d90dda9132a6 Mon Sep 17 00:00:00 2001 From: Sergiu Ciumac Date: Wed, 5 Jun 2024 15:54:25 +0300 Subject: [PATCH 3/3] Version bump. --- src/SoundFingerprinting/SoundFingerprinting.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SoundFingerprinting/SoundFingerprinting.csproj b/src/SoundFingerprinting/SoundFingerprinting.csproj index 21523fb4..129f272b 100644 --- a/src/SoundFingerprinting/SoundFingerprinting.csproj +++ b/src/SoundFingerprinting/SoundFingerprinting.csproj @@ -4,7 +4,7 @@ true false enable - 10.4.0-beta + 10.4.0 Sergiu Ciumac SoundFingerprinting is a C# framework that implements an efficient algorithm of audio fingerprinting and identification. Designed for developers, enthusiasts, researchers in the fields of audio processing, data mining, digital signal processing. https://github.com/addictedcs/soundfingerprinting