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);
}
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);
}
}
}
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;
}
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);
}
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);
}
Aggregations