Skip to content

Commit

Permalink
OPUS : Basic unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeugma440 committed Dec 15, 2024
1 parent d48e9af commit 29d2951
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
43 changes: 43 additions & 0 deletions ATL.unit-test/IO/MetaData/OPUS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using ATL.AudioData;

namespace ATL.test.IO.MetaData
{
[TestClass]
public class OPUS : MetaIOTest
{
public OPUS()
{
emptyFile = "OPUS/empty.opus";
notEmptyFile = "OPUS/opus.opus";
tagType = MetaDataIOFactory.TagType.NATIVE;

testData.Conductor = null;
testData.Date = DateTime.Parse("1997-06-20");
testData.PublishingDate = DateTime.Parse("1998-07-21");
testData.CatalogNumber = "44887733";
}

[TestMethod]
public void TagIO_R_OPUS_simple()
{
new ConsoleLogger();

string location = TestUtils.GetResourceLocationRoot() + notEmptyFile;
AudioDataManager theFile = new AudioDataManager(AudioDataIOFactory.GetInstance().GetFromPath(location));

readExistingTagsOnFile(theFile);
}

[TestMethod]
public void TagIO_RW_OPUS_Empty()
{
test_RW_Empty(emptyFile, true, true, true, false);
}

[TestMethod]
public void tagIO_RW_OPUS_Existing()
{
test_RW_Existing(notEmptyFile, 2);
}
}
}
Binary file added ATL.unit-test/Resources/OPUS/empty.opus
Binary file not shown.
Binary file modified ATL.unit-test/Resources/OPUS/opus.opus
Binary file not shown.
8 changes: 6 additions & 2 deletions ATL/AudioData/IO/Ogg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ private bool getInfo(BufferedBinaryReader source, FileInfo info, ReadTagParams r

if (readTagParams.PrepareForWriting) // Metrics to prepare writing
{
// TODO Speex
if (CONTENTS_VORBIS == contents || CONTENTS_FLAC == contents)
{
// Determine the boundaries of 3rd header (Setup header) by searching from the last-but-one page
Expand Down Expand Up @@ -660,7 +659,7 @@ private bool getInfo(BufferedBinaryReader source, FileInfo info, ReadTagParams r
info.CommentHeaderEnd = source.Position - OGG_PAGE_ID.Length;
}
}
else if (CONTENTS_OPUS == contents)
else if (CONTENTS_OPUS == contents || CONTENTS_SPEEX == contents)
{
info.SetupHeaderStart = info.SetupHeaderEnd;
info.CommentHeaderEnd = info.SetupHeaderStart;
Expand Down Expand Up @@ -925,6 +924,11 @@ public async Task<bool> WriteAsync(Stream s, TagData tag, ProgressToken<float> w
vorbisTag.switchOggBehaviour();
await vorbisTag.WriteAsync(memStream, tag);
}
else if (CONTENTS_SPEEX == contents)
{
vorbisTag.switchOggBehaviour();
await vorbisTag.WriteAsync(memStream, tag);
}
else if (CONTENTS_FLAC == contents)
{
vorbisTag.switchFlacBehaviour();
Expand Down

0 comments on commit 29d2951

Please sign in to comment.