Skip to content

Commit

Permalink
✨ Add MkaAudioTagger mapping for AnyToMkaAudioExtractor
Browse files Browse the repository at this point in the history
Implement missing tagger decision for MKA audio files to ensure proper handling of this format
  • Loading branch information
CXwudi committed Dec 25, 2024
1 parent 6e46bf3 commit ebfbdeb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package mikufan.cx.vvd.extractor.component
import mikufan.cx.vvd.common.exception.RuntimeVocaloidException
import mikufan.cx.vvd.extractor.component.extractor.base.BaseAudioExtractor
import mikufan.cx.vvd.extractor.component.extractor.impl.AacToM4aAudioExtractor
import mikufan.cx.vvd.extractor.component.extractor.impl.AnyToMkaAudioExtractor
import mikufan.cx.vvd.extractor.component.extractor.impl.OpusToOggAudioExtractor
import mikufan.cx.vvd.extractor.component.tagger.base.BaseAudioTagger
import mikufan.cx.vvd.extractor.component.tagger.impl.M4aAudioTagger
import mikufan.cx.vvd.extractor.component.tagger.impl.MkaAudioTagger
import mikufan.cx.vvd.extractor.component.tagger.impl.Mp3AudioTagger
import mikufan.cx.vvd.extractor.component.tagger.impl.OggOpusAudioTagger
import mikufan.cx.vvd.extractor.component.util.MediaFormatChecker
Expand Down Expand Up @@ -53,6 +55,7 @@ class TaggerDeciderCore(
when (val decidedExtractor = decidedExtractorOpt.get()) {
is AacToM4aAudioExtractor -> beanFactory.getBean<M4aAudioTagger>()
is OpusToOggAudioExtractor -> beanFactory.getBean<OggOpusAudioTagger>()
is AnyToMkaAudioExtractor -> beanFactory.getBean<MkaAudioTagger>()
else -> error("This should not happened, unknown audio extractor: ${decidedExtractor.name}")
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import io.mockk.mockk
import mikufan.cx.vvd.common.exception.RuntimeVocaloidException
import mikufan.cx.vvd.extractor.component.extractor.base.BaseAudioExtractor
import mikufan.cx.vvd.extractor.component.extractor.impl.AacToM4aAudioExtractor
import mikufan.cx.vvd.extractor.component.extractor.impl.AnyToMkaAudioExtractor
import mikufan.cx.vvd.extractor.component.extractor.impl.OpusToOggAudioExtractor
import mikufan.cx.vvd.extractor.component.tagger.impl.M4aAudioTagger
import mikufan.cx.vvd.extractor.component.tagger.impl.MkaAudioTagger
import mikufan.cx.vvd.extractor.component.tagger.impl.Mp3AudioTagger
import mikufan.cx.vvd.extractor.component.tagger.impl.OggOpusAudioTagger
import mikufan.cx.vvd.extractor.component.util.MediaFormatChecker
Expand Down Expand Up @@ -41,6 +43,7 @@ class TaggerDeciderCoreTest : ShouldSpec({
every { getBean<M4aAudioTagger>() } returns mockk<M4aAudioTagger>(relaxed = true)
every { getBean<OggOpusAudioTagger>() } returns mockk<OggOpusAudioTagger>(relaxed = true)
every { getBean<Mp3AudioTagger>() } returns mockk<Mp3AudioTagger>(relaxed = true)
every { getBean<MkaAudioTagger>() } returns mockk<MkaAudioTagger>(relaxed = true)
}
}

Expand All @@ -64,6 +67,15 @@ class TaggerDeciderCoreTest : ShouldSpec({
tagger.shouldBeInstanceOf<OggOpusAudioTagger>()
coVerify(exactly = 0) { mockAudioFormatChecker.checkAudioFormat(any()) }
}
should("decide mka tagger for mka file produced by any->mka extractor") {
val mockAudioFormatChecker = createMockChecker()
val mockBeanFactory = createMockFactory()
val taggerDecider = TaggerDeciderCore(mockAudioFormatChecker, mockBeanFactory)

val tagger = taggerDecider.decideTagger(Optional.of(mockk<AnyToMkaAudioExtractor>(relaxed = true)), null)
tagger.shouldBeInstanceOf<MkaAudioTagger>()
coVerify(exactly = 0) { mockAudioFormatChecker.checkAudioFormat(any()) }
}
should("throw exception for unknown extractor") {
val mockAudioFormatChecker = createMockChecker()
val mockBeanFactory = createMockFactory()
Expand Down

0 comments on commit ebfbdeb

Please sign in to comment.