Fixed bug that Listen only mode didn't work if the user didn't have a microphone connected. The problem was an unchecked null reference on microphone. fixes #765

This commit is contained in:
Hugo Lazzari 2013-05-16 13:59:02 -03:00
parent 98f8b9be4f
commit 87093309f3
4 changed files with 112 additions and 57 deletions

View File

@ -133,6 +133,7 @@ bbb.toolbar.phone.toolTip.start = Share My Microphone
bbb.toolbar.phone.toolTip.stop = Stop Sharing My Microphone
bbb.toolbar.phone.toolTip.mute = Stop Listening Voice Conference
bbb.toolbar.phone.toolTip.unmute = Start Listening Voice Conference
bbb.toolbar.phone.toolTip.nomic = You don't have a Microphone
bbb.toolbar.deskshare.toolTip.start = Share My Desktop
bbb.toolbar.deskshare.toolTip.stop = Stop Sharing My Desktop
bbb.toolbar.video.toolTip.start = Share My Camera

View File

@ -18,18 +18,18 @@
*/
package org.bigbluebutton.modules.phone.managers {
import com.asfusion.mate.events.Dispatcher;
import flash.events.ActivityEvent;
import flash.events.AsyncErrorEvent;
import flash.events.IEventDispatcher;
import flash.events.NetStatusEvent;
import flash.events.StatusEvent;
import flash.media.Microphone;
import flash.media.MicrophoneEnhancedMode;
import flash.media.MicrophoneEnhancedOptions;
import flash.media.SoundCodec;
import flash.net.NetConnection;
import flash.net.NetStream;
import com.asfusion.mate.events.Dispatcher;
import flash.events.ActivityEvent;
import flash.events.AsyncErrorEvent;
import flash.events.IEventDispatcher;
import flash.events.NetStatusEvent;
import flash.events.StatusEvent;
import flash.media.Microphone;
import flash.media.MicrophoneEnhancedMode;
import flash.media.MicrophoneEnhancedOptions;
import flash.media.SoundCodec;
import flash.net.NetConnection;
import flash.net.NetStream;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.core.BBB;
import org.bigbluebutton.main.events.BBBEvent;
@ -45,8 +45,8 @@ package org.bigbluebutton.modules.phone.managers {
private var mic:Microphone = null;
private var isCallConnected:Boolean = false;
private var muted:Boolean = false;
private var audioCodec:String = "SPEEX";
private var dispatcher:Dispatcher;
private var audioCodec:String = "SPEEX";
private var dispatcher:Dispatcher;
private var listeningOnGlobal:Boolean;
private var savedAudio:Boolean = false;
@ -78,31 +78,34 @@ package org.bigbluebutton.modules.phone.managers {
if ((BBB.getFlashPlayerVersion() >= 10.3) && (phoneOptions.enabledEchoCancel)) {
LogUtil.debug("Using acoustic echo cancellation.");
mic = Microphone(Microphone["getEnhancedMicrophone"]());
var options:MicrophoneEnhancedOptions = new MicrophoneEnhancedOptions();
options.mode = MicrophoneEnhancedMode.FULL_DUPLEX;
options.autoGain = false;
options.echoPath = 128;
options.nonLinearProcessing = true;
mic['enhancedOptions'] = options;
if(mic != null) {
var options:MicrophoneEnhancedOptions = new MicrophoneEnhancedOptions();
options.mode = MicrophoneEnhancedMode.FULL_DUPLEX;
options.autoGain = false;
options.echoPath = 128;
options.nonLinearProcessing = true;
mic['enhancedOptions'] = options;
}
} else {
}
mic.setUseEchoSuppression(true);
mic.setLoopBack(false);
mic.setSilenceLevel(0,20000);
if (audioCodec == "SPEEX") {
mic.encodeQuality = 6;
mic.codec = SoundCodec.SPEEX;
mic.framesPerPacket = 1;
mic.rate = 16;
LogUtil.debug("Using SPEEX whideband codec.");
} else {
mic.codec = SoundCodec.NELLYMOSER;
mic.rate = 8;
LogUtil.debug("Using Nellymoser codec.");
}
mic.gain = 60;
if(mic != null) {
mic.setUseEchoSuppression(true);
mic.setLoopBack(false);
mic.setSilenceLevel(0,20000);
if (audioCodec == "SPEEX") {
mic.encodeQuality = 6;
mic.codec = SoundCodec.SPEEX;
mic.framesPerPacket = 1;
mic.rate = 16;
LogUtil.debug("Using SPEEX whideband codec.");
} else {
mic.codec = SoundCodec.NELLYMOSER;
mic.rate = 8;
LogUtil.debug("Using Nellymoser codec.");
}
mic.gain = 60;
}
}
public function initWithNoMicrophone(): void {
@ -295,4 +298,4 @@ package org.bigbluebutton.modules.phone.managers {
LogUtil.debug("Recieve ON METADATA from SIP");
}
}
}
}

View File

@ -27,6 +27,7 @@ package org.bigbluebutton.modules.phone.maps
import org.bigbluebutton.modules.phone.PhoneOptions;
import org.bigbluebutton.modules.phone.views.components.ToolbarButton;
import org.bigbluebutton.modules.phone.views.components.MuteButton;
public class PhoneEventMapDelegate {
private var phoneOptions:PhoneOptions;
private var phoneButton:ToolbarButton;
@ -49,7 +50,9 @@ package org.bigbluebutton.modules.phone.maps
public function addToolbarButton():void {
phoneButton.toggle = true;
if(phoneButton.noMicrophone())
phoneButton.disableButton();
if (phoneOptions.showButton) {
// Use the GLobal Dispatcher so that this message will be heard by the
// main application.
@ -62,6 +65,9 @@ package org.bigbluebutton.modules.phone.maps
var event2:ToolbarButtonEvent = new ToolbarButtonEvent(ToolbarButtonEvent.ADD);
event2.button = soundButton;
globalDispatcher.dispatchEvent(event2);
}

View File

@ -54,6 +54,7 @@
public const ACTIVE_STATE:Number = 1;
private var _currentState:Number = DEFAULT_STATE;
private var _changeState:Boolean = false;
private var stopChangingIcon:Boolean = false;
[Bindable] public var phoneIcon:Class = images.headsetDefaultIcon;
@ -86,40 +87,77 @@
}
dispatcher.dispatchEvent(askToChangeEvent);
}
if(stopChangingIcon) {
disableButton();
}
}
private function mouseOverHandler(event:MouseEvent):void {
if(_currentState == ACTIVE_STATE)
phoneIcon = images.headsetInactiveIcon;
else
phoneIcon = images.headsetActiveIcon;
if(stopChangingIcon) {
disableButton();
}
else {
if(stopChangingIcon == false) {
if(_currentState == ACTIVE_STATE)
phoneIcon = images.headsetInactiveIcon;
else
phoneIcon = images.headsetActiveIcon;
}
else {
phoneIcon = images.headsetDefaultIcon;
}
}
}
private function mouseOutHandler(event:MouseEvent):void {
if(_currentState == ACTIVE_STATE)
phoneIcon = images.headsetActiveIcon;
else
phoneIcon = images.headsetDefaultIcon;
if(stopChangingIcon) {
disableButton();
}
else {
if(_currentState == ACTIVE_STATE)
phoneIcon = images.headsetActiveIcon;
else
phoneIcon = images.headsetDefaultIcon;
}
}
public function disableButton():void {
LogUtil.debug("TESTE TESTE DESATIVA DESATIVA");
this.selected = false;
this.enabled = false;
stopChangingIcon = true;
phoneIcon = images.headsetDefaultIcon;
this.toolTip = ResourceUtil.getInstance().getString('bbb.toolbar.phone.toolTip.nomic');
}
public function userJoinedConference(joined: Boolean):void {
if (joined) {
this.selected = true;
this.enabled = true;
_currentState = ACTIVE_STATE;
phoneIcon = images.headsetActiveIcon;
this.toolTip = ResourceUtil.getInstance().getString('bbb.toolbar.phone.toolTip.stop');
if(stopChangingIcon) {
disableButton();
}
else {
this.selected = true;
this.enabled = true;
_currentState = ACTIVE_STATE;
phoneIcon = images.headsetActiveIcon;
this.toolTip = ResourceUtil.getInstance().getString('bbb.toolbar.phone.toolTip.stop');
}
} else {
this.selected = false;
this.enabled = true;
_currentState = DEFAULT_STATE;
phoneIcon = images.headsetDefaultIcon;
this.toolTip = ResourceUtil.getInstance().getString('bbb.toolbar.phone.toolTip.start');
if(stopChangingIcon) {
disableButton();
}
else {
this.selected = false;
this.enabled = true;
_currentState = DEFAULT_STATE;
phoneIcon = images.headsetDefaultIcon;
this.toolTip = ResourceUtil.getInstance().getString('bbb.toolbar.phone.toolTip.start');
}
}
}
private function noMicrophone():Boolean {
public function noMicrophone():Boolean {
return ((Microphone.getMicrophone() == null) || (Microphone.names.length == 0)
|| ((Microphone.names.length == 1) && (Microphone.names[0] == "Unknown Microphone")));
}
@ -130,6 +168,10 @@
_currentState = DEFAULT_STATE;
phoneIcon = images.headsetDefaultIcon;
this.toolTip = ResourceUtil.getInstance().getString('bbb.toolbar.phone.toolTip.start');
if(stopChangingIcon) {
disableButton();
}
}
@ -156,6 +198,9 @@
phoneIcon = images.headsetDefaultIcon;
this.toolTip = ResourceUtil.getInstance().getString('bbb.toolbar.phone.toolTip.start');
}
if(stopChangingIcon) {
disableButton();
}
}
public function getAlignment():String{