public void flushWriterTest() { YuvVideoHandler yvh = new YuvVideoHandler(); YuvVideoInfo info = new YuvVideoInfo(readPath); info.width = 352; info.height = 240; info.yuvFormat = YuvFormat.YUV420_IYUV; yvh.setReadContext(readPath, info); // write context cannot be set without a valid read context writePath = sampleVideosPath + "\\americanFootball_352x240_125_Copy.yuv"; YuvVideoInfo writeinfo = new YuvVideoInfo(); writeinfo.path = writePath; writeinfo.width = 352; writeinfo.height = 240; writeinfo.yuvFormat = YuvFormat.YUV420_IYUV; yvh.setWriteContext(writePath, writeinfo); int oldFrameByteSize = yvh.frameByteSize; yvh.flushWriter(); Assert.AreEqual(oldFrameByteSize, yvh.frameByteSize); Assert.AreEqual(0, yvh.positionReader); System.Drawing.Bitmap testframe = yvh.getFrame(); System.Drawing.Bitmap[] frames = new System.Drawing.Bitmap[1]; frames[0] = testframe; yvh.writeFrames(4, frames); yvh.flushWriter(); yvh.writeFrames(4, frames); }
public void writeContextTest() { YuvVideoHandler yvh = new YuvVideoHandler(); YuvVideoInfo info = new YuvVideoInfo(readPath); info.width = 352; info.height = 240; info.yuvFormat = YuvFormat.YUV420_IYUV; yvh.setWriteContext(readPath, info); yvh.setReadContext(readPath, info); yvh.setWriteContext(readPath, info); Assert.AreEqual(info, yvh.writeVidInfo); Assert.IsTrue(yvh.consistent); string falsePath = "\\bla_cif.yuv"; YuvVideoInfo falseInfo = new YuvVideoInfo(); falseInfo.path = falsePath; try { yvh.setWriteContext(falsePath, falseInfo); Assert.Fail("no exception thrown"); } catch (Exception ) { } try { yvh.setWriteContext(falsePath, info); Assert.Fail("no exception thrown"); } catch (Exception ) { } try { yvh.setWriteContext(readPath, falseInfo); Assert.Fail("no exception thrown"); } catch (Exception) { } }