From 4eebdf00fa4b0d083faae37cda1d4b7c1e730254 Mon Sep 17 00:00:00 2001 From: Ghazi Triki Date: Wed, 23 May 2018 16:09:15 +0100 Subject: [PATCH] Add a new message RecordAndClearPreviousMarkersCmd. --- ...ordAndClearPreviousMarkersCmdMsgHdlr.scala | 45 +++++++++++++++++++ .../SendRecordingTimerInternalMsgHdlr.scala | 4 +- .../core/apps/users/UsersApp.scala | 1 + .../domain/MeetingInactivityTracker.scala | 35 +++++++-------- .../senders/ReceivedJsonMsgHandlerActor.scala | 13 +++--- .../core/running/MeetingActor.scala | 2 + .../bigbluebutton/core2/AnalyticsActor.scala | 1 + .../bigbluebutton/common2/msgs/UsersMgs.scala | 8 ++++ .../org/bigbluebutton/main/events/BBBEvent.as | 3 +- .../main/model/users/UserService.as | 6 +++ .../main/views/RecordWindow.mxml | 8 +++- .../modules/users/maps/UsersMainEventMap.mxml | 6 ++- .../modules/users/services/MessageSender.as | 21 +++++++++ 13 files changed, 122 insertions(+), 31 deletions(-) create mode 100644 akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RecordAndClearPreviousMarkersCmdMsgHdlr.scala diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RecordAndClearPreviousMarkersCmdMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RecordAndClearPreviousMarkersCmdMsgHdlr.scala new file mode 100644 index 0000000000..7cf88f55ed --- /dev/null +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RecordAndClearPreviousMarkersCmdMsgHdlr.scala @@ -0,0 +1,45 @@ +package org.bigbluebutton.core.apps.users + +import org.bigbluebutton.common2.msgs._ +import org.bigbluebutton.core.domain.MeetingState2x +import org.bigbluebutton.core.running.{ LiveMeeting, OutMsgRouter } +import org.bigbluebutton.core2.MeetingStatus2x +import org.bigbluebutton.core.util.TimeUtil +import org.bigbluebutton.core.bus.BigBlueButtonEvent +import org.bigbluebutton.core.api.SendRecordingTimerInternalMsg + +trait RecordAndClearPreviousMarkersCmdMsgHdlr { + this: UsersApp => + + val liveMeeting: LiveMeeting + val outGW: OutMsgRouter + + def handleRecordAndClearPreviousMarkersCmdMsg(msg: RecordAndClearPreviousMarkersCmdMsg, state: MeetingState2x): MeetingState2x = { + log.info("Set a new recording marker and clear previous ones. meetingId=" + liveMeeting.props.meetingProp.intId + " recording=" + msg.body.recording) + + def buildRecordingStatusChangedEvtMsg(meetingId: String, userId: String, recording: Boolean): BbbCommonEnvCoreMsg = { + val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, meetingId, userId) + val envelope = BbbCoreEnvelope(RecordingStatusChangedEvtMsg.NAME, routing) + val body = RecordingStatusChangedEvtMsgBody(recording, userId) + val header = BbbClientMsgHeader(RecordingStatusChangedEvtMsg.NAME, meetingId, userId) + val event = RecordingStatusChangedEvtMsg(header, body) + + BbbCommonEnvCoreMsg(envelope, event) + } + + // Do not allow stop recording and clear previous markers + if (liveMeeting.props.recordProp.allowStartStopRecording && + MeetingStatus2x.isRecording(liveMeeting.status) != msg.body.recording) { + + MeetingStatus2x.recordingStarted(liveMeeting.status) + + val tracker = state.recordingTracker.resetTimer(TimeUtil.timeNowInMs()) + val event = buildRecordingStatusChangedEvtMsg(liveMeeting.props.meetingProp.intId, msg.body.setBy, msg.body.recording) + outGW.send(event) + + state.update(tracker) + } else { + state + } + } +} \ No newline at end of file diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/SendRecordingTimerInternalMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/SendRecordingTimerInternalMsgHdlr.scala index b4c71c0d72..ec66454710 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/SendRecordingTimerInternalMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/SendRecordingTimerInternalMsgHdlr.scala @@ -14,7 +14,7 @@ trait SendRecordingTimerInternalMsgHdlr { val outGW: OutMsgRouter def handleSendRecordingTimerInternalMsg(msg: SendRecordingTimerInternalMsg, state: MeetingState2x): MeetingState2x = { - def buildUpdateReocrdingTimerEvtMsg(meetingId: String, recordingTime: Long): BbbCommonEnvCoreMsg = { + def buildUpdateRecordingTimerEvtMsg(meetingId: String, recordingTime: Long): BbbCommonEnvCoreMsg = { val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, meetingId, "not-used") val envelope = BbbCoreEnvelope(UpdateRecordingTimerEvtMsg.NAME, routing) val body = UpdateRecordingTimerEvtMsgBody(recordingTime) @@ -33,7 +33,7 @@ trait SendRecordingTimerInternalMsgHdlr { val recordingTime = TimeUtil.millisToSeconds(tracker.recordingDuration()) - val event = buildUpdateReocrdingTimerEvtMsg(liveMeeting.props.meetingProp.intId, recordingTime) + val event = buildUpdateRecordingTimerEvtMsg(liveMeeting.props.meetingProp.intId, recordingTime) outGW.send(event) state.update(tracker) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala index bf532ed983..31210511e5 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala @@ -19,6 +19,7 @@ class UsersApp( with LogoutAndEndMeetingCmdMsgHdlr with MeetingActivityResponseCmdMsgHdlr with SetRecordingStatusCmdMsgHdlr + with RecordAndClearPreviousMarkersCmdMsgHdlr with SendRecordingTimerInternalMsgHdlr with UpdateWebcamsOnlyForModeratorCmdMsgHdlr with GetRecordingStatusReqMsgHdlr diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/domain/MeetingInactivityTracker.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/domain/MeetingInactivityTracker.scala index 820c72672d..6b8530aba4 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/domain/MeetingInactivityTracker.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/domain/MeetingInactivityTracker.scala @@ -1,12 +1,11 @@ package org.bigbluebutton.core.domain case class MeetingInactivityTracker( - val maxInactivityTimeoutInMs: Long, - val warningBeforeMaxInMs: Long, - lastActivityTimestampInMs: Long, - warningSent: Boolean, - warningSentOnTimestampInMs: Long -) { + val maxInactivityTimeoutInMs: Long, + val warningBeforeMaxInMs: Long, + lastActivityTimestampInMs: Long, + warningSent: Boolean, + warningSentOnTimestampInMs: Long) { def setWarningSentAndTimestamp(nowInMs: Long): MeetingInactivityTracker = { copy(warningSent = true, warningSentOnTimestampInMs = nowInMs) } @@ -33,13 +32,12 @@ case class MeetingInactivityTracker( } case class MeetingExpiryTracker( - startedOnInMs: Long, - userHasJoined: Boolean, - lastUserLeftOnInMs: Option[Long], - durationInMs: Long, - meetingExpireIfNoUserJoinedInMs: Long, - meetingExpireWhenLastUserLeftInMs: Long -) { + startedOnInMs: Long, + userHasJoined: Boolean, + lastUserLeftOnInMs: Option[Long], + durationInMs: Long, + meetingExpireIfNoUserJoinedInMs: Long, + meetingExpireWhenLastUserLeftInMs: Long) { def setUserHasJoined(): MeetingExpiryTracker = { if (!userHasJoined) { copy(userHasJoined = true, lastUserLeftOnInMs = None) @@ -92,10 +90,9 @@ case class MeetingExpiryTracker( } case class MeetingRecordingTracker( - startedOnInMs: Long, - previousDurationInMs: Long, - currentDurationInMs: Long -) { + startedOnInMs: Long, + previousDurationInMs: Long, + currentDurationInMs: Long) { def startTimer(nowInMs: Long): MeetingRecordingTracker = { copy(startedOnInMs = nowInMs) @@ -105,8 +102,8 @@ case class MeetingRecordingTracker( copy(currentDurationInMs = 0L, previousDurationInMs = previousDurationInMs + nowInMs - startedOnInMs, startedOnInMs = 0L) } - def stopTimer(nowInMs: Long): MeetingRecordingTracker = { - copy(startedOnInMs = 0L, previousDurationInMs = 0L, currentDurationInMs = 0L) + def resetTimer(nowInMs: Long): MeetingRecordingTracker = { + copy(startedOnInMs = nowInMs, previousDurationInMs = 0L, currentDurationInMs = 0L) } def udpateCurrentDuration(nowInMs: Long): MeetingRecordingTracker = { diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala index 1f17d6504b..e3ba573415 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala @@ -15,12 +15,11 @@ object ReceivedJsonMsgHandlerActor { class ReceivedJsonMsgHandlerActor( val eventBus: BbbMsgRouterEventBus, - val incomingJsonMessageBus: IncomingJsonMessageBus -) - extends Actor with ActorLogging - with SystemConfiguration - with ReceivedJsonMsgDeserializer - with ReceivedMessageRouter { + val incomingJsonMessageBus: IncomingJsonMessageBus) + extends Actor with ActorLogging + with SystemConfiguration + with ReceivedJsonMsgDeserializer + with ReceivedMessageRouter { def receive = { case msg: ReceivedJsonMessage => @@ -238,6 +237,8 @@ class ReceivedJsonMsgHandlerActor( routeGenericMsg[LogoutAndEndMeetingCmdMsg](envelope, jsonNode) case SetRecordingStatusCmdMsg.NAME => routeGenericMsg[SetRecordingStatusCmdMsg](envelope, jsonNode) + case RecordAndClearPreviousMarkersCmdMsg.NAME => + routeGenericMsg[RecordAndClearPreviousMarkersCmdMsg](envelope, jsonNode) case GetRecordingStatusReqMsg.NAME => routeGenericMsg[GetRecordingStatusReqMsg](envelope, jsonNode) case GetScreenshareStatusReqMsg.NAME => diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala index 9ff320978f..47373bba81 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala @@ -208,6 +208,8 @@ class MeetingActor( case m: LogoutAndEndMeetingCmdMsg => usersApp.handleLogoutAndEndMeetingCmdMsg(m, state) case m: SetRecordingStatusCmdMsg => state = usersApp.handleSetRecordingStatusCmdMsg(m, state) + case m: RecordAndClearPreviousMarkersCmdMsg => + state = usersApp.handleRecordAndClearPreviousMarkersCmdMsg(m, state) case m: GetWebcamsOnlyForModeratorReqMsg => usersApp.handleGetWebcamsOnlyForModeratorReqMsg(m) case m: UpdateWebcamsOnlyForModeratorCmdMsg => usersApp.handleUpdateWebcamsOnlyForModeratorCmdMsg(m) case m: GetRecordingStatusReqMsg => usersApp.handleGetRecordingStatusReqMsg(m) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/AnalyticsActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/AnalyticsActor.scala index 3ae329403e..83c6177c4d 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/AnalyticsActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/AnalyticsActor.scala @@ -75,6 +75,7 @@ class AnalyticsActor extends Actor with ActorLogging { case m: StartRecordingVoiceConfSysMsg => logMessage(msg) case m: StopRecordingVoiceConfSysMsg => logMessage(msg) case m: UpdateRecordingTimerEvtMsg => logMessage(msg) + case m: RecordAndClearPreviousMarkersCmdMsg => logMessage(msg) case m: TransferUserToVoiceConfSysMsg => logMessage(msg) case m: UserBroadcastCamStartMsg => logMessage(msg) case m: UserBroadcastCamStopMsg => logMessage(msg) diff --git a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMgs.scala b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMgs.scala index ad96a834a7..83145ca8f2 100755 --- a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMgs.scala +++ b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMgs.scala @@ -92,6 +92,14 @@ object SetRecordingStatusCmdMsg { val NAME = "SetRecordingStatusCmdMsg" } case class SetRecordingStatusCmdMsg(header: BbbClientMsgHeader, body: SetRecordingStatusCmdMsgBody) extends StandardMsg case class SetRecordingStatusCmdMsgBody(recording: Boolean, setBy: String) +/** + * Sent by user to start recording mark and ignore previsous marks + */ +object RecordAndClearPreviousMarkersCmdMsg { val NAME = "RecordAndClearPreviousMarkersCmdMsg" } +case class RecordAndClearPreviousMarkersCmdMsg(header: BbbClientMsgHeader, body: RecordAndClearPreviousMarkersCmdMsgBody) extends StandardMsg +case class RecordAndClearPreviousMarkersCmdMsgBody(recording: Boolean, setBy: String) + + /** * Sent to all users about start recording mark. */ diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/events/BBBEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/events/BBBEvent.as index b78fbd656d..deb0120340 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/events/BBBEvent.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/events/BBBEvent.as @@ -47,7 +47,8 @@ package org.bigbluebutton.main.events { public static const MIC_SETTINGS_CLOSED:String = "MIC_SETTINGS_CLOSED"; public static const CAM_SETTINGS_CLOSED:String = "CAM_SETTINGS_CLOSED"; public static const JOIN_VOICE_FOCUS_HEAD:String = "JOIN_VOICE_FOCUS_HEAD"; - public static const CHANGE_RECORDING_STATUS:String = "CHANGE_RECORDING_STATUS"; + public static const RECORD_AND_CLEAR_PREVIOUS_MARKERS:String = "RECORD_AND_CLEAR_PREVIOUS_MARKERS"; + public static const CHANGE_RECORDING_STATUS:String = "RECORD_AND_CLEAR_PREVIOUS_MARKERS"; public static const CHANGE_WEBCAMS_ONLY_FOR_MODERATOR:String = "CHANGE_WEBCAMS_ONLY_FOR_MODERATOR"; public static const SETTINGS_CONFIRMED:String = "BBB_SETTINGS_CONFIRMED"; diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as index 89275de4ee..9c355030c9 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as @@ -192,6 +192,12 @@ package org.bigbluebutton.main.model.users } } + public function recordAndClearPreviousMarkers(e:BBBEvent):void { + if (this.isModerator() && !e.payload.remote) { + sender.recordAndClearPreviousMarkers(UsersUtil.getMyUserID(), e.payload.recording); + } + } + public function userLoggedIn(e:UsersConnectionEvent):void { LOGGER.debug("In userLoggedIn - reconnecting and allowed to join"); if (reconnecting && ! LiveMeeting.inst().me.waitingForApproval) { diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/RecordWindow.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/RecordWindow.mxml index bc7c1eac20..1dc87112e5 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/RecordWindow.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/RecordWindow.mxml @@ -50,13 +50,17 @@ close(); } - var event:BBBEvent = new BBBEvent(BBBEvent.CHANGE_RECORDING_STATUS); + var event:BBBEvent; + if (_recordingFlag && clearRecordingsChecbox.selected) { + event = new BBBEvent(BBBEvent.RECORD_AND_CLEAR_PREVIOUS_MARKERS); + } else { + event = new BBBEvent(BBBEvent.CHANGE_RECORDING_STATUS); + } event.payload.remote = false; event.payload.recording = _recordingFlag; var d:Dispatcher = new Dispatcher(); d.dispatchEvent(event); - this.enabled = false; LOGGER.debug("Changing record status to {0}", [event.payload.recording]); if (!_recordingFlag && getLayoutOptions().logoutOnStopRecording) { diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml index 3cb98496eb..6a951c1b22 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml @@ -109,7 +109,11 @@ with BigBlueButton; if not, see . - + + + + + diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageSender.as b/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageSender.as index 06f83c9364..20f2e39592 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageSender.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageSender.as @@ -329,6 +329,27 @@ package org.bigbluebutton.modules.users.services ); //_netConnection.call } + public function recordAndClearPreviousMarkers(userID:String, recording:Boolean):void { + var message:Object = { + header: {name: "RecordAndClearPreviousMarkersCmdMsg", meetingId: UsersUtil.getInternalMeetingID(), + userId: UsersUtil.getMyUserID()}, + body: {recording: recording, setBy: userID} + }; + + var _nc:ConnectionManager = BBB.initConnectionManager(); + _nc.sendMessage2x( + function(result:String):void { // On successful result + }, + function(status:String):void { // status - On error occurred + var logData:Object = UsersUtil.initLogData(); + logData.tags = ["apps"]; + logData.logCode = "error_sending_change_recording_status"; + LOGGER.info(JSON.stringify(logData)); + }, + JSON.stringify(message) + ); //_netConnection.call + } + public function muteAllUsers(mute:Boolean):void { var message:Object = { header: {name: "MuteMeetingCmdMsg", meetingId: UsersUtil.getInternalMeetingID(),