Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ShazamKit] Updates Xcode13 beta1 #12189

Merged
merged 23 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,7 @@ COMMON_FRAMEWORKS = \
Network \
OSLog \
SceneKit \
ShazamKit \
SoundAnalysis \
SpriteKit \
StoreKit \
Expand Down
266 changes: 266 additions & 0 deletions src/shazamkit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
using System;
using CoreGraphics;
using Foundation;
using ObjCRuntime;
using AVFoundation;

namespace ShazamKit {

[Native]
[iOS (15,0), Mac (12,0), Watch (8,0), TV (15,0), MacCatalyst (15,0)]
[ErrorDomain ("SHErrorDomain")]
public enum SHErrorCode : long
{
InvalidAudioFormat = 100,
AudioDiscontinuity = 101,
SignatureInvalid = 200,
SignatureDurationInvalid = 201,
MatchAttemptFailed = 202,
CustomCatalogInvalid = 300,
CustomCatalogInvalidURL = 301,
MediaLibrarySyncFailed = 400,
}

[iOS (15,0), Mac (12,0), Watch (8,0), TV (15,0), MacCatalyst (15,0)]
[Static]
enum SHMediaItemProperty
{
[Field ("SHMediaItemShazamID")]
ShazamId,
[Field ("SHMediaItemTitle")]
Title,
[Field ("SHMediaItemSubtitle")]
Subtitle,
[Field ("SHMediaItemArtist")]
Artist,
[Field ("SHMediaItemWebURL")]
WebUrl,
[Field ("SHMediaItemAppleMusicID")]
AppleMusicId,
[Field ("SHMediaItemAppleMusicURL")]
AppleMusicUrl,
[Field ("SHMediaItemArtworkURL")]
ArtworkUrl,
[Field ("SHMediaItemVideoURL")]
VideoUrl,
[Field ("SHMediaItemExplicitContent")]
ExplicitContent,
[Field ("SHMediaItemGenres")]
Genres,
[Field ("SHMediaItemISRC")]
Isrc,
[Field ("SHMediaItemMatchOffset")]
MatchOffset,
[Field ("SHMediaItemFrequencySkew")]
FrequencySkew,
}

[iOS (15,0), Mac (12,0), Watch (8,0), TV (15,0), MacCatalyst (15,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface SHCatalog
{
[Export ("minimumQuerySignatureDuration")]
double MinimumQuerySignatureDuration { get; }

[Export ("maximumQuerySignatureDuration")]
double MaximumQuerySignatureDuration { get; }
}

[iOS (15,0), Mac (12,0), Watch (8,0), TV (15,0), MacCatalyst (15,0)]
[BaseType (typeof (SHCatalog))]
interface SHCustomCatalog
{
[Export ("addReferenceSignature:representingMediaItems:error:")]
bool Add (SHSignature signature, SHMediaItem[] mediaItems, [NullAllowed] out NSError error);

[Export ("addCustomCatalogFromURL:error:")]
bool Add (NSUrl url, [NullAllowed] out NSError error);

[Export ("writeToURL:error:")]
bool Write (NSUrl url, [NullAllowed] out NSError error);

[Static]
[Export ("new")]
[return: Release]
tj-devel709 marked this conversation as resolved.
Show resolved Hide resolved
SHCustomCatalog Create ();
}

[iOS (15,0), Mac (12,0), Watch (8,0), TV (15,0), MacCatalyst (15,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface SHMatch : NSSecureCoding
{
[Export ("mediaItems", ArgumentSemantic.Strong)]
SHMatchedMediaItem[] MediaItems { get; }

[Export ("querySignature", ArgumentSemantic.Strong)]
SHSignature QuerySignature { get; }
}

[iOS (15,0), Mac (12,0), Watch (8,0), TV (15,0), MacCatalyst (15,0)]
[BaseType (typeof (SHMediaItem))]
tj-devel709 marked this conversation as resolved.
Show resolved Hide resolved
[DisableDefaultCtor]
interface SHMatchedMediaItem : NSSecureCoding
{
[Export ("frequencySkew")]
float FrequencySkew { get; }

[Export ("matchOffset")]
double MatchOffset { get; }

[Export ("predictedCurrentMatchOffset")]
double PredictedCurrentMatchOffset { get; }
}

[iOS (15,0), Mac (12,0), Watch (8,0), TV (15,0), MacCatalyst (15,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface SHMediaItem : NSSecureCoding, NSCopying
{
[NullAllowed]
[Export ("shazamID")]
string ShazamId { get; }

[NullAllowed]
[Export ("title")]
string Title { get; }

[NullAllowed]
[Export ("subtitle")]
string Subtitle { get; }

[NullAllowed]
[Export ("artist")]
string Artist { get; }

[Export ("genres", ArgumentSemantic.Strong)]
string[] Genres { get; }

[NullAllowed]
[Export ("appleMusicID")]
string AppleMusicId { get; }

[NullAllowed]
[Export ("appleMusicURL", ArgumentSemantic.Strong)]
NSUrl AppleMusicUrl { get; }

[NullAllowed]
[Export ("webURL", ArgumentSemantic.Strong)]
NSUrl WebUrl { get; }

[NullAllowed]
[Export ("artworkURL", ArgumentSemantic.Strong)]
NSUrl ArtworkUrl { get; }

[NullAllowed]
[Export ("videoURL", ArgumentSemantic.Strong)]
NSUrl VideoUrl { get; }

[Export ("explicitContent")]
bool ExplicitContent { get; }

[NullAllowed]
[Export ("isrc")]
string Isrc { get; }

[Static]
[Export ("mediaItemWithProperties:")]
SHMediaItem Create (NSDictionary<NSString, NSObject> properties);

[Async]
[Static]
[Export ("fetchMediaItemWithShazamID:completionHandler:")]
void FetchMediaItem (string shazamId, Action<SHMediaItem, NSError> completionHandler);

[Export ("valueForProperty:")]
NSObject GetValue (string property);

[Export ("objectForKeyedSubscript:")]
NSObject GetObject (string key);
}

[iOS (15,0), Mac (12,0), Watch (8,0), TV (15,0), MacCatalyst (15,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface SHMediaLibrary
{
[Static]
[Export ("defaultLibrary", ArgumentSemantic.Strong)]
SHMediaLibrary DefaultLibrary { get; }
spouliot marked this conversation as resolved.
Show resolved Hide resolved

[Async]
[Export ("addMediaItems:completionHandler:")]
void Add (SHMediaItem[] mediaItems, Action<NSError> completionHandler);
}

[iOS (15,0), Mac (12,0), Watch (8,0), TV (15,0), MacCatalyst (15,0)]
[BaseType (typeof (NSObject))]
tj-devel709 marked this conversation as resolved.
Show resolved Hide resolved
interface SHSession
{
[Export ("catalog", ArgumentSemantic.Strong)]
SHCatalog Catalog { get; }

[Wrap ("WeakDelegate")]
[NullAllowed]
ISHSessionDelegate Delegate { get; set; }

[NullAllowed, Export ("delegate", ArgumentSemantic.Weak)]
NSObject WeakDelegate { get; set; }

[Export ("initWithCatalog:")]
IntPtr Constructor (SHCatalog catalog);

[Export ("matchStreamingBuffer:atTime:")]
void Match (AVAudioPcmBuffer buffer, [NullAllowed] AVAudioTime time);

[Export ("matchSignature:")]
void Match (SHSignature signature);
}

[iOS (15,0), Mac (12,0), Watch (8,0), TV (15,0), MacCatalyst (15,0)]
[BaseType (typeof (NSObject))]
tj-devel709 marked this conversation as resolved.
Show resolved Hide resolved
[DisableDefaultCtor]
interface SHSignature : NSSecureCoding, NSCopying
{
[Export ("initWithDataRepresentation:error:")]
[DesignatedInitializer]
IntPtr Constructor (NSData dataRepresentation, [NullAllowed] out NSError error);

[Export ("duration")]
double Duration { get; }

[Export ("dataRepresentation", ArgumentSemantic.Strong)]
NSData DataRepresentation { get; }

[Static]
[Export ("signatureWithDataRepresentation:error:")]
[return: NullAllowed]
SHSignature GetSignature (NSData dataRepresentation, [NullAllowed] out NSError error);
}

[iOS (15,0), Mac (12,0), Watch (8,0), TV (15,0), MacCatalyst (15,0)]
[BaseType (typeof (NSObject))]
interface SHSignatureGenerator
{
[Export ("appendBuffer:atTime:error:")]
bool Append (AVAudioPcmBuffer buffer, [NullAllowed] AVAudioTime time, [NullAllowed] out NSError error);

[Export ("signature")]
SHSignature Signature { get; }
}

interface ISHSessionDelegate {}

[iOS (15,0), Mac (12,0), Watch (8,0), TV (15,0), MacCatalyst (15,0)]
[Protocol, Model (AutoGeneratedName = true)]
[BaseType (typeof (NSObject))]
interface SHSessionDelegate
{
[Export ("session:didFindMatch:")]
void DidFindMatch (SHSession session, SHMatch match);

[Export ("session:didNotFindMatchForSignature:error:")]
void DidNotFindMatch (SHSession session, SHSignature signature, [NullAllowed] NSError error);
}
}
4 changes: 4 additions & 0 deletions tests/introspection/iOS/iOSApiClassPtrTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ protected override bool Skip (Type type)
if (Runtime.Arch == Arch.SIMULATOR)
return true;
break;
case "ShazamKit": // missing in the sim
if (Runtime.Arch == Arch.SIMULATOR)
return true;
break;
}

// While the following types are categories and contains a class_ptr
Expand Down
5 changes: 5 additions & 0 deletions tests/introspection/iOS/iOSApiSelectorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ protected override bool Skip (Type type)
return true;
break;
#endif // HAS_WATCHCONNECTIVITY
case "ShazamKit":
// ShazamKit is not fully supported in the simulator
if (Runtime.Arch == Arch.SIMULATOR)
return true;
break;
}

switch (type.Name) {
Expand Down
68 changes: 0 additions & 68 deletions tests/xtro-sharpie/MacCatalyst-ShazamKit.todo

This file was deleted.

Loading