MediaWriter writer = new MediaWriter(OUTPUT_FILENAME, reader);
reader.addListener(writer);
writer.addListener(new MediaViewer(mViewerMode, true, 0));
MediaDebugListener readerCounter = new MediaDebugListener(URL, META_DATA);
MediaDebugListener writerCounter = new MediaDebugListener(EVENT, META_DATA);
reader.addListener(readerCounter);
writer.addListener(writerCounter);
IError rv;
while ((rv = reader.readPacket()) == null)
;
assertEquals(IError.Type.ERROR_EOF , rv.getType());
assertEquals(READER_VIDEO_FRAME_COUNT , readerCounter.getCount(VIDEO));
assertEquals(READER_AUDIO_FRAME_COUNT , readerCounter.getCount(AUDIO));
assertEquals(1 , readerCounter.getCount(OPEN));
assertEquals(1 , readerCounter.getCount(CLOSE));
assertEquals(2 , readerCounter.getCount(ADD_STREAM));
assertEquals(2 , readerCounter.getCount(OPEN_STREAM));
assertEquals(2 , readerCounter.getCount(CLOSE_STREAM));
assertEquals(READER_PACKET_READ_COUNT , readerCounter.getCount(READ_PACKET));
assertEquals(READER_PACKET_WRITE_COUNT, readerCounter.getCount(WRITE_PACKET));
assertEquals(0 , readerCounter.getCount(HEADER));
assertEquals(0 , readerCounter.getCount(FLUSH));
assertEquals(0 , readerCounter.getCount(TRAILER));
assertEquals(WRITER_VIDEO_FRAME_COUNT , writerCounter.getCount(VIDEO));
assertEquals(WRITER_AUDIO_FRAME_COUNT , writerCounter.getCount(AUDIO));
assertEquals(1 , writerCounter.getCount(OPEN));
assertEquals(1 , writerCounter.getCount(CLOSE));
assertEquals(2 , writerCounter.getCount(ADD_STREAM));
assertEquals(2 , writerCounter.getCount(OPEN_STREAM));
assertEquals(2 , writerCounter.getCount(CLOSE_STREAM));
assertEquals(WRITER_PACKET_READ_COUNT , writerCounter.getCount(READ_PACKET));
assertEquals(WRITER_PACKET_WRITE_COUNT, writerCounter.getCount(WRITE_PACKET));
assertEquals(1 , writerCounter.getCount(HEADER));
assertEquals(1 , writerCounter.getCount(FLUSH));
assertEquals(1 , writerCounter.getCount(TRAILER));
assert(outputFile.exists());
assertEquals(OUTPUT_FILE_SIZE, outputFile.length(), 2000);
log.debug("reader " + readerCounter);