coder = mCoders.get(i);
if (coder == null)
{
// now get the coder for the given stream index
IStream stream = getContainer().getStream(i);
try
{
coder = stream.getStreamCoder();
// put the coder into the coder map, event if it not a supported
// type so that on further reads it will find the coder but choose
// not decode unsupported types
mCoders.put(i, coder);
// and release our coder to the list
coder = null;
super.onAddStream(new AddStreamEvent(this, i));
}
finally
{
if (coder != null) coder.delete();
if (stream != null)
stream.delete();
}
}
}
}
coder = mCoders.get(streamIndex);
IStream stream = getContainer().getStream(streamIndex);
try
{
ICodec.Type type = coder.getCodecType();
// if the coder is not open, open it
// NOTE: MediaReader currently supports audio & video streams
if (!coder.isOpen()
&& (type == ICodec.Type.CODEC_TYPE_AUDIO || type == ICodec.Type.CODEC_TYPE_VIDEO))
{
if (coder.open(null, null) < 0)
throw new RuntimeException("could not open coder for stream: "
+ streamIndex);
mOpenedStreams.add(stream);
super.onOpenCoder(new OpenCoderEvent(this, stream.getIndex()));
stream = null;
}
} finally {
if (stream != null)
stream.delete();
}
// return back the reference we had
return coder;
}