Skip to content

[MediaExtension] Implement this new framework. #21176

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

Merged
merged 6 commits into from
Sep 12, 2024
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
9 changes: 9 additions & 0 deletions src/AVFoundation/AVTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,15 @@ public bool HasUniformFormatDescriptions {

[MarshalAs (UnmanagedType.I1)]
public bool HasUniformFormatDescriptions;

internal AVSampleCursorChunkInfo_Blittable ToBlittable ()
{
var rv = new AVSampleCursorChunkInfo_Blittable ();
rv.HasUniformSampleSizes = HasUniformSampleSizes;
rv.HasUniformSampleDurations = HasUniformSampleDurations;
rv.HasUniformFormatDescriptions = HasUniformFormatDescriptions;
return rv;
}
#endif
}

Expand Down
1 change: 1 addition & 0 deletions src/Foundation/NSObject.mac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public partial class NSObject {
static IntPtr sw = Dlfcn.dlopen (Constants.SharedWithYouLibrary, 1);
static IntPtr swc = Dlfcn.dlopen (Constants.SharedWithYouCoreLibrary, 1);
static IntPtr th = Dlfcn.dlopen (Constants.ThreadNetworkLibrary, 1);
static IntPtr mx = Dlfcn.dlopen (Constants.MediaExtensionLibrary, 1);
static IntPtr ni = Dlfcn.dlopen (Constants.NearbyInteractionLibrary, 1);
static IntPtr sm = Dlfcn.dlopen (Constants.ServiceManagementLibrary, 1);
static IntPtr sa = Dlfcn.dlopen (Constants.SafetyKitLibrary, 1);
Expand Down
77 changes: 77 additions & 0 deletions src/MediaExtension/MEByteSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#if NET
#if MONOMAC
using System;

using Foundation;
using ObjCRuntime;

namespace MediaExtension {
public partial class MEByteSource {
/// <summary>Read data asynchronously into a byte array.</summary>
/// <param name="offset">The offset (relative to the start of the ifle) where to start reading.</param>
/// <param name="data">The byte array to write the data into.</param>
/// <param name="completionHandler">The delegate which is called when the read operation has completed.</param>
/// <remarks>This overload will try to fill the <paramref name="data" /> byte array with data.</remarks>
public void ReadData (long offset, byte[] data, MEByteSourceReadBytesCallback completionHandler)
{
ReadData ((nuint) data.Length, offset, data, completionHandler);
}

/// <summary>Read data asynchronously into a byte array.</summary>
/// <param name="length">The number of bytes to read.</param>
/// <param name="offset">The offset (relative to the start of the ifle) where to start reading.</param>
/// <param name="data">The byte array to write the data into.</param>
/// <param name="completionHandler">The delegate which is called when the read operation has completed.</param>
public void ReadData (nuint length, long offset, byte[] data, MEByteSourceReadBytesCallback completionHandler)
{
if (data is null)
ThrowHelper.ThrowArgumentNullException (nameof (data));

if (length > (nuint) data.Length)
ThrowHelper.ThrowArgumentOutOfRangeException (nameof (length), length, $"length cannot be higher than the length of the data array.");

unsafe {
fixed (byte* dataPtr = data) {
ReadData (length, offset, dataPtr, completionHandler);
}
}
}

/// <summary>Read data synchronously into a byte array.</summary>
/// <param name="offset">The offset (relative to the start of the ifle) where to start reading.</param>
/// <param name="data">The byte array to write the data into.</param>
/// <param name="bytesRead">Upon return, will contain the number of read bytes.</param>
/// <param name="error">Null if an error occurred, otherwise an <see cref="NSError" /> instance with information about the error. The error will be <see cref="MEError.EndOfStream" /> if the end was reached.</param>
/// <returns>True if successful, false otherwise.</returns>
/// <remarks>This overload will try to fill the <paramref name="data" /> byte array with data.</remarks>
public bool ReadData (long offset, byte[] data, out nuint bytesRead, out NSError? error)
{
return ReadData ((nuint) data.Length, offset, data, out bytesRead, out error);
}

/// <summary>Read data synchronously into a byte array.</summary>
/// <param name="length">The number of bytes to read.</param>
/// <param name="offset">The offset (relative to the start of the ifle) where to start reading.</param>
/// <param name="data">The byte array to write the data into.</param>
/// <param name="bytesRead">Upon return, will contain the number of read bytes.</param>
/// <param name="error">Null if an error occurred, otherwise an <see cref="NSError" /> instance with information about the error. The error will be <see cref="MEError.EndOfStream" /> if the end was reached.</param>
/// <returns>True if successful, false otherwise.</returns>
public bool ReadData (nuint length, long offset, byte[] data, out nuint bytesRead, out NSError? error)
{
if (data is null)
ThrowHelper.ThrowArgumentNullException (nameof (data));

if (length > (nuint) data.Length)
ThrowHelper.ThrowArgumentOutOfRangeException (nameof (length), length, $"length cannot be higher than the length of the data array.");

unsafe {
fixed (byte* dataPtr = data) {
return ReadData (length, offset, dataPtr, out bytesRead, out error);
}
}
}

}
}
#endif // MONOMAC
#endif // NET
42 changes: 42 additions & 0 deletions src/MediaExtension/MERawProcessingBooleanParameter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#if NET
#if MONOMAC
using System;

using Foundation;
using ObjCRuntime;

namespace MediaExtension {
/// <summary>This enum is used to select how to initialize a new instance of a <see cref="MERawProcessingBooleanParameter" />.</summary>
public enum MERawProcessingBooleanParameterInitializationOption {
/// <summary>The <c>neutralOrCameraValue</c> parameter passed to the constructor is a neutral value.</summary>
NeutralValue,
/// <summary>The <c>neutralOrCameraValue</c> parameter passed to the constructor is a camera value.</summary>
CameraValue,
}

public partial class MERawProcessingBooleanParameter {
/// <summary>Create a new <see cref="MERawProcessingBooleanParameter" /> instance.</summary>
/// <param name="name">The name of the parameter.</param>
/// <param name="key">The key value for the parameter.</param>
/// <param name="description">The description for the parameter.</param>
/// <param name="initialValue">The parameter's initial value.</param>
/// <param name="neutralOrCameraValue">The parameter's neutral or camera value.</param>
/// <param name="option">Specifies whether <paramref name="neutralOrCameraValue" /> is a neutral or a camera value.</param>
public MERawProcessingBooleanParameter (string name, string key, string description, bool initialValue, bool neutralOrCameraValue, MERawProcessingBooleanParameterInitializationOption option)
: base (NSObjectFlag.Empty)
{
switch (option) {
case MERawProcessingBooleanParameterInitializationOption.NeutralValue:
InitializeHandle (_InitWithNeutralValue (name, key, description, initialValue, neutralOrCameraValue));
break;
case MERawProcessingBooleanParameterInitializationOption.CameraValue:
InitializeHandle (_InitWithCameraValue (name, key, description, initialValue, neutralOrCameraValue));
break;
default:
throw new ArgumentOutOfRangeException (nameof (option), option, "Invalid enum value.");
}
}
}
}
#endif // MONOMAC
#endif // NET
44 changes: 44 additions & 0 deletions src/MediaExtension/MERawProcessingFloatParameter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#if NET
#if MONOMAC
using System;

using Foundation;
using ObjCRuntime;

namespace MediaExtension {
/// <summary>This enum is used to select how to initialize a new instance of a <see cref="MERawProcessingFloatParameter" />.</summary>
public enum MERawProcessingFloatParameterInitializationOption {
/// <summary>The <c>neutralOrCameraValue</c> parameter passed to the constructor is a neutral value.</summary>
NeutralValue,
/// <summary>The <c>neutralOrCameraValue</c> parameter passed to the constructor is a camera value.</summary>
CameraValue,
}

public partial class MERawProcessingFloatParameter {
/// <summary>Create a new <see cref="MERawProcessingFloatParameter" /> instance.</summary>
/// <param name="name">The name of the parameter.</param>
/// <param name="key">The key value for the parameter.</param>
/// <param name="description">The description for the parameter.</param>
/// <param name="initialValue">The parameter's initial value.</param>
/// <param name="maximum">The parameter's maximum value.</param>
/// <param name="minimum">The parameter's minimum value.</param>
/// <param name="neutralOrCameraValue">The parameter's neutral or camera value.</param>
/// <param name="option">Specifies whether <paramref name="neutralOrCameraValue" /> is a neutral or a camera value.</param>
public MERawProcessingFloatParameter (string name, string key, string description, float initialValue, float maximum, float minimum, float neutralOrCameraValue, MERawProcessingFloatParameterInitializationOption option)
: base (NSObjectFlag.Empty)
{
switch (option) {
case MERawProcessingFloatParameterInitializationOption.NeutralValue:
InitializeHandle (_InitWithNeutralValue (name, key, description, initialValue, maximum, minimum, neutralOrCameraValue));
break;
case MERawProcessingFloatParameterInitializationOption.CameraValue:
InitializeHandle (_InitWithCameraValue (name, key, description, initialValue, maximum, minimum, neutralOrCameraValue));
break;
default:
throw new ArgumentOutOfRangeException (nameof (option), option, "Invalid enum value.");
}
}
}
}
#endif // MONOMAC
#endif // NET
44 changes: 44 additions & 0 deletions src/MediaExtension/MERawProcessingIntegerParameter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#if NET
#if MONOMAC
using System;

using Foundation;
using ObjCRuntime;

namespace MediaExtension {
/// <summary>This enum is used to select how to initialize a new instance of a <see cref="MERawProcessingIntegerParameter" />.</summary>
public enum MERawProcessingIntegerParameterInitializationOption {
/// <summary>The <c>neutralOrCameraValue</c> parameter passed to the constructor is a neutral value.</summary>
NeutralValue,
/// <summary>The <c>neutralOrCameraValue</c> parameter passed to the constructor is a camera value.</summary>
CameraValue,
}

public partial class MERawProcessingIntegerParameter {
/// <summary>Create a new <see cref="MERawProcessingIntegerParameter" /> instance.</summary>
/// <param name="name">The name of the parameter.</param>
/// <param name="key">The key value for the parameter.</param>
/// <param name="description">The description for the parameter.</param>
/// <param name="initialValue">The parameter's initial value.</param>
/// <param name="maximum">The parameter's maximum value.</param>
/// <param name="minimum">The parameter's minimum value.</param>
/// <param name="neutralOrCameraValue">The parameter's neutral or camera value.</param>
/// <param name="option">Specifies whether <paramref name="neutralOrCameraValue" /> is a neutral or a camera value.</param>
public MERawProcessingIntegerParameter (string name, string key, string description, nint initialValue, nint maximum, nint minimum, nint neutralOrCameraValue, MERawProcessingIntegerParameterInitializationOption option)
: base (NSObjectFlag.Empty)
{
switch (option) {
case MERawProcessingIntegerParameterInitializationOption.NeutralValue:
InitializeHandle (_InitWithNeutralValue (name, key, description, initialValue, maximum, minimum, neutralOrCameraValue));
break;
case MERawProcessingIntegerParameterInitializationOption.CameraValue:
InitializeHandle (_InitWithCameraValue (name, key, description, initialValue, maximum, minimum, neutralOrCameraValue));
break;
default:
throw new ArgumentOutOfRangeException (nameof (option), option, "Invalid enum value.");
}
}
}
}
#endif // MONOMAC
#endif // NET
43 changes: 43 additions & 0 deletions src/MediaExtension/MERawProcessingListParameter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#if NET
#if MONOMAC
using System;

using Foundation;
using ObjCRuntime;

namespace MediaExtension {
/// <summary>This enum is used to select how to initialize a new instance of a <see cref="MERawProcessingListParameter" />.</summary>
public enum MERawProcessingListParameterInitializationOption {
/// <summary>The <c>neutralOrCameraValue</c> parameter passed to the constructor is a neutral value.</summary>
NeutralValue,
/// <summary>The <c>neutralOrCameraValue</c> parameter passed to the constructor is a camera value.</summary>
CameraValue,
}

public partial class MERawProcessingListParameter {
/// <summary>Create a new <see cref="MERawProcessingListParameter" /> instance.</summary>
/// <param name="name">The name of the parameter.</param>
/// <param name="key">The key value for the parameter.</param>
/// <param name="description">The description for the parameter.</param>
/// <param name="listElements">The parameter's list elements value.</param>
/// <param name="initialValue">The parameter's initial value.</param>
/// <param name="neutralOrCameraValue">The parameter's neutral or camera value.</param>
/// <param name="option">Specifies whether <paramref name="neutralOrCameraValue" /> is a neutral or a camera value.</param>
public MERawProcessingListParameter (string name, string key, string description, MERawProcessingListElementParameter[] listElements, nint initialValue, nint neutralOrCameraValue, MERawProcessingListParameterInitializationOption option)
: base (NSObjectFlag.Empty)
{
switch (option) {
case MERawProcessingListParameterInitializationOption.NeutralValue:
InitializeHandle (_InitWithNeutralValue (name, key, description, listElements, initialValue, neutralOrCameraValue));
break;
case MERawProcessingListParameterInitializationOption.CameraValue:
InitializeHandle (_InitWithCameraValue (name, key, description, listElements, initialValue, neutralOrCameraValue));
break;
default:
throw new ArgumentOutOfRangeException (nameof (option), option, "Invalid enum value.");
}
}
}
}
#endif // MONOMAC
#endif // NET
28 changes: 28 additions & 0 deletions src/MediaExtension/MESampleCursor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#if NET
#if MONOMAC
using System;

using AVFoundation;
using Foundation;
using ObjCRuntime;

namespace MediaExtension {
public partial interface IMESampleCursor {
/// <summary>Compute an exact sample location based on data returned from <see cref="GetEstimatedSampleLocation" />.</summary>
/// <param name="estimatedSampleLocation">The estimated sample location returned from <see cref="GetEstimatedSampleLocation" />.</param>
/// <param name="refinementData">The refinement data returned from <see cref="GetEstimatedSampleLocation" />.</param>
/// <param name="refinedLocation">Upon return, the exact location of the sample.</param>
/// <param name="error">Upon return, null if successful, otherwise an <see cref="NSError" /> instance for the error.</param>
/// <returns>True if successful, false otherwise.</returns>
public bool RefineSampleLocation (AVSampleCursorStorageRange estimatedSampleLocation, byte [] refinementData, out AVSampleCursorStorageRange refinedLocation, out NSError? error)
{
unsafe {
fixed (byte* refinementDataPtr = refinementData) {
return RefineSampleLocation (estimatedSampleLocation, refinementDataPtr, (nuint) refinementData.Length, out refinedLocation, out error);
}
}
}
}
}
#endif // MONOMAC
#endif // NET
3 changes: 3 additions & 0 deletions src/build/generator-frameworks.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ partial class Frameworks {
"MailKit",
"MapKit",
"MediaAccessibility",
"MediaExtension",
"MediaLibrary",
"MediaPlayer",
"MediaToolbox",
Expand Down Expand Up @@ -659,6 +660,7 @@ partial class Frameworks {
bool? _MailKit;
bool? _MapKit;
bool? _MediaAccessibility;
bool? _MediaExtension;
bool? _MediaLibrary;
bool? _MediaPlayer;
bool? _MediaSetup;
Expand Down Expand Up @@ -831,6 +833,7 @@ partial class Frameworks {
public bool HaveMailKit { get { if (!_MailKit.HasValue) _MailKit = GetValue ("MailKit"); return _MailKit.Value; } }
public bool HaveMapKit { get { if (!_MapKit.HasValue) _MapKit = GetValue ("MapKit"); return _MapKit.Value; } }
public bool HaveMediaAccessibility { get { if (!_MediaAccessibility.HasValue) _MediaAccessibility = GetValue ("MediaAccessibility"); return _MediaAccessibility.Value; } }
public bool HaveMediaExtension { get { if (!_MediaExtension.HasValue) _MediaExtension = GetValue ("MediaExtension"); return _MediaExtension.Value; } }
public bool HaveMediaLibrary { get { if (!_MediaLibrary.HasValue) _MediaLibrary = GetValue ("MediaLibrary"); return _MediaLibrary.Value; } }
public bool HaveMediaPlayer { get { if (!_MediaPlayer.HasValue) _MediaPlayer = GetValue ("MediaPlayer"); return _MediaPlayer.Value; } }
public bool HaveMediaSetup { get { if (!_MediaSetup.HasValue) _MediaSetup = GetValue ("MediaSetup"); return _MediaSetup.Value; } }
Expand Down
11 changes: 11 additions & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,16 @@ MEDIAACCESSIBILITY_SOURCES = \
MediaAccessibility/MediaAccessibility.cs \
MediaAccessibility/MAImageCaptioning.cs \

# MediaExtesion

MEDIAEXTENSION_SOURCES = \
MediaExtension/MEByteSource.cs \
MediaExtension/MERawProcessingBooleanParameter.cs \
MediaExtension/MERawProcessingFloatParameter.cs \
MediaExtension/MERawProcessingIntegerParameter.cs \
MediaExtension/MERawProcessingListParameter.cs \
MediaExtension/MESampleCursor.cs \

# MediaPlayer

MEDIAPLAYER_API_SOURCES = \
Expand Down Expand Up @@ -2173,6 +2183,7 @@ MACOS_FRAMEWORKS = \
MailKit \
MapKit \
MediaAccessibility \
MediaExtension \
MediaLibrary \
MediaPlayer \
MediaToolbox \
Expand Down
Loading
Loading