Display screensharing for iOS.

This commit is contained in:
Ghazi Triki 2018-06-18 17:52:35 +01:00
parent 09b6e29ac1
commit 9bb392fdd5
4 changed files with 154 additions and 12 deletions

View File

@ -55,9 +55,12 @@ package org.bigbluebutton.air.common.views {
}
public function close():void {
player.removeEventListener(BBBRtmpPlayerEvent.CONNECTED, onConnected);
player.removeEventListener(BBBRtmpPlayerEvent.CONNECTION_FAILED, onConnectionFailed);
player.removeEventListener(BBBRtmpPlayerEvent.DISCONNECTED, onDisconnected);
if (player) {
player.removeEventListener(BBBRtmpPlayerEvent.CONNECTED, onConnected);
player.removeEventListener(BBBRtmpPlayerEvent.CONNECTING, onConnecting);
player.removeEventListener(BBBRtmpPlayerEvent.CONNECTION_FAILED, onConnectionFailed);
player.removeEventListener(BBBRtmpPlayerEvent.DISCONNECTED, onDisconnected);
}
if (getChildAt(0) == image) {
removeChild(image);
}

View File

@ -0,0 +1,120 @@
package org.bigbluebutton.air.screenshare.views {
import flash.display.DisplayObject;
import mx.core.UIComponent;
import spark.components.Image;
import org.bigbluebutton.BBBRtmpPlayer;
import org.bigbluebutton.BBBRtmpPlayerEvent;
// FIXME : Work in progress class, needs behave like Android screensahring display
public class IOSScreenshareView extends UIComponent {
protected var player:BBBRtmpPlayer;
protected var videoComp:DisplayObject;
protected var originalVideoWidth:Number;
protected var originalVideoHeight:Number;
public function resizeForPortrait():void {
// if we have device where screen width less than screen height e.g. phone
if (width < height) {
// make the video width full width of the screen
videoComp.width = width;
// calculate height based on a video width, it order to keep the same aspect ratio
videoComp.height = (videoComp.width / originalVideoWidth) * originalVideoHeight;
// if calculated height appeared to be bigger than screen height, recalculuate the video size based on width
if (height < videoComp.height) {
// make the video height full height of the screen
videoComp.height = height;
// calculate width based on a video height, it order to keep the same aspect ratio
videoComp.width = ((originalVideoWidth * videoComp.height) / originalVideoHeight);
}
} // if we have device where screen height less than screen width e.g. tablet
else {
// make the video height full height of the screen
videoComp.height = height;
// calculate width based on a video height, it order to keep the same aspect ratio
videoComp.width = ((originalVideoWidth * videoComp.height) / originalVideoHeight);
// if calculated width appeared to be bigger than screen width, recalculuate the video size based on height
if (width < videoComp.width) {
// make the video width full width of the screen
videoComp.width = width;
// calculate height based on a video width, it order to keep the same aspect ratio
videoComp.height = (videoComp.width / originalVideoWidth) * originalVideoHeight;
}
}
videoComp.x = width - videoComp.width;
videoComp.y = height - videoComp.height;
}
private function get image():Image {
return videoComp as Image;
}
public function startStream(uri:String, streamName:String, imgWidth:Number, imgHeight:Number, meetingId:String, authToken:String, externalUserId:String):void {
if (player) {
close();
}
videoComp = new Image();
if (numChildren == 0) {
addChild(videoComp);
}
this.originalVideoWidth = imgWidth;
this.originalVideoHeight = imgHeight;
var url:String = uri + "/" + streamName + " live=1 conn=S:" + meetingId + " conn=S:" + externalUserId + " conn=S:" + authToken;
player = new BBBRtmpPlayer(url);
player.addEventListener(BBBRtmpPlayerEvent.CONNECTED, onConnected);
player.addEventListener(BBBRtmpPlayerEvent.CONNECTING, onConnecting);
player.addEventListener(BBBRtmpPlayerEvent.CONNECTION_FAILED, onConnectionFailed);
player.addEventListener(BBBRtmpPlayerEvent.DISCONNECTED, onDisconnected);
player.play();
}
private function onConnected(e:BBBRtmpPlayerEvent):void {
image.source = player.getBmpData();
}
private function onConnecting(e:BBBRtmpPlayerEvent):void {
trace("EVENT: " + e.type + " MESSAGE: " + e.getMessage());
}
private function onConnectionFailed(e:BBBRtmpPlayerEvent):void {
close();
}
private function onDisconnected(e:BBBRtmpPlayerEvent):void {
close();
}
public function close():void {
player.addEventListener(BBBRtmpPlayerEvent.CONNECTED, onConnected);
player.addEventListener(BBBRtmpPlayerEvent.CONNECTING, onConnecting);
player.removeEventListener(BBBRtmpPlayerEvent.CONNECTION_FAILED, onConnectionFailed);
player.removeEventListener(BBBRtmpPlayerEvent.DISCONNECTED, onDisconnected);
if (getChildAt(0) == image) {
removeChild(image);
}
videoComp = null;
player = null;
}
override protected function updateDisplayList(w:Number, h:Number):void {
super.updateDisplayList(w, h);
if (player) {
resizeForPortrait();
}
}
}
}

View File

@ -10,9 +10,11 @@ package org.bigbluebutton.air.screenshare.views {
import flash.media.VideoStatus;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.system.Capabilities;
import spark.components.Group;
import org.bigbluebutton.air.common.views.IOSVideoView;
import org.bigbluebutton.air.main.views.RectCoverView;
public class ScreenshareDock extends Group {
@ -31,7 +33,16 @@ package org.bigbluebutton.air.screenshare.views {
private var _topRect:RectCoverView;
private var _bottomRect:RectCoverView;
public function ScreenshareDock():void { }
private var _iosScrenshareView:IOSScreenshareView;
public function ScreenshareDock():void {
if (Capabilities.version.indexOf("IOS") >= 0) {
_iosScrenshareView = new IOSScreenshareView();
_iosScrenshareView.percentWidth = 100;
_iosScrenshareView.percentHeight = 100;
addElement(_iosScrenshareView);
}
}
private function onStageVideoState(event:StageVideoAvailabilityEvent):void {
var available:Boolean = (event.availability == StageVideoAvailability.AVAILABLE);
@ -167,21 +178,25 @@ package org.bigbluebutton.air.screenshare.views {
}
public function viewStream(conn:NetConnection, streamId:String, width:int, height:int):void {
public function startStream(conn:NetConnection, streamId:String, width:int, height:int, meetingId:String, authToken:String, externalUserId:String):void {
//trace("************ ScreenshareView: viewing of screenshare streamId=" + streamId + " w=" + width + " h=" + height);
_conn = conn;
_streamId = streamId;
_origVidWidth = width;
_origVidHeight = height;
if (stage == null) {
//trace("************ ScreenshareView: STAGE IS NULL!!!!!!!!");
if (Capabilities.version.indexOf("IOS") >= 0) {
_iosScrenshareView.startStream(conn.uri, streamId, width, height, meetingId, authToken, externalUserId);
} else {
stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, onStageVideoState);
if (stage == null) {
//trace("************ ScreenshareView: STAGE IS NULL!!!!!!!!");
} else {
stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, onStageVideoState);
}
}
}
public function streamStopped(session:String, reason:String):void {
public function stopStream(session:String, reason:String):void {
if (_screenshareRunningListener != null) {
_screenshareRunningListener(_usingStageVideo, false);
}

View File

@ -1,5 +1,6 @@
package org.bigbluebutton.air.screenshare.views {
import org.bigbluebutton.air.main.models.IConferenceParameters;
import org.bigbluebutton.air.screenshare.model.IScreenshareModel;
import org.bigbluebutton.air.screenshare.services.IScreenshareConnection;
@ -16,6 +17,9 @@ package org.bigbluebutton.air.screenshare.views {
[Inject]
public var model:IScreenshareModel;
[Inject]
public var conferenceParameters:IConferenceParameters;
override public function initialize():void {
//trace("************ ScreenshareViewMediator:: INIT **************");
model.screenshareStreamStartedSignal.add(viewStream);
@ -26,11 +30,11 @@ package org.bigbluebutton.air.screenshare.views {
}
public function viewStream(streamId:String, width:int, height:int):void {
view.viewStream(conn.connection, streamId, width, height);
view.startStream(conn.connection, streamId, width, height, conferenceParameters.meetingID, conferenceParameters.authToken, conferenceParameters.externUserID);
}
public function streamStopped(session:String, reason:String):void {
view.streamStopped(session, reason);
view.stopStream(session, reason);
}
override public function destroy():void {