diff --git a/src/Downloader/DownloadConfiguration.cs b/src/Downloader/DownloadConfiguration.cs index 2882c28..e2af52f 100644 --- a/src/Downloader/DownloadConfiguration.cs +++ b/src/Downloader/DownloadConfiguration.cs @@ -6,43 +6,25 @@ namespace Downloader; public class DownloadConfiguration : ICloneable, INotifyPropertyChanged { - private int _bufferBlockSize; - private int _chunkCount; - private long _maximumBytesPerSecond; - private int _maximumTryAgainOnFailover; + private int _bufferBlockSize = 1024; // usually, hosts support max to 8000 bytes + private int _chunkCount = 1; // file parts to download + private long _maximumBytesPerSecond = ThrottledStream.Infinite; // No-limitation in download speed + private int _maximumTryAgainOnFailover = int.MaxValue; // the maximum number of times to fail. private long _maximumMemoryBufferBytes; - private bool _checkDiskSizeBeforeDownload; - private bool _parallelDownload; - private int _parallelCount; - private int _timeout; - private bool _rangeDownload; - private long _rangeLow; - private long _rangeHigh; - private bool _clearPackageOnCompletionWithFailure; - private long _minimumSizeOfChunking; - private bool _reserveStorageSpaceBeforeStartingDownload; + private bool _checkDiskSizeBeforeDownload = true; // check disk size for temp and file path + private bool _parallelDownload = false; // download parts of file as parallel or not + private int _parallelCount = 0; // number of parallel downloads + private int _timeout = 1000; // timeout (millisecond) per stream block reader + private bool _rangeDownload = false; // enable ranged download + private long _rangeLow = 0; // starting byte offset + private long _rangeHigh = 0; // ending byte offset + private bool _clearPackageOnCompletionWithFailure = false; // Clear package and downloaded data when download completed with failure + private long _minimumSizeOfChunking = 512; // minimum size of chunking to download a file in multiple parts + private bool _reserveStorageSpaceBeforeStartingDownload = false; // Before starting the download, reserve the storage space of the file as file size. + private bool _enableLiveStreaming = false; // Get on demand downloaded data with ReceivedBytes on downloadProgressChanged event public event PropertyChangedEventHandler PropertyChanged = delegate { }; - public DownloadConfiguration() - { - RequestConfiguration = new RequestConfiguration(); // default requests configuration - _maximumTryAgainOnFailover = int.MaxValue; // the maximum number of times to fail. - _parallelDownload = false; // download parts of file as parallel or not - _parallelCount = 0; // number of parallel downloads - _chunkCount = 1; // file parts to download - _timeout = 1000; // timeout (millisecond) per stream block reader - _bufferBlockSize = 1024; // usually, hosts support max to 8000 bytes - _maximumBytesPerSecond = ThrottledStream.Infinite; // No-limitation in download speed - _checkDiskSizeBeforeDownload = true; // check disk size for temp and file path - _rangeDownload = false; // enable ranged download - _rangeLow = 0; // starting byte offset - _rangeHigh = 0; // ending byte offset - _clearPackageOnCompletionWithFailure = false; // Clear package and downloaded data when download completed with failure - _minimumSizeOfChunking = 512; // minimum size of chunking to download a file in multiple parts - _reserveStorageSpaceBeforeStartingDownload = false; // Before starting the download, reserve the storage space of the file as file size. - } - /// /// Create the OnPropertyChanged method to raise the event /// The calling member's name will be used as the parameter. @@ -195,7 +177,7 @@ public long RangeHigh /// /// Custom body of your requests /// - public RequestConfiguration RequestConfiguration { get; set; } + public RequestConfiguration RequestConfiguration { get; set; } = new(); // default requests configuration /// /// Download timeout per stream file blocks @@ -272,6 +254,21 @@ public long MaximumMemoryBufferBytes OnPropertyChanged(); } } + + /// + /// Set live streaming is enable or not. If it's enable get the on demand downloaded data + /// with ReceivedBytes on downloadProgressChanged event + /// Note: This option may consume more memory because copied each block of downloaded data in to ReceivedBytes + /// + public bool EnableLiveStreaming + { + get => _enableLiveStreaming; + set + { + _enableLiveStreaming = value; + OnPropertyChanged(); + } + } public object Clone() {