com.smaxe.uv.stream
Class MediaData

java.lang.Object
  extended by com.smaxe.uv.stream.MediaData
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
MediaDataByteArray

public abstract class MediaData
extends java.lang.Object
implements java.io.Serializable

MediaData - media (audio/video/flv) data.

Author:
Andrei Sochirca
See Also:
Serialized Form

Field Summary
 int rtime
          Media frame relative time (since the last frame time) in milliseconds.
 long timestamp
          Media frame stream timestamp (since the stream start timestamp) in milliseconds.
 
Constructor Summary
MediaData()
          Constructor.
MediaData(int rtime)
          Constructor.
MediaData(int rtime, long timestamp)
          Constructor.
 
Method Summary
 boolean hasAbsoluteTimestamp()
          Checks if rtime defines absolute stream timestamp (rather than 'relative' time).
abstract  java.io.InputStream read()
          Returns InputStream to read media data.
abstract  int size()
          Returns media data size (including tag byte).
abstract  int tag()
          Returns media data tag.
 java.lang.String toString()
           
abstract  int write(java.io.OutputStream os, int offset, int length)
          Writes video data to the os.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rtime

public int rtime
Media frame relative time (since the last frame time) in milliseconds.


timestamp

public long timestamp
Media frame stream timestamp (since the stream start timestamp) in milliseconds.

Constructor Detail

MediaData

public MediaData()
Constructor.


MediaData

public MediaData(int rtime)
Constructor.

Parameters:
rtime - relative time (in milliseconds)

MediaData

public MediaData(int rtime,
                 long timestamp)
Constructor.

Parameters:
rtime - relative time (in milliseconds)
timestamp - stream timestamp (in milliseconds)
Method Detail

hasAbsoluteTimestamp

public boolean hasAbsoluteTimestamp()
Checks if rtime defines absolute stream timestamp (rather than 'relative' time).

Note:
- Method returns true if 'rtime' equals 'timestamp'.

Returns:
true if 'rtime' defines absolute stream timestamp; otherwise false

size

public abstract int size()
Returns media data size (including tag byte).

Returns:
media data size

tag

public abstract int tag()
Returns media data tag.

Note: Tag is the first byte of the media data. It contains media frame info, like frame type, codec, etc.

Returns:
video tag

read

public abstract java.io.InputStream read()
                                  throws java.io.IOException
Returns InputStream to read media data.

Returns:
video data
Throws:
java.io.IOException - if an I/O exception occurred

write

public abstract int write(java.io.OutputStream os,
                          int offset,
                          int length)
                   throws java.io.IOException
Writes video data to the os.

Parameters:
os - output stream to fill with media data
os -
offset - data offset
length - number of bytes to write
Returns:
number of written bytes
Throws:
java.io.IOException - if an I/O exception occurred

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object