use of org.apache.openmeetings.screenshare.CaptureScreen in project openmeetings by apache.
the class CursorJob method execute.
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
JobDataMap data = context.getJobDetail().getJobDataMap();
CaptureScreen capture = (CaptureScreen) data.get(CAPTURE_KEY);
if (!capture.getSendFrameGuard()) {
capture.sendCursorStatus();
}
}
use of org.apache.openmeetings.screenshare.CaptureScreen in project openmeetings by apache.
the class EncodeJob method execute.
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
JobDataMap data = context.getJobDetail().getJobDataMap();
CaptureScreen capture = (CaptureScreen) data.get(CAPTURE_KEY);
if (screen == null) {
dim = capture.getDim();
screen = new Rectangle(dim.getSpinnerX(), dim.getSpinnerY(), dim.getSpinnerWidth(), dim.getSpinnerHeight());
}
long start = 0;
if (log.isTraceEnabled()) {
start = System.currentTimeMillis();
}
image = ScreenV1Encoder.getImage(dim, screen, robot);
if (log.isTraceEnabled()) {
log.trace(String.format("encode: Image was captured in %s ms, size %sk", System.currentTimeMillis() - start, 4 * image.length * image[0].length / 1024));
start = System.currentTimeMillis();
}
try {
VideoData vData = capture.getEncoder().encode(image);
if (log.isTraceEnabled()) {
long now = System.currentTimeMillis();
log.trace(String.format("encode: Image was encoded in %s ms, timestamp is %s", now - start, now - capture.getStartTime()));
}
capture.getFrames().offer(vData);
capture.getEncoder().createUnalteredFrame();
} catch (Exception e) {
log.error("Error while encoding: ", e);
}
}
use of org.apache.openmeetings.screenshare.CaptureScreen in project openmeetings by apache.
the class SendJob method execute.
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
JobDataMap data = context.getJobDetail().getJobDataMap();
CaptureScreen capture = (CaptureScreen) data.get(CAPTURE_KEY);
capture.setSendFrameGuard(true);
if (log.isTraceEnabled()) {
long real = System.currentTimeMillis() - capture.getStartTime();
log.trace(String.format("send: Enter method, timestamp: %s, real: %s, diff: %s", capture.getTimestamp(), real, real - capture.getTimestamp().get()));
}
VideoData f = capture.getFrames().poll();
if (log.isTraceEnabled()) {
log.trace(String.format("send: Getting %s image", f == null ? "DUMMY" : "CAPTURED"));
}
f = f == null ? capture.getEncoder().getUnalteredFrame() : f;
if (f != null) {
capture.pushVideo(f, capture.getTimestamp().get());
if (log.isTraceEnabled()) {
long real = System.currentTimeMillis() - capture.getStartTime();
log.trace(String.format("send: Sending video %sk, timestamp: %s, real: %s, diff: %s", f.getData().capacity() / 1024, capture.getTimestamp(), real, real - capture.getTimestamp().get()));
}
capture.getTimestamp().addAndGet(capture.getTimestampDelta());
if (log.isTraceEnabled()) {
log.trace(String.format("send: new timestamp: %s", capture.getTimestamp()));
}
} else if (log.isTraceEnabled()) {
log.trace("send: nothing to send");
}
capture.setSendFrameGuard(false);
}
Aggregations