-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reading archives uses 7zip code. The project can be found here: https://github.com/aidan-g/BASS_ZIPSTREAM
- Loading branch information
pudding
committed
Jan 28, 2024
1 parent
c8d89a2
commit cf0f1ca
Showing
21 changed files
with
1,056 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.IO; | ||
|
||
namespace FoxTunes.Interfaces | ||
{ | ||
public interface IFileAbstraction : IDisposable | ||
{ | ||
string FileName { get; } | ||
|
||
Stream ReadStream { get; } | ||
|
||
Stream WriteStream { get; } | ||
|
||
void CloseStream(Stream stream); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using FoxTunes.Interfaces; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace FoxTunes | ||
{ | ||
public class TagLibFileAbstraction : global::TagLib.File.IFileAbstraction | ||
{ | ||
public TagLibFileAbstraction(IFileAbstraction fileAbstraction) | ||
{ | ||
this.FileAbstraction = fileAbstraction; | ||
} | ||
|
||
public IFileAbstraction FileAbstraction { get; private set; } | ||
|
||
public string Name | ||
{ | ||
get | ||
{ | ||
return this.FileAbstraction.FileName; | ||
} | ||
} | ||
|
||
public Stream ReadStream | ||
{ | ||
get | ||
{ | ||
return this.FileAbstraction.ReadStream; | ||
} | ||
} | ||
|
||
public Stream WriteStream | ||
{ | ||
get | ||
{ | ||
return this.FileAbstraction.WriteStream; | ||
} | ||
} | ||
|
||
public void CloseStream(Stream stream) | ||
{ | ||
this.FileAbstraction.CloseStream(stream); | ||
} | ||
|
||
public static TagLibFileAbstraction Create(IFileAbstraction fileAbstraction) | ||
{ | ||
return new TagLibFileAbstraction(fileAbstraction); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using FoxTunes.Interfaces; | ||
using ManagedBass; | ||
using ManagedBass.ZipStream; | ||
using System.Collections.Generic; | ||
|
||
namespace FoxTunes | ||
{ | ||
public class BassArchiveStreamProvider : BassStreamProvider | ||
{ | ||
public BassArchiveStreamProviderBehaviour Behaviour { get; private set; } | ||
|
||
public override void InitializeComponent(ICore core) | ||
{ | ||
this.Behaviour = ComponentRegistry.Instance.GetComponent<BassArchiveStreamProviderBehaviour>(); | ||
base.InitializeComponent(core); | ||
} | ||
|
||
public override bool CanCreateStream(PlaylistItem playlistItem) | ||
{ | ||
//The behaviour is not loaded for utilities so we can't check whether it's enabled. | ||
//if (this.Behaviour == null || !this.Behaviour.Enabled) | ||
//{ | ||
// return false; | ||
//} | ||
var fileName = default(string); | ||
var entryName = default(string); | ||
return ArchiveUtils.ParseUrl(playlistItem.FileName, out fileName, out entryName); | ||
} | ||
|
||
public override IBassStream CreateBasicStream(PlaylistItem playlistItem, IEnumerable<IBassStreamAdvice> advice, BassFlags flags) | ||
{ | ||
var fileName = default(string); | ||
var entryName = default(string); | ||
if (!ArchiveUtils.ParseUrl(playlistItem.FileName, out fileName, out entryName)) | ||
{ | ||
//This shouldn't happen as CanCreateStream would have returned false. | ||
return BassStream.Empty; | ||
} | ||
var index = default(int); | ||
if (!ArchiveUtils.GetEntryIndex(fileName, entryName, out index)) | ||
{ | ||
//The associated entry was not found. | ||
return BassStream.Empty; | ||
} | ||
var channelHandle = BassZipStream.CreateStream(fileName, index, Flags: flags); | ||
return this.CreateBasicStream(channelHandle, advice, flags); | ||
} | ||
|
||
public override IBassStream CreateInteractiveStream(PlaylistItem playlistItem, IEnumerable<IBassStreamAdvice> advice, BassFlags flags) | ||
{ | ||
var fileName = default(string); | ||
var entryName = default(string); | ||
if (!ArchiveUtils.ParseUrl(playlistItem.FileName, out fileName, out entryName)) | ||
{ | ||
//This shouldn't happen as CanCreateStream would have returned false. | ||
return BassStream.Empty; | ||
} | ||
var index = default(int); | ||
if (!ArchiveUtils.GetEntryIndex(fileName, entryName, out index)) | ||
{ | ||
//The associated entry was not found. | ||
return BassStream.Empty; | ||
} | ||
var channelHandle = BassZipStream.CreateStream(fileName, index, Flags: flags); | ||
return this.CreateInteractiveStream(channelHandle, advice, flags); | ||
} | ||
} | ||
} |
Oops, something went wrong.