-
Notifications
You must be signed in to change notification settings - Fork 9
IOS integration #39
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
Open
lil-jon-crunk
wants to merge
4
commits into
AvionBlock:master
Choose a base branch
from
lil-jon-crunk:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
IOS integration #39
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1ca2c26
DEV: Add production-ready Apple platform support and smoke tests
lil-jon-crunk 0ae29a7
Fix iOS native version metadata in xcframework build
lil-jon-crunk 176bd5d
feat(core): make use_static nullable with auto platform mode (iOS def…
lil-jon-crunk de6535c
Merge pull request #1 from lil-jon-crunk/dev
lil-jon-crunk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
|
|
||
| jobs: | ||
| test-core: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, windows-latest, macos-latest] | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 9.0.x | ||
| - name: Run core tests | ||
| run: dotnet test ./OpusSharp.Core.Tests/OpusSharp.Core.Tests.csproj --configuration Release | ||
|
|
||
| smoke-apple: | ||
| runs-on: macos-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 9.0.x | ||
| - name: Install iOS workload | ||
| run: dotnet workload install ios | ||
| - name: Pack local NuGet feed | ||
| run: ./packall.sh | ||
| - name: Run host package smoke | ||
| run: dotnet run --project ./samples/PackageSmoke/Host/OpusSharp.Smoke.Host.csproj --configuration Release | ||
| - name: Build iOS package smoke | ||
| run: dotnet build ./samples/PackageSmoke/iOS/OpusSharp.Smoke.iOS.csproj --configuration Release -f net9.0-ios -p:RuntimeIdentifier=iossimulator-arm64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -364,3 +364,7 @@ FodyWeavers.xsd | |
|
|
||
| # Rider | ||
| .idea | ||
|
|
||
| # Dev machine | ||
| OpusSharp.RuntimeCheck | ||
| global.json | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <Project> | ||
| <PropertyGroup> | ||
| <OpusSharpVersion>1.7.0</OpusSharpVersion> | ||
| <RepositoryUrl>https://github.com/AvionBlock/OpusSharp</RepositoryUrl> | ||
| </PropertyGroup> | ||
| </Project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| using System.Runtime.InteropServices; | ||
| using OpusSharp.Core; | ||
| using Xunit; | ||
|
|
||
| namespace OpusSharp.Core.Tests; | ||
|
|
||
| public sealed class NativeLibrarySmokeTests | ||
| { | ||
| public NativeLibrarySmokeTests() | ||
| { | ||
| TestNativeLibraryBootstrapper.EnsureInitialized(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Version_ReturnsNonEmptyString() | ||
| { | ||
| var version = OpusInfo.Version(); | ||
|
|
||
| Assert.False(string.IsNullOrWhiteSpace(version)); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void StringError_ReturnsKnownMessage() | ||
| { | ||
| var error = OpusInfo.StringError((int)OpusErrorCodes.OPUS_INVALID_PACKET); | ||
|
|
||
| Assert.False(string.IsNullOrWhiteSpace(error)); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void OpusException_PreservesMessageAndInnerException() | ||
| { | ||
| var inner = new InvalidOperationException("inner"); | ||
| var exception = new OpusException("outer", inner); | ||
|
|
||
| Assert.Equal("outer", exception.Message); | ||
| Assert.Same(inner, exception.InnerException); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void PublicEnumValues_MatchExpectedOpusConstants() | ||
| { | ||
| Assert.Equal(-4, (int)OpusErrorCodes.OPUS_INVALID_PACKET); | ||
| Assert.Equal(2048, (int)OpusPredefinedValues.OPUS_APPLICATION_VOIP); | ||
| Assert.Equal(4002, (int)EncoderCTL.OPUS_SET_BITRATE); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void DefaultOpusExceptionCtor_ProducesExceptionInstance() | ||
| { | ||
| var exception = new OpusException(); | ||
|
|
||
| Assert.NotNull(exception); | ||
| } | ||
|
|
||
| private static class TestNativeLibraryBootstrapper | ||
| { | ||
| private static bool _initialized; | ||
|
|
||
| public static void EnsureInitialized() | ||
| { | ||
| if (_initialized) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| var sourcePath = GetNativeLibraryPath(); | ||
| var destinationPath = Path.Combine(AppContext.BaseDirectory, Path.GetFileName(sourcePath)); | ||
|
|
||
| if (!File.Exists(destinationPath)) | ||
| { | ||
| File.Copy(sourcePath, destinationPath, overwrite: true); | ||
| } | ||
|
|
||
| _initialized = true; | ||
| } | ||
|
|
||
| private static string GetNativeLibraryPath() | ||
| { | ||
| var repoRoot = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "../../../../")); | ||
| var runtimeFolder = GetRuntimeFolder(); | ||
| var fileName = GetNativeLibraryFileName(); | ||
| var path = Path.Combine(repoRoot, "OpusSharp.Natives", "runtimes", runtimeFolder, "native", fileName); | ||
|
|
||
| if (!File.Exists(path)) | ||
| { | ||
| throw new FileNotFoundException($"Native opus library was not found at '{path}'."); | ||
| } | ||
|
|
||
| return path; | ||
| } | ||
|
|
||
| private static string GetRuntimeFolder() | ||
| { | ||
| if (OperatingSystem.IsMacOS()) | ||
| { | ||
| return RuntimeInformation.ProcessArchitecture switch | ||
| { | ||
| Architecture.Arm64 => "osx-arm64", | ||
| Architecture.X64 => "osx-x64", | ||
| _ => throw new PlatformNotSupportedException("Unsupported macOS architecture.") | ||
| }; | ||
| } | ||
|
|
||
| if (OperatingSystem.IsLinux()) | ||
| { | ||
| return RuntimeInformation.ProcessArchitecture switch | ||
| { | ||
| Architecture.Arm => "linux-arm", | ||
| Architecture.Arm64 => "linux-arm64", | ||
| Architecture.X64 => "linux-x64", | ||
| Architecture.X86 => "linux-x86", | ||
| _ => throw new PlatformNotSupportedException("Unsupported Linux architecture.") | ||
| }; | ||
| } | ||
|
|
||
| if (OperatingSystem.IsWindows()) | ||
| { | ||
| return RuntimeInformation.ProcessArchitecture switch | ||
| { | ||
| Architecture.Arm64 => "win-arm64", | ||
| Architecture.X64 => "win-x64", | ||
| Architecture.X86 => "win-x86", | ||
| _ => throw new PlatformNotSupportedException("Unsupported Windows architecture.") | ||
| }; | ||
| } | ||
|
|
||
| throw new PlatformNotSupportedException("Unsupported host operating system."); | ||
| } | ||
|
|
||
| private static string GetNativeLibraryFileName() | ||
| { | ||
| if (OperatingSystem.IsWindows()) | ||
| { | ||
| return "opus.dll"; | ||
| } | ||
|
|
||
| if (OperatingSystem.IsLinux()) | ||
| { | ||
| return "opus.so"; | ||
| } | ||
|
|
||
| if (OperatingSystem.IsMacOS()) | ||
| { | ||
| return "opus.dylib"; | ||
| } | ||
|
|
||
| throw new PlatformNotSupportedException("Unsupported host operating system."); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net9.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <IsPackable>false</IsPackable> | ||
| <IsTestProject>true</IsTestProject> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" /> | ||
| <PackageReference Include="xunit" Version="2.9.2" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"> | ||
| <PrivateAssets>all</PrivateAssets> | ||
| <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
| </PackageReference> | ||
| <ProjectReference Include="..\OpusSharp.Core\OpusSharp.Core.csproj" /> | ||
| </ItemGroup> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Versions need to be 1.6.1. since the official opus version is currently 1.6.1.