Files
voice-cat/clients/apple/VoiceCat.iOS/IosScreenCapture.cs
Talon 08e6c5930a
Build and test / test (macos-latest) (push) Canceled after 0s
Build and test / test (ubuntu-24.04) (push) Canceled after 0s
Build and test / test (windows-latest) (push) Canceled after 0s
Build and test / apple-client (push) Canceled after 0s
Retire legacy implementations and flatten managed layout
2026-09-21 00:11:32 +02:00

26 lines
1.2 KiB
C#

using System.Runtime.InteropServices;
using Foundation;
namespace VoiceCat.iOS;
internal static partial class IosScreenCapture
{
internal static void Present()
{
if (!OperatingSystem.IsIOSVersionAtLeast(27)) return;
NSUrl? root = NSFileManager.DefaultManager.GetContainerUrl(IosConstants.AppGroup);
if (root?.Path is null) throw new InvalidOperationException("The VoiceCat App Group is unavailable.");
string path = Path.Combine(root.Path, "voicecat", "broadcast_audio.ring"); Directory.CreateDirectory(Path.GetDirectoryName(path)!);
if (!IsAvailable) throw new InvalidOperationException("Screen audio sharing is unavailable on this device."); PresentNative(path);
}
internal static bool IsAvailable => OperatingSystem.IsIOSVersionAtLeast(27) && Available() != 0;
[LibraryImport("__Internal", EntryPoint = "vc_ios_screen_capture_available")]
private static partial int Available();
[LibraryImport("__Internal", EntryPoint = "vc_ios_screen_capture_present", StringMarshalling = StringMarshalling.Utf8)]
private static partial void PresentNative(string ringPath);
[LibraryImport("__Internal", EntryPoint = "vc_ios_screen_capture_stop")]
internal static partial void Stop();
}