Skip to content

Commit

Permalink
add curl, move stuff around
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Jun Kit committed Aug 14, 2021
1 parent 8595377 commit 8c59642
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 4 deletions.
File renamed without changes.
File renamed without changes.
56 changes: 52 additions & 4 deletions Spottie.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
4764B3A526842ECA00AE471E /* WebAPIImageCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4764B3A426842ECA00AE471E /* WebAPIImageCollection.swift */; };
4764B3A82684867600AE471E /* DurationFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4764B3A72684867600AE471E /* DurationFormatter.swift */; };
47C56F602679A789003EA20A /* PlayerCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C56F5F2679A789003EA20A /* PlayerCommands.swift */; };
47F77E5C26C7D04400FC882B /* spottie_curl.c in Sources */ = {isa = PBXBuildFile; fileRef = 47F77E5B26C7D04400FC882B /* spottie_curl.c */; };
47F77E5F26C7D19800FC882B /* libcurl.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 47F77E5E26C7D11D00FC882B /* libcurl.tbd */; };
47F77E6126C7D2E000FC882B /* PlayerCore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F77E6026C7D2E000FC882B /* PlayerCore.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -158,13 +161,20 @@
4764B3A426842ECA00AE471E /* WebAPIImageCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebAPIImageCollection.swift; sourceTree = "<group>"; };
4764B3A72684867600AE471E /* DurationFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DurationFormatter.swift; sourceTree = "<group>"; };
47C56F5F2679A789003EA20A /* PlayerCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerCommands.swift; sourceTree = "<group>"; };
47F77E5926C7D04400FC882B /* Spottie-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Spottie-Bridging-Header.h"; sourceTree = "<group>"; };
47F77E5A26C7D04400FC882B /* spottie_curl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = spottie_curl.h; sourceTree = "<group>"; };
47F77E5B26C7D04400FC882B /* spottie_curl.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = spottie_curl.c; sourceTree = "<group>"; };
47F77E5E26C7D11D00FC882B /* libcurl.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libcurl.tbd; path = usr/lib/libcurl.tbd; sourceTree = SDKROOT; };
47F77E6026C7D2E000FC882B /* PlayerCore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerCore.swift; sourceTree = "<group>"; };
47F77E6326C7D39E00FC882B /* player_core.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = player_core.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
47306147265656ED001E3A1F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
47F77E5F26C7D19800FC882B /* libcurl.tbd in Frameworks */,
470201C6265CF4560030ECA9 /* SDWebImageSwiftUI in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -176,7 +186,10 @@
isa = PBXGroup;
children = (
4730614C265656ED001E3A1F /* Spottie */,
47306156265656EF001E3A1F /* Info.plist */,
47306157265656EF001E3A1F /* Spottie.entitlements */,
4730614B265656ED001E3A1F /* Products */,
47F77E5D26C7D11D00FC882B /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -192,14 +205,14 @@
isa = PBXGroup;
children = (
4730616B26565EB8001E3A1F /* Backend */,
47F77E6226C7D2E600FC882B /* PlayerCore */,
4764B3A62684865B00AE471E /* Utilities */,
4730617526588C40001E3A1F /* ViewModels */,
4730615D26565706001E3A1F /* Views */,
47C56F5E2679A779003EA20A /* Commands */,
4730614D265656ED001E3A1F /* SpottieApp.swift */,
47306151265656EF001E3A1F /* Assets.xcassets */,
47306156265656EF001E3A1F /* Info.plist */,
47306157265656EF001E3A1F /* Spottie.entitlements */,
47F77E5926C7D04400FC882B /* Spottie-Bridging-Header.h */,
47306153265656EF001E3A1F /* Preview Content */,
);
path = Spottie;
Expand Down Expand Up @@ -247,6 +260,7 @@
4730616B26565EB8001E3A1F /* Backend */ = {
isa = PBXGroup;
children = (
47F77E5826C7D01700FC882B /* CURL */,
4730617026566280001E3A1F /* Types */,
4730616C26565ED1001E3A1F /* HTTPClient.swift */,
4730617326587EF6001E3A1F /* WebsocketClient.swift */,
Expand Down Expand Up @@ -373,6 +387,32 @@
path = Commands;
sourceTree = "<group>";
};
47F77E5826C7D01700FC882B /* CURL */ = {
isa = PBXGroup;
children = (
47F77E5A26C7D04400FC882B /* spottie_curl.h */,
47F77E5B26C7D04400FC882B /* spottie_curl.c */,
);
path = CURL;
sourceTree = "<group>";
};
47F77E5D26C7D11D00FC882B /* Frameworks */ = {
isa = PBXGroup;
children = (
47F77E5E26C7D11D00FC882B /* libcurl.tbd */,
);
name = Frameworks;
sourceTree = "<group>";
};
47F77E6226C7D2E600FC882B /* PlayerCore */ = {
isa = PBXGroup;
children = (
47F77E6326C7D39E00FC882B /* player_core.h */,
47F77E6026C7D2E000FC882B /* PlayerCore.swift */,
);
path = PlayerCore;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -407,6 +447,7 @@
TargetAttributes = {
47306149265656ED001E3A1F = {
CreatedOnToolsVersion = 12.5;
LastSwiftMigration = 1300;
};
};
};
Expand Down Expand Up @@ -481,6 +522,7 @@
4730618D26591E50001E3A1F /* ImageObject.swift in Sources */,
470201C8265CF8D90030ECA9 /* PlayerControls.swift in Sources */,
4730619B26591FFC001E3A1F /* TrackSeekedEvent.swift in Sources */,
47F77E6126C7D2E000FC882B /* PlayerCore.swift in Sources */,
470201B1265B54720030ECA9 /* WebAPISimplifiedAlbumObject.swift in Sources */,
470201B5265B56350030ECA9 /* WebAPIImageObject.swift in Sources */,
47C56F602679A789003EA20A /* PlayerCommands.swift in Sources */,
Expand All @@ -502,6 +544,7 @@
4730619D26592023001E3A1F /* PlaybackPausedEvent.swift in Sources */,
475798D3266F12EB00AADF2F /* RecommendationsResponse.swift in Sources */,
475798D1266F103100AADF2F /* WebAPIPlaylistTrackObject.swift in Sources */,
47F77E5C26C7D04400FC882B /* spottie_curl.c in Sources */,
475798CF266F101600AADF2F /* WebAPIPublicUserObject.swift in Sources */,
4730618F26591E9C001E3A1F /* ContextChangedEvent.swift in Sources */,
4764B3A1268407C600AE471E /* TrackListItem.swift in Sources */,
Expand Down Expand Up @@ -644,19 +687,22 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Spottie/Spottie.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_ASSET_PATHS = "\"Spottie/Preview Content\"";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Spottie/Info.plist;
INFOPLIST_FILE = Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
PRODUCT_BUNDLE_IDENTIFIER = ljk.Spottie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Spottie/Spottie-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
Expand All @@ -666,19 +712,21 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Spottie/Spottie.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_ASSET_PATHS = "\"Spottie/Preview Content\"";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Spottie/Info.plist;
INFOPLIST_FILE = Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
PRODUCT_BUNDLE_IDENTIFIER = ljk.Spottie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Spottie/Spottie-Bridging-Header.h";
SWIFT_VERSION = 5.0;
};
name = Release;
Expand Down
16 changes: 16 additions & 0 deletions Spottie/Backend/CURL/spottie_curl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// spottie_curl.c
// Spottie
//
// Created by Lee Jun Kit on 14/8/21.
//

#include "spottie_curl.h"

CURLcode curl_easy_setopt_string(CURL *curl, CURLoption option, const char *param) {
return curl_easy_setopt(curl, option, param);
}

CURLcode curl_easy_setopt_bool(CURL *curl, CURLoption option, bool param) {
return curl_easy_setopt(curl, option, param);
}
17 changes: 17 additions & 0 deletions Spottie/Backend/CURL/spottie_curl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// spottie_curl.h
// Spottie
//
// Created by Lee Jun Kit on 14/8/21.
//

#ifndef spottie_curl_h
#define spottie_curl_h

#include <stdbool.h>
#include <curl/curl.h>

CURLcode curl_easy_setopt_string(CURL *curl, CURLoption option, const char *param);
CURLcode curl_easy_setopt_bool(CURL *curl, CURLoption option, bool param);

#endif /* spottie_curl_h */
31 changes: 31 additions & 0 deletions Spottie/PlayerCore/PlayerCore.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// PlayerCore.swift
// Spottie
//
// Created by Lee Jun Kit on 14/8/21.
//

import Foundation

class PlayerCore {
func run() {
let t = Thread.init {
/*
librespot_init(f.toOpaque()) { user_data, ptr, len in
if let pointer = ptr {
let data = Data(bytes: pointer, count: Int(len))
do {
let ff: Foo = Unmanaged.fromOpaque(user_data!).takeUnretainedValue();
let json = try ff.rawDecode(data)
print(json)
} catch {
print("json error: \(error.localizedDescription)")
}
}
}
*/
}
t.name = "AnvilRust"
t.start()
}
}
20 changes: 20 additions & 0 deletions Spottie/PlayerCore/player_core.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// player_core.h
// Spottie
//
// Created by Lee Jun Kit on 14/8/21.
//

#ifndef player_core_h
#define player_core_h

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

void librespot_init(const void *user_data,
void (*event_callback)(const void*, uint8_t*, uintptr_t));


#endif /* player_core_h */
6 changes: 6 additions & 0 deletions Spottie/Spottie-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

#include "player_core.h"
#include "spottie_curl.h"
4 changes: 4 additions & 0 deletions Spottie/SpottieApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import Combine

@main
struct SpottieApp: App {
init() {

}

@StateObject private var playerViewModel = PlayerViewModel(EventBroker())

var body: some Scene {
Expand Down

0 comments on commit 8c59642

Please sign in to comment.