From 7f5feda71cc7ad93f8d8e7a01d5009a38eb49c98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20VIGNELLES?= Date: Fri, 22 May 2020 14:40:20 +0200 Subject: [PATCH] Declared non-seekable streams as non-seekable in callback input These are the same changes as https://github.com/ZeBobo5/Vlc.DotNet/pull/648 Also increased the buffer size to match the libvlc buffer size. # Conflicts: # src/LibVLCSharp/Media.cs --- src/LibVLCSharp/Media.cs | 4 ++-- src/LibVLCSharp/MediaInput.cs | 5 +++++ src/LibVLCSharp/StreamMediaInput.cs | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/LibVLCSharp/Media.cs b/src/LibVLCSharp/Media.cs index 202f8e7ab..ccbebcb11 100644 --- a/src/LibVLCSharp/Media.cs +++ b/src/LibVLCSharp/Media.cs @@ -41,7 +41,7 @@ internal struct Native [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "libvlc_media_new_callbacks")] internal static extern IntPtr LibVLCMediaNewCallbacks(IntPtr libVLC, InternalOpenMedia openCb, InternalReadMedia readCb, - InternalSeekMedia seekCb, InternalCloseMedia closeCb, IntPtr opaque); + InternalSeekMedia? seekCb, InternalCloseMedia closeCb, IntPtr opaque); [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "libvlc_media_add_option")] @@ -295,7 +295,7 @@ static IntPtr CtorFromInput(LibVLC libVLC, MediaInput input) return Native.LibVLCMediaNewCallbacks(libVLC.NativeReference, OpenMediaCallbackHandle, ReadMediaCallbackHandle, - SeekMediaCallbackHandle, + input.CanSeek ? SeekMediaCallbackHandle : null, CloseMediaCallbackHandle, GCHandle.ToIntPtr(input.GcHandle)); } diff --git a/src/LibVLCSharp/MediaInput.cs b/src/LibVLCSharp/MediaInput.cs index 3a94e6422..44b3ba237 100644 --- a/src/LibVLCSharp/MediaInput.cs +++ b/src/LibVLCSharp/MediaInput.cs @@ -23,6 +23,11 @@ protected MediaInput() GcHandle = GCHandle.Alloc(this); } + /// + /// A value indicating whether this Media input can be seeked in. + /// + public bool CanSeek { get; protected set; } = true; + /// /// LibVLC calls this method when it wants to open the media /// diff --git a/src/LibVLCSharp/StreamMediaInput.cs b/src/LibVLCSharp/StreamMediaInput.cs index 6f30b2f09..0587e9a5b 100644 --- a/src/LibVLCSharp/StreamMediaInput.cs +++ b/src/LibVLCSharp/StreamMediaInput.cs @@ -21,6 +21,7 @@ public class StreamMediaInput : MediaInput public StreamMediaInput(Stream stream) { _stream = stream ?? throw new ArgumentNullException(nameof(stream)); + CanSeek = stream.CanSeek; } ///