public class TimelineWriter extends Object
Modifier and Type | Field and Description |
---|---|
protected long |
datagramsBytePos |
protected TimelineReader.Index |
idx |
protected MaryHeader |
maryHdr |
protected long |
numDatagrams |
protected TimelineReader.ProcHeader |
procHdr |
protected RandomAccessFile |
raf |
protected int |
sampleRate |
protected long |
timeIdxBytePos |
protected long |
timePtr |
Constructor and Description |
---|
TimelineWriter(String fileName,
String procHdrString,
int reqSampleRate,
double setIdxIntervalInSeconds)
Constructor to create a timeline.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Output the internally maintained indexes and close the file.
|
void |
feed(Datagram[] dArray,
int reqSampleTime)
Write a series of datagrams to the timeline.
|
void |
feed(Datagram d,
int reqSampleRate)
Write one datagram to the timeline.
|
long |
getBytePointer()
Get the current byte position in the file
|
long |
getDatagramsBytePos()
Returns the position of the datagram zone
|
TimelineReader.Index |
getIndex() |
long |
getNumDatagrams()
Returns the current number of datagrams in the timeline.
|
int |
getSampleRate()
Returns the sample rate of the timeline.
|
long |
getTimePointer()
Get the current time position in the file
|
protected long |
scaleTime(int reqSampleRate,
long targetTimeInSamples)
Scales a discrete time to the timeline's sample rate.
|
protected void |
setBytePointer(long bytePos)
Set the current byte position in the file
|
protected void |
setTimePointer(long timePosition)
Set the current time position in the file
|
protected long |
unScaleTime(int reqSampleRate,
long timelineTimeInSamples)
Unscales a discrete time from the timeline's sample rate.
|
protected RandomAccessFile raf
protected MaryHeader maryHdr
protected TimelineReader.ProcHeader procHdr
protected TimelineReader.Index idx
protected int sampleRate
protected long numDatagrams
protected long datagramsBytePos
protected long timeIdxBytePos
protected long timePtr
public TimelineWriter(String fileName, String procHdrString, int reqSampleRate, double setIdxIntervalInSeconds)
fileName
- The file to read the timeline from.procHdrString
- the string to use as a processing header.reqSampleRate
- the sample rate requested to measure time in this timeline.setIdxIntervalInSeconds
- the interval between two index entries, in secondspublic long getBytePointer() throws IOException
IOException
- IOExceptionpublic long getTimePointer()
protected void setBytePointer(long bytePos) throws IOException
bytePos
- bytePosIOException
- IOExceptionprotected void setTimePointer(long timePosition)
timePosition
- timePositionprotected long scaleTime(int reqSampleRate, long targetTimeInSamples)
reqSampleRate
- the externally given sample rate.targetTimeInSamples
- a discrete time, with respect to the externally given sample rate.protected long unScaleTime(int reqSampleRate, long timelineTimeInSamples)
reqSampleRate
- the externally given sample rate.timelineTimeInSamples
- a discrete time, with respect to the timeline sample rate.public TimelineReader.Index getIndex()
public long getDatagramsBytePos()
public long getNumDatagrams()
public int getSampleRate()
public void close() throws IOException
IOException
- IOExceptionpublic void feed(Datagram d, int reqSampleRate) throws IOException
d
- the datagram to write.reqSampleRate
- the sample rate at which the datagram duration is expressed.IOException
- IOExceptionpublic void feed(Datagram[] dArray, int reqSampleTime) throws IOException
dArray
- an array of datagrams.reqSampleTime
- the sample rate at which the datagram durations are expressed.IOException
- IOExceptionCopyright © 2000–2016 DFKI GmbH. All rights reserved.