Add BBBRtmpPlayer ANE

This commit is contained in:
João Francisco Siebel 2018-06-11 11:49:52 -03:00
parent 7dfe3f3093
commit 07e723a904
6 changed files with 590 additions and 402 deletions

View File

@ -15,7 +15,7 @@
<!-- A universally unique application identifier. Must be unique across all AIR applications.
Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
<id>com.bigbluebutton.AIRClient</id>
<id>com.bigbluebutton.Main</id>
<!-- Used as the filename for the application. Required. -->
<filename>BigBlueButton</filename>
@ -385,5 +385,6 @@
<extensions>
<extensionID>com.freshplanet.AirCapabilities</extensionID>
<extensionID>com.juankpro.ane.LocalNotification</extensionID>
<extensionID>org.bigbluebutton.BBBRtmpPlayer</extensionID>
</extensions>
</application>

View File

@ -0,0 +1,162 @@
package org.bigbluebutton.air.common.views
{
import mx.core.UIComponent;
import spark.components.Image;
import org.bigbluebutton.BBBRtmpPlayer;
import org.bigbluebutton.BBBRtmpPlayerEvent;
public class IOSVideoView extends UIComponent {
protected var _image:Image;
protected var player:BBBRtmpPlayer;
protected var originalVideoWidth:Number;
protected var originalVideoHeight:Number;
public function IOSVideoView():void {
_image = new Image();
addChild(_image);
}
public function startStream(uri:String, streamName:String, imgWidth:Number, imgHeight:Number, meetingId:String, authToken:String, externalUserId:String):void {
if(player) {
close();
}
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.NEW_IMAGE, onNewImage);
player.addEventListener(BBBRtmpPlayerEvent.CONNECTING, onConnecting);
player.addEventListener(BBBRtmpPlayerEvent.CONNECTION_FAILED, onConnectionFailed);
player.addEventListener(BBBRtmpPlayerEvent.DISCONNECTED, onDisconnected);
player.play();
}
private function onConnecting(e:BBBRtmpPlayerEvent):void {
trace("EVENT: " + e.type + " MESSAGE: " + e.getMessage());
}
private function onNewImage(e:BBBRtmpPlayerEvent):void {
_image.source = player.getLastImage();
}
private function onConnectionFailed(e:BBBRtmpPlayerEvent):void {
close();
}
private function onDisconnected(e:BBBRtmpPlayerEvent):void {
close();
}
public function close():void {
player.removeEventListener(BBBRtmpPlayerEvent.NEW_IMAGE, onNewImage);
player.removeEventListener(BBBRtmpPlayerEvent.CONNECTION_FAILED, onConnectionFailed);
player.removeEventListener(BBBRtmpPlayerEvent.DISCONNECTED, onDisconnected);
_image = new Image();
}
override protected function updateDisplayList(w:Number, h:Number):void {
super.updateDisplayList(w, h);
if (player) {
resizeForPortrait();
}
}
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
_image.width = width;
// calculate height based on a video width, it order to keep the same aspect ratio
_image.height = (_image.width / originalVideoWidth) * originalVideoHeight;
// if calculated height appeared to be bigger than screen height, recalculuate the video size based on width
if (height < _image.height) {
// make the video height full height of the screen
_image.height = height;
// calculate width based on a video height, it order to keep the same aspect ratio
_image.width = ((originalVideoWidth * _image.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
_image.height = height;
// calculate width based on a video height, it order to keep the same aspect ratio
_image.width = ((originalVideoWidth * _image.height) / originalVideoHeight);
// if calculated width appeared to be bigger than screen width, recalculuate the video size based on height
if (width < _image.width) {
// make the video width full width of the screen
_image.width = width;
// calculate height based on a video width, it order to keep the same aspect ratio
_image.height = (_image.width / originalVideoWidth) * originalVideoHeight;
}
}
_image.x = width - _image.width;
_image.y = height - _image.height;
}
public function resizeForLandscape():void {
if (height < width) {
_image.height = width;
_image.width = ((originalVideoWidth * _image.height) / originalVideoHeight);
if (width < _image.width) {
_image.width = height;
_image.height = (_image.width / originalVideoWidth) * originalVideoHeight;
}
} else {
_image.width = height;
_image.height = (_image.width / originalVideoWidth) * originalVideoHeight;
if (height < _image.height) {
_image.height = width;
_image.width = ((originalVideoWidth * _image.height) / originalVideoHeight);
}
}
}
public function rotateVideo(rotation:Number):void {
if (_image && stage.contains(_image)) {
removeChild(_image);
}
_image = new Image();
switch (rotation) {
case 0:
resizeForPortrait();
_image.x = width / 2 - _image.width / 2;
_image.y = height / 2 - _image.height / 2; // + topMenuBarHeight;
break;
case -90:
resizeForLandscape();
_image.x = (width / 2) - (_image.height / 2);
_image.y = (height / 2) + (_image.width / 2); // + topMenuBarHeight;
break;
case 90:
resizeForLandscape();
_image.x = (width / 2) + (_image.height / 2);
_image.y = (height / 2) - (_image.width / 2); // + topMenuBarHeight;
break;
case 180:
resizeForPortrait();
_image.x = width / 2 + _image.width / 2;
_image.y = (height / 2) + (_image.height / 2); // + topMenuBarHeight
break;
default:
break;
}
_image.rotation = rotation;
addChild(_image);
}
}
}

View File

@ -12,8 +12,8 @@ package org.bigbluebutton.air.main.models {
function get pageTransitionStartSignal():ISignal;
function get currentPage():String;
function get lastPage():String;
function popPage(animation:int = TransitionAnimationEnum.APPEAR):void;
function pushPage(value:String, details:Object = null, animation:int = TransitionAnimationEnum.APPEAR):void;
function popPage(animation:int = 0):void;
function pushPage(value:String, details:Object = null, animation:int = 0):void;
function get currentPageDetails():Object;
}
}

View File

@ -40,7 +40,9 @@ package org.bigbluebutton.air.main.views {
// If we are in the Flash Builder debugger the InvokeEvent will never be fired
if (Capabilities.isDebugger) {
//var url:String = "bigbluebutton://test-install.blindsidenetworks.com/bigbluebutton/api/join?fullName=AIR&meetingID=Demo+Meeting&password=mp&redirect=false&checksum=3fdf56e9915c1031c3ea012b4ec8823cedd7c272";
var url:String = "bigbluebutton://test-install.blindsidenetworks.com/bigbluebutton/api/join?fullName=User+2021828&meetingID=Demo+Meeting&password=ap&redirect=true&checksum=8751963df96437c7d435eac8124e4fb3ec147115";
//var url:String = "bigbluebutton://test-install.blindsidenetworks.com/bigbluebutton/api/join?fullName=User+2021828&meetingID=Demo+Meeting&password=ap&redirect=true&checksum=8751963df96437c7d435eac8124e4fb3ec147115";
//var url:String = "bigbluebuttons://dev21.bigbluebutton.org/bigbluebutton/api/join?meetingID=Demo+Meeting&fullName=AAA&password=mp&checksum=5516fb6f7d7330d0c02fd94c8e1fb683957e2da4a1c7013f66004b68148d4478";
var url:String = "bigbluebutton://206.47.241.19/bigbluebutton/api/join?meetingID=Demo+Meeting&fullName=AAA&password=mp&checksum=94cc8981bf215b13101fa4d3307d3aca8512578b23b91b7be8042f65abd4a007";
joinRoom(url);
}
}

View File

@ -1,29 +1,48 @@
package org.bigbluebutton.air.video.views {
import flash.net.NetConnection;
import flash.system.Capabilities;
import spark.components.Group;
import org.bigbluebutton.air.common.views.IOSVideoView;
import org.bigbluebutton.air.common.views.VideoView;
public class WebcamDock extends Group {
private var _video:VideoView;
private var _iosVideoView:IOSVideoView;
public function WebcamDock() {
super();
if (Capabilities.version.indexOf("IOS") >= 0) {
_iosVideoView = new IOSVideoView();
_iosVideoView.percentWidth = 100;
_iosVideoView.percentHeight = 100;
addElement(_iosVideoView);
} else {
_video = new VideoView();
_video.percentHeight = 100;
_video.percentWidth = 100;
addElement(_video);
}
}
public function startStream(connection:NetConnection, name:String, streamName:String, userId:String, oWidth:Number, oHeight:Number):void {
public function startStream(connection:NetConnection, name:String, streamName:String, userId:String, oWidth:Number, oHeight:Number, meetingId:String, authToken:String, externalUserId:String):void {
if (Capabilities.version.indexOf("IOS") >= 0) {
_iosVideoView.startStream(connection.uri, streamName, oWidth, oHeight, meetingId, authToken, externalUserId);
} else {
_video.startStream(connection, name, streamName, userId, oWidth, oHeight);
}
}
public function closeStream():void {
if (Capabilities.version.indexOf("IOS") >= 0) {
_iosVideoView.close();
} else {
_video.close();
}
}
}
}

View File

@ -1,4 +1,5 @@
package org.bigbluebutton.air.video.views {
import org.bigbluebutton.air.main.models.IConferenceParameters;
import org.bigbluebutton.air.main.models.IMeetingData;
import org.bigbluebutton.air.main.models.IUserSession;
import org.bigbluebutton.air.video.models.VideoProfile;
@ -18,6 +19,9 @@ package org.bigbluebutton.air.video.views {
[Inject]
public var userSession:IUserSession;
[Inject]
public var conferenceParameters:IConferenceParameters;
override public function initialize():void {
meetingData.webcams.webcamChangeSignal.add(onWebcamChangeSignal);
@ -65,7 +69,7 @@ package org.bigbluebutton.air.video.views {
private function startWebcam(webcam:WebcamStreamInfo):void {
var videoProfile:VideoProfile = userSession.videoProfileManager.getVideoProfileByStreamName(webcam.streamId);
if (videoProfile) {
view.startStream(userSession.videoConnection.connection, webcam.name, webcam.streamId, webcam.userId, videoProfile.width, videoProfile.height);
view.startStream(userSession.videoConnection.connection, webcam.name, webcam.streamId, webcam.userId, videoProfile.width, videoProfile.height, conferenceParameters.meetingID, conferenceParameters.authToken, conferenceParameters.externUserID);
meetingData.webcams.viewedWebcamStream = webcam.streamId;
}
}