Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
121 lines (106 sloc) 4.1 KB
/*** RED5 Open Source Flash Server - http://www.osflash.org/red5** Copyright (c) 2006-2009 by respective authors (see below). All rights reserved.** This library is free software; you can redistribute it and/or modify it under the* terms of the GNU Lesser General Public License as published by the Free Software* Foundation; either version 2.1 of the License, or (at your option) any later* version.** This library is distributed in the hope that it will be useful, but WITHOUT ANY* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.** You should have received a copy of the GNU Lesser General Public License along* with this library; if not, write to the Free Software Foundation, Inc.,* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/// ** AUTO-UI IMPORT STATEMENTS **import org.red5.samples.livestream.videoconference.Subscriber;// ** END AUTO-UI IMPORT STATEMENTS **import org.red5.samples.livestream.videoconference.Connection;import org.red5.net.Stream;import flash.external.*;import org.red5.samples.livestream.videoconference.Broadcaster;class org.red5.samples.livestream.videoconference.VideoPool extends MovieClip {// Constants: public static var CLASS_REF = org.red5.samples.livestream.videoconference.VideoPool; public static var LINKAGE_ID:String = "org.red5.samples.livestream.videoconference.VideoPool";// Public Properties: public var connection:Connection;// Private Properties: private var subscriberList:Array;// UI Elements: public var broadcaster:Broadcaster; // Initialization: private function VideoPool() {} private function onLoad():Void { configUI(); }// Public Methods: public function resetAll():Void { _global.tt("RESET ALL"); // if the user disconnects, but doesn't close the client, reset all subscribers for(var i:Number=0;i<subscriberList.length;i++) { if(subscriberList[i].connected) { subscriberList[i].reset(); } } } public function subscribe(p_id:Number):Void { // VideoPool recieves an id to subscribe to // if bogus id is returned, don't add if(p_id == "undefined" || isNaN(p_id) || p_id == "") return; _global.tt("isNaN", isNaN(p_id), p_id); // it first has to manage which of the video screens is available, if any var s:Subscriber = getVideoContainer(p_id); if (s != null) { s.subscribe("videoStream_" + p_id, connection); } } public function setConnection(p_connection:Connection):Void { connection = p_connection; } public function removeSubscriber(s:Subscriber): Void { for(var i= 0; i < subscriberList.length; i++) { var mc:Subscriber = Subscriber(subscriberList[i]); if (mc.videoStream == s.videoStream) { subscriberList.removeItemAt(i); } } for (var i= 0; i< subscriberList.length; i++) { var mc2:Subscriber = Subscriber(subscriberList[i]); var positionX:Number = broadcaster._x + (subscriberList.length%4) * broadcaster._width; var positionY:Number = broadcaster._y + (broadcaster._height * Math.floor(subscriberList.length/4)); mc2._x = positionX; mc2._y = positionY; _global.tt('REPOSITION SUBSCRIBER ' + mc2.videoStream + '; x:' + positionX + 'y:' + positionY ); } s.removeMovieClip(); _level0.instance1.scrollPane.invalidate(); }// Semi-Private Methods:// Private Methods: private function configUI():Void { subscriberList = []; } private function getVideoContainer(p_id:Number):Subscriber { var d:Number = 1; if (subscriberList.length > 0) { d = subscriberList[subscriberList.length - 1].getDepth() + 1; } var positionX:Number = broadcaster._x + ((subscriberList.length + 1)%4) * broadcaster._width; var positionY:Number = broadcaster._y + (broadcaster._height * Math.floor((subscriberList.length + 1)/4)); attachMovie("org.red5.samples.livestream.videoconference.Subscriber", "subscriber_" + p_id, d, {_x:positionX, _y:positionY}); var s:Subscriber = _level0.instance1.scrollPane.content["subscriber_" + p_id]; s.videoPool = this; subscriberList.push(s); return s; }}