Merge remote branch 'mconf/master'

This commit is contained in:
Marco Calderon 2011-03-10 10:03:15 +00:00
commit d225ff4d44
5 changed files with 257 additions and 69 deletions

View File

@ -56,6 +56,7 @@
dependsOn="ViewersModule"
videoQuality="70"
presenterShareOnly="false"
resolutions="160x120,320x240,640x480,1280x720"
/>
<module name="WhiteboardModule" url="WhiteboardModule.swf?v=VERSION"

View File

@ -68,6 +68,10 @@
return Number(_attributes.videoQuality);
}
public function get resolutions():String {
return _attributes.resolutions;
}
public function get presenterShareOnly():Boolean{
if (_attributes.presenterShareOnly == "true") return true;
else return false;

View File

@ -56,6 +56,7 @@
if (userid == module.userid) return;
var window:VideoWindow = new VideoWindow();
window.resolutions = module.resolutions.split(",");
if (mock) {
window.startVideo(module.mockConnection, stream);
@ -64,7 +65,6 @@
window.startVideo(module.connection, stream);
}
window.title = name;
var windowEvent:OpenWindowEvent = new OpenWindowEvent(OpenWindowEvent.OPEN_WINDOW_EVENT);
windowEvent.window = window;
globalDispatcher.dispatchEvent(windowEvent);
@ -91,6 +91,7 @@
publishWindow.streamName = module.userid.toString();
publishWindow.userrole = module.role;
publishWindow.quality = module.quality;
publishWindow.resolutions = module.resolutions.split(",");
var windowEvent:OpenWindowEvent = new OpenWindowEvent(OpenWindowEvent.OPEN_WINDOW_EVENT);
windowEvent.window = publishWindow;

View File

@ -25,10 +25,9 @@
xmlns:pubVid="flexlib.mdi.containers.*"
implements="org.bigbluebutton.common.IBbbModuleWindow"
creationComplete="init()"
width="{camWidth + 6}" height="{camHeight + 73}"
width="{camWidth + 6}" height="{camHeight + 75}"
title="{ResourceUtil.getInstance().getString('bbb.publishVideo.title')}"
backgroundImage="{bbbLogo}"
resizable="false"
xmlns:mate="http://mate.asfusion.com/">
<mx:Script>
@ -39,6 +38,7 @@
import mx.events.ResizeEvent;
import org.bigbluebutton.common.Images;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.main.views.MainCanvas;
import org.bigbluebutton.modules.videoconf.events.CloseAllWindowsEvent;
import org.bigbluebutton.modules.videoconf.events.StartBroadcastEvent;
@ -48,7 +48,7 @@
private var images:Images = new Images();
[Bindable] public var camIcon:Class = images.control_play;
[Bindable] public var bbbLogo:Class = images.bbb_logo;
[Bindable] private var resolutions:Array = new Array("320x240", "640x480");
[Bindable] public var resolutions:Array = new Array("320x240", "640x480");
private var video:Video;
public var streamName:String;
@ -57,14 +57,33 @@
private var _userrole:String;
public var quality:Number = 0;
private var _bResizePossible:Boolean = true;
private var _nAspectRatio:Number = 1;
private var _minWidth:int = 166;
private var _minHeight:int = 149;
private var _nSavedVideoWidth:Number = 0;
private var _nSavedVideoHeight:Number = 0;
private var _nOldWindowWidth:Number = 0;
private var _nOldWindowHeight:Number = 0;
private function init():void{
currentState = "dispVideoOptionsControlBar";
checkIfMacCamera();
if (isPresenter()) showResControls(true);
if (Camera.names.length > 1) showVideoControls(true);
if (!isPresenter() && Camera.names.length == 1) startPublishing();
addEventListener(MDIWindowEvent.RESIZE_END, onResizeEvent);
addEventListener(MDIWindowEvent.RESIZE, onResizeEvent);
addEventListener(MDIWindowEvent.MAXIMIZE, onMaximize);
addEventListener(MDIWindowEvent.RESTORE, onRestore);
this.minWidth = _minWidth;
this.minHeight = _minHeight;
maximizeRestoreBtn.visible = false;
this.resizable = false;
}
public function getPrefferedPosition():String{
@ -85,6 +104,7 @@
//Next two lines may seem redundant but they're not. Do not delete.
video.width = camWidth;
video.height = camHeight;
adjustWindowSize();
video.attachCamera(camera);
videoHolder.addChild(video);
// addChild(videoHolder);
@ -96,6 +116,9 @@
showVideoControls(false);
showResControls(false);
maximizeRestoreBtn.visible = true;
this.resizable = true;
}
override public function close(event:MouseEvent=null):void{
@ -115,13 +138,10 @@
}
private function setResolution():void{
if (cmbResolution.selectedLabel == "320x240"){
camHeight = 240;
camWidth = 320;
} else if (cmbResolution.selectedLabel == "640x480"){
camHeight = 480;
camWidth = 640;
}
var res:Array = cmbResolution.selectedLabel.split( "x" );
camWidth = Number(res[0]);
camHeight = Number(res[1]);
_nAspectRatio = (camWidth/camHeight);
this.streamName = cmbResolution.selectedLabel.concat(this.streamName);
}
@ -144,7 +164,7 @@
videoOptionsBar.visible = true;
btnStartPublish.visible = true;
cmbCameraSelector.visible = false;
currentState = "dispQuitControlBar";
currentState = "dispVideo";
}
}
@ -172,6 +192,98 @@
}
}
private function adjustWindowSize():void{
videoHolder.width = video.width;
videoHolder.height = video.height;
this.width = video.width + 6;
this.height = video.height + 29;
// prevent to show a video window bigger than the parent window
if (this.width > this.parent.width) {
video.width = this.parent.width - 6;
video.height = Math.floor(video.width / _nAspectRatio);
adjustWindowSize();
}
if (this.height > this.parent.height) {
video.height = this.parent.height - 29;
video.width = Math.floor(video.height * _nAspectRatio);
adjustWindowSize();
}
if (this.width < _minWidth) {
video.width = _minWidth - 6;
video.height = Math.floor(video.width / _nAspectRatio);
adjustWindowSize();
}
if (this.height < _minHeight) {
video.height = _minHeight - 29;
video.width = Math.floor(video.height * _nAspectRatio);
adjustWindowSize();
}
}
public function onResizeEvent(event:MDIWindowEvent):void {
if (event.type == MDIWindowEvent.RESIZE) {
// test if we are already resizing
if (_bResizePossible) {
_bResizePossible = false;
resizeWindow();
_bResizePossible = true;
}
} else if (event.type == MDIWindowEvent.RESIZE_END) {
adjustWindowSize();
}
}
private function resizeWindow():void {
// prevent the window for blinking
if (this.width == _nOldWindowWidth && this.height == _nOldWindowHeight) {
adjustWindowSize();
return;
}
_nOldWindowWidth = this.width;
_nOldWindowHeight = this.height;
if (this.width == video.width + 6) {
// if it's a vertical resizing
video.height = this.height - 29;
video.width = video.height * _nAspectRatio;
} else {
// if it's a horizontal resizing
video.width = this.width - 6;
video.height = Math.floor (video.width / _nAspectRatio);
}
adjustWindowSize();
}
public function onMaximize(event:MDIWindowEvent):void {
_nSavedVideoWidth = video.width;
_nSavedVideoHeight = video.height;
var tmpWidth:Number = this.parent.width - 6;
var tmpHeight:Number = this.parent.height - 29;
if (tmpWidth > tmpHeight * _nAspectRatio)
tmpWidth = tmpHeight * _nAspectRatio;
if (tmpHeight > Math.floor(tmpWidth / _nAspectRatio))
tmpHeight = Math.floor(tmpWidth / _nAspectRatio);
video.width = tmpWidth;
video.height = tmpHeight;
video.x = Math.floor ((this.parent.width - 6 - video.width) / 2);
video.y = Math.floor ((this.parent.height - 29 - video.height) / 2);
}
public function onRestore(event:MDIWindowEvent):void {
video.x = 0;
video.y = 0;
video.width = _nSavedVideoWidth;
video.height = _nSavedVideoHeight;
adjustWindowSize();
}
override protected function resourcesChanged():void{
super.resourcesChanged();
this.title = ResourceUtil.getInstance().getString('bbb.publishVideo.title');
@ -182,7 +294,9 @@
<pubVid:states>
<!--http://stackoverflow.com/questions/369120/why-does-mxstates-have-trouble-being-resolved-to-a-component-implementation-->
<mx:State name="dispQuitControlBar">
<mx:State name="dispVideo">
</mx:State>
<!--mx:State name="dispQuitControlBar">
<mx:AddChild>
<mx:ControlBar id="quitOptionsBar">
<mx:Spacer width="50%"/>
@ -190,7 +304,7 @@
<mx:Spacer width="50%"/>
</mx:ControlBar>
</mx:AddChild>
</mx:State>
</mx:State-->
<mx:State name="dispVideoOptionsControlBar">
<mx:AddChild>
<mx:ControlBar id="videoOptionsBar">

View File

@ -24,7 +24,7 @@
xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="init()"
implements="org.bigbluebutton.common.IBbbModuleWindow"
resizable="true" xmlns:mate="http://mate.asfusion.com/">
xmlns:mate="http://mate.asfusion.com/">
<mx:Script>
<![CDATA[
@ -40,6 +40,8 @@
import org.bigbluebutton.main.views.MainCanvas;
import org.bigbluebutton.modules.videoconf.events.CloseAllWindowsEvent;
public var resolutions:Array = new Array("320x240", "640x480");
private var video:Video;
private var ns:NetStream;
private var videoHolder:UIComponent;
@ -47,12 +49,16 @@
private var videoHeight:Number;
private var videoWidth:Number;
private var _maxWidth:int = 800;
private var _maxHeight:int = 800;
private var _minWidth:int = 60;
private var _minHeight:int = 60;
private var _bResizePossible:Boolean = true;
private var _nAspectRatio:Number = 1;
private var _minWidth:int = 166;
private var _minHeight:int = 149;
private var _nSavedVideoWidth:Number = 0;
private var _nSavedVideoHeight:Number = 0;
private var _nOldWindowWidth:Number = 0;
private var _nOldWindowHeight:Number = 0;
private var _xPosition:int;
private var _yPosition:int;
@ -63,12 +69,19 @@
videoHolder = new UIComponent();
videoHolder.addChild(video);
this.addChild(videoHolder);
maximizeRestoreBtn.visible = false;
addEventListener(MDIWindowEvent.RESIZE_END, onResizeEndEvent);
addEventListener(MDIWindowEvent.RESIZE_END, onResizeEvent);
addEventListener(MDIWindowEvent.RESIZE, onResizeEvent);
addEventListener(MDIWindowEvent.MAXIMIZE, onMaximize);
addEventListener(MDIWindowEvent.RESTORE, onRestore);
addEventListener(MDIWindowEvent.CLOSE, onCloseEvent);
globalDispatcher = new Dispatcher();
this.minWidth = _minWidth;
this.minHeight = _minHeight;
maximizeRestoreBtn.visible = true;
this.resizable = true;
}
private function onCloseEvent(event:MDIWindowEvent = null):void {
@ -93,36 +106,35 @@
video.height = this.height;
video.attachNetStream(ns);
ns.play(stream);
this.stream = stream;
this.width = video.width + 6;
this.height = video.height + 29;
this.stream = stream;
}
private function setVideoResolution(stream:String):void{
var resString:String = stream.substr(0, 7);
switch(resString){
case "320x240":
this.width = 320;
this.height = 240;
_nAspectRatio = (this.width/this.height)
break;
case "640x480":
this.width = 640;
this.height = 480;
for each (var resStr:String in resolutions){
LogUtil.debug("VideoWindow::setVideoResolution testing " + resStr);
if (resStr == stream.substr(0, resStr.length)) {
var res:Array = resStr.split( "x" );
this.width = Number(res[0]);
this.height = Number(res[1]);
LogUtil.debug("VideoWindow::setVideoResolution width=" + this.width + " height=" + this.height);
_nAspectRatio = (this.width/this.height);
break;
}
}
}
private function onAsyncError(e:AsyncErrorEvent):void{
LogUtil.debug("VIdeoWindow::asyncerror " + e.toString());
LogUtil.debug("VideoWindow::asyncerror " + e.toString());
}
public function onMetaData(info:Object):void{
LogUtil.debug("metadata: width=" + info.width + " height=" + info.height);
videoHolder.width = info.width;
videoHolder.height = info.height;
video.width = info.width;
video.height = info.height;
adjustWindowSize();
}
public function getPrefferedPosition():String{
@ -154,43 +166,99 @@
this.close();
}
public function onResizeEndEvent(event:MDIWindowEvent):void {
// make sure the height of the window is correct
if ( video.height + 29 > this.height) {
this.height = video.height + 29;
}
}
public function onResizeEvent(event:Event):void {
// test if we are already resizing
if (_bResizePossible) {
_bResizePossible = false;
resizeWindow();
_bResizePossible = true;
}
}
private function resizeWindow():void {
if (this.width > _maxWidth) {
this.width = _maxWidth;
}
if (this.height > _maxHeight) {
this.height = _maxHeight;
}
if (this.height < _minHeight) {
this.height = _minHeight;
}
if (this.width < _minWidth) {
this.width = _minWidth;
}
// recalc size of video based on the width and height of the window
video.width = this.width - 6;
// make sure the video has a correct aspectratio to avoid tall or flat faces
video.height = Math.floor (video.width / _nAspectRatio);
private function adjustWindowSize():void{
videoHolder.width = video.width;
videoHolder.height = video.height;
this.width = video.width + 6;
this.height = video.height + 29;
// prevent to show a video window bigger than the parent window
if (this.width > this.parent.width) {
video.width = this.parent.width - 6;
video.height = Math.floor(video.width / _nAspectRatio);
adjustWindowSize();
}
if (this.height > this.parent.height) {
video.height = this.parent.height - 29;
video.width = Math.floor(video.height * _nAspectRatio);
adjustWindowSize();
}
if (this.width < _minWidth) {
video.width = _minWidth - 6;
video.height = Math.floor(video.width / _nAspectRatio);
adjustWindowSize();
}
if (this.height < _minHeight) {
video.height = _minHeight - 29;
video.width = Math.floor(video.height * _nAspectRatio);
adjustWindowSize();
}
}
public function onResizeEvent(event:MDIWindowEvent):void {
if (event.type == MDIWindowEvent.RESIZE) {
// test if we are already resizing
if (_bResizePossible) {
_bResizePossible = false;
resizeWindow();
_bResizePossible = true;
}
} else if (event.type == MDIWindowEvent.RESIZE_END) {
adjustWindowSize();
}
}
private function resizeWindow():void {
// prevent the window for blinking
if (this.width == _nOldWindowWidth && this.height == _nOldWindowHeight) {
adjustWindowSize();
return;
}
_nOldWindowWidth = this.width;
_nOldWindowHeight = this.height;
if (this.width == video.width + 6) {
// if it's a vertical resizing
video.height = this.height - 29;
video.width = video.height * _nAspectRatio;
} else {
// if it's a horizontal resizing
video.width = this.width - 6;
video.height = Math.floor (video.width / _nAspectRatio);
}
adjustWindowSize();
}
public function onMaximize(event:MDIWindowEvent):void {
_nSavedVideoWidth = video.width;
_nSavedVideoHeight = video.height;
var tmpWidth:Number = this.parent.width - 6;
var tmpHeight:Number = this.parent.height - 29;
if (tmpWidth > tmpHeight * _nAspectRatio)
tmpWidth = tmpHeight * _nAspectRatio;
if (tmpHeight > Math.floor(tmpWidth / _nAspectRatio))
tmpHeight = Math.floor(tmpWidth / _nAspectRatio);
video.width = tmpWidth;
video.height = tmpHeight;
video.x = Math.floor ((this.parent.width - 6 - video.width) / 2);
video.y = Math.floor ((this.parent.height - 29 - video.height) / 2);
}
public function onRestore(event:MDIWindowEvent):void {
video.x = 0;
video.y = 0;
video.width = _nSavedVideoWidth;
video.height = _nSavedVideoHeight;
adjustWindowSize();
}
]]>
</mx:Script>