From 2fe729832e0fb2f2ac8adcb61bf3217e9751f8fe Mon Sep 17 00:00:00 2001 From: Vlad Jerca Date: Fri, 1 Mar 2019 20:45:47 +0200 Subject: [PATCH] FFMpegCore: enable root configuration view ctor Former-commit-id: 02ac7c5ac0835722f6c66c083aa38db389cd220c --- FFMpegCore/FFMPEG/FFBase.cs | 25 ++++++++++++++++++++----- FFMpegCore/FFMPEG/FFMpegOptions.cs | 7 +++++++ 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 FFMpegCore/FFMPEG/FFMpegOptions.cs diff --git a/FFMpegCore/FFMPEG/FFBase.cs b/FFMpegCore/FFMPEG/FFBase.cs index cc52b39..d38c8ca 100644 --- a/FFMpegCore/FFMPEG/FFBase.cs +++ b/FFMpegCore/FFMPEG/FFBase.cs @@ -14,12 +14,27 @@ public abstract class FFBase : IDisposable protected string ConfiguredRoot; protected Process Process; - protected FFBase() + protected FFBase(FFMpegOptions opts = null) { - ConfiguredRoot = - !File.Exists(_ConfigFile) ? - _DefaultRoot : - JsonConvert.DeserializeObject>(File.ReadAllText(_ConfigFile))["RootDirectory"]; + var options = opts; + + if ( + opts == null && + File.Exists(_ConfigFile) + ) + { + options = JsonConvert.DeserializeObject(File.ReadAllText(_ConfigFile)); + } + + if (options == null) + { + options = new FFMpegOptions + { + RootDirectory = _DefaultRoot + }; + } + + ConfiguredRoot = options.RootDirectory; } /// diff --git a/FFMpegCore/FFMPEG/FFMpegOptions.cs b/FFMpegCore/FFMPEG/FFMpegOptions.cs new file mode 100644 index 0000000..5030e39 --- /dev/null +++ b/FFMpegCore/FFMPEG/FFMpegOptions.cs @@ -0,0 +1,7 @@ +namespace FFMpegCore.FFMPEG +{ + public class FFMpegOptions + { + public string RootDirectory { get; set; } + } +}