Commit 58014cd0 authored by Martin Finkel's avatar Martin Finkel

MediaConfiguration: Add DisableHardwareDecoding, SetFileCaching and SetNetworkCaching

parent eb3223ef
...@@ -305,7 +305,10 @@ namespace LibVLCSharp.Shared ...@@ -305,7 +305,10 @@ namespace LibVLCSharp.Shared
{ {
if (mediaConfiguration == null) throw new ArgumentNullException(nameof(mediaConfiguration)); if (mediaConfiguration == null) throw new ArgumentNullException(nameof(mediaConfiguration));
AddOption(mediaConfiguration.Build()); foreach(var option in mediaConfiguration.Build())
{
AddOption(option);
}
} }
/// <summary>Add an option to the media with configurable flags.</summary> /// <summary>Add an option to the media with configurable flags.</summary>
...@@ -1080,23 +1083,5 @@ namespace LibVLCSharp.Shared ...@@ -1080,23 +1083,5 @@ namespace LibVLCSharp.Shared
Playlist = 5 Playlist = 5
} }
#endregion #endregion
/// <summary>
/// Small configuration helper
/// </summary>
public class MediaConfiguration
{
HashSet<string> _options = new HashSet<string>();
public MediaConfiguration EnableHardwareDecoding()
{
#if ANDROID
_options.Add(":codec=mediacodec_ndk");
#endif
return this;
}
public string Build() => string.Join(",", _options);
}
} }
\ No newline at end of file
using System.Collections.Generic;
namespace LibVLCSharp.Shared
{
/// <summary>
/// Helper object with fluent API for advanced media configuration
/// If an API is not covered here, use <see cref="Media.AddOption(string)"/>
/// with CLI argument from https://wiki.videolan.org/VLC_command-line_help/
/// </summary>
public class MediaConfiguration
{
HashSet<string> _options = new HashSet<string>();
/// <summary>
/// Enable hardware decoding (should be on by default)
/// </summary>
public MediaConfiguration EnableHardwareDecoding()
{
#if ANDROID
_options.Add(":codec=mediacodec_ndk");
#else
_options.Add(":avcodec=hw=any");
#endif
return this;
}
/// <summary>
/// Disable hardware decoding
/// </summary>
public MediaConfiguration DisableHardwareDecoding()
{
#if ANDROID
_options.Add(":codec=all");
#else
_options.Add(":avcodec=none");
#endif
return this;
}
/// <summary>
/// File caching value for local files, in milliseconds.
/// </summary>
/// <param name="caching">caching value (0 to 60000)</param>
/// <returns></returns>
public MediaConfiguration SetFileCaching(uint caching)
{
_options.Add($":file-caching={caching}");
return this;
}
/// <summary>
/// Network caching value for network resources, in milliseconds.
/// </summary>
/// <param name="caching">caching value (0 to 60000)</param>
/// <returns></returns>
public MediaConfiguration SetNetworkCaching(uint caching)
{
_options.Add($":network-caching={caching}");
return this;
}
public HashSet<string> Build() => _options;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment