|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfi.helsinki.cs.ohtu.mpeg2.ElementaryStream
fi.helsinki.cs.ohtu.mpeg2.AudioStream
public class AudioStream
Represents an elementary stream of MPEG audio data. This class provides a relatively high-level interface to write audio streams. The class collects sequential audio frames together and generates timestamps for them. The data are then delivered to packetizers.
Field Summary | |
---|---|
private boolean |
closed
|
private boolean |
discont
|
private double |
duration
|
private boolean |
firstAu
|
private java.util.List<AVPacketizer> |
packers
|
private long |
ptsBase
|
Constructor Summary | |
---|---|
AudioStream()
Creates a new AudioStream instance. |
|
AudioStream(long pts)
Creates a new AudioStream instance with given
initial PTS. |
Method Summary | |
---|---|
void |
close()
Closes this ElementaryStream . |
private byte[] |
encodeFrame(AudioFrame frame)
Encodes an audio frame in an array of bytes. |
void |
flush()
Flushes buffered data, if any, to the packetizers. |
AVPacketizer |
getPacketizer(int asid)
Creates a new packetizer for this AudioStream . |
AVPacketizer |
getPacketizer(int asid,
int decoderBuffer)
Creates a packetizer for this AudioStream . |
long |
getPts()
Returns the current PTS. |
void |
releasePacketizer(AVPacketizer esp)
Releases a packetizer for this ElementaryStream . |
void |
setPts(double pts)
Sets the presentation timestamp (PTS) for the next access unit. |
void |
setPts(long pts)
Sets the presentation timestamp (PTS) for the next access unit. |
void |
write(AudioFrame frame)
Writes an audio frame into this AudioStream and
updates the PTS accordingly. |
void |
write(AudioFrame frame,
long pts)
Writes an audio frame with given PTS into this AudioStream . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private long ptsBase
private double duration
private boolean firstAu
private boolean discont
private boolean closed
private java.util.List<AVPacketizer> packers
Constructor Detail |
---|
public AudioStream(long pts)
AudioStream
instance with given
initial PTS.
pts
- the PTS for the first access unitpublic AudioStream()
AudioStream
instance. The PTS
defaults to zero.
Method Detail |
---|
public long getPts()
public void setPts(long pts)
pts
- the PTS, in ticks of the 90kHz clockpublic void setPts(double pts)
pts
- the PTS, in secondspublic void write(AudioFrame frame, long pts)
AudioStream
. The PTS will be used as a time base
for the following audio frames.
frame
- the audio frame to writepts
- the PTs for the audio framepublic void write(AudioFrame frame)
AudioStream
and
updates the PTS accordingly.
frame
- the audio frame to writepublic AVPacketizer getPacketizer(int asid, int decoderBuffer)
AudioStream
. Audio stream
number, asid
, defines the stream id for audio packets.
decoderBuffer
defines how much audio data can be waiting
to be decoded at the audio decoder at any moment. The lower the
number the lower the resource demands. However, low buffer sizes
make it difficult to maintain smooth playback.
asid
- the stream number for the packetized stream,
in range [0, 32]decoderBuffer
- the size of the audio decoder buffer,
in bytes; has to be at least 3072
public AVPacketizer getPacketizer(int asid)
AudioStream
. The audio
decoder buffer defaults to 4KiB.
getPacketizer
in class ElementaryStream
asid
- the stream number for the packetized stream,
in range [0, 32]
getPacketizer(int, int)
public void releasePacketizer(AVPacketizer esp)
ElementaryStream
ElementaryStream
.
After releasing the packetizer will not receive more
data from this stream.
releasePacketizer
in class ElementaryStream
esp
- the packetizer to releasepublic void flush()
ElementaryStream
flush
in class ElementaryStream
public void close()
ElementaryStream
ElementaryStream
. After this call
no more data shall be written into this stream.
close
in class ElementaryStream
private byte[] encodeFrame(AudioFrame frame)
frame
- the audio frame to be encoded
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |