|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
fi.helsinki.cs.ohtu.mpeg2.PESPacketizingOutputStream
public class PESPacketizingOutputStream
An OutputStream implementation which encapsulates written data to PES packets. Arbitrary PES packet types and header parameters are supported by the notion of an optional template packet. The template packet, which is a PESPacket or a subclass thereof, is filled up with the input data. When the packet is full (with an optional limit of just how full it can be) it is written to the stream and its contents emptied using the reset() method. However, as the reset() method calls insertTemplateBytes() on the subclass, the packet will always have the desired additional header data in it before any data written using this stream class. The stream can wrap either a BitOutputStream or a ProgramStream.
Field Summary | |
---|---|
private BitOutputStream |
bos
|
private boolean |
dirty
|
private int |
maxPacketLength
|
private ProgramStream |
ps
|
private PESPacket |
template
|
Constructor Summary | |
---|---|
PESPacketizingOutputStream(BitOutputStream stream,
PESPacket template)
Constructs a new instance using an existing PESPacket (or more likely, a subclass) instance as the template and writing directly to a BitOutputStream. |
|
PESPacketizingOutputStream(BitOutputStream stream,
StreamID streamID)
Constructs a new instance using a newly-created PESPacket class with the given stream ID as the template and writing directly to a BitOutputStream. |
|
PESPacketizingOutputStream(ProgramStream stream,
PESPacket template)
Constructs a new instance using an existing PESPacket (or more likely, a subclass) instance as the template and writing to a ProgramStream. |
|
PESPacketizingOutputStream(ProgramStream stream,
StreamID streamID)
Constructs a new instance using a newly-created PESPacket class with the given stream ID as the template and writing to a ProgramStream. |
Method Summary | |
---|---|
void |
aboutToReset(PESPacket packet)
Used to flush data when needed, for example, when the template header fields have been changed. |
void |
close()
Closes the stream. |
void |
flush()
Flushes the stream, writing the filled-up template packet to the underlying stream. |
int |
getMaxPacketLength()
Returns the maximum packet length, as set by setMaxPacketLength() or a constructor. |
PESPacket |
getTemplate()
Gets the template packet currently in use. |
BitOutputStream |
getUnderlyingBOS()
Returns the BitOutputStream this stream is wrapping. |
ProgramStream |
getUnderlyingPS()
Returns the ProgramStream this stream is wrapping. |
void |
setMaxPacketLength(int length)
Sets the maximum packet length. |
void |
setTemplate(PESPacket template)
Sets the template packet to use. |
void |
setUnderlyingBOS(BitOutputStream bos)
Sets the stream to wrap the given BitOutputStream. |
void |
setUnderlyingPS(ProgramStream ps)
Sets the stream to wrap the given ProgramStream. |
void |
write(int byteValue)
Writes a byte to the stream, filling up the template. |
Methods inherited from class java.io.OutputStream |
---|
write, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private BitOutputStream bos
private ProgramStream ps
private PESPacket template
private int maxPacketLength
private boolean dirty
Constructor Detail |
---|
public PESPacketizingOutputStream(BitOutputStream stream, StreamID streamID)
stream
- The stream to write the resulting packets to.streamID
- The stream ID for the template PESPacket to specify in the common header.public PESPacketizingOutputStream(BitOutputStream stream, PESPacket template)
stream
- The stream to write the resulting packets to.template
- The template to use, as if setTemplate(template) was called.public PESPacketizingOutputStream(ProgramStream stream, StreamID streamID)
stream
- The stream to write the resulting packets to.streamID
- The stream ID for the template PESPacket to specify in the common header.public PESPacketizingOutputStream(ProgramStream stream, PESPacket template)
stream
- The stream to write the resulting packets to.template
- The template to use, as if setTemplate(template) was called.Method Detail |
---|
public BitOutputStream getUnderlyingBOS()
null
is returned.
public void setUnderlyingBOS(BitOutputStream bos)
bos
- The stream to wrap.public ProgramStream getUnderlyingPS()
null
is returned.
public void setUnderlyingPS(ProgramStream ps)
ps
- The stream to wrap.public int getMaxPacketLength()
public void setMaxPacketLength(int length)
length
- The new maximum length. Must be in range [1..65535].public PESPacket getTemplate()
public void setTemplate(PESPacket template)
template
- The new template packet.public void write(int byteValue) throws java.io.IOException
write
in class java.io.OutputStream
byteValue
- The byte to write.
java.io.IOException
- Propagated from flush() and the template stream write.OutputStream.write(int)
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
- Propagated from writing the filled-up template to the underlying stream.Flushable.flush()
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.OutputStream
java.io.IOException
- Propagated from flush() and closing the underlying stream.Closeable.close()
public void aboutToReset(PESPacket packet) throws java.io.IOException
aboutToReset
in interface PESPacketAboutToResetListener
packet
- The packet to be reset.
java.io.IOException
- Propagated from #flush().PESPacketAboutToResetListener.aboutToReset(PESPacket)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |