...
 
Commits (17)
......@@ -26,4 +26,7 @@
<PropertyGroup Condition="$(TargetFramework.StartsWith('uap'))">
<DefineConstants>$(DefineConstants);UWP;NET</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0'">
<DefineConstants>$(DefineConstants);UWP10_0</DefineConstants>
</PropertyGroup>
</Project>
\ No newline at end of file
......@@ -27,7 +27,7 @@ Features:
</Description>
<TargetFramework>net47</TargetFramework>
<RootNamespace>LibVLCSharp.Forms.Platforms.GTK</RootNamespace>
<PackageVersion>0.8.1</PackageVersion>
<Version>3.0.1</Version>
<PackageId>LibVLCSharp.Forms.GTK</PackageId>
<Authors>VideoLAN</Authors>
<Owners>VideoLAN</Owners>
......
......@@ -27,7 +27,7 @@ Features:
</Description>
<TargetFramework>net47</TargetFramework>
<RootNamespace>LibVLCSharp.Forms.Platforms.WPF</RootNamespace>
<PackageVersion>0.8.1</PackageVersion>
<Version>3.0.1</Version>
<PackageId>LibVLCSharp.Forms.WPF</PackageId>
<Authors>VideoLAN</Authors>
<Owners>VideoLAN</Owners>
......
......@@ -30,7 +30,7 @@ Features:
<RootNamespace>LibVLCSharp.Forms</RootNamespace>
<NeutralLanguage>en</NeutralLanguage>
<LangVersion>7.3</LangVersion>
<Version>0.8.1</Version>
<Version>3.0.1</Version>
<PackageId>LibVLCSharp.Forms</PackageId>
<Authors>VideoLAN</Authors>
<Owners>VideoLAN</Owners>
......
......@@ -20,24 +20,24 @@ namespace LibVLCSharp.Forms.Platforms.Android
{
base.OnElementChanged(e);
if (Control == null)
if (e.NewElement != null)
{
SetNativeControl(new LibVLCSharp.Platforms.Android.VideoView(Context));
if (Control == null)
{
SetNativeControl(new LibVLCSharp.Platforms.Android.VideoView(Context));
e.NewElement.MediaPlayerChanging += OnMediaPlayerChanging;
if (Control.MediaPlayer != e.NewElement.MediaPlayer)
{
OnMediaPlayerChanging(this, new MediaPlayerChangingEventArgs(Control.MediaPlayer, e.NewElement.MediaPlayer));
}
}
}
if (e.OldElement != null)
{
e.OldElement.MediaPlayerChanging -= OnMediaPlayerChanging;
}
if (e.NewElement != null)
{
e.NewElement.MediaPlayerChanging += OnMediaPlayerChanging;
if (Control.MediaPlayer != e.NewElement.MediaPlayer)
{
OnMediaPlayerChanging(this, new MediaPlayerChangingEventArgs(Control.MediaPlayer, e.NewElement.MediaPlayer));
}
}
}
}
private void OnMediaPlayerChanging(object sender, MediaPlayerChangingEventArgs e)
......
......@@ -15,24 +15,24 @@ namespace LibVLCSharp.Forms.Platforms.Mac
{
base.OnElementChanged(e);
if (Control == null)
if (e.NewElement != null)
{
SetNativeControl(new LibVLCSharp.Platforms.Mac.VideoView());
if (Control == null)
{
SetNativeControl(new LibVLCSharp.Platforms.Mac.VideoView());
e.NewElement.MediaPlayerChanging += OnMediaPlayerChanging;
if (Control.MediaPlayer != e.NewElement.MediaPlayer)
{
OnMediaPlayerChanging(this, new MediaPlayerChangingEventArgs(Control.MediaPlayer, e.NewElement.MediaPlayer));
}
}
}
if (e.OldElement != null)
{
e.OldElement.MediaPlayerChanging -= OnMediaPlayerChanging;
}
if (e.NewElement != null)
{
e.NewElement.MediaPlayerChanging += OnMediaPlayerChanging;
if (Control.MediaPlayer != e.NewElement.MediaPlayer)
{
OnMediaPlayerChanging(this, new MediaPlayerChangingEventArgs(Control.MediaPlayer, e.NewElement.MediaPlayer));
}
}
}
private void OnMediaPlayerChanging(object sender, MediaPlayerChangingEventArgs e)
......
......@@ -17,24 +17,24 @@ namespace LibVLCSharp.Forms.Platforms.iOS
{
base.OnElementChanged(e);
if(Control == null)
if (e.NewElement != null)
{
SetNativeControl(new LibVLCSharp.Forms.Platforms.iOS.VideoView());
if (Control == null)
{
SetNativeControl(new LibVLCSharp.Platforms.iOS.VideoView());
e.NewElement.MediaPlayerChanging += OnMediaPlayerChanging;
if (Control.MediaPlayer != e.NewElement.MediaPlayer)
{
OnMediaPlayerChanging(this, new MediaPlayerChangingEventArgs(Control.MediaPlayer, e.NewElement.MediaPlayer));
}
}
}
if (e.OldElement != null)
{
e.OldElement.MediaPlayerChanging -= OnMediaPlayerChanging;
}
if (e.NewElement != null)
{
e.NewElement.MediaPlayerChanging += OnMediaPlayerChanging;
if (Control.MediaPlayer != e.NewElement.MediaPlayer)
{
OnMediaPlayerChanging(this, new MediaPlayerChangingEventArgs(Control.MediaPlayer, e.NewElement.MediaPlayer));
}
}
}
private void OnMediaPlayerChanging(object sender, MediaPlayerChangingEventArgs e)
......@@ -42,26 +42,4 @@ namespace LibVLCSharp.Forms.Platforms.iOS
Control.MediaPlayer = e.NewMediaPlayer;
}
}
public class VideoView : LibVLCSharp.Platforms.iOS.VideoView, IVisualElementRenderer
{
public VisualElement Element { get; private set; }
public UIView NativeView => this;
public UIViewController ViewController => ViewController;
public event EventHandler<VisualElementChangedEventArgs> ElementChanged;
public SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint) => this.GetSizeRequest(widthConstraint, heightConstraint);
public void SetElement(VisualElement element)
{
Element = element;
ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(null, Element));
}
public void SetElementSize(Size size) => Element.Layout(new Rectangle(Element.X, Element.Y, size.Width, size.Height));
}
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ libvlc needs to be installed separately.
</Description>
<TargetFramework>net47</TargetFramework>
<RootNamespace>LibVLCSharp.GTK</RootNamespace>
<Version>0.8.1</Version>
<Version>3.0.1</Version>
<PackageId>LibVLCSharp.GTK</PackageId>
<Authors>VideoLAN</Authors>
<Owners>VideoLAN</Owners>
......
......@@ -29,7 +29,7 @@ Features:
<RootNamespace>LibVLCSharp.WPF</RootNamespace>
<NeutralLanguage>en</NeutralLanguage>
<LangVersion>7.3</LangVersion>
<Version>0.8.1</Version>
<Version>3.0.1</Version>
<PackageId>LibVLCSharp.WPF</PackageId>
<UseWPF>true</UseWPF>
<Authors>VideoLAN</Authors>
......
......@@ -21,7 +21,7 @@
</Description>
<TargetFrameworks>net40</TargetFrameworks>
<RootNamespace>LibVLCSharp.WinForms</RootNamespace>
<Version>0.8.1</Version>
<Version>3.0.1</Version>
<PackageId>LibVLCSharp.WinForms</PackageId>
<Authors>VideoLAN</Authors>
<Owners>VideoLAN</Owners>
......

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.0
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibVLCSharp", "LibVLCSharp\LibVLCSharp.csproj", "{D1C3B7C4-713B-46B2-B33A-E9298C819921}"
EndProject
......@@ -65,6 +65,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibVLCSharp.WinForms.Sample
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibVLCSharp.UWP.Sample", "Samples\LibVLCSharp.UWP.Sample\LibVLCSharp.UWP.Sample.csproj", "{B0796D95-FA72-4154-9668-1F939BF03816}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibVLCSharp.D3DCallbacks", "Samples\LibVLCSharp.D3DCallbacks\LibVLCSharp.D3DCallbacks.csproj", "{2182D09E-594C-472D-BB15-37ECEAA9DD22}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
......@@ -1579,6 +1581,62 @@ Global
{B0796D95-FA72-4154-9668-1F939BF03816}.Release|x86.ActiveCfg = Release|x86
{B0796D95-FA72-4154-9668-1F939BF03816}.Release|x86.Build.0 = Release|x86
{B0796D95-FA72-4154-9668-1F939BF03816}.Release|x86.Deploy.0 = Release|x86
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|ARM64.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|ARM64.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|ARM.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|ARM64.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|ARM64.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|iPhone.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|x64.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|x64.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|x86.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.AppStore|x86.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|ARM.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|ARM.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|ARM64.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|iPhone.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|x64.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|x64.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|x86.ActiveCfg = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Debug|x86.Build.0 = Debug|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|Any CPU.Build.0 = Release|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|ARM.ActiveCfg = Release|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|ARM.Build.0 = Release|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|ARM64.ActiveCfg = Release|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|ARM64.Build.0 = Release|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|iPhone.ActiveCfg = Release|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|iPhone.Build.0 = Release|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|x64.ActiveCfg = Release|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|x64.Build.0 = Release|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|x86.ActiveCfg = Release|Any CPU
{2182D09E-594C-472D-BB15-37ECEAA9DD22}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -1602,6 +1660,7 @@ Global
{B6182E93-C6B0-4494-840E-BB045933857C} = {799A84A2-2161-4676-878B-5610E3586137}
{65A8ECFD-4D73-48A3-A05E-3D8807FEB0C2} = {799A84A2-2161-4676-878B-5610E3586137}
{B0796D95-FA72-4154-9668-1F939BF03816} = {799A84A2-2161-4676-878B-5610E3586137}
{2182D09E-594C-472D-BB15-37ECEAA9DD22} = {799A84A2-2161-4676-878B-5610E3586137}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AB1424F9-871B-444A-9278-18227672889C}
......
......@@ -20,13 +20,13 @@
libvlc needs to be installed separately. See VideoLAN.LibVLC.* packages.
</Description>
<TargetFrameworks>netstandard2.0;netstandard1.1;net40;net471</TargetFrameworks>
<TargetFrameworks Condition="!$([MSBuild]::IsOsPlatform('Linux'))">$(TargetFrameworks);MonoAndroid81;Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('Windows'))">$(TargetFrameworks);uap10.0</TargetFrameworks>
<TargetFrameworks Condition="!$([MSBuild]::IsOsPlatform('Linux'))">$(TargetFrameworks);Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('Windows'))">$(TargetFrameworks);uap10.0;uap10.0.16299</TargetFrameworks>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);IncludeAWindow</TargetsForTfmSpecificBuildOutput>
<RootNamespace>LibVLCSharp</RootNamespace>
<NeutralLanguage>en</NeutralLanguage>
<LangVersion>7.3</LangVersion>
<PackageVersion>0.8.1</PackageVersion>
<Version>4.0-alpha</Version>
<PackageId>LibVLCSharp</PackageId>
<Authors>VideoLAN</Authors>
<Owners>VideoLAN</Owners>
......
using System;
using LibVLCSharp.Shared.Helpers;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
......@@ -37,6 +38,9 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, EntryPoint = "JNI_OnLoad")]
internal static extern int JniOnLoad(IntPtr javaVm, IntPtr reserved = default(IntPtr));
#endif
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_get_version")]
internal static extern IntPtr LibVLCVersion();
}
#if NET || NETSTANDARD
......@@ -50,6 +54,8 @@ namespace LibVLCSharp.Shared
/// Load the native libvlc library (if necessary, depending on platform)
/// <para/> Ensure that you installed the VideoLAN.LibVLC.[YourPlatform] package in your target project
/// <para/> This will throw a <see cref="VLCException"/> if the native libvlc libraries cannot be found or loaded.
/// <para/> It may also throw a <see cref="VLCException"/> if the LibVLC and LibVLCSharp major versions do not match.
/// See https://code.videolan.org/videolan/LibVLCSharp/blob/master/VERSIONING.md for more info about the versioning strategy.
/// </summary>
/// <param name="libvlcDirectoryPath">The path to the directory that contains libvlc and libvlccore
/// No need to specify unless running netstandard 1.1, or using custom location for libvlc
......@@ -63,9 +69,26 @@ namespace LibVLCSharp.Shared
InitializeUWP();
#elif NET || NETSTANDARD
InitializeDesktop(libvlcDirectoryPath);
#endif
#if !UWP10_0 && !NETSTANDARD1_1
EnsureVersionsMatch();
#endif
}
#if !UWP10_0 && !NETSTANDARD1_1
/// <summary>
/// Checks whether the major version of LibVLC and LibVLCSharp match <para/>
/// Throws an NotSupportedException if the major versions mismatch
/// </summary>
static void EnsureVersionsMatch()
{
var libvlcMajorVersion = int.Parse(Native.LibVLCVersion().FromUtf8().Split('.').First());
var libvlcsharpMajorVersion = Assembly.GetExecutingAssembly().GetName().Version.Major;
if(libvlcMajorVersion != libvlcsharpMajorVersion)
throw new VLCException($"Version mismatch between LibVLC {libvlcMajorVersion} and LibVLCSharp {libvlcsharpMajorVersion}. " +
$"They must share the same major version number");
}
#endif
#if ANDROID
static void InitializeAndroid()
{
......
......@@ -602,6 +602,11 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.UnityPlugin, EntryPoint = "getVideoFrameVLC")]
internal static extern IntPtr GetFrame(IntPtr mediaPlayer, out bool updated);
#endif
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_direct3d_set_callbacks")]
internal static extern bool LibVLCVideoDirect3DSetCallbacks(IntPtr mediaplayer, Direct3DEngine engine,
LibVLCD3DSetupCb setupCb, LibVLCD3DCleanupCb cleanupCb, LibVLCD3DUpdateOutputCb updateOutputCb,
LibVLCSwapCb swapCb, LibVLCD3DStartEndRenderingCb startEndRenderingCb, LibVLCD3DSelectPlaneCb selectPlaneCb, IntPtr opaque);
}
MediaPlayerEventManager _eventManager;
......@@ -1648,6 +1653,26 @@ namespace LibVLCSharp.Shared
public bool SetRenderer(RendererItem rendererItem) =>
Native.LibVLCMediaPlayerSetRenderer(NativeReference, rendererItem.NativeReference) == 0;
/// <summary>
/// Set callbacks and data to render decoded video to a custom Direct3D output <para/>
/// warning: VLC will perform video rendering in its own thread and at its own rate,
/// You need to provide your own synchronisation mechanism.
/// <para/>LibVLC 4.0.0 or later
/// </summary>
/// <param name="engine">the GPU engine to use</param>
/// <param name="setupCb">callback to setup and return the device to use (cannot be NULL)</param>
/// <param name="cleanupCb">callback to cleanup the device given by the <see cref="LibVLCD3DSetupCb"/> callback</param>
/// <param name="updateOutputCb">callback to notify of the source format and get the rendering format used by the host (cannot be NULL)</param>
/// <param name="swapCb">callback to tell the host it should display the rendered picture (cannot be NULL)</param>
/// <param name="startEndRenderingCb">callback to tell the host the rendering is starting/ended (cannot be NULL)</param>
/// <param name="selectPlaneCb">callback to select different D3D11 rendering targets</param>
/// <param name="opaque">private pointer passed to the <see cref="LibVLCD3DCleanupCb"/> callback</param>
/// <returns>true Direct3D selected and callbacks set, false otherwise</returns>
public bool SetDirect3DCallbacks(Direct3DEngine engine, LibVLCD3DSetupCb setupCb, LibVLCD3DCleanupCb cleanupCb,
LibVLCD3DUpdateOutputCb updateOutputCb, LibVLCSwapCb swapCb, LibVLCD3DStartEndRenderingCb startEndRenderingCb,
LibVLCD3DSelectPlaneCb selectPlaneCb, IntPtr opaque)
=> Native.LibVLCVideoDirect3DSetCallbacks(NativeReference, engine, setupCb, cleanupCb, updateOutputCb, swapCb, startEndRenderingCb, selectPlaneCb, opaque);
/// <summary>Gets the media role.
/// <para/> version LibVLC 3.0.0 and later.
/// </summary>
......@@ -1861,8 +1886,88 @@ namespace LibVLCSharp.Shared
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void LibVLCVolumeCb(IntPtr data, float volume, [MarshalAs(UnmanagedType.I1)] bool mute);
#endregion
/// <summary>
/// Setup the rendering environment. <para/>
/// For <see cref="Direct3DEngine.D3D9"/>, the output must be a IDirect3DDevice9*.
/// A reference to this object is held until <see cref="LibVLCD3DSetupCb"/> is called.
/// the device must be created with D3DPRESENT_PARAMETERS.hDeviceWindow set to 0.
/// <para/>
/// For <see cref="Direct3DEngine.D3D11"/>, the output must be a ID3D11DeviceContext*.
/// A reference to this object is held until <see cref="LibVLCD3DSetupCb"/> is called.
/// The ID3D11Device used to create ID3D11DeviceContext must have multithreading enabled.
/// <para/>
/// version LibVLC 4.0.0 or later
/// </summary>
/// <param name="opaque">private pointer passed to the <see cref="SetDirect3DCallbacks"/>
/// on input. The callback can change this value on output to be passed to all the other callbacks set on <see cref="SetDirect3DCallbacks"/>. [IN/OUT]
/// </param>
/// <param name="config">requested <see cref="D3DConfig"/> of the video device</param>
/// <param name="setup"><see cref="D3DSetup"/> to fill</param>
/// <returns>true on success</returns>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool LibVLCD3DSetupCb(IntPtr opaque, D3DConfig config, ref D3DSetup setup);
/// <summary>
/// Cleanup the rendering environment initialized during <see cref="LibVLCD3DSetupCb"/>.
/// <para/>
/// version LibVLC 4.0.0 or later
/// </summary>
/// <param name="opaque">private pointer set on the opaque parameter of <see cref="LibVLCD3DSetupCb"/> [IN]</param>
/// <returns></returns>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool LibVLCD3DCleanupCb(IntPtr opaque);
/// <summary>
/// Update the rendering output setup. <para/>
/// Tone mapping, range and color conversion will be done depending on the values set in the output structure.
/// </summary>
/// <param name="opaque">private pointer passed to the <see cref="SetDirect3DCallbacks"/>[IN]</param>
/// <param name="config">configuration of the video that will be rendered [IN]</param>
/// <param name="output">output configuration describing with how the rendering is setup [OUT]</param>
/// <returns>true on success</returns>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool LibVLCD3DUpdateOutputCb(IntPtr opaque, D3DConfig config, ref OutputConfig output);
/// <summary>
/// Callback prototype called after performing drawing calls.
/// <para/> LibVLC 4.0.0 or later
/// </summary>
/// <param name="opaque">private pointer passed to the @a libvlc_video_set_output_callbacks() [IN]</param>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void LibVLCSwapCb(IntPtr opaque);
/// <summary>
/// Tell the host the rendering is about to start/has finished. <para/>
/// LibVLC 4.0.0 or later
/// </summary>
/// <param name="opaque">private pointer set on the opaque parameter of @a libvlc_video_direct3d_device_setup_cb() [IN]</param>
/// <param name="enter">true if the rendering is about to start, false if it's finished</param>
/// <param name="hdr">libvlc_video_direct3d_hdr10_metadata_t* or NULL [IN]</param>
/// <returns>true on success</returns>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool LibVLCD3DStartEndRenderingCb(IntPtr opaque, bool enter, D3DHDR10Metadata hdr);
/// <summary>
/// Tell the host the rendering for the given plane is about to start
/// note This is only used with <see cref="Direct3DEngine.D3D11"/>.
/// <para/>
/// The host should call OMSetRenderTargets for Direct3D11.If this callback is
/// not used (set to NULL in <see cref="SetDirect3DCallbacks"/>) OMSetRenderTargets
/// has to be set during the <see cref="LibVLCD3DStartEndRenderingCb"/> entering call.
/// <para/>
/// The number of planes depend on the DXGI_FORMAT returned during the
/// \ref LIBVLC_VIDEO_UPDATE_OUTPUT call.It's usually one plane except for
/// semi-planar formats like DXGI_FORMAT_NV12 or DXGI_FORMAT_P010.
/// <para/>LibVLC 4.0.0 or later
/// </summary>
/// <param name="opaque">private pointer set on the opaque parameter of <see cref="LibVLCD3DSetupCb"/> [IN]</param>
/// <param name="plane">number of the rendering plane to select</param>
/// <returns>true on success</returns>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool LibVLCD3DSelectPlaneCb(IntPtr opaque, ulong plane);
#endregion
/// <summary>
/// Get the Event Manager from which the media player send event.
/// </summary>
......@@ -2085,6 +2190,63 @@ namespace LibVLCSharp.Shared
}
}
[StructLayout(LayoutKind.Sequential)]
public readonly struct D3DDeviceConfig
{
public readonly bool HardwareDecoding;
public readonly IntPtr ReportSizeChange;
public readonly IntPtr ReportOpaque;
}
[StructLayout(LayoutKind.Sequential)]
public readonly struct D3DConfig
{
public readonly uint Width;
public readonly uint Height;
public readonly uint BitDepth;
public readonly bool FullRange;
public readonly ColorSpace ColorSpace;
public readonly ColorPrimaries Primaries;
public readonly TransferFunction Transfer;
}
[StructLayout(LayoutKind.Sequential)]
public struct D3DSetup
{
public IntPtr DeviceContext { get; set; }
}
[StructLayout(LayoutKind.Sequential)]
public struct OutputConfig
{
public int SurfaceFormat { get; set; }
public bool FullRange { get; set; }
public ColorSpace ColorSpace { get; set; }
public ColorPrimaries ColorPrimaries { get; set; }
public TransferFunction TransferFunction { get; set; }
}
/// <summary>
///
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct D3DHDR10Metadata
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
internal ushort[] RedPrimary;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
internal ushort[] GreenPrimary;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
internal ushort[] BluePrimary;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
internal ushort[] WhitePoint;
internal uint MaxMasteringLuminance;
internal uint MinMasteringLuminance;
internal ushort MaxContentLightLevel;
internal ushort MaxFrameAverageLightLevel;
}
/// <summary>Description for titles</summary>
public enum Title
{
......@@ -2231,5 +2393,60 @@ namespace LibVLCSharp.Shared
Accessibility = 8,
/// <summary>Testing</summary>
Test = 9
}
}
/// <summary>
/// Enumeration of the Video engine to be used on output.
/// can be passed to <see cref="SetDirect3DCallbacks"/>
/// </summary>
public enum Direct3DEngine
{
/// <summary>
/// Direct3D11 rendering engine
/// </summary>
D3D11,
/// <summary>
/// Direct3D9 rendering engine
/// </summary>
D3D9
}
/// <summary>
/// Enumeration of the Video color spaces.
/// </summary>
public enum ColorSpace
{
BT601 = 1,
BT709 = 2,
BT2020 = 3
}
/// <summary>
/// Enumeration of the Video color primaries.
/// </summary>
public enum ColorPrimaries
{
BT601_525 = 1,
BT601_625 = 2,
BT709 = 3,
BT2020 = 4,
DCI_P3 = 5,
BT470_M = 6,
}
/// <summary>
/// Enumeration of the Video transfer functions.
/// </summary>
public enum TransferFunction
{
LINEAR = 1,
SRGB = 2,
BT470_BG = 3,
BT470_M = 4,
BT709 = 5,
PQ = 6,
SMPTE_240 = 7,
HLG = 8,
}
}
LibVLCSharp version 3.0.1
=========================
* Add libvlc/libvlcsharp version check
* Add Xamarin.Forms 4.0 support for LibVLCSharp.Forms
LibVLCSharp version 3.0.0
=========================
* First stable release: https://mfkl.github.io/libvlc/crossplatform/xamarin/forms/release/2019/05/13/LibVLCSharp-goes-stable.html
* VS2019 support
LibVLCSharp version 0.8.1
=========================
* Fix ARM debug support for UWP.
......
......@@ -124,8 +124,8 @@
</PropertyGroup>
<Error Condition="!Exists('..\..\..\packages\Xamarin.Forms.3.2.0.871581\build\netstandard2.0\Xamarin.Forms.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Xamarin.Forms.3.2.0.871581\build\netstandard2.0\Xamarin.Forms.props'))" />
<Error Condition="!Exists('..\..\..\packages\Xamarin.Forms.3.2.0.871581\build\netstandard2.0\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Xamarin.Forms.3.2.0.871581\build\netstandard2.0\Xamarin.Forms.targets'))" />
<Error Condition="!Exists('..\..\..\packages\VideoLAN.LibVLC.Mac.3.1.2\build\VideoLAN.LibVLC.Mac.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\VideoLAN.LibVLC.Mac.3.1.2\build\VideoLAN.LibVLC.Mac.targets'))" />
<Error Condition="!Exists('..\..\..\packages\VideoLAN.LibVLC.Mac.3.1.3\build\VideoLAN.LibVLC.Mac.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\VideoLAN.LibVLC.Mac.3.1.3\build\VideoLAN.LibVLC.Mac.targets'))" />
</Target>
<Import Project="..\..\..\packages\Xamarin.Forms.3.2.0.871581\build\netstandard2.0\Xamarin.Forms.targets" Condition="Exists('..\..\..\packages\Xamarin.Forms.3.2.0.871581\build\netstandard2.0\Xamarin.Forms.targets')" />
<Import Project="..\..\..\packages\VideoLAN.LibVLC.Mac.3.1.2\build\VideoLAN.LibVLC.Mac.targets" Condition="Exists('..\..\..\packages\VideoLAN.LibVLC.Mac.3.1.2\build\VideoLAN.LibVLC.Mac.targets')" />
<Import Project="..\..\..\packages\VideoLAN.LibVLC.Mac.3.1.3\build\VideoLAN.LibVLC.Mac.targets" Condition="Exists('..\..\..\packages\VideoLAN.LibVLC.Mac.3.1.3\build\VideoLAN.LibVLC.Mac.targets')" />
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="VideoLAN.LibVLC.Mac" version="3.1.2" targetFramework="xamarinmac20" />
<package id="VideoLAN.LibVLC.Mac" version="3.1.3" targetFramework="xamarinmac20" />
<package id="Xamarin.Forms" version="3.2.0.871581" targetFramework="xamarinmac20" />
</packages>
\ No newline at end of file
......@@ -43,7 +43,7 @@ namespace LibVLCSharp.Forms.Sample
MediaPlayer = new MediaPlayer(LibVLC)
{
Media = new Media(LibVLC,
"http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4",
"https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4",
FromType.FromLocation)
};
}
......
......@@ -33,7 +33,7 @@ namespace LibVLCSharp.Android.Sample
_videoView = new VideoView(this) { MediaPlayer = _mediaPlayer };
AddContentView(_videoView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
var media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation);
var media = new Media(_libVLC, "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", FromType.FromLocation);
var configuration = new MediaConfiguration();
configuration.EnableHardwareDecoding();
media.AddOption(configuration);
......
<Project Sdk="MSBuild.Sdk.Extras">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net471</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<PlatformTarget>x64</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<None Remove="MiniCube.fx" />
</ItemGroup>
<ItemGroup>
<Content Include="MiniCube.fx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="SharpDX" Version="4.2.0" />
<PackageReference Include="SharpDX.D3DCompiler" Version="4.2.0" />
<PackageReference Include="SharpDX.Desktop" Version="4.2.0" />
<PackageReference Include="SharpDX.Direct3D11" Version="4.2.0" />
<PackageReference Include="SharpDX.DXGI" Version="4.2.0" />
<PackageReference Include="SharpDX.Mathematics" Version="4.2.0" />
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="4.0.0-alpha2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\LibVLCSharp\LibVLCSharp.csproj" />
</ItemGroup>
</Project>
Texture2D shaderTexture;
SamplerState samplerState;
struct PS_INPUT
{
float4 position : SV_POSITION;
float4 textureCoord : TEXCOORD0;
};
float4 PShader(PS_INPUT In) : SV_TARGET
{
return shaderTexture.Sample(samplerState, In.textureCoord);
}
struct VS_INPUT
{
float4 position : POSITION;
float4 textureCoord : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 position : SV_POSITION;
float4 textureCoord : TEXCOORD0;
};
VS_OUTPUT VShader(VS_INPUT In)
{
return In;
}
\ No newline at end of file
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using LibVLCSharp.Shared;
using SharpDX;
using SharpDX.D3DCompiler;
using SharpDX.Direct3D;
using SharpDX.Direct3D11;
using SharpDX.DXGI;
using SharpDX.Mathematics.Interop;
using SharpDX.Windows;
using Buffer = SharpDX.Direct3D11.Buffer;
using Device = SharpDX.Direct3D11.Device;
namespace LibVLCSharp.D3DCallbacks
{
/// <summary>
/// SharpDX MiniCube Direct3D 11 Sample
/// </summary>
internal static class Program
{
static bool Setup(IntPtr opaque, D3DConfig config, ref D3DSetup setup)
{
setup.DeviceContext = context.NativePointer;
return true;
}
private static bool Cleanup(IntPtr opaque)
{
//signature.Dispose();
//vertexShaderByteCode.Dispose();
//vertexShader.Dispose();
//pixelShaderByteCode.Dispose();
//pixelShader.Dispose();
//vertices.Dispose();
//layout.Dispose();
//contantBuffer.Dispose();
//depthBuffer.Dispose();
//depthView.Dispose();
//renderView.Dispose();
//backBuffer.Dispose();
//context.ClearState();
//context.Flush();
//device.Dispose();
//context.Dispose();
//swapChain.Dispose();
//factory.Dispose();
return true;
}
private static bool UpdateOutput(IntPtr opaque, D3DConfig config, ref OutputConfig output)
{
var renderFormat = Format.R8G8B8A8_UNorm;
var textDesc = new Texture2DDescription
{
MipLevels = 1,
SampleDescription = new SampleDescription { Count = 1 },
OptionFlags = 0,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
Usage = ResourceUsage.Default,
CpuAccessFlags = 0,
ArraySize = 1,
Format = renderFormat,
Height = Convert.ToInt32(config.Height),
Width = Convert.ToInt32(config.Width)
};
texture = new Texture2D(device, textDesc);
var resViewDesc = new ShaderResourceViewDescription
{
Dimension = ShaderResourceViewDimension.Texture2D,
// miplevels
Format = textDesc.Format
};
textureShaderInput = new ShaderResourceView(device, texture, resViewDesc);
var renderTargetDesc = new RenderTargetViewDescription
{
Format = textDesc.Format,
Dimension = RenderTargetViewDimension.Texture2D
};
textureRenderTarget = new RenderTargetView(device, texture, renderTargetDesc);
output.SurfaceFormat = (int)renderFormat;
output.FullRange = true;
output.ColorSpace = ColorSpace.BT709;
output.ColorPrimaries = ColorPrimaries.BT709;
output.TransferFunction = TransferFunction.SRGB;
return true;
}
private static void Swap(IntPtr opaque)
{
swapChain.Present(0, PresentFlags.None);
}
private static bool StartEndRendering(IntPtr opaque, bool enter, D3DHDR10Metadata hdr)
{
if(enter)
{
context.ComputeShader.SetShaderResources(0);
context.ClearRenderTargetView(textureRenderTarget, blackRGBA);
return true;
}
context.OutputMerger.SetTargets(swapchainRenderTarget);
context.ClearRenderTargetView(swapchainRenderTarget, orangeRGBA);
context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
context.InputAssembler.InputLayout = shadersInputLayout;
int[] offset = { 0 };
context.InputAssembler.SetVertexBuffers(slot: 0, vertexBuffers: new Buffer[] { vertexBuffer },
stridesRef: new int[] { Convert.ToInt32(vertexBufferStride) },
offsetsRef: offset);
context.InputAssembler.SetIndexBuffer(indexBuffer, Format.R16_UInt, 0);
context.VertexShader.SetShader(vs, null, 0);
context.PixelShader.SetSamplers(0, 1, samplerState);
context.PixelShader.SetShaderResources(0, 1, textureShaderInput);
context.PixelShader.SetShader(ps, null, 0);
SwapChainDescription desc;
//swapChain.Description.
var viewport = new RawViewportF() { Height = form.Height, Width = form.Width };
context.Rasterizer.SetViewport(viewport);
context.DrawIndexed(Convert.ToInt32(quadIndexCount), 0, 0);
return true;
}
private static bool SelectPlane(IntPtr opaque, ulong plane)
{
if (plane != 0) return false;
context.OutputMerger.SetRenderTargets(textureRenderTarget);
return true;
}
static DeviceContext context;
static Device device;
static SwapChain swapChain;
static SwapChainDescription desc;
static Texture2D texture;
static ShaderResourceView textureShaderInput;
static RenderTargetView textureRenderTarget;
static readonly RawColor4 blackRGBA = new RawColor4 { R = 0.5f, G = 0.5f, B = 0.0f, A = 1.0f };
static readonly RawColor4 orangeRGBA = new RawColor4 { R = 1.0f, G = 0.5f, B = 0.0f, A = 1.0f };
static RenderTargetView swapchainRenderTarget;
static InputLayout shadersInputLayout;
static Buffer vertexBuffer;
static uint vertexBufferStride;
static Buffer indexBuffer;
static VertexShader vs;
static SamplerState samplerState;
static PixelShader ps;
static RenderForm form;
static uint quadIndexCount;
static readonly float BORDER_LEFT = -0.95f;
static readonly float BORDER_RIGHT = 0.85f;
static readonly float BORDER_TOP = 0.95f;
static readonly float BORDER_BOTTOM = -0.90f;
private static void InitializeDirect3D()
{
var desc = new SwapChainDescription
{
BufferCount = 1,
ModeDescription = new ModeDescription { Format = Format.R8G8B8A8_UNorm, Height = form.ClientSize.Height, Width = form.ClientSize.Width },
Usage = Usage.RenderTargetOutput,
OutputHandle = form.Handle,
SampleDescription = new SampleDescription { Count = 1 },
IsWindowed = true,
Flags = SwapChainFlags.AllowModeSwitch
};
Device.CreateWithSwapChain(DriverType.Hardware,
DeviceCreationFlags.VideoSupport | DeviceCreationFlags.Debug,
new FeatureLevel[] { FeatureLevel.Level_11_0 },
desc,
out device,
out swapChain);
context = device.ImmediateContext;
var multithread = device.QueryInterface<DeviceMultithread>();
multithread.SetMultithreadProtected(true);
multithread.Dispose();
var backBuffer = swapChain.GetBackBuffer<Texture2D>(0);
swapchainRenderTarget = new RenderTargetView(device, backBuffer);
backBuffer.Dispose();
var vertexShaderByteCode = ShaderBytecode.CompileFromFile("MiniCube.fx", "VShader", "vs_4_0");
var vertexShader = new VertexShader(device, vertexShaderByteCode);
var ied = new InputElement[]
{
new InputElement
{
SemanticName = "POSITION",
SemanticIndex = 0,
Format = Format.R32G32B32_Float,
Slot = 0
},
new InputElement
{
SemanticName = "TEXCOORD",
SemanticIndex = 0,
Format = Format.R32G32_Float,
Slot = 0
}
};
shadersInputLayout = new InputLayout(device, vertexShaderByteCode.Bytecode.Data, ied);
ShaderInput[] OurVerticles = new ShaderInput[]
{
new ShaderInput
{
position = new Position
{
x = BORDER_LEFT,
y = BORDER_BOTTOM,
z = 0.0f
},
texture = new Texture { x = 0.0f, y = 1.0f }
},
new ShaderInput
{
position = new Position
{
x = BORDER_RIGHT,
y = BORDER_BOTTOM,
z = 0.0f
},
texture = new Texture { x = 1.0f, y = 1.0f }
},
new ShaderInput
{
position = new Position
{
x = BORDER_RIGHT,
y = BORDER_TOP,
z = 0.0f
},
texture = new Texture { x = 1.0f, y = 0.0f }
},
new ShaderInput
{
position = new Position
{
x = BORDER_LEFT,
y = BORDER_TOP,
z = 0.0f
},
texture = new Texture { x = 0.0f, y = 0.0f }
}
};
var sizeInBytes = Marshal.SizeOf<ShaderInput>() * 4;
var bd = new BufferDescription
{
Usage = ResourceUsage.Dynamic,
SizeInBytes = sizeInBytes,
BindFlags = BindFlags.VertexBuffer,
CpuAccessFlags = CpuAccessFlags.Write
};
vertexBuffer = new Buffer(device, bd);
vertexBufferStride = Convert.ToUInt32(Marshal.SizeOf(OurVerticles[0]));
var dataBox = context.MapSubresource(vertexBuffer, 0, MapMode.WriteDiscard, 0);
long LongPtr = dataBox.DataPointer.ToInt64();
for (int i = 0; i < OurVerticles.Length; i++)
{
IntPtr RectPtr = new IntPtr(LongPtr);
Marshal.StructureToPtr(OurVerticles[i], RectPtr, false);
LongPtr += Marshal.SizeOf(typeof(ShaderInput));
}
context.UnmapSubresource(vertexBuffer, 0);
quadIndexCount = 6;
var quadDescription = new BufferDescription
{
Usage = ResourceUsage.Dynamic,
SizeInBytes = sizeof(ushort) * Convert.ToInt32(quadIndexCount),
BindFlags = BindFlags.IndexBuffer,
CpuAccessFlags = CpuAccessFlags.Write
};
indexBuffer = new Buffer(device, quadDescription);
ushort[] trianglePost = new ushort[6];
dataBox = context.MapSubresource(indexBuffer, 0, MapMode.WriteDiscard, 0);
//LongPtr = dataBox.DataPointer.ToInt64();
//for(var i = 0; i < quadIndexCount; i++)
//{
// IntPtr RectPtr = new IntPtr(LongPtr);
// Marshal.StructureToPtr(OurVerticles[i], RectPtr, false);
// LongPtr += Marshal.SizeOf(typeof(ShaderInput));
//}
////dataBox.DataPointer
context.UnmapSubresource(indexBuffer, 0);
var sampDesc = new SamplerStateDescription
{
Filter = Filter.MinMagLinearMipPoint,
AddressU = TextureAddressMode.Clamp,
AddressV = TextureAddressMode.Clamp,
AddressW = TextureAddressMode.Clamp,
ComparisonFunction = Comparison.Always,
MinimumLod = 0,
MaximumLod = float.MaxValue
};
samplerState = new SamplerState(device, sampDesc);
}
private static void Main()
{
Core.Initialize();
var libvlc = new LibVLC();
var mp = new MediaPlayer(libvlc);
mp.Media = new Media(libvlc, "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", FromType.FromLocation);
// CreateContext();
form = new RenderForm("SharpDX - MiniCube Direct3D11 Sample");
//form.Handle
InitializeDirect3D();
mp.SetDirect3DCallbacks(Direct3DEngine.D3D11, Setup, Cleanup, UpdateOutput, Swap, StartEndRendering, SelectPlane, IntPtr.Zero);
mp.Play();
// SwapChain description
//desc = new SwapChainDescription()
//{
// BufferCount = 1,
// ModeDescription =
// new ModeDescription(form.ClientSize.Width, form.ClientSize.Height,
// new Rational(60, 1), Format.R8G8B8A8_UNorm),
// IsWindowed = true,
// OutputHandle = form.Handle,
// SampleDescription = new SampleDescription(1, 0),
// SwapEffect = SwapEffect.Discard,
// Usage = Usage.RenderTargetOutput
//};
// Used for debugging dispose object references
// Configuration.EnableObjectTracking = true;
// Disable throws on shader compilation errors
//Configuration.ThrowOnShaderCompileError = false;
// Create Device and SwapChain
// Ignore all windows events
//var factory = swapChain.GetParent<Factory>();
//factory.MakeWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll);
//// Compile Vertex and Pixel shaders
//var vertexShaderByteCode = ShaderBytecode.CompileFromFile("MiniCube.fx", "VS", "vs_4_0");
//var vertexShader = new VertexShader(device, vertexShaderByteCode);
//var pixelShaderByteCode = ShaderBytecode.CompileFromFile("MiniCube.fx", "PS", "ps_4_0");
//var pixelShader = new PixelShader(device, pixelShaderByteCode);
//var signature = ShaderSignature.GetInputSignature(vertexShaderByteCode);
//// Layout from VertexShader input signature
//var layout = new InputLayout(device, signature, new[]
// {
// new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
// new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0)
// });
//// Instantiate Vertex buiffer from vertex data
//var vertices = Buffer.Create(device, BindFlags.VertexBuffer, new[]
// {
// new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), // Front
// new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
// new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
// new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
// new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
// new Vector4( 1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
// new Vector4(-1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), // BACK
// new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f),
// new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f),
// new Vector4(-1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f),
// new Vector4( 1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f),
// new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f),
// new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), // Top
// new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f),
// new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f),
// new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f),
// new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f),
// new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f),
// new Vector4(-1.0f,-1.0f, -1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), // Bottom
// new Vector4( 1.0f,-1.0f, 1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f),
// new Vector4(-1.0f,-1.0f, 1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f),
// new Vector4(-1.0f,-1.0f, -1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f),
// new Vector4( 1.0f,-1.0f, -1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f),
// new Vector4( 1.0f,-1.0f, 1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f),
// new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), // Left
// new Vector4(-1.0f, -1.0f, 1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f),
// new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f),
// new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f),
// new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f),
// new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f),
// new Vector4( 1.0f, -1.0f, -1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), // Right
// new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f),
// new Vector4( 1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f),
// new Vector4( 1.0f, -1.0f, -1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f),
// new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f),
// new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f),
// });
//// Create Constant Buffer
//var contantBuffer = new Buffer(device, Utilities.SizeOf<Matrix>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
//// Prepare All the stages
//context.InputAssembler.InputLayout = layout;
//context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
//context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertices, Utilities.SizeOf<Vector4>() * 2, 0));
//context.VertexShader.SetConstantBuffer(0, contantBuffer);
//context.VertexShader.Set(vertexShader);
//context.PixelShader.Set(pixelShader);
//// Prepare matrices
//var view = Matrix.LookAtLH(new Vector3(0, 0, -5), new Vector3(0, 0, 0), Vector3.UnitY);
//Matrix proj = Matrix.Identity;
//// Use clock
//var clock = new Stopwatch();
//clock.Start();
//// Declare texture for rendering
//bool userResized = true;
//Texture2D backBuffer = null;
//RenderTargetView renderView = null;
//Texture2D depthBuffer = null;
//DepthStencilView depthView = null;
//// Setup handler on resize form
//form.UserResized += (sender, args) => userResized = true;
//// Setup full screen mode change F5 (Full) F4 (Window)
//form.KeyUp += (sender, args) =>
//{
// if (args.KeyCode == Keys.F5)
// swapChain.SetFullscreenState(true, null);
// else if (args.KeyCode == Keys.F4)
// swapChain.SetFullscreenState(false, null);
// else if (args.KeyCode == Keys.Escape)
// form.Close();
//};
//// Main loop
//RenderLoop.Run(form, () =>
//{
// // If Form resized
// if (userResized)
// {
// // Dispose all previous allocated resources
// Utilities.Dispose(ref backBuffer);
// Utilities.Dispose(ref renderView);
// Utilities.Dispose(ref depthBuffer);
// Utilities.Dispose(ref depthView);
// // Resize the backbuffer
// swapChain.ResizeBuffers(desc.BufferCount, form.ClientSize.Width, form.ClientSize.Height, Format.Unknown, SwapChainFlags.None);
// // Get the backbuffer from the swapchain
// backBuffer = Texture2D.FromSwapChain<Texture2D>(swapChain, 0);
// // Renderview on the backbuffer
// renderView = new RenderTargetView(device, backBuffer);
// // Create the depth buffer
// depthBuffer = new Texture2D(device, new Texture2DDescription()
// {
// Format = Format.D32_Float_S8X24_UInt,
// ArraySize = 1,
// MipLevels = 1,
// Width = form.ClientSize.Width,
// Height = form.ClientSize.Height,
// SampleDescription = new SampleDescription(1, 0),
// Usage = ResourceUsage.Default,
// BindFlags = BindFlags.DepthStencil,
// CpuAccessFlags = CpuAccessFlags.None,
// OptionFlags = ResourceOptionFlags.None
// });
// // Create the depth buffer view
// depthView = new DepthStencilView(device, depthBuffer);
// // Setup targets and viewport for rendering
// context.Rasterizer.SetViewport(new Viewport(0, 0, form.ClientSize.Width, form.ClientSize.Height, 0.0f, 1.0f));
// context.OutputMerger.SetTargets(depthView, renderView);
// // Setup new projection matrix with correct aspect ratio
// proj = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, form.ClientSize.Width / (float)form.ClientSize.Height, 0.1f, 100.0f);
// // We are done resizing
// userResized = false;
// }
// var time = clock.ElapsedMilliseconds / 1000.0f;
// var viewProj = Matrix.Multiply(view, proj);
// // Clear views
// context.ClearDepthStencilView(depthView, DepthStencilClearFlags.Depth, 1.0f, 0);
// context.ClearRenderTargetView(renderView, Color.Black);
// // Update WorldViewProj Matrix
// var worldViewProj = Matrix.RotationX(time) * Matrix.RotationY(time * 2) * Matrix.RotationZ(time * .7f) * viewProj;
// worldViewProj.Transpose();
// context.UpdateSubresource(ref worldViewProj, contantBuffer);
// // Draw the cube
// context.Draw(36, 0);
// // Present!
// swapChain.Present(0, PresentFlags.None);
//});
//// Release all resources
//signature.Dispose();
//vertexShaderByteCode.Dispose();
//vertexShader.Dispose();
//pixelShaderByteCode.Dispose();
//pixelShader.Dispose();
//vertices.Dispose();
//layout.Dispose();
//contantBuffer.Dispose();
//depthBuffer.Dispose();
//depthView.Dispose();
//renderView.Dispose();
//backBuffer.Dispose();
//context.ClearState();
//context.Flush();
//device.Dispose();
//context.Dispose();
//swapChain.Dispose();
//factory.Dispose();
}
private static void CreateContext()
{
Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out device, out swapChain);
context = device.ImmediateContext;
}
}
public struct Position
{
public float x { get; set; }
public float y { get; set; }
public float z { get; set; }
}
public struct Texture
{
public float x { get; set; }
public float y { get; set; }
}
public struct ShaderInput
{
//public ShaderInput(Position p, Texture t)
//{
// position = p;
// texture = t;
//}
public Position position { get; set; }
public Texture texture { get; set; }
}
}
\ No newline at end of file
......@@ -7,6 +7,6 @@ let main argv =
Core.Initialize()
let libVLC = new LibVLC()
let mp = new MediaPlayer(libVLC)
mp.Play(new Media(libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation)) |> ignore
mp.Play(new Media(libVLC, "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", FromType.FromLocation)) |> ignore
let result = Console.ReadKey()
0
\ No newline at end of file
......@@ -28,7 +28,7 @@ namespace LibVLCSharp.GTK.Sample
//Starts playing
using (var media = new Media(libvlc,
"http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4",
"https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4",
FromType.FromLocation))
{
mediaPlayer.Play(media);
......
......@@ -99,5 +99,11 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
<Import Project="..\..\packages\VideoLAN.LibVLC.Mac.3.1.2\build\VideoLAN.LibVLC.Mac.targets" Condition="Exists('..\..\packages\VideoLAN.LibVLC.Mac.3.1.2\build\VideoLAN.LibVLC.Mac.targets')" />
<Import Project="..\..\packages\VideoLAN.LibVLC.Mac.3.1.3\build\VideoLAN.LibVLC.Mac.targets" Condition="Exists('..\..\packages\VideoLAN.LibVLC.Mac.3.1.3\build\VideoLAN.LibVLC.Mac.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\VideoLAN.LibVLC.Mac.3.1.3\build\VideoLAN.LibVLC.Mac.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\VideoLAN.LibVLC.Mac.3.1.3\build\VideoLAN.LibVLC.Mac.targets'))" />
</Target>
</Project>
\ No newline at end of file
......@@ -31,7 +31,7 @@ namespace LibVLCSharp.Mac.Sample
View = _videoView;
_videoView.MediaPlayer.Play(new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation));
_videoView.MediaPlayer.Play(new Media(_libVLC, "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", FromType.FromLocation));
}
public override NSObject RepresentedObject
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="VideoLAN.LibVLC.Mac" version="3.1.2" targetFramework="xamarinmac20" />
<package id="VideoLAN.LibVLC.Mac" version="3.1.3" targetFramework="xamarinmac20" />
</packages>
\ No newline at end of file
......@@ -7,8 +7,8 @@
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.4" />
<PackageReference Include="VideoLAN.LibVLC.Mac" Version="3.1.2" />
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.6" />
<PackageReference Include="VideoLAN.LibVLC.Mac" Version="3.1.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\LibVLCSharp\LibVLCSharp.csproj" />
......
......@@ -11,7 +11,7 @@ namespace LibVLCSharp.NetCore.Sample
using(var libVLC = new LibVLC())
{
var media = new Media(libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation);
var media = new Media(libVLC, "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", FromType.FromLocation);
using(var mp = new MediaPlayer(media))
{
media.Dispose();
......
......@@ -20,7 +20,7 @@ namespace LibVLCSharp.UWP.Sample
_libVLC = new LibVLC(VideoView.SwapChainOptions);
_mediaPlayer = new MediaPlayer(_libVLC);
VideoView.MediaPlayer = _mediaPlayer;
this._mediaPlayer.Play(new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation));
this._mediaPlayer.Play(new Media(_libVLC, "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", FromType.FromLocation));
};
Unloaded += (s, e) =>
......
......@@ -44,7 +44,7 @@ namespace LibVLCSharp.WPF.Sample
if (!parent.VideoView.MediaPlayer.IsPlaying)
{
parent.VideoView.MediaPlayer.Play(new Media(_libVLC,
"http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation));
"https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", FromType.FromLocation));
}
}
}
......
......@@ -45,7 +45,7 @@ namespace LibVLCSharp.WPF.Sample
if (!VideoView.MediaPlayer.IsPlaying)
{
VideoView.MediaPlayer.Play(new Media(_libVLC,
"http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation));
"https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", FromType.FromLocation));
}
}
}
......
......@@ -25,7 +25,7 @@ namespace LibVLCSharp.WinForms.Sample
private void Form1_Load(object sender, EventArgs e)
{
_mp.Play(new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation));
_mp.Play(new Media(_libVLC, "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", FromType.FromLocation));
}
}
}
\ No newline at end of file
......@@ -10,7 +10,7 @@ namespace LibVLCSharp.Windows.Net40.Sample
Core.Initialize();
var libVLC = new LibVLC();
var media = new Media(libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation);
var media = new Media(libVLC, "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", FromType.FromLocation);
var mp = new MediaPlayer(media);
mp.Play();
Console.ReadKey();
......
......@@ -83,5 +83,11 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<Import Project="..\..\packages\VideoLAN.LibVLC.iOS.3.1.5-alpha\build\VideoLAN.LibVLC.iOS.targets" Condition="Exists('..\..\packages\VideoLAN.LibVLC.iOS.3.1.5-alpha\build\VideoLAN.LibVLC.iOS.targets')" />
<Import Project="..\..\packages\VideoLAN.LibVLC.iOS.3.3.1\build\VideoLAN.LibVLC.iOS.targets" Condition="Exists('..\..\packages\VideoLAN.LibVLC.iOS.3.3.1\build\VideoLAN.LibVLC.iOS.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\VideoLAN.LibVLC.iOS.3.3.1\build\VideoLAN.LibVLC.iOS.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\VideoLAN.LibVLC.iOS.3.3.1\build\VideoLAN.LibVLC.iOS.targets'))" />
</Target>
</Project>
\ No newline at end of file
......@@ -22,7 +22,7 @@ namespace LibVLCSharp.iOS.Sample