Search in sources :

Example 6 with IoBuffer

use of org.apache.mina.core.buffer.IoBuffer in project bigbluebutton by bigbluebutton.

the class FileRecorder method start.

public void start() {
    try {
        fo = new FileOutputStream(flvFilename);
        fo.write(svf.encodeHeader());
    } catch (FileNotFoundException e1) {
        log.error(StackTraceUtil.getStackTrace(e1));
        RecordErrorEvent event = new RecordErrorEvent(session);
        event.setReason("Failed to create recording output.");
        listeners.notifyListeners(event);
    } catch (IOException e) {
        log.error(StackTraceUtil.getStackTrace(e));
        RecordErrorEvent event = new RecordErrorEvent(session);
        event.setReason("Cannot record to recording output.");
        listeners.notifyListeners(event);
    }
    sendCapturedScreen = true;
    log.info("Starting stream");
    capturedScreenSender = new Runnable() {

        public void run() {
            while (sendCapturedScreen) {
                try {
                    IoBuffer frame = screenQueue.take();
                    recordFrameToFile(frame);
                } catch (InterruptedException e) {
                    log.error("InterruptedExeption while taking event.");
                    RecordErrorEvent event = new RecordErrorEvent(session);
                    event.setReason("Cannot record to recording output.");
                    listeners.notifyListeners(event);
                }
            }
        }
    };
    exec.execute(capturedScreenSender);
    RecordStartedEvent event = new RecordStartedEvent(session);
    event.setFile(flvFilename);
    listeners.notifyListeners(event);
}
Also used : RecordStartedEvent(org.bigbluebutton.deskshare.server.recorder.event.RecordStartedEvent) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) RecordErrorEvent(org.bigbluebutton.deskshare.server.recorder.event.RecordErrorEvent) IOException(java.io.IOException) IoBuffer(org.apache.mina.core.buffer.IoBuffer)

Example 7 with IoBuffer

use of org.apache.mina.core.buffer.IoBuffer in project bigbluebutton by bigbluebutton.

the class ScreenshareStreamListener method packetReceived.

@Override
public void packetReceived(IBroadcastStream stream, IStreamPacket packet) {
    IoBuffer buf = packet.getData();
    if (buf != null)
        buf.rewind();
    if (buf == null || buf.remaining() == 0) {
        return;
    }
    if (packet instanceof VideoData) {
        if (!firstPacketReceived) {
            firstPacketReceived = true;
            IConnection conn = Red5.getConnectionLocal();
            String meetingId = conn.getScope().getName();
            String filename = recordingDir;
            if (!filename.endsWith("/")) {
                filename.concat("/");
            }
            filename = filename.concat(meetingId).concat("/").concat(stream.getPublishedName()).concat(".flv");
            Map<String, String> event = new HashMap<String, String>();
            event.put("module", "Deskshare");
            event.put("timestamp", genTimestamp().toString());
            event.put("meetingId", meetingId);
            event.put("file", filename);
            event.put("stream", stream.getPublishedName());
            event.put("eventName", "DeskshareStartedEvent");
            recordingService.record(conn.getScope().getName(), event);
        }
    }
}
Also used : HashMap(java.util.HashMap) VideoData(org.red5.server.net.rtmp.event.VideoData) IConnection(org.red5.server.api.IConnection) IoBuffer(org.apache.mina.core.buffer.IoBuffer)

Example 8 with IoBuffer

use of org.apache.mina.core.buffer.IoBuffer in project bigbluebutton by bigbluebutton.

the class BlockStreamProtocolDecoder method tryToParsePolicyRequest.

private boolean tryToParsePolicyRequest(IoSession session, IoBuffer in, ProtocolDecoderOutput out) {
    byte[] message = new byte[POLICY_REQUEST.length];
    if (in.remaining() >= POLICY_REQUEST.length) {
        in.get(message, 0, message.length);
        if (Arrays.equals(message, POLICY_REQUEST)) {
            log.debug("Sending cross domain policy to the user");
            IoBuffer buffer = IoBuffer.allocate(8);
            buffer.setAutoExpand(true);
            try {
                buffer.putString("<cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"*\" /></cross-domain-policy>", Charset.forName("UTF-8").newEncoder());
                buffer.put((byte) 0);
            } catch (CharacterCodingException e) {
                e.printStackTrace();
                return false;
            }
            buffer.flip();
            session.write(buffer);
            return true;
        }
    }
    return false;
}
Also used : CharacterCodingException(java.nio.charset.CharacterCodingException) IoBuffer(org.apache.mina.core.buffer.IoBuffer)

Example 9 with IoBuffer

use of org.apache.mina.core.buffer.IoBuffer in project streamsx.topology by IBMStreams.

the class TestTupleEncoder method encode.

@Override
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
    TestTuple tuple = (TestTuple) message;
    IoBuffer buffer = IoBuffer.allocate(4 + 4 + tuple.getTupleData().length);
    buffer.putInt(tuple.getTesterId());
    buffer.putInt(tuple.getTupleData().length);
    buffer.put(tuple.getTupleData());
    buffer.flip();
    out.write(buffer);
}
Also used : IoBuffer(org.apache.mina.core.buffer.IoBuffer)

Example 10 with IoBuffer

use of org.apache.mina.core.buffer.IoBuffer in project cxf by apache.

the class IoSessionOutputStream method write.

@Override
public void write(int b) throws IOException {
    IoBuffer buf = IoBuffer.allocate(1);
    buf.put((byte) b);
    buf.flip();
    write(buf);
}
Also used : IoBuffer(org.apache.mina.core.buffer.IoBuffer)

Aggregations

IoBuffer (org.apache.mina.core.buffer.IoBuffer)49 Test (org.junit.Test)8 VideoData (org.red5.server.net.rtmp.event.VideoData)4 UnknownHostException (java.net.UnknownHostException)3 HashMap (java.util.HashMap)3 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)3 AudioData (org.red5.server.net.rtmp.event.AudioData)3 Gson (com.google.gson.Gson)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 ByteBuffer (java.nio.ByteBuffer)2 CharacterCodingException (java.nio.charset.CharacterCodingException)2 Exchange (org.apache.camel.Exchange)2 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)2 DefaultExchange (org.apache.camel.impl.DefaultExchange)2 Message (ca.uhn.hl7v2.model.Message)1 AddressedEnvelope (io.netty.channel.AddressedEnvelope)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)1 DatagramPacket (io.netty.channel.socket.DatagramPacket)1