本文整理汇总了Java中javax.media.Buffer.setHeader方法的典型用法代码示例。如果您正苦于以下问题:Java Buffer.setHeader方法的具体用法?Java Buffer.setHeader怎么用?Java Buffer.setHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.Buffer
的用法示例。
在下文中一共展示了Buffer.setHeader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import javax.media.Buffer; //导入方法依赖的package包/类
public void read(Buffer buffer) throws IOException {
synchronized (this) {
Object outdata = buffer.getData();
if (outdata == null || !(outdata.getClass() == Format.intArray) ||
((int[])outdata).length < maxDataLength) {
outdata = new int[maxDataLength];
buffer.setData(outdata);
}
buffer.setFormat( rgbFormat );
buffer.setTimeStamp( (long) (seqNo * (1000 / frameRate) * 1000000) );
BufferedImage bi = robot.createScreenCapture(
new Rectangle(x, y, width, height));
bi.getRGB(0, 0, width, height,
(int[])outdata, 0, width);
buffer.setSequenceNumber( seqNo );
buffer.setLength(maxDataLength);
buffer.setFlags(Buffer.FLAG_KEY_FRAME);
buffer.setHeader( null );
seqNo++;
}
}
示例2: read
import javax.media.Buffer; //导入方法依赖的package包/类
public void read(Buffer buffer) throws IOException {
synchronized (this) {
Object outdata = buffer.getData();
if (outdata == null || !(outdata.getClass() == Format.byteArray) ||
((byte[])outdata).length < maxDataLength) {
outdata = new byte[maxDataLength];
buffer.setData(outdata);
}
if (videoData) {
buffer.setFormat( rgbFormat );
buffer.setTimeStamp( (long) (seqNo * (1000 / frameRate) * 1000000) );
int lineNo = (seqNo * 2) % size.height;
int chunkStart = lineNo * size.width * 3;
System.arraycopy(data, chunkStart,
outdata, 0,
maxDataLength - (chunkStart));
if (chunkStart != 0) {
System.arraycopy(data, 0,
outdata, maxDataLength - chunkStart,
chunkStart);
}
} else {
buffer.setFormat( audioFormat );
buffer.setTimeStamp( 1000000000 / 8 );
for (int i = 0; i < 1000; i++) {
((byte[])outdata)[i] = (byte) (Math.sin(i / freq) * 32);
freq = (freq + 0.01);
if (freq > 10.0)
freq = 2.0;
}
}
buffer.setSequenceNumber( seqNo );
buffer.setLength(maxDataLength);
buffer.setFlags(0);
buffer.setHeader( null );
seqNo++;
}
}
示例3: read
import javax.media.Buffer; //导入方法依赖的package包/类
public void read(Buffer buffer) {
//System.err.println("entering read");
synchronized (this) {
while (!dataPending) {
try {
wait();
} catch (InterruptedException ie) {
}
}
}
//System.err.println("... in read");
// Swap
Object data = buffer.getData();
Format format = buffer.getFormat();
Object header = buffer.getHeader();
buffer.setData(pendingBuffer.getData());
buffer.setFormat(pendingBuffer.getFormat());
buffer.setHeader(pendingBuffer.getHeader());
buffer.setTimeStamp(pendingBuffer.getTimeStamp());
buffer.setFlags(pendingBuffer.getFlags() | Buffer.FLAG_NO_SYNC);
buffer.setLength(pendingBuffer.getLength());
buffer.setOffset(pendingBuffer.getOffset());
buffer.setSequenceNumber(pendingBuffer.getSequenceNumber());
pendingBuffer.setData(data);
pendingBuffer.setFormat(format);
pendingBuffer.setHeader(header);
dataPending = false;
synchronized (this) {
notifyAll();
}
}
示例4: read
import javax.media.Buffer; //导入方法依赖的package包/类
public void read(Buffer buffer) throws IOException {
synchronized (this) {
// {
Object outdata = buffer.getData();
if (rateChanged || outdata == null
|| !(outdata.getClass() == Format.intArray)
|| ((int[]) outdata).length < maxDataLength) {
outdata = new int[maxDataLength];
buffer.setData(outdata);
// System.out.println("rateChanged is: "+rateChanged+" and framerate is: "
// + frameRate);
rateChanged = false;
}
buffer.setFormat(rgbFormat);
if (!everChanged) {
timeStamp = (long) (seqNo * (1000 / frameRate) * 1000000);
} else {
if (rateChanged2) {
OldStampCons = timeStamp;
rateChanged2 = false;
}
timeStamp = OldStampCons
+ (long) (seqNo * (1000 / frameRate) * 1000000);
// System.out.println("timeStamp is: " + timeStamp);
}
/*
* if (rateChanged2 && everChanged) { timeStamp = timeStamp + (long)
* (seqNo * (1000 / frameRate) * 1000000);
* System.out.println("timeStamp is: " + timeStamp); rateChanged2
* ++; } else { timeStamp = (long) (seqNo * (1000 / frameRate) *
* 1000000); System.out.println("timeStamp is: " + timeStamp); }
*/
// buffer.setTimeStamp( (long) (seqNo * (1000 / frameRate) *
// 1000000) );
buffer.setTimeStamp(timeStamp);
// System.out.println("timeStamp is: " + timeStamp);
// System.out.println("framerate is: " + frameRate);
int ww = width;
// ww = ww+1;
// x = x+1;
// y = y+1;
// height = height+1;
// System.out.println("width is: "+width);
BufferedImage bi = robot.createScreenCapture(new Rectangle(x, y,
width, height));
// bi.getRGB(0, 0, width, height,
// (int[])outdata, 0, width);
bi.getRGB(0, 0, width, height, (int[]) outdata, 0, width);
buffer.setSequenceNumber(seqNo);
buffer.setLength(maxDataLength);
buffer.setFlags(Buffer.FLAG_KEY_FRAME);
buffer.setHeader(null);
seqNo++;
}
}