diff --git a/bigbluebutton-client/resources/prod/lib/3rd-party.js b/bigbluebutton-client/resources/prod/lib/3rd-party.js index 09057acc43c43dbde28d5df80296acbb83d81be1..9d6002af671a7568b62152d36840c9fa12d10cd8 100755 --- a/bigbluebutton-client/resources/prod/lib/3rd-party.js +++ b/bigbluebutton-client/resources/prod/lib/3rd-party.js @@ -1,4 +1,6 @@ +var presenterUserID = ""; + var registerListeners = function() { console.log("Listening for events."); BBB.listen("SwitchedLayoutEvent", function(bbbEvent) { @@ -9,6 +11,50 @@ var registerListeners = function() { }); BBB.listen("SwitchedPresenterEvent", function(bbbEvent) { console.log("Switched Presenter [amIPresenter=" + bbbEvent.amIPresenter + ",role=" + bbbEvent.role + ",newPresenterUserID=" + bbbEvent.newPresenterUserID + "]."); + + presenterUserID = bbbEvent.newPresenterUserID; + + if (bbbEvent.amIPresenter) { + console.log("*** I am presenter. Am I publishing webcam?"); + BBB.listen("AmISharingCamQueryResponse", function(bbbEvent2) { + console.log("AmISharingCamQueryResponse [isPublishing=" + bbbEvent2.isPublishing + ",camIndex=" + bbbEvent2.camIndex + "]"); + }); + BBB.amISharingWebcam(); + BBB.amISharingWebcam(function(bbbEvent3) { + console.log("amISharingWebcam [isPublishing=" + bbbEvent3.isPublishing + + ",camIndex=" + bbbEvent3.camIndex + + ",camWidth=" + bbbEvent3.camWidth + + ",camHeight=" + bbbEvent3.camHeight + + ",camKeyFrameInterval=" + bbbEvent3.camKeyFrameInterval + + ",camModeFps=" + bbbEvent3.camModeFps + + ",camQualityBandwidth=" + bbbEvent3.camQualityBandwidth + + ",camQualityPicture=" + bbbEvent3.camQualityPicture + + "]"); + if (bbbEvent3.isPublishing) { + CAM_PREVIEW.stopPreviewCamera(); + CAM_PREVIEW.previewCamera(bbbEvent3.camIndex, bbbEvent3.camWidth, bbbEvent3.camHeight, bbbEvent3.camKeyFrameInterval, + bbbEvent3.camModeFps, bbbEvent3.camQualityBandwidth, bbbEvent3.camQualityPicture); + } + }); + } else { + console.log("*** I am NOT presenter. Is new presenter publishing webcam?"); + BBB.listen("IsUserPublishingCamResponse", function(bbbEvent4) { + console.log("IsUserPublishingCamResponse [isUserPublishing=" + bbbEvent4.isUserPublishing + + ",uri=" + bbbEvent4.uri + + ",streamName=" + bbbEvent4.streamName + "]"); + }); + BBB.isUserSharingWebcam(bbbEvent.newPresenterUserID); + BBB.isUserSharingWebcam(bbbEvent.newPresenterUserID, function(bbbEvent5) { + console.log("isUserSharingWebcam [isUserPublishing=" + bbbEvent5.isUserPublishing + + ",uri=" + bbbEvent5.uri + + ",streamName=" + bbbEvent5.streamName + "]"); + if (presenterUserID == bbbEvent.userID) { + CAM_VIEW.stopViewWebcamStream(); + CAM_VIEW.viewWebcamStream(bbbEvent.uri, bbbEvent.streamName); + } + }); + CAM_PREVIEW.stopPreviewCamera(); + } }); BBB.listen("UserLeftEvent", function(bbbEvent) { console.log("User [" + bbbEvent.userID + "] has left."); @@ -36,12 +82,18 @@ var registerListeners = function() { }); BBB.listen("CamStreamSharedEvent", function(bbbEvent) { console.log("User CamStreamSharedEvent [" + bbbEvent.uri + "," + bbbEvent.streamName + "]"); - CAM_VIEW.viewWebcamStream(bbbEvent.uri, bbbEvent.streamName); + if (presenterUserID == bbbEvent.userID) { + CAM_VIEW.stopViewWebcamStream(); + CAM_VIEW.viewWebcamStream(bbbEvent.uri, bbbEvent.streamName); + } }); BBB.listen("BroadcastingCameraStartedEvent", function(bbbEvent) { console.log("User BroadcastingCameraStartedEvent [" + bbbEvent.camIndex + "] [" + bbbEvent.camWidth + "]"); - CAM_PREVIEW.previewCamera(bbbEvent.camIndex, bbbEvent.camWidth, bbbEvent.camHeight, bbbEvent.camKeyFrameInterval, - bbbEvent.camModeFps, bbbEvent.camQualityBandwidth, bbbEvent.camQualityPicture); + if (bbbEvent.isPresenter) { + CAM_PREVIEW.stopPreviewCamera(); + CAM_PREVIEW.previewCamera(bbbEvent.camIndex, bbbEvent.camWidth, bbbEvent.camHeight, bbbEvent.camKeyFrameInterval, + bbbEvent.camModeFps, bbbEvent.camQualityBandwidth, bbbEvent.camQualityPicture); + } }); BBB.listen("BroadcastingCameraStoppedEvent", function(bbbEvent) { console.log("User BroadcastingCameraStoppedEvent ]"); @@ -73,7 +125,9 @@ var amIPresenterSync = function() { var getMyUserInfoAsynch = function() { BBB.listen("GetMyUserInfoResponse", function(bbbEvent) { - console.log("User info response [myUserID=" + bbbEvent.myUserID + ",myUsername=" + bbbEvent.myUsername + ",myAvatarURL=" + bbbEvent.myAvatarURL + ",myRole=" + bbbEvent.myRole + ",amIPresenter=" + bbbEvent.amIPresenter + "]."); + console.log("User info response [myUserID=" + bbbEvent.myUserID + + ",myUsername=" + bbbEvent.myUsername + ",myAvatarURL=" + bbbEvent.myAvatarURL + + ",myRole=" + bbbEvent.myRole + ",amIPresenter=" + bbbEvent.amIPresenter + "]."); }); BBB.getMyUserInfo(); @@ -81,7 +135,9 @@ var getMyUserInfoAsynch = function() { var getMyUserInfoSynch = function() { BBB.getMyUserInfo(function(userInfo) { - console.log("User info callback [myUserID=" + userInfo.myUserID + ",myUsername=" + userInfo.myUsername + ",myAvatarURL=" + userInfo.myAvatarURL + ",myRole=" + userInfo.myRole + ",amIPresenter=" + userInfo.amIPresenter + "]."); + console.log("User info callback [myUserID=" + userInfo.myUserID + + ",myUsername=" + userInfo.myUsername + ",myAvatarURL=" + userInfo.myAvatarURL + + ",myRole=" + userInfo.myRole + ",amIPresenter=" + userInfo.amIPresenter + "]."); }); }