FileDocCategorySizeDatePackage
VideoFormat.javaAPI DocJMF 2.1.1e9116Mon May 12 12:20:34 BST 2003javax.media.format

VideoFormat

public class VideoFormat extends Format
Encapsulates format information for video data. The attributes of a VideoFormat include the encoding type, frame size, frame rate, and the data type.
since
JMF 2.0

Fields Summary
protected Dimension
size
protected int
maxDataLength
protected float
frameRate
public static final String
CINEPAK
Cinepak format.
public static final String
JPEG
JPEG format.
public static final String
JPEG_RTP
JPEG RTP format
public static final String
MPEG
MPEG format.
public static final String
MPEG_RTP
MPEG RTP format.
public static final String
H261
H.261 format.
public static final String
H261_RTP
H261 RTP format
public static final String
H263
H.263 format.
public static final String
H263_RTP
H.263 (RFC 2190) RTP format
public static final String
H263_1998_RTP
H.263+ (RFC 2429 aka H263-1998) RTP format
public static final String
RGB
Raw RGB format.
public static final String
YUV
Raw YUV or YCrCb format.
public static final String
IRGB
8-bit Indexed RGB format.
public static final String
SMC
Sorensen format.
public static final String
RLE
Run Length Encoded video format.
public static final String
RPZA
public static final String
MJPG
Motion JPEG format.
public static final String
MJPEGA
Motion JPEG-A format.
public static final String
MJPEGB
Motion JPEG-B format.
public static final String
INDEO32
Indeo Video 3.2
public static final String
INDEO41
Indeo Interactive 4.1
public static final String
INDEO50
Indeo Interactive 5.0
Constructors Summary
public VideoFormat(String encoding)
Constructs a VideoFormat with the specified encoding type.

param
encoding A String that describes the encoding type for this VideoFormat.

    
                               
       
 	super(encoding);
    
public VideoFormat(String encoding, Dimension size, int maxDataLength, Class dataType, float frameRate)
Constructs a VideoFormat with the specified attributes.

param
encoding A String that describes the encoding type for this VideoFormat.
param
size The size of a video frame.
param
maxDataLength The maximum length of a data chunk.
param
dataType The type of data. For example, byte array.
param
frameRate The frame rate.

	this(encoding);
	if (size != null)
	    this.size = new Dimension(size);
	this.maxDataLength = maxDataLength;
	this.dataType = dataType;
	this.frameRate = frameRate;
    
Methods Summary
public java.lang.Objectclone()
Creates a clone of this VideoFormat by copying each field to the clone.

return
A clone of this VideoFormat.

	VideoFormat f = new VideoFormat(encoding, size, maxDataLength,
					dataType, frameRate);
	f.copy(this);
	return f;
    
protected voidcopy(javax.media.Format f)
Copies the attributes from the specified Format into this VideoFormat.

param
f The Format to copy the attributes from.

	super.copy(f);
	VideoFormat vf = (VideoFormat)f;
	if (vf.size != null)
	    size = new Dimension(vf.size); 
	maxDataLength = vf.maxDataLength;
	frameRate = vf.frameRate;
    
public booleanequals(java.lang.Object format)
Compares the specified Format with this VideoFormat. Returns true only if the specified Format is a VideoFormat object and all of its attributes are identical to the attributes in this VideoFormat.

param
format The Format to compare.
return
true if the specified Format is the same as this one.

	if (format instanceof VideoFormat) {
	    VideoFormat vf = (VideoFormat)format;

	    if (size == null || vf.size == null) {
		if (size != vf.size)
		    return false;
	    } else {
		if (!size.equals(vf.size))
		    return false;
	    }
	    
	    return super.equals(format) &&
		maxDataLength == vf.maxDataLength &&
		frameRate == vf.frameRate;
	}
	return false;
    
public floatgetFrameRate()
Gets the frame rate associated with this VideoFormat.

return
The frame rate.

	return frameRate;
    
public intgetMaxDataLength()
Gets the length of the largest data chunk associated with this VideoFormat.

return
The maximum length of a data chunk in this VideoFormat.

	return maxDataLength;
    
public java.awt.DimensiongetSize()
Gets the dimensions of a video frame in this VideoFormat.

return
A Dimension that specifies the frame size.

	return size;
    
public javax.media.Formatintersects(javax.media.Format format)
Finds the attributes shared by two matching Format objects. If the specified Format does not match this one, the result is undefined.

param
The matching Format to intersect with this VideoFormat.
return
A Format object with its attributes set to those attributes common to both Format objects.
see
#matches

	Format fmt;
	if ((fmt = super.intersects(format)) == null)
	    return null;
	if (!(format instanceof VideoFormat))
	    return fmt;
	VideoFormat other = (VideoFormat)format;
	VideoFormat res = (VideoFormat)fmt;
	res.size = (size != null ?
		    size : other.size);
	res.maxDataLength = (maxDataLength != NOT_SPECIFIED ?
			     maxDataLength : other.maxDataLength);
	res.frameRate = (frameRate != NOT_SPECIFIED ?
			 frameRate : other.frameRate);
	return res;
    
public booleanmatches(javax.media.Format format)
Checks whether or not the specified Format matches this VideoFormat. Matches only compares the attributes that are defined in the specified Format, unspecified attributes are ignored.

The two Format objects do not have to be of the same class to match. For example, if "A" are "B" are being compared, a match is possible if "A" is derived from "B" or "B" is derived from "A". (The compared attributes must still match, or matches fails.)

param
format The Format to compare with this one.
return
true if the specified Format matches this one, false if it does not.

	if (!super.matches(format))
	    return false;
	if (!(format instanceof VideoFormat))
	    return true;

	VideoFormat vf = (VideoFormat)format;

	return 
	    (size == null || vf.size == null ||
	     size.equals(vf.size)) &&
	    (frameRate == NOT_SPECIFIED || vf.frameRate == NOT_SPECIFIED ||
	     frameRate == vf.frameRate);
    
public javax.media.Formatrelax()
Generate a format that's less restrictive than this format but contains the basic attributes that will make this resulting format useful for format matching.

return
A Format that's less restrictive than the this format.

	VideoFormat fmt;
	if ((fmt = (VideoFormat)super.relax()) == null)
	    return null;

	fmt.size = null;
	fmt.maxDataLength = NOT_SPECIFIED;
	fmt.frameRate = NOT_SPECIFIED;

	return fmt;
    
public java.lang.StringtoString()
Gets a String representation of the attributes of this VideoFormat. For example: "RGB, 352x240, ...".

return
A String that describes the VideoFormat attributes.

	String s = "";
	if (getEncoding() != null)
	    s += getEncoding().toUpperCase();
	else
	    s += "N/A";
	if (size != null)
	    s += ", " + size.width + "x" + size.height;
	if (frameRate != NOT_SPECIFIED)
	    s += ", FrameRate=" + ((int)(frameRate * 10) / 10f);
	if (maxDataLength != NOT_SPECIFIED)
	    s += ", Length=" + maxDataLength;
	if (dataType != null && dataType != Format.byteArray)
	    s += ", " + dataType;
	return s;