destinationFile.delete();
assert(!destinationFile.exists());
// create the reader
MediaReader reader = new MediaReader(mSource);
// construct a writer which does not get called directly by the
// MediaReader, and thus many things need to be handled manually
if (mTestContainer)
{
final MediaWriter writer = new MediaWriter(mDestination,
reader.getContainer());
writer.setMaskLateStreamExceptions(false);
writer.addListener(new MediaViewer(mViewerMode, true));
writer.addListener(new MediaDebugListener(OPEN, CLOSE));
reader.addListener(new MediaListenerAdapter()
{
public void onVideoPicture(IVideoPictureEvent event)
{
writer.onVideoPicture(event);
}
/** {@inheritDoc} */
public void onAudioSamples(IAudioSamplesEvent event)
{
writer.onAudioSamples(event);
}
});
// transcode
while (reader.readPacket() == null)
;
// close the container
writer.close();
}
// construct a writer give a reader, the easy simple case
else
{
// construct the writer, no need to keep a reference to the
// writer, it's maintained in the reader
MediaWriter writer = new MediaWriter(mDestination, reader);
reader.addListener(writer);
writer.setMaskLateStreamExceptions(false);
writer.addListener(new MediaViewer(mViewerMode, true));
writer.addListener(new MediaDebugListener(EVENT, META_DATA));
// transcode
while (reader.readPacket() == null)
;
}
// confirm file exists and has at least 50k of data