use of org.red5.server.api.scope.IScope in project bigbluebutton by bigbluebutton.
the class FlashToSipAudioStream method start.
public void start(IBroadcastStream broadcastStream, IScope scope) throws StreamException {
if (log.isDebugEnabled())
log.debug("startTranscodingStream({},{})", broadcastStream.getPublishedName(), scope.getName());
mInputListener = new IStreamListener() {
public void packetReceived(IBroadcastStream broadcastStream, IStreamPacket packet) {
IoBuffer buf = packet.getData();
if (buf != null)
buf.rewind();
if (buf == null || buf.remaining() == 0) {
log.debug("skipping empty packet with no data");
return;
}
if (packet instanceof AudioData) {
byte[] data = SerializeUtils.ByteBufferToByteArray(buf);
// Remove the first byte as it is the codec id.
transcoder.handlePacket(data, 1, data.length - 1);
}
}
};
broadcastStream.addStreamListener(mInputListener);
rtpSender = new RtpStreamSender(srcSocket, connInfo);
rtpSender.connect();
transcoder.start();
}
use of org.red5.server.api.scope.IScope in project bigbluebutton by bigbluebutton.
the class ConnectionInvokerService method sendBroadcastMessage.
private void sendBroadcastMessage(final BroadcastClientMessage msg) {
if (log.isTraceEnabled()) {
Gson gson = new Gson();
String json = gson.toJson(msg.getMessage());
log.trace("Handle broadcast message: " + msg.getMessageName() + " msg=" + json);
}
Runnable sender = new Runnable() {
public void run() {
IScope meetingScope = getScope(msg.getMeetingID());
if (meetingScope != null) {
List<Object> params = new ArrayList<Object>();
params.add(msg.getMessageName());
params.add(msg.getMessage());
if (log.isTraceEnabled()) {
Gson gson = new Gson();
String json = gson.toJson(msg.getMessage());
log.trace("Broadcast message: " + msg.getMessageName() + " msg=" + json);
}
ServiceUtils.invokeOnAllScopeConnections(meetingScope, "onMessageFromServer", params.toArray(), null);
}
}
};
/**
* We need to add a way to cancel sending when the thread is blocked.
* Red5 uses a semaphore to guard the rtmp connection and we've seen
* instances where our thread is blocked preventing us from sending messages
* to other connections. (ralam nov 19, 2015)
*/
long endNanos = System.nanoTime() + SEND_TIMEOUT;
Future<?> f = runExec.submit(sender);
try {
// Only wait for the remaining time budget
long timeLeft = endNanos - System.nanoTime();
f.get(timeLeft, TimeUnit.NANOSECONDS);
} catch (ExecutionException e) {
log.warn("ExecutionException while sending broadcast message[" + msg.getMessageName() + "]");
} catch (InterruptedException e) {
log.warn("Interrupted exception while sending broadcast message[" + msg.getMessageName() + "]");
Thread.currentThread().interrupt();
} catch (TimeoutException e) {
log.warn("Timeout exception while sending broadcast message[" + msg.getMessageName() + "]");
f.cancel(true);
}
}
use of org.red5.server.api.scope.IScope in project bigbluebutton by bigbluebutton.
the class ParticipantsService method userEmojiStatus.
public void userEmojiStatus(Map<String, String> msg) {
IScope scope = Red5.getConnectionLocal().getScope();
String meetingId = scope.getName();
String userId = (String) msg.get("userId");
String emojiStatus = (String) msg.get("emojiStatus");
if (StringUtils.isEmpty(emojiStatus)) {
log.warn("Invalid EmojiStatus from client: meetingId=" + meetingId + ", userId=" + userId + ",emoji=" + emojiStatus);
// Set emojiStatus=none if passed is null.
emojiStatus = "none";
}
red5InGW.userEmojiStatus(meetingId, userId, emojiStatus);
}
use of org.red5.server.api.scope.IScope in project bigbluebutton by bigbluebutton.
the class ParticipantsService method ejectUserFromMeeting.
public void ejectUserFromMeeting(Map<String, String> msg) {
IScope scope = Red5.getConnectionLocal().getScope();
String meetingId = scope.getName();
String userId = (String) msg.get("userId");
String ejectedBy = (String) msg.get("ejectedBy");
red5InGW.ejectUserFromMeeting(meetingId, userId, ejectedBy);
}
use of org.red5.server.api.scope.IScope in project bigbluebutton by bigbluebutton.
the class ParticipantsService method shareWebcam.
public void shareWebcam(String stream) {
IScope scope = Red5.getConnectionLocal().getScope();
String meetingId = scope.getName();
String userId = getBbbSession().getInternalUserID();
red5InGW.shareWebcam(meetingId, userId, stream);
}
Aggregations