public void TestDecodeFrameNeedMore() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-epic.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.OpenFeed(); byte[] fileBytes = File.ReadAllBytes(path); byte[] buffer = new byte[8]; Array.Copy(fileBytes, buffer, 8); 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; Assert.That(() => error = mpg123.DecodeFrame(ref num, ref buffer, ref bytes), Throws.Nothing); Assert.That(error, Is.EqualTo(Mpg123.Errors.NEED_MORE)); }
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 TestGetFormatOK() //must fail because there isn't stream loaded { Mpg123 handle = new Mpg123(); long rate = 0; int channels = 0, encoding = 0; Assert.That(handle.GetFormat(ref rate, ref channels, ref encoding), Is.Not.EqualTo(Mpg123.Errors.OK)); }
public void TestReadNeedMore() { Mpg123 mpg123 = new Mpg123(); mpg123.OpenFeed(); byte[] buffer = new byte[8]; uint done = 0; int b = 0, c = 0; long a = 0; mpg123.GetFormat(ref a, ref b, ref c); Mpg123.Errors error = Mpg123.Errors.OK; Assert.That(() => error = mpg123.Read(buffer, ref done), Throws.Nothing); Assert.That(error, Is.EqualTo(Mpg123.Errors.NEED_MORE)); }
public void TestDecodeFrameNoNewFormat() { 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; int b = 0, c = 0; long a = 0; mpg123.GetFormat(ref a, ref b, ref c); Assert.That(mpg123.DecodeFrame(ref num, ref buffer, ref bytes), Is.EqualTo(Mpg123.Errors.OK)); }
public void TestReadNoNewFormat() { 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]; int b = 0, c = 0; long a = 0; mpg123.GetFormat(ref a, ref b, ref c); Assert.That(mpg123.Read(buffer, ref done), Is.EqualTo(Mpg123.Errors.OK)); }
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 TestFeedReadNoNeedMore() { Mpg123 mpg123 = new Mpg123(); mpg123.OpenFeed(); string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-epic.mp3"); byte[] inBuffer = File.ReadAllBytes(path); byte[] outBuffer = new byte[inBuffer.Length]; uint done = 0; mpg123.Feed(inBuffer); long a = 0; int b = 0, c = 0; mpg123.GetFormat(ref a, ref b, ref c); Assert.That(mpg123.Read(outBuffer, ref done), Is.EqualTo(Mpg123.Errors.OK)); Assert.That(done, Is.EqualTo(inBuffer.Length)); }
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)); }