diff --git a/bbb-video/src/main/java/org/bigbluebutton/app/video/EventRecordingService.java b/bbb-video/src/main/java/org/bigbluebutton/app/video/EventRecordingService.java index ff9f49ecf47cb10a420799b5510b1422a6b629f1..4bdec5c1df4e6b7f547df283519762cddc6c5006 100755 --- a/bbb-video/src/main/java/org/bigbluebutton/app/video/EventRecordingService.java +++ b/bbb-video/src/main/java/org/bigbluebutton/app/video/EventRecordingService.java @@ -18,14 +18,20 @@ */ package org.bigbluebutton.app.video; - import java.util.Map; - +import org.apache.commons.pool2.impl.GenericObjectPoolConfig; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.Protocol; public class EventRecordingService { + private static Logger log = Red5LoggerFactory.getLogger(EventRecordingService.class, "video"); + private static final String COLON = ":"; - + + private JedisPool redisPool; private final String host; private final int port; private final int keyExpiry; @@ -36,19 +42,37 @@ public class EventRecordingService { this.keyExpiry = keyExpiry; } - public void record(String meetingId, Map<String, String> event) { - Jedis jedis = new Jedis(host, port); - Long msgid = jedis.incr("global:nextRecordedMsgId"); - String key = "recording:" + meetingId + COLON + msgid; - jedis.hmset(key, event); - /** - * We set the key to expire after 14 days as we are still - * recording the event into redis even if the meeting is not - * recorded. (ralam sept 23, 2015) - */ - jedis.expire(key, keyExpiry); - key = "meeting:" + meetingId + COLON + "recordings"; - jedis.rpush(key, msgid.toString()); - jedis.expire(key, keyExpiry); + public void record(String meetingId, Map<String, String> event) { + Jedis jedis = redisPool.getResource(); + try { + Long msgid = jedis.incr("global:nextRecordedMsgId"); + String key = "recording:" + meetingId + COLON + msgid; + jedis.hmset(key, event); + /** + * We set the key to expire after 14 days as we are still + * recording the event into redis even if the meeting is not + * recorded. (ralam sept 23, 2015) + */ + jedis.expire(key, keyExpiry); + key = "meeting:" + meetingId + COLON + "recordings"; + jedis.rpush(key, msgid.toString()); + jedis.expire(key, keyExpiry); + } catch (Exception e) { + log.warn("Cannot record the info meeting:" + meetingId, e); + } finally { + jedis.close(); + } + + } + + public void stop() { + + } + + public void start() { + // Set the name of this client to be able to distinguish when doing + // CLIENT LIST on redis-cli + redisPool = new JedisPool(new GenericObjectPoolConfig(), host, port, Protocol.DEFAULT_TIMEOUT, null, + Protocol.DEFAULT_DATABASE, "BbbRed5AppsPub"); } } diff --git a/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoStream.java b/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoStream.java index 8381fd4f413b9756477e2a971e1450c661028d1a..df6eab7ea0afd9396478bc9315963b8a9de0607d 100755 --- a/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoStream.java +++ b/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoStream.java @@ -44,6 +44,7 @@ public class VideoStream { public synchronized void stopRecording() { if (cstream.isRecording()) { + log.info("***** Stopping recording"); cstream.stopRecording(); videoStreamListener.stopRecording(); videoStreamListener.reset(); diff --git a/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoStreamListener.java b/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoStreamListener.java index a79135aee2c9a0301134e2bb2a86e5e71922ff67..2dec365053862572fcf16d78fca2c485c5ac0946 100755 --- a/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoStreamListener.java +++ b/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoStreamListener.java @@ -127,6 +127,7 @@ public class VideoStreamListener implements IStreamListener { packetCount++; if (!firstPacketReceived) { + log.info("******* Receiving first video packet"); firstPacketReceived = true; publishing = true; firstPacketTime = lastVideoTime; @@ -142,7 +143,7 @@ public class VideoStreamListener implements IStreamListener { event.put("meetingId", meetingId); event.put("stream", streamId); event.put("eventName", "StartWebcamShareEvent"); - + log.info("******* StartWebcamShareEvent " + streamId); recordingService.record(meetingId, event); } } @@ -181,6 +182,8 @@ public class VideoStreamListener implements IStreamListener { event.put("stream", streamId); event.put("duration", new Long(publishDuration).toString()); event.put("eventName", "StopWebcamShareEvent"); + + log.info("******* StopWebcamShareEvent " + streamId); recordingService.record(meetingId, event); } } diff --git a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessagePublisher.java b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessagePublisher.java index 2ad2ecd9988ab4bc2ac0074ff39c4f53d27ef8b2..05483e7c10302f3acbd2ff2fef78ce2ebc15f07e 100755 --- a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessagePublisher.java +++ b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessagePublisher.java @@ -1,8 +1,8 @@ package org.bigbluebutton.red5.pubsub; -import org.bigbluebutton.common.messages.MessagingConstants; -import org.bigbluebutton.common.messages.UserSharedWebcamMessage; -import org.bigbluebutton.common.messages.UserUnshareWebcamRequestMessage; + +//import org.bigbluebutton.common.messages.UserSharedWebcamMessage; +//import org.bigbluebutton.common.messages.UserUnshareWebcamRequestMessage; import java.util.HashMap; import java.util.Map; import com.google.gson.Gson; @@ -49,7 +49,8 @@ public class MessagePublisher { sender.send("to-akka-apps-redis-channel", json); } - // Polling + // Polling + /* public void userSharedWebcamMessage(String meetingId, String userId, String streamId) { UserSharedWebcamMessage msg = new UserSharedWebcamMessage(meetingId, userId, streamId); sender.send(MessagingConstants.TO_USERS_CHANNEL, msg.toJson()); @@ -59,6 +60,7 @@ public class MessagePublisher { UserUnshareWebcamRequestMessage msg = new UserUnshareWebcamRequestMessage(meetingId, userId, streamId); sender.send(MessagingConstants.TO_USERS_CHANNEL, msg.toJson()); } + */ public void startRotateLeftTranscoderRequest(String meetingId, String transcoderId, String streamName, String ipAddress) { Map<String, String> params = new HashMap<String, String>(); @@ -146,4 +148,4 @@ public class MessagePublisher { header.put(Constants.MEETING_ID, meetingId); return header; } -} \ No newline at end of file +} diff --git a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessagingConstants.java b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessagingConstants.java new file mode 100755 index 0000000000000000000000000000000000000000..381f800f2a0cd70a9ed183aa483dcc36154184e8 --- /dev/null +++ b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessagingConstants.java @@ -0,0 +1,81 @@ +/** + * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ + * + * Copyright (c) 2014 BigBlueButton Inc. and by respective authors (see below). + * + * This program is free software; you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3.0 of the License, or (at your option) any later + * version. + * + * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. + * + */ + +package org.bigbluebutton.red5.pubsub; + +public class MessagingConstants { + + public static final String FROM_BBB_APPS_CHANNEL = "bigbluebutton:from-bbb-apps"; + public static final String FROM_BBB_APPS_PATTERN = FROM_BBB_APPS_CHANNEL + ":*"; + public static final String FROM_SYSTEM_CHANNEL = FROM_BBB_APPS_CHANNEL + ":system"; + public static final String FROM_MEETING_CHANNEL = FROM_BBB_APPS_CHANNEL + ":meeting"; + public static final String FROM_PRESENTATION_CHANNEL = FROM_BBB_APPS_CHANNEL + ":presentation"; + public static final String FROM_POLLING_CHANNEL = FROM_BBB_APPS_CHANNEL + ":polling"; + public static final String FROM_USERS_CHANNEL = FROM_BBB_APPS_CHANNEL + ":users"; + public static final String FROM_WHITEBOARD_CHANNEL = FROM_BBB_APPS_CHANNEL + ":whiteboard"; + public static final String FROM_DESK_SHARE_CHANNEL = FROM_BBB_APPS_CHANNEL + ":deskshare"; + + public static final String TO_BBB_APPS_CHANNEL = "bigbluebutton:to-bbb-apps"; + public static final String TO_BBB_APPS_PATTERN = TO_BBB_APPS_CHANNEL + ":*"; + public static final String TO_MEETING_CHANNEL = TO_BBB_APPS_CHANNEL + ":meeting"; + public static final String TO_SYSTEM_CHANNEL = TO_BBB_APPS_CHANNEL + ":system"; + public static final String TO_PRESENTATION_CHANNEL = TO_BBB_APPS_CHANNEL + ":presentation"; + public static final String TO_POLLING_CHANNEL = TO_BBB_APPS_CHANNEL + ":polling"; + public static final String TO_USERS_CHANNEL = TO_BBB_APPS_CHANNEL + ":users"; + public static final String TO_VOICE_CHANNEL = TO_BBB_APPS_CHANNEL + ":voice"; + public static final String TO_WHITEBOARD_CHANNEL = TO_BBB_APPS_CHANNEL + ":whiteboard"; + + public static final String BBB_APPS_KEEP_ALIVE_CHANNEL = "bigbluebutton:from-bbb-apps:keepalive"; + + public static final String TO_BBB_HTML5_CHANNEL = "bigbluebutton:to-bbb-html5"; + + public static final String TO_VOICE_CONF_CHANNEL = "bigbluebutton:to-voice-conf"; + public static final String TO_VOICE_CONF_PATTERN = TO_VOICE_CONF_CHANNEL + ":*"; + public static final String TO_VOICE_CONF_SYSTEM_CHAN = TO_VOICE_CONF_CHANNEL + ":system"; + public static final String FROM_VOICE_CONF_CHANNEL = "bigbluebutton:from-voice-conf"; + public static final String FROM_VOICE_CONF_PATTERN = FROM_VOICE_CONF_CHANNEL + ":*"; + public static final String FROM_VOICE_CONF_SYSTEM_CHAN = FROM_VOICE_CONF_CHANNEL + ":system"; + + public static final String FROM_BBB_RECORDING_CHANNEL = "bigbluebutton:from-rap"; + + public static final String TO_BBB_TRANSCODE_CHANNEL = "bigbluebutton:to-bbb-transcode"; + public static final String TO_BBB_TRANSCODE_PATTERN = TO_BBB_TRANSCODE_CHANNEL + ":*"; + public static final String TO_BBB_TRANSCODE_SYSTEM_CHAN = TO_BBB_TRANSCODE_CHANNEL + ":system"; + public static final String FROM_BBB_TRANSCODE_CHANNEL = "bigbluebutton:from-bbb-transcode"; + public static final String FROM_BBB_TRANSCODE_PATTERN = FROM_BBB_TRANSCODE_CHANNEL + ":*"; + public static final String FROM_BBB_TRANSCODE_SYSTEM_CHAN = FROM_BBB_TRANSCODE_CHANNEL + ":system"; + + + public static final String DESTROY_MEETING_REQUEST_EVENT = "DestroyMeetingRequestEvent"; + public static final String CREATE_MEETING_REQUEST_EVENT = "CreateMeetingRequestEvent"; + public static final String END_MEETING_REQUEST_EVENT = "EndMeetingRequestEvent"; + public static final String MEETING_STARTED_EVENT = "meeting_created_message"; + public static final String MEETING_ENDED_EVENT = "meeting_ended_event"; + public static final String MEETING_DESTROYED_EVENT = "meeting_destroyed_event"; + public static final String USER_JOINED_EVENT = "UserJoinedEvent"; + public static final String USER_LEFT_EVENT = "UserLeftEvent"; + public static final String USER_LEFT_VOICE_REQUEST = "user_left_voice_request"; + public static final String USER_STATUS_CHANGE_EVENT = "UserStatusChangeEvent"; + public static final String USER_ROLE_CHANGE_EVENT = "UserRoleChangeEvent"; + public static final String SEND_POLLS_EVENT = "SendPollsEvent"; + public static final String RECORD_STATUS_EVENT = "RecordStatusEvent"; + public static final String SEND_PUBLIC_CHAT_MESSAGE_REQUEST = "send_public_chat_message_request"; + public static final String SEND_PRIVATE_CHAT_MESSAGE_REQUEST = "send_private_chat_message_request"; + public static final String MUTE_USER_REQUEST = "mute_user_request"; +} diff --git a/bbb-video/src/main/webapp/WEB-INF/red5-web.xml b/bbb-video/src/main/webapp/WEB-INF/red5-web.xml index 99342ccabc69412ba0debecb8fa262a60287c2e2..0e7430097483cd76e851b6ea5e15d0e0cda5e2b9 100755 --- a/bbb-video/src/main/webapp/WEB-INF/red5-web.xml +++ b/bbb-video/src/main/webapp/WEB-INF/red5-web.xml @@ -62,7 +62,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. <property name="messageSender" ref="redisSender"/> </bean> - <bean id="redisRecorder" class="org.bigbluebutton.app.video.EventRecordingService"> + <bean id="redisRecorder" class="org.bigbluebutton.app.video.EventRecordingService" + init-method="start" destroy-method="stop"> <constructor-arg index="0" value="${redis.host}"/> <constructor-arg index="1" value="${redis.port}"/> <constructor-arg index="2" value="${redis.keyExpiry}"/>