Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions src/SensitiveContentAnalysis/SCVideoStreamAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Foundation;
using ObjCRuntime;

namespace SensitiveContentAnalysis {
#if __IOS__ && !__MACCATALYST__
public partial class SCVideoStreamAnalyzer {
/// <summary>Create a new <see cref="SCVideoStreamAnalyzer" /> instance with the specified particant and stream direction.</summary>
/// <param name="participantUuid">The unique identifier for a participant in the conference call.</param>
/// <param name="streamDirection">Specifies whether the stream comes from the local camera or a remote location.</param>
/// <param name="error">The error object if an error occurs.</param>
/// <returns>A new <see cref="SCVideoStreamAnalyzer" /> instance with the specified particant and stream direction if successful, <see langword="null" /> otherwise.</returns>
public static SCVideoStreamAnalyzer? Create (string participantUuid, SCVideoStreamAnalyzerStreamDirection streamDirection, out NSError? error)
{
var rv = new SCVideoStreamAnalyzer (NSObjectFlag.Empty);
rv.InitializeHandle (rv._InitWithParticipantUuid (participantUuid, streamDirection, out error), "initWithParticipantUUID:streamDirection:error:", false);
if (rv.Handle == NativeHandle.Zero) {
rv.Dispose ();
return null;
}
return rv;
}
}
#endif // __IOS__ && !__MACCATALYST__
}
5 changes: 5 additions & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,11 @@ SECURITY_SOURCES = \
Security/SslConnection.cs \
Security/SslContext.cs \

# SensitiveContentAnalysis

SENSITIVECONTENTANALYSIS_SOURCES = \
SensitiveContentAnalysis/SCVideoStreamAnalyzer.cs \

# SensorKit

SENSORKIT_CORE_SOURCES = \
Expand Down
62 changes: 62 additions & 0 deletions src/sensitivecontentanalysis.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using AVFoundation;
using CoreGraphics;
using CoreVideo;
using Foundation;
using ObjCRuntime;
using VideoToolbox;

namespace SensitiveContentAnalysis {
[NoTV, Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
Expand All @@ -10,6 +13,21 @@ namespace SensitiveContentAnalysis {
interface SCSensitivityAnalysis {
[Export ("sensitive")]
bool Sensitive { [Bind ("isSensitive")] get; }

// From the VideoStreamAnalysis (SCSensitiveAnalysis) category
[NoTV, NoMacCatalyst, NoMac, iOS (26, 0)]
[Export ("shouldInterruptVideo")]
bool ShouldInterruptVideo { get; }

// From the VideoStreamAnalysis (SCSensitiveAnalysis) category
[NoTV, NoMacCatalyst, NoMac, iOS (26, 0)]
[Export ("shouldIndicateSensitivity")]
bool ShouldIndicateSensitivity { get; }

// From the VideoStreamAnalysis (SCSensitiveAnalysis) category
[NoTV, NoMacCatalyst, NoMac, iOS (26, 0)]
[Export ("shouldMuteAudio")]
bool ShouldMuteAudio { get; }
}

[NoTV, Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
Expand Down Expand Up @@ -38,4 +56,48 @@ interface SCSensitivityAnalyzer {
[Async]
NSProgress AnalyzeVideo (NSUrl fileUrl, Action<SCSensitivityAnalysis, NSError> completionHandler);
}

[NoTV, NoMacCatalyst, NoMac, iOS (26, 0)]
[Native]
public enum SCVideoStreamAnalyzerStreamDirection : long {
Outgoing = 1,
Incoming = 2,
}

delegate void SCVideoStreamAnalysisChangeHandler ([NullAllowed] SCSensitivityAnalysis analysis, [NullAllowed] NSError error);

[NoTV, NoMacCatalyst, NoMac, iOS (26, 0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface SCVideoStreamAnalyzer {
[NullAllowed, Export ("analysis")]
SCSensitivityAnalysis Analysis { get; }

[Export ("analysisChangedHandler", ArgumentSemantic.Copy)]
[NullAllowed]
SCVideoStreamAnalysisChangeHandler AnalysisChangedHandler { get; set; }

[Export ("initWithParticipantUUID:streamDirection:error:")]
[Internal]
NativeHandle _InitWithParticipantUuid (string participantUuid, SCVideoStreamAnalyzerStreamDirection streamDirection, [NullAllowed] out NSError error);

[Export ("analyzePixelBuffer:")]
void AnalyzePixelBuffer (CVPixelBuffer pixelBuffer);

// From the SessionManagement (SCVideoStreamAnalyzer) category
[Export ("beginAnalysisOfDecompressionSession:error:")]
bool BeginAnalysisOfDecompressionSession (VTDecompressionSession decompressionSession, [NullAllowed] out NSError error);

// From the SessionManagement (SCVideoStreamAnalyzer) category
[Export ("beginAnalysisOfCaptureDeviceInput:error:")]
bool BeginAnalysisOfCaptureDeviceInput (AVCaptureDeviceInput captureDeviceInput, [NullAllowed] out NSError error);

// From the SessionManagement (SCVideoStreamAnalyzer) category
[Export ("endAnalysis")]
void EndAnalysis ();

// From the SessionManagement (SCVideoStreamAnalyzer) category
[Export ("continueStream")]
void ContinueStream ();
}
}
3 changes: 3 additions & 0 deletions src/videotoolbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

namespace VideoToolbox {

interface VTSession : INativeObject { }
interface VTDecompressionSession : VTSession { }

/// <summary>A class that encapsulates keys necessary for compression sessions. Used by <see cref="VideoToolbox.VTCompressionProperties" /></summary>
[MacCatalyst (13, 1)]
[Static]
Expand Down
4 changes: 4 additions & 0 deletions tests/cecil-tests/Documentation.KnownFailures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6047,6 +6047,8 @@ F:Security.TlsProtocolVersion.Tls13
F:SensitiveContentAnalysis.SCSensitivityAnalysisPolicy.DescriptiveInterventions
F:SensitiveContentAnalysis.SCSensitivityAnalysisPolicy.Disabled
F:SensitiveContentAnalysis.SCSensitivityAnalysisPolicy.SimpleInterventions
F:SensitiveContentAnalysis.SCVideoStreamAnalyzerStreamDirection.Incoming
F:SensitiveContentAnalysis.SCVideoStreamAnalyzerStreamDirection.Outgoing
F:SensorKit.SRAcousticSettingsAccessibilityBackgroundSoundsName.Airplane
F:SensorKit.SRAcousticSettingsAccessibilityBackgroundSoundsName.Babble
F:SensorKit.SRAcousticSettingsAccessibilityBackgroundSoundsName.BalancedNoise
Expand Down Expand Up @@ -29149,6 +29151,8 @@ T:Security.TlsCipherSuiteGroup
T:Security.TlsProtocolVersion
T:SecurityUI.SFCertificatePresentation
T:SensitiveContentAnalysis.SCSensitivityAnalysisPolicy
T:SensitiveContentAnalysis.SCVideoStreamAnalysisChangeHandler
T:SensitiveContentAnalysis.SCVideoStreamAnalyzerStreamDirection
T:SensorKit.SRAbsoluteTime
T:SensorKit.SRAcousticSettingsAccessibilityBackgroundSoundsName
T:SensorKit.SRAcousticSettingsAccessibilityHeadphoneAccommodationsMediaEnhanceApplication
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#if HAS_SENSITIVECONTENTANALYSIS

using System;

using Foundation;
using SensitiveContentAnalysis;

using NUnit.Framework;


namespace MonoTouchFixtures.SensitiveContentAnalysis;

#if __IOS__ && !__MACCATALYST__

[TestFixture]
[Preserve (AllMembers = true)]
public class SCVideoStreamAnalyzerTests {
[Test]
public void Create ()
{
TestRuntime.AssertXcodeVersion (26, 0);

using var obj = SCVideoStreamAnalyzer.Create ("placeholder", SCVideoStreamAnalyzerStreamDirection.Outgoing, out var error);
// There are a number of other reasons for this to fail:
// * We don't have a valid participant uuid.
// * A specific entitlement is required (com.apple.developer.sensitivecontentanalysis.client)
// * Only works when "the Communication Safety parental control in Screen Time is enabled, or when the Sensitive Content Warnings setting is turned on".
Assert.That (obj, Is.Null, "Null");
Assert.That (error, Is.Not.Null, "Error");
}
}

#endif // __IOS__ && !__MACCATALYST__

#endif // HAS_SENSITIVECONTENTANALYSIS

This file was deleted.

Loading