Typical usage for reading looks like this:
IContainer container = IContainer.make(); if (container.open("myfile.flv", IContainer.Type.READ, null) <0) throw new RuntimeException("failed to open"); int numStreams = container.getNumStreams(); for(i = 0; i < numStreams; i++) { IStream stream = container.getStream(i); ...query IStream for stream information... } IPacket packet = IPacket.make(); while(container.readNextPacket(packet) >= 0) { ... Do something with the packet... } container.close();
Typical usage for writing looks like this (makes an FLV file with one audio track encoded as mp3 data):
IContainer container = IContainer.make(); if (container.open("myfile.flv", IContainer.Type.WRITE, null) <0) throw new RuntimeException("failed to open"); IStream stream = container.addNewStream(0); IStreamCoder coder = stream.getStreamCoder(); coder.setCodec(ICodec.ID.CODEC_ID_MP3); coder.setSampleRate(22050); coder.setChannels(2); coder.setBitRate(64000); if (coder.open()<0) throw new RuntimeException("could not open coder"); if (container.writeHeader() < 0) throw new RuntimeException(); IPacket packet = IPacket.make(); while( ... have more data to process ... ) { then assuming it generated an IPacket for you... if (container.writePacket(packet)<0) throw new RuntimeException("could not write packet"); } if (container.writeTrailer() <0) throw new RuntimeException(); container.close();
This interface is not intended to be implemented by clients.
Containers implement the IAdaptable
interface; extensions are managed by the platform's adapter manager.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|