Skip to content
Open
Changes from 1 commit
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
34 changes: 34 additions & 0 deletions src/LibVLCSharp/Shared/MediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,7 @@
}

LibVLCVideoFormatCb? _videoFormatCb;
LibVLCVideoFormatCbEx? _videoFormatCbEx;
LibVLCVideoCleanupCb? _videoCleanupCb;
IntPtr _videoUserData = IntPtr.Zero;

Expand All @@ -1317,11 +1318,25 @@
public void SetVideoFormatCallbacks(LibVLCVideoFormatCb formatCb, LibVLCVideoCleanupCb? cleanupCb)
{
_videoFormatCb = formatCb ?? throw new ArgumentNullException(nameof(formatCb));
_videoFormatCbEx = null;
_videoCleanupCb = cleanupCb;
Native.LibVLCVideoSetFormatCallbacks(NativeReference, VideoFormatCallbackHandle,
(cleanupCb == null)? null : _videoCleanupCb);
}

/// <summary>
/// This variant passes pitches and lines as IntPtr to allow multi-plane data access.
/// </summary>

public void SetVideoFormatCallbacksEx(LibVLCVideoFormatCbEx formatCb, LibVLCVideoCleanupCb? cleanupCb)
{
_videoFormatCbEx = formatCb ?? throw new ArgumentNullException(nameof(formatCb));
_videoFormatCb = null;
_videoCleanupCb = cleanupCb;
Native.LibVLCVideoSetFormatCallbacks(NativeReference, VideoFormatCallbackExHandle,

Check failure on line 1336 in src/LibVLCSharp/Shared/MediaPlayer.cs

View check run for this annotation

Azure Pipelines / videolan.libvlcsharp (Build Linux)

src/LibVLCSharp/Shared/MediaPlayer.cs#L1336

src/LibVLCSharp/Shared/MediaPlayer.cs(1336,67): Error CS1503: Argument 2: cannot convert from 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCbEx' to 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCb'

Check failure on line 1336 in src/LibVLCSharp/Shared/MediaPlayer.cs

View check run for this annotation

Azure Pipelines / videolan.libvlcsharp (Build Linux)

src/LibVLCSharp/Shared/MediaPlayer.cs#L1336

src/LibVLCSharp/Shared/MediaPlayer.cs(1336,67): Error CS1503: Argument 2: cannot convert from 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCbEx' to 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCb'

Check failure on line 1336 in src/LibVLCSharp/Shared/MediaPlayer.cs

View check run for this annotation

Azure Pipelines / videolan.libvlcsharp (Build Linux)

src/LibVLCSharp/Shared/MediaPlayer.cs#L1336

src/LibVLCSharp/Shared/MediaPlayer.cs(1336,67): Error CS1503: Argument 2: cannot convert from 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCbEx' to 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCb'

Check failure on line 1336 in src/LibVLCSharp/Shared/MediaPlayer.cs

View check run for this annotation

Azure Pipelines / videolan.libvlcsharp (Build Linux)

src/LibVLCSharp/Shared/MediaPlayer.cs#L1336

src/LibVLCSharp/Shared/MediaPlayer.cs(1336,67): Error CS1503: Argument 2: cannot convert from 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCbEx' to 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCb'

Check failure on line 1336 in src/LibVLCSharp/Shared/MediaPlayer.cs

View check run for this annotation

Azure Pipelines / videolan.libvlcsharp (Build Linux)

src/LibVLCSharp/Shared/MediaPlayer.cs#L1336

src/LibVLCSharp/Shared/MediaPlayer.cs(1336,67): Error CS1503: Argument 2: cannot convert from 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCbEx' to 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCb'

Check failure on line 1336 in src/LibVLCSharp/Shared/MediaPlayer.cs

View check run for this annotation

Azure Pipelines / videolan.libvlcsharp

src/LibVLCSharp/Shared/MediaPlayer.cs#L1336

src/LibVLCSharp/Shared/MediaPlayer.cs(1336,67): Error CS1503: Argument 2: cannot convert from 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCbEx' to 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCb'

Check failure on line 1336 in src/LibVLCSharp/Shared/MediaPlayer.cs

View check run for this annotation

Azure Pipelines / videolan.libvlcsharp

src/LibVLCSharp/Shared/MediaPlayer.cs#L1336

src/LibVLCSharp/Shared/MediaPlayer.cs(1336,67): Error CS1503: Argument 2: cannot convert from 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCbEx' to 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCb'

Check failure on line 1336 in src/LibVLCSharp/Shared/MediaPlayer.cs

View check run for this annotation

Azure Pipelines / videolan.libvlcsharp

src/LibVLCSharp/Shared/MediaPlayer.cs#L1336

src/LibVLCSharp/Shared/MediaPlayer.cs(1336,67): Error CS1503: Argument 2: cannot convert from 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCbEx' to 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCb'

Check failure on line 1336 in src/LibVLCSharp/Shared/MediaPlayer.cs

View check run for this annotation

Azure Pipelines / videolan.libvlcsharp

src/LibVLCSharp/Shared/MediaPlayer.cs#L1336

src/LibVLCSharp/Shared/MediaPlayer.cs(1336,67): Error CS1503: Argument 2: cannot convert from 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCbEx' to 'LibVLCSharp.Shared.MediaPlayer.LibVLCVideoFormatCb'
(cleanupCb == null)? null : _videoCleanupCb);
}

/// <summary>
/// Enable or disable key press events handling, according to the LibVLC hotkeys configuration.
/// By default and for historical reasons, keyboard events are handled by the LibVLC video widget.
Expand Down Expand Up @@ -1786,6 +1801,7 @@
static readonly LibVLCVideoUnlockCb VideoUnlockCallbackHandle = VideoUnlockCallback;
static readonly LibVLCVideoDisplayCb VideoDisplayCallbackHandle = VideoDisplayCallback;
static readonly LibVLCVideoFormatCb VideoFormatCallbackHandle = VideoFormatCallback;
static readonly LibVLCVideoFormatCbEx VideoFormatCallbackExHandle = VideoFormatCallbackEx;

[MonoPInvokeCallback(typeof(LibVLCVideoLockCb))]
private static IntPtr VideoLockCallback(IntPtr opaque, IntPtr planes)
Expand Down Expand Up @@ -1830,6 +1846,18 @@
return 0;
}

[MonoPInvokeCallback(typeof(LibVLCVideoFormatCbEx))]
private static uint VideoFormatCallbackEx(ref IntPtr opaque, IntPtr chroma, ref uint width, ref uint height, IntPtr pitches, IntPtr lines)
{
var mediaPlayer = MarshalUtils.GetInstance<MediaPlayer>(opaque);
if (mediaPlayer?._videoFormatCbEx != null)
{
return mediaPlayer._videoFormatCbEx(ref mediaPlayer._videoUserData, chroma, ref width, ref height, pitches, lines);
}

return 0;
}

static readonly LibVLCAudioPlayCb AudioPlayCallbackHandle = AudioPlayCallback;
static readonly LibVLCAudioPauseCb AudioPauseCallbackHandle = AudioPauseCallback;
static readonly LibVLCAudioResumeCb AudioResumeCallbackHandle = AudioResumeCallback;
Expand Down Expand Up @@ -2008,6 +2036,12 @@
public delegate uint LibVLCVideoFormatCb(ref IntPtr opaque, IntPtr chroma, ref uint width,
ref uint height, ref uint pitches, ref uint lines);

/// <summary>Callback prototype</summary>
/// <remarks>Passes pitches and lines as IntPtr to allow multi-plane data access.</remarks>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate uint LibVLCVideoFormatCbEx(ref IntPtr opaque, IntPtr chroma, ref uint width,
ref uint height, IntPtr pitches, IntPtr lines);

/// <summary>Callback prototype to configure picture buffers format.</summary>
/// <param name="opaque">
/// <para>private pointer as passed to libvlc_video_set_callbacks()</para>
Expand Down
Loading