Search in sources :

Example 1 with CaptureScreen

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();
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) CaptureScreen(org.apache.openmeetings.screenshare.CaptureScreen)

Example 2 with CaptureScreen

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);
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) Rectangle(java.awt.Rectangle) VideoData(org.red5.server.net.rtmp.event.VideoData) CaptureScreen(org.apache.openmeetings.screenshare.CaptureScreen) JobExecutionException(org.quartz.JobExecutionException) AWTException(java.awt.AWTException)

Example 3 with CaptureScreen

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);
}
Also used : JobDataMap(org.quartz.JobDataMap) VideoData(org.red5.server.net.rtmp.event.VideoData) CaptureScreen(org.apache.openmeetings.screenshare.CaptureScreen)

Aggregations

CaptureScreen (org.apache.openmeetings.screenshare.CaptureScreen)3 JobDataMap (org.quartz.JobDataMap)3 VideoData (org.red5.server.net.rtmp.event.VideoData)2 AWTException (java.awt.AWTException)1 Rectangle (java.awt.Rectangle)1 JobExecutionException (org.quartz.JobExecutionException)1