public void TestOpenPathInvalid() { string path = "test.mp3"; Mpg123 mpg123 = new Mpg123(); Assert.That(() => mpg123.Open(path), Throws.TypeOf <Mpg123.ErrorException>()); }
public void TestDecodeFrameNumFrames() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-scifi.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); byte[] buffer = null; int num = 0; uint bytes = 0; int b = 0, c = 0; long a = 0; mpg123.GetFormat(ref a, ref b, ref c); Mpg123.Errors error = Mpg123.Errors.OK; while (error == Mpg123.Errors.OK) { error = mpg123.DecodeFrame(ref num, ref buffer, ref bytes); } Assert.That(num, Is.GreaterThan(0)); }
public void TestOpenPathValid() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = dirName + "/bensound-epic.mp3"; Mpg123 mpg123 = new Mpg123(); Assert.That(() => mpg123.Open(path), Throws.Nothing); }
public void TestOpenFeedOpen() { Mpg123 mpg123 = new Mpg123(); string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-epic.mp3"); mpg123.Open(path); Assert.That(() => mpg123.OpenFeed(), Throws.Nothing); }
public void TestFeature() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = dirName + "/bensound-epic.mp3"; Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); Assert.That(() => mpg123.Feature(Mpg123.Mpg123FeatureSet.MPG123_FEATURE_EQUALIZER), Throws.Nothing); }
public void TestReadNullBuffer() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-epic.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); uint done = 0; Assert.That(() => mpg123.Read(null, ref done), Throws.TypeOf <NullReferenceException>()); }
public void TestReadOpen() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-epic.mp3"); byte[] buffer = new byte[1000]; Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); uint done = 0; Assert.That(() => mpg123.Read(buffer, ref done), Throws.Nothing); }
public void TestReadNewFormat() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-epic.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); uint done = 0; byte[] buffer = new byte[1000]; Assert.That(mpg123.Read(buffer, ref done), Is.EqualTo(Mpg123.Errors.NEW_FORMAT)); }
public void TestDecodeFrameNewFormat() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-epic.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); byte[] buffer = null; int num = 0; uint bytes = 0; Assert.That(mpg123.DecodeFrame(ref num, ref buffer, ref bytes), Is.EqualTo(Mpg123.Errors.NEW_FORMAT)); }
public void TestFramePosParsedFrame() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-scifi.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); byte[] buffer = null; int num = 0; uint bytes = 0; mpg123.DecodeFrame(ref num, ref buffer, ref bytes); Assert.That(mpg123.FramePos(), Is.GreaterThan(0)); }
public void TestReadDoneBytes() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-scifi.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); uint done = 0; byte[] buffer = new byte[1000]; while (mpg123.Read(buffer, ref done) != Mpg123.Errors.OK) { } Assert.That(done, Is.EqualTo(1000)); }
public void TestSetParamGetParam() { long setValue = 2; long getValue = 0; double getFValue = 0; string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = dirName + "/bensound-epic.mp3"; Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); mpg123.SetParam(Mpg123.Mpg123Params.MPG123_DOWNSPEED, setValue); mpg123.GetParam(Mpg123.Mpg123Params.MPG123_DOWNSPEED, ref getValue, ref getFValue); Assert.That(getValue, Is.EqualTo(2)); Assert.That(getFValue, Is.EqualTo(0)); }
public void TestDecodeFrameOpen() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-epic.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); byte[] buffer = null; int num = 0; uint bytes = 0; Mpg123.Errors error = Mpg123.Errors.OK; while (error == Mpg123.Errors.OK) { Assert.That(() => error = mpg123.DecodeFrame(ref num, ref buffer, ref bytes), Throws.Nothing); } }
public void TestSeekToEndWithStreamLoaded() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-scifi.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); byte[] buffer = new byte[1000]; uint end = 0; while (mpg123.Read(buffer, ref end) != Mpg123.Errors.OK) { } long seekOffset = mpg123.Seek(0, SeekOrigin.End); Assert.That(seekOffset, Is.GreaterThan(0)); }
public void TestDecodeFrameBufferLength0() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-epic.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); byte[] buffer = null; int num = 0; uint bytes = 0; while (mpg123.DecodeFrame(ref num, ref buffer, ref bytes) != Mpg123.Errors.OK) { } Assert.That(buffer.Length, Is.EqualTo(bytes)); }
public void TestTellWithLoadedStream() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-scifi.mp3"); byte[] buffer = new byte[1000]; Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); uint end = 0; while (mpg123.Read(buffer, ref end) != Mpg123.Errors.OK) { } long seekPosition = mpg123.Tell(); Assert.That(seekPosition, Is.GreaterThan(0)); }
public void TestDecodeFrameNumFramesTotal() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-epic.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); byte[] buffer = null; int num = 1; uint bytes = 0; Mpg123.Errors error = Mpg123.Errors.OK; while (error != Mpg123.Errors.DONE) { error = mpg123.DecodeFrame(ref num, ref buffer, ref bytes); } Assert.That(num, Is.EqualTo(6834)); }
public void TestReadEmptyBuffer() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-epic.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); uint done = 0; byte[] buffer = new byte[0]; Mpg123.Errors error = Mpg123.Errors.OK; while (error == Mpg123.Errors.OK) { Assert.That(() => error = mpg123.Read(buffer, ref done), Throws.Nothing); } Assert.That(done, Is.EqualTo(0)); }
static void Main(string[] args) { foreach (string decoder in Mpg123.Decoders) { Console.WriteLine(decoder); } Out123 out123 = new Out123(); out123.Open(); Mpg123 mpg123 = new Mpg123(); mpg123.Open("Assets/bensound-epic.mp3"); int offset = 0; while (true) { byte[] data = null; uint size = 0; Mpg123.Errors error = mpg123.DecodeFrame(ref offset, ref data, ref size); if (error == Mpg123.Errors.NEW_FORMAT) { long rate = 0; int channels = 0; int encoding = 0; mpg123.GetFormat(ref rate, ref channels, ref encoding); out123.Start(rate, channels, encoding); } else if (error == Mpg123.Errors.OK) { out123.Play(data); } } Console.ReadLine(); }
public void TestSeekEndOutOfBounds() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-scifi.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); byte[] buffer = new byte[1000]; uint end = 0; while (mpg123.Read(buffer, ref end) != Mpg123.Errors.OK) { } long offsets = 0; long step = 0; ulong fill = 0; mpg123.Index(ref offsets, ref step, ref fill); //i expect to get an exception because the seek will be set to (end + 1) Assert.That(() => mpg123.Seek(-1, SeekOrigin.Begin), Throws.TypeOf <Mpg123.ErrorException>()); }
public void TestDecodeFrameBufferLength1() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-scifi.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); byte[] buffer = null; int num = 0; uint bytes = 0; int b = 0, c = 0; long a = 0; mpg123.GetFormat(ref a, ref b, ref c); mpg123.DecodeFrame(ref num, ref buffer, ref bytes); Assert.That(buffer.Length, Is.EqualTo(188)); mpg123.DecodeFrame(ref num, ref buffer, ref bytes); Assert.That(buffer.Length, Is.EqualTo(4608)); }
public void TestOpenPathNull() { Mpg123 mpg123 = new Mpg123(); Assert.That(() => mpg123.Open(null), Throws.Nothing); }