EVME_HOSTING_PATH = "http://www.esprelive.com/sales/eagle/evme2.2.2/hosting/"; EVME_XSL_PATH = "http://www.esprelive.com/sales/eagle/evme2.2.2/mediaengine/"; EVME_HOST_DOMAIN = "www.esprelive.com"; EVME_CHAT_PATH = "http://www.esprelive.com/projects/parrot/evme2.2.2/chat/ChannelManager.php"; EVME_VXN_ADDR = "67.19.80.130"; EVME_VXN_PORT = "443"; //Actor.sdlPathType = "absolute"; function ComponentFactory(){ this.codebase = "http://www.esprelive.com/sales/eagle/evme2.2.2/mediaengine/components/"; var componentdata = eval({"components":{"encoder":{"code":"es.me.driver.encoder.AppletEncoder","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0","package_spec":""},"capture":{"code":"es.me.driver.capture.AppletCapture","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0","package_spec":""},"uploader":{"code":"es.me.driver.upload.AppletUpload","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0"},"director":{"code":"es.theater.ClipContextApplet","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0"},"actor":{"code":"es.theater.ClipActorApplet","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0"},"sdlWriter":{"code":"es.theater.ClipContextApplet","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0"},"clipViewer":{"cache_archive":"cv.jar,evmResources.jar,eVChat.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0"},"clipViewerSigned":{"cache_archive":"cv_signed.jar,evmResources.jar,eVChat.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0"},"fileUtil":{"code":"es.me.espre.util.FileUtilityApplet","cache_archive":"me-fso_signed.jar,messaging_signed.jar,me-common_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0"},"evcInstaller":{"code":"es.installer.AppletUpgrade","cache_archive":"EvcInstaller.jar","\/\/cache_version":"1.0.0.0"},"evChat":{"code":"espre.eVChat.JChatApplet","cache_archive":"evpa_signed.jar,evmResources.jar,eVChat.jar,commons-codec-1.2.jar,commons-httpclient-3.0.1.jar,commons-logging-1.1.jar,json-2.0.jar,log4j-1.2.13.jar,me-common_signed.jar,me-driver_signed.jar,messaging_signed.jar,me-core_signed.jar,evme-installer_signed.jar","\/\/cache_version":"1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0,1.0.0.0"}}}); this.getAppletInformation = function (appletType) { if (componentdata['components'][appletType] != "" || componentdata['components'][appletType] != "undefined") { return componentdata['components'][appletType]; } else { return false; } } } // $Id$ function EncodeRequest() { var that = this; //Let the private functions access the object instance. //acquire ParameterManager capabilities this.PMgr = ParameterManager; this.PMgr("general"); var encoder = Encoder.theInstance(); // get the singleton. var requestState = "idle"; // use this to track the request // states are: idle, encoding, completed, errored, cancelled this.integerStringValidator = function (group, name, _value) { //meLogger.write('Integer String Validator Called', 1); if(isNaN(parseInt(_value)))return false; return true; } // define the progress parameters this.defineParameter("general","xmlFile"); this.defineParameter("general","sdlFile"); this.defineParameter("general","videoProgress","defaultValue","0","validator",this.integerStringValidator); this.defineParameter("general","audioProgress","defaultValue","0","validator",this.integerStringValidator); //API functions this.startEncode = function(){ if(requestState == "encoding") return false; var _xmlFile = this.getParameter('xmlFile'); var _sdlFile = this.getParameter('sdlFile'); if((_xmlFile === null) || (_sdlFile === null)) return false; // must have an xml file. _xmlFile = _xmlFile.replace(/\\/g, "/"); _sdlFile = _sdlFile.replace(/\\/g, "/"); this.setParameter("general","xmlFile",_xmlFile); this.setParameter("general","sdlFile",_sdlFile); meLogger.write(_xmlFile, 2); var result = encoder.startEncode(this); if(result == true){ setRequestState("encoding"); } else{ setRequestState("errored"); this.setParameter("errors","Encoder busy with another request"); } return result; // true indicates that the request has been posted } this.start = this.startEncode; this.cancelEncode = function(){ if(requestState == "encoding") encoder.cancelEncode(this); setRequestState("cancelled") return; } this.cancel = this.cancelEncode; this.getProgress = function(){ if(requestState == "encoding") { return (this.getParameter("videoProgress") + this.getParameter("audioProgress"))/2; } if(requestState == "completed") return 100; return 0; } this.getVideoProgress = function(){ if(requestState == "encoding") return this.getParameter("videoProgress"); if(requestState == "completed") return 100; return 0; } this.getAudioProgress = function(){ if(requestState == "encoding") return this.getParameter("audioProgress"); if(requestState == "completed") return 100; return 0; } this.getErrors = function(){ if(requestState == "errored") return this.getParameter("errors"); return ""; } this.isCompleted = function(){ if(requestState == "completed" || requestState == "cancelled") return true; return false; } this.isEncoding = function(){ if(requestState == "encoding") return true; return false; } this.isError = function(){ if(requestState == "errored") return true; return false; } this.getState = function(){ return requestState; } // Private functions function setRequestState(_state){ var oldState = requestState; if (_state != requestState){ requestState = _state; meLogger.write('EncodeRequest: '+ oldState + ' -> ' + requestState); } } // add public callback functions for status, progress, etc. this.updateVideoProgress = function(_value) { this.setParameter("videoProgress",_value); } this.updateAudioProgress = function(_value) { this.setParameter("audioProgress",_value); } this.updateState = function(_state){ if(_state == "initializing" || _state == "ready") return; if(_state == "errored"){ this.setParameter("errors",encoder.getErrors()); meLogger.write(encoder.getErrors(), 3); } setRequestState(_state); } } function Clip(_name, _file, _ctx) { var that = this; // acquire parametermanager this.PMgr = ParameterManager; this.PMgr("general"); // if (typeof Clip.counter == 'undefined') { // Clip.counter = 1; // } var order = 0; // should be updated when added to a collection var container = _ctx; this.setOrder = setOrder; this.getOrder = getOrder; this.equals = equals; this.getContainer = getContainer; this.prepare4Encoding = prepare4Encoding; this.revertFromEncoding = revertFromEncoding; function getContainer(){ return container; } this.remove = function() { if((container)&&(ControlData == container.constructor)) { return container.removeClip(this); } return false; }; this.rename = function(_name) { var oldName = this.getParameter('general','name'); this.setParameter('general','name',_name); container.update('renameClip',oldName,_name); }; this.changeFile = function(_value){ this.setParameter('general','file',_value); }; this.fileValidator = function(_group,_name,_value) { if(_value.indexOf('.avi') > 0){ if(container.getClipByFile(_value)) { var ex = new MeException('File =>' + _value + '<= is already associated with another clip.'); throw ex; } else { meLogger.write('valid file name used.=> ' + _value, 1); return true; } } else { meLogger.write(_value + ' is not a valid file name. Name = '+_name + ' Group='+ _group, 2); throw new MeException('File =>' + _value + '<= is not a valid file name.'); } return false; }; this.nameValidator = function (group, _name, _value) { meLogger.write('Name Validator Called on ' + _value, 1); if(_value === null || _value === ""){ //return false; var ex = new MeException('Clip => '+ _value + '<= is not a valid clip name'); throw ex; } if(container){ if(ControlData == container.constructor) { if(container.getClip(_value)) { throw new MeException('Clip =>' + _value + '<= already exists'); } } else { return false; } meLogger.write('Valid clip name is used=>' + _value, 2); return true; } throw new MeException('name can not be validated. '); }; /** * X.equals(y) = 1 if x > y, -1 if X < Y and 0 if x = y **/ function equals(anotherClip) { if (anotherClip instanceof Clip) { if(order > anotherClip.getOrder()){ return 1; } if(order < anotherClip.getOrder()){ return -1; } if(order == anotherClip.getOrder()){ return 0; } } throw new MeException("Could not compare Clips."); } function setOrder(_order) { order = _order; } function getOrder() { return order; } function prepare4Encoding(_base){ meLogger.write('updating clip information.'); var success = true; //assume success // delete any existing artifacts deleteFile(toPath(_base,'video_s' + this.getOrder() + '.dat'),true); deleteFile(toPath(_base,'video_s' + this.getOrder() + '.idx'),true); deleteFile(toPath(_base,'audio_s' + this.getOrder() + '.dat'),true); deleteFile(toPath(_base,'audio_s' + this.getOrder() + '.idx'),true); if(!success) return false; //Unable to delete sdl file this.setParameter('video','dataOut', toPath(_base,'video_s'+ this.getOrder() + '.dat')); this.setParameter('video','indexOut', toPath(_base,'video_s'+ this.getOrder() + '.idx')); this.setParameter('audio','dataOut', toPath(_base,'audio_s'+ this.getOrder() + '.dat')); this.setParameter('audio','indexOut', toPath(_base,'audio_s'+ this.getOrder() + '.idx')); return success; } function revertFromEncoding(){ try{ this.removeParameter('video','dataOut'); this.removeParameter('video','indexOut'); this.removeParameter('audio','dataOut'); this.removeParameter('audio','indexOut'); } catch(e) { alert("Clip.revertFromEncoding EXCEPTION: " + e.message); meLogger.write(e.name + ':- ' + e.message); } } function init(){ if((container)&&(ControlData == container.constructor)) { if(container.getClipByFile(_file)) { var ex = new MeException('File =>' + _file + '<= already associated with another clip in this project.'); throw ex; } if(container.getClip(_name)) { throw new MeException('Clip =>' + _name + '<= already exists'); } else { that.setProperty('general', 'name', 'validator', that.nameValidator,container); that.setProperty('general', 'file', 'validator', that.fileValidator,container); that.setParameter('general','name', _name); that.setParameter('general','file', _file); //order = Clip.counter++; //return; } } else { throw new MeException('Error initializing Clip object.'); } } this.createDocumentFragment = function (xmlDocument) { xmlDocument = xmlDocument || xutil.getDomDocument(); var fragment = xmlDocument.createDocumentFragment(); var node = xmlDocument.createElement('subclip'); node.appendChild(this._createDocumentFragment(xmlDocument)); fragment.appendChild(node); return fragment; }; this.toXML = null; this.toXML = function (xmlDocument) { xmlDocument = xmlDocument || xutil.getDomDocument(); var xmlString = xutil.serializeToString(this.createDocumentFragment(xmlDocument)); return xmlString; }; this.getSDL = function(_base){ return toPath(_base,'video_s'+ this.getOrder() + '.dat.sdl'); //assumes this is the first clip in the sequence }; init(); } // supporting classes /** * **/ function ClipCollection(){ this.Col = MeCollection; this.Col(); this.add=function(obj) { this.push(obj); obj.setOrder(this.length); }; // the purpose of this method is to adjust the order of each clip after a clip deletion this.adjustOrder = function(){ for (var i = 0; i < this.length; i++) { (this[i]).setOrder(i+1); } }; } // $Id: ParameterMap.js 50 2007-01-24 21:47:47Z plin $ function ParameterMap(defaultGroupName) { var that = this; // let the private functions access the object. var defaultGroup = defaultGroupName || "general"; var tables = new Object(); // primary structure describes parameters: // tables[group][name]["value"|property]=value // (TBD) tables[group]["parameters"][name]["value"|property]=value // (TBD) extended structure describes groups // (TBD) tables[group]["groupDesc"][name]["value"]=value var supportedGroups = []; function keys(object) { var _keys = []; for (var property in object) _keys.push(property); return _keys; } this.keys = keys; this.asArray = function (object) { if (!object) return []; var results = []; for (var i = 0, length = object.length; i < length; i++) { results.push(object[i]); } return results; } function createGroup(group) { //alert("Creating group " + group + "\n\nCurrent groups: " + keys(tables)); tables[group] = new Object(); supportedGroups = keys(tables); return tables[group]; } function getGroup(group) { group = group || defaultGroup; group = group.toString(); if (!tables[group]) { createGroup(group); } return tables[group]; } function getCell(group, name) { if (!getGroup(group)[name]) { getGroup(group)[name] = {}; } return getGroup(group)[name]; } function checkArgs(args) { if (args.length < args.callee.length) { throw new Error('Missing input parameters.'); } var inputs = that.asArray(arguments); inputs.shift(); if (inputs.length == 0) return; for (var index = 0, length = inputs.length; index < length; index++){ var value = inputs[index]; if (!value || 'string' !== typeof value) { throw new Error('Illegal input parameter.'); } } } this.getSupportedGroups = function() { return [].concat(supportedGroups); } this._setParameter = function (group, name, value) { checkArgs(arguments, name); getCell(group, name).value = value; } this.setParameter = this._setParameter; this._getParameter = function (group, name) { checkArgs(arguments, name); return getCell(group, name).value; } this.getParameter = this._getParameter; this.defineParameter = function (group, name) {/* parameter,value) */ checkArgs(arguments, name); var cell = getCell(group, name); for (var i = 2,length = arguments.length ; (i+1) " + e.message, 3); } return xmlString; } this._toXML = this.toXML; // this.toString = this.toXML; } var meInitialized = false; var meInitInProgress = false; var jds = null; function meInit() { var status = false; if (true) // (!meInitInProgress) { meInitInProgress = true; if (!meInitialized) { if (!dr || (dr === null)) { dr = jDirectorInit(); } //alert('meSupport.meInit actorInstanceCtr: ' + actorInstanceCtr); var i; for (i = 1; i <= actorInstanceCtr; i++) { //debugger; var anActor = actorInstanceMap[i]; if (anActor.isDeferred()) { setTimeout('meInit()',1000); return; } anActor.init(); } if (jds === null) { //if (document.getElementById('director') == null) //{ //alert('meSupport.meInit DIRECTOR DIV NOT FOUND'); //} jds = jDirStart(dr,'director'); } if (!clipDirector || (clipDirector === null)) { // COMMENTED OUT BY DON SMITH -- Replacing with callback from AppletManager //setClipDirector(dr.getInstance()); } nbrOfContexts = contextIdx; if (ctxReady === null) ctxReady = new Object(); if (ctxPlaying === null) ctxPlaying = new Object(); waitForClipDirectorInitialized(); for (i = 1; i <= contextIdx; i++) { ctxReady[i] = false; ctxPlaying[i] = contextDefinitionMap[i].getClipDescriptor().getAutoplay(); } meInitialized = true; status = true; } meInitInProgress = false; } return status; } function ChannelManager(host) { var url = host; var docbase = document.location.href; if (docbase.lastIndexOf('/') !=-1) { docbase = docbase.substr(0,docbase.lastIndexOf('/') + 1); } var HTTPRequestObj = new HttpRequest(); this.registerChannels = function(name){ var response = HTTPRequestObj.sendRequest("GET", url, Array("name=" + name, "mode=sendAndRegister","docbase=" + docbase), false); if (response != "" && response != null) { return JSON.parse(response); } else { return null; } } this.lookupChannels = function(name){ var response = HTTPRequestObj.sendRequest("GET", url, Array("name=" + name, "mode=sendAndLookUp","docbase=" + docbase), false); if (response != "" && response != null) { return JSON.parse(response); } else { return null; } } this.deregisterChannels = function(name){ var response = HTTPRequestObj.sendRequest("GET", url, Array("name=" + name, "mode=sendAndDelete","docbase=" + docbase), false); if (response != "" && response != null) { return JSON.parse(response); } else { return null; } } } function AVDevice(audio, video) { if(AVDevice.deviceAppletState === null || AVDevice.isInitializing()) return null; // must have supporting applet running var that = this; //*** DEVICE APPLET STATES ( AVDevice.deviceAppletState ) are: initializing, ready, active *** this.PMgr = ParameterManager; // From ParameterManager.js (JavaScript file) this.PMgr("device"); // this.eventManager = EventManager; //support events // this.eventManager(); //Device Object Array and Object ID to track the Device Objects that are Created this.objectID = AVDevice.AVDeviceObjectArray.length; AVDevice.AVDeviceObjectArray[this.objectID] = this; var captureTimeout = null; // define validators for parameter management this.integerStringValidator = function (group, name, _value) { if(isNaN(_value)) return false; return true; }; this.audioIndexValidator = function (group, name, _value) { if(isNaN(_value)) return false; // must be an integer var value = parseInt(_value); if(value < -1) return false; // range from -1 to return true; }; this.videoIndexValidator = function (group, name, _value) { if(isNaN(_value)) return false; // must be an integer var value = parseInt(_value); if(value < -1) return false; // range from -1 to return true; }; this.audioNameValidator = function (group, name, _value) { if(typeof _value != "string") return false; return true; }; this.videoNameValidator = function (group, name, _value) { if(typeof _value != "string") return false; return true; }; //Parameters Allowed for each device object this.defineParameter("device","audioIndex","defaultValue",-1,"validator",this.audioIndexValidator); //Index from the Audio Devices Array this.defineParameter("device","videoIndex","defaultValue",-1,"validator",this.videoIndexValidator); //Index from the Video Devices Array this.defineParameter("device","audioName","defaultValue","","validator",this.audioNameValidator); //Name from the Audio Devices Array this.defineParameter("device","videoName","defaultValue","","validator",this.videoNameValidator); //Name from the Video Devices Array //User Defined Device Parameters this.defineParameter("device","framerate","defaultValue",30); //Frame Rate this.defineParameter("device","height","defaultValue",240); //Resolution Height this.defineParameter("device","width","defaultValue",320); //Resolution Width this.defineParameter("device","timelimit","defaultValue",120); //Timelimit for Capture Process this.defineParameter("device","outputfile","defaultValue","./default.avi"); // File name for the captured (AVI) file (Path is optional and the default path is User's Home Directory) //To Retrieve Capture Progress this.defineParameter("device","captureProgress","defaultValue","0","validator",this.integerStringValidator); //instance state model properties. this.setProperty("device","captureStateModel","captureState",false); this.setProperty("device","captureStateModel","completedState",false); this.setProperty("device","captureStateModel","erroredState",false); this.setProperty("device","previewStateModel","previewState",false); //Public Method to Start the Preview Process this.startPreview = function() { if (AVDevice.deviceAppletState === null || AVDevice.deviceAppletState == "initializing") return false; if(!this.isActive() && AVDevice.deviceAppletState == "busy"){ if(AVDevice.theActiveInstance().isCapturing()) return false; // don't disturb a capture if(AVDevice.theActiveInstance().isPreviewing()) AVDevice.theActiveInstance().stopPreview(); } if(!this.isCapturing()){ // Assert current parameters if(!declareActive()) return false; // couldn't find an AVDevice pair directorTrace('AVDevice.startPreview' + '\n outputfile: ' + this.getParameter("outputfile") + '\n height: ' + this.getParameter("height") + '\n width: ' + this.getParameter("width") + '\n timelimit: ' + this.getParameter("timelimit") + '\n framerate: ' + this.getParameter("framerate")); AVDevice.deviceApplet.ep_setCaptureParams(this.getParameter("outputfile"), this.getParameter("height"), this.getParameter("width"), this.getParameter("timelimit"), this.getParameter("framerate")); AVDevice.deviceApplet.ep_setActiveDevice(AVDevice.activeAudio,AVDevice.activeVideo); //must follow ep_setCaptureParams } AVDevice.deviceApplet.ep_setPreview(true); setAppletState("busy"); this.setProperty("device","previewStateModel","previewState",true); return true; }; //Public Method to Stop the Preview Process this.stopPreview = function() { if (!this.isActive() || !this.isPreviewing()) return true; //nothing to do AVDevice.deviceApplet.ep_setPreview(false); if(!this.isCapturing()) setAppletState("ready"); this.setProperty("device","previewStateModel","previewState",false); return true; }; //Public Method to determine whether the Preview Process is in Progress this.isPreviewing = function() { return this.getProperty("device","previewStateModel","previewState"); }; //Public Method to Start the Capture Process this.startCapture = function(_timelimit) { //timelimit optional if (AVDevice.deviceAppletState === null || AVDevice.deviceAppletState == "initializing") return false; if(this.isCapturing()) return true; // already capturing, do nothing if(!this.isActive() && AVDevice.deviceAppletState == "busy"){ if(AVDevice.theActiveInstance().isCapturing()) return false; // don't disturb a capture if(AVDevice.theActiveInstance().isPreviewing()) AVDevice.theActiveInstance().stopPreview(); } //alert("We are capturing using AVDevice!!!"); var timelimit = this.getParameter("timelimit"); if(!(typeof _timelimit == "undefined") && !isNaN(_timelimit)) timelimit = _timelimit; if(!declareActive()) return false; // couldn't find an AVDevice pair AVDevice.deviceApplet.ep_setActiveDevice(AVDevice.activeAudio,AVDevice.activeVideo); AVDevice.deviceApplet.ep_startCapture(this.getParameter("outputfile"), this.getParameter("height"), this.getParameter("width"), timelimit, this.getParameter("framerate")); setAppletState("busy"); this.setProperty("device","captureStateModel","captureState",true); this.setProperty("device","captureStateModel","completedState",false); this.setProperty("device","captureStateModel","erroredState",false); setTimeout(queryCaptureState,500); return true; }; //Public Method to Stop the Capture Process this.stopCapture = function() { if (this.isCapturing()) { AVDevice.deviceApplet.ep_stopCapture(); //State update will be driven by queryCaptureState return true; } return false; }; //Public Method to query for Capture Progress this.getCaptureProgress = function() { if (this.isCapturing() || this.isCompleted()) { return that.getParameter("captureProgress"); } return 0; }; //Public Method to query for errors this.getErrors = function() { if(that.isErrored()){ var errors = that.getParameter("errors"); if(errors !== null) return errors; } return ""; }; //Public Method to determine whether the Capture Process is in Progress this.isCapturing = function() { return this.getProperty("device","captureStateModel","captureState"); }; //Public Method to determine whether the Capture Process is Completed this.isCompleted = function() { return this.getProperty("device","captureStateModel","completedState"); }; //Public Method to determine whether an Error occurred during the Capture Process this.isError = function() { return this.getProperty("device","captureStateModel","erroredState"); }; //Public Method to determine which Device Object is Active (Previewing or Capturing) this.isActive = function() { if (AVDevice.activeDeviceObjectID == this.objectID) return true; return false; }; // Private method to initialize instance var init = function(audio, video){ // To populate the devices Array if ((AVDevice.audioDevicesArray === null) && (AVDevice.videoDevicesArray === null)) { AVDevice.getAudioDeviceList(); AVDevice.getVideoDeviceList(); } // To set the default device (per default selection algorithm) as Active Device if ((AVDevice.activeVideo == -1) && (AVDevice.videoDevicesArray[0] !== null)) { AVDevice.activeVideo = getDefaultDeviceIndex(AVDevice.videoDevicesArray); } if ((AVDevice.activeAudio == -1) && (AVDevice.audioDevicesArray[0] !== null)) { AVDevice.activeAudio = getDefaultDeviceIndex(AVDevice.videoDevicesArray); } // To set the Audio Index and Name Parameter if (audio) { that.setParameter("audioName",audio); that.setParameter("audioIndex",resolveNameToIndex(audio,AVDevice.audioDevicesArray)); } else { that.setParameter("audioName","defaultDevice"); that.setParameter("audioIndex","-1"); } // To set the Video Index and Name Parameter // Assume defaults, then correct with supplied if possible if (video) { that.setParameter("videoName",video); that.setParameter("videoIndex",resolveNameToIndex(video,AVDevice.videoDevicesArray)); } else { that.setParameter("videoName","defaultDevice"); that.setParameter("videoIndex","-1"); } }; //Private Method to Query the State while the Capturing Process is in Progress. var queryCaptureState = function() { captureTimeout = null; var currentState = "ready"; var progress = that.getParameter("captureProgress"); if(that.isActive()){ currentState = AVDevice.deviceApplet.ep_getCapturingState(); //Current State from the Device Applet progress = AVDevice.deviceApplet.ep_getCaptureProgress(); } var captureProgress = progress >= 0 ? progress : 0; // Current State from Device Applet are: Ready, Started, Errored if (currentState == "started"){ setAppletState("busy"); that.setParameter("captureProgress",captureProgress); captureTimeout = window.setTimeout(queryCaptureState,500); return; } if (currentState == "errored"){ that.setProperty("device","captureStateModel","erroredState",true); that.setParameter("captureProgress",captureProgress); that.setParameter("errors",AVDevice.deviceApplet.ep_getErrors()); if(!that.isPreviewing()) setAppletState("ready"); } if (currentState == "ready"){ that.setProperty("device","captureStateModel","captureState",false); that.setProperty("device","captureStateModel","completedState",true); that.setParameter("captureProgress",captureProgress); if(!that.isPreviewing()) setAppletState("ready"); } }; //Private Function to set the Applet State var setAppletState = function(_state){ var oldState = AVDevice.deviceAppletState; if (_state != AVDevice.deviceAppletState){ AVDevice.deviceAppletState = _state; that.setParameter("state",_state); } }; //Private Function to get the default device index var getDefaultDeviceIndex = function(deviceArray) { if(deviceArray === null || typeof deviceArray.length == "undefined" || deviceArray.length === 0) return -1; // no devices available //Prefer first Logitech device //or first Labtec device //or first device for (var deviceIndex = 0; deviceIndex < deviceArray.length; deviceIndex++) { var aDevice = deviceArray[deviceIndex].toLowerCase(); if (aDevice.indexOf("logitech") != -1) return deviceIndex; if (aDevice.indexOf("labtec") != -1) return deviceIndex; } return 0; // use first in list }; var resolveNameToIndex = function(_name,_deviceArray){ if(_deviceArray === null || typeof _deviceArray.length == "undefined" || _deviceArray.length === 0) return -1; // no devices available for (var index = 0; index < _deviceArray.length; index++) { if (_deviceArray[index] == _name) { return index; } } return -1; }; var resolveIndexToName = function(_index,_deviceArray){ if(_deviceArray === null || typeof _deviceArray.length == "undefined" || _deviceArray.length === 0 || _index < 0 || _index > (_deviceArray.length - 1)) return ""; // no device at that index available return _deviceArray[_index]; }; // declare me the active device... var declareActive = function(){ //take this opportunity to adjust name<->index relationships. //if name is set then it is king. index is adjusted to match. //if name is not set then index is used to update name and then name becomes king again // if the index does not match to a name, both are set to temporarily defaults var videoDevice = that.getParameter("videoIndex"); var audioDevice = that.getParameter("audioIndex"); var audioName = that.getParameter("audioName"); var videoName = that.getParameter("videoName"); if(videoName !== ""){ videoDevice = resolveNameToIndex(videoName,AVDevice.videoDevicesArray); that.setParameter("videoIndex",videoDevice); }else{ //no name present try index if(videoDevice != -1){ videoName = resolveIndexToName(videoDevice,AVDevice.videoDevicesArray); if(videoName !== ""){ //name found that.setParameter("videoName",videoName); }else{ //no name found, temporarily default both videoDevice = -1; } } } if(audioName !== ""){ audioDevice = resolveNameToIndex(audioName,AVDevice.audioDevicesArray); that.setParameter("audioIndex",audioDevice); }else{ //no name present try index if(audioDevice != -1){ audioName = resolveIndexToName(audioDevice,AVDevice.audioDevicesArray); if(audioName !== ""){ //name found that.setParameter("audioName",audioName); }else{ //no name found, temporarily default both audioDevice = -1; } } } // go active with devices as specified, or use defaults if(videoDevice == -1) videoDevice = getDefaultDeviceIndex(AVDevice.videoDevicesArray); if(videoDevice == -1) return false; // no video devices available if(audioDevice == -1) audioDevice = getDefaultDeviceIndex(AVDevice.audioDevicesArray); if(audioDevice == -1) return false; // no audio devices available AVDevice.activeVideo = videoDevice; AVDevice.activeAudio = audioDevice; AVDevice.activeDeviceObjectID = that.objectID; return true; }; // execute the init after all functions are defined init(audio, video); } // End of AVDevice class //Static Public Variables ( *** Not Part of the User API ***[Should not be accessed by the User] ) AVDevice.appspec = null; // Holds appspec information for AVDevice AVDevice.deviceApplet = null; // Device Applet ( *** SHOULD be CREATED even before creating Device Objects or Querying for Devices) AVDevice.deviceAppletState = null; // The STATUS of Device Applet (Updated and Maintained by the Device Class) //*** DEVICE APPLET STATES ( AVDevice.deviceAppletState ) ARE: INITIALIZING, READY, PREVIEWING, CAPTURING, COMPLETED, ERRORED *** AVDevice.activeVideo = -1; // To track the Active Video Device AVDevice.activeAudio = -1; // To track the Active Audio Device AVDevice.activeDeviceObjectID = null; // To track the Device Object that's Active AVDevice.audioDevicesArray = null; // List of Audio Devices AVDevice.videoDevicesArray = null; // List of Video Devices AVDevice.AVDeviceObjectArray = new Array(); // List (ID) of Device Object Created AVDevice.callbackAfterInstallation = null; // User CallBack Function After Installation //Static Public functions //Static Public method to Install and Start the Device Applet using AppSpec and AppletManager AVDevice.setDefaultAppspec = function() { if(AVDevice.appspec === null){ AVDevice.appspec = new AppletSpec("capture"); AVDevice.appspec.setParameter("name","captureApplet"); AVDevice.appspec.setParameter("visible","true"); AVDevice.appspec.addParameter("disableInstall","false"); AVDevice.appspec.setParameter("width","320"); AVDevice.appspec.setParameter("height","240"); } return AVDevice.appspec; } AVDevice.Install = function(callbackmethod) { if ((AVDevice.deviceApplet === null) && (AVDevice.deviceAppletState === null)) { AVDevice.callbackAfterInstallation = callbackmethod; AVDevice.deviceAppletState = "initializing"; if(AVDevice.appspec === null){ AVDevice.setDefaultAppspec(); } AppletManager.theInstance().startApplet(AVDevice.appspec, AVDevice.installCallbackmethod, 'captureAppletElement'); } } //Callback for the Device Applet (once its loaded and started) AVDevice.installCallbackmethod = function(applet) { AVDevice.deviceApplet = applet; AVDevice.deviceAppletState = "ready"; cameraCaptureDocument = applet; //TODO EAO live or die? - leave it to keep Actor happy for now if (AVDevice.callbackAfterInstallation !== null) { AVDevice.callbackAfterInstallation(applet); AVDevice.callbackAfterInstallation = null; } // Only when the callback method is provided by the User } //Static Public method to check for Installation // Installation will be invoked if necessary AVDevice.isInstalled = function(callbackmethod) { if (AVDevice.deviceAppletState === null || AVDevice.deviceAppletState == "initializing"){ if(callbackmethod !== null){ AVDevice.Install(callbackmethod); } return false; } return true; } //Static State queries AVDevice.isInitializing = function() { return (AVDevice.deviceAppletState == "initializing"); } AVDevice.isReady = function() { return (AVDevice.deviceAppletState == "ready"); } AVDevice.isPreviewing = function() { var activeInstance = AVDevice.theActiveInstance(); return (activeInstance === null) ? false : activeInstance.isPreviewing(); } AVDevice.isCapturing = function() { var activeInstance = AVDevice.theActiveInstance(); return (activeInstance === null) ? false : activeInstance.isCapturing(); } AVDevice.isCompleted = function() { var activeInstance = AVDevice.theActiveInstance(); return (activeInstance === null) ? false : activeInstance.isCompleted(); } AVDevice.isErrored = function() { var activeInstance = AVDevice.theActiveInstance(); return (activeInstance === null) ? false : activeInstance.isErrored(); } AVDevice.getErrors = function() { if(AVDevice.isErrored()){ return AVDevice.theActiveInstance().getErrors(); } return ""; } //Static Public method to query for the list of Video Devices in Users System AVDevice.getVideoDeviceList = function() { if(AVDevice.isInstalled()){ var videoDevicesList = String(AVDevice.deviceApplet.ep_getVideoDevices()); AVDevice.videoDevicesArray = videoDevicesList.split(";"); return AVDevice.videoDevicesArray; } return new Array(); } //Static Public method to query for the list of Audio Devices in Users System AVDevice.getAudioDeviceList = function() { if(AVDevice.isInstalled()){ var audioDevicesList = String(AVDevice.deviceApplet.ep_getAudioDevices()); AVDevice.audioDevicesArray = audioDevicesList.split(";"); return AVDevice.audioDevicesArray; } return new Array(); } //Static Public method to query for the Active Audio Device AVDevice.getActiveAudio = function() { if(AVDevice.isInstalled() && AVDevice.activeAudio != -1){ return AVDevice.audioDevicesArray[AVDevice.activeAudio]; }else{ return ""; } } //Static Public method to query for the Active Video Device AVDevice.getActiveVideo = function() { if(AVDevice.isInstalled() && AVDevice.activeVideo != -1){ return AVDevice.videoDevicesArray[AVDevice.activeVideo]; }else{ return ""; } } //Static Public method to retrieve the currently active avDevice instance AVDevice.theActiveInstance = function(){ if(AVDevice.activeDeviceObjectID === null) return null; return AVDevice.AVDeviceObjectArray[AVDevice.activeDeviceObjectID]; } /** * @fileoverview This file provides all the functionalities to communicate with server by AJAX request * * @author Espre Team * @version 0.1 * * @param {String} script_filename * @constructor */ function AjaxClient() {} AjaxClient.prototype = { requestType:"POST", // type GET,POST passed to open isAsync:false, // when set to true, async calls are made xmlhttp:false, // where an XMLHttpRequest instance is stored callback:false, // what is called when a successful async call is made /* method to initialize an xmlhttpclient */ init:function() { if (window.XMLHttpRequest) this.xmlhttp = new XMLHttpRequest(); else if (window.ActiveXObject) this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); else alert("AjaxClient. Cannot create XMLHTTPRequest object"); /* try { this.xmlhttp = new XMLHttpRequest(); // Mozilla / Safari } catch (e) { // IE //alert("AjaxClient.init EXCEPTION: " + e.message); var XMLHTTP_IDS = new Array("MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"); var success = false; for (var i=0;i < XMLHTTP_IDS.length && !success; i++) { try { this.xmlhttp = new ActiveXObject(XMLHTTP_IDS[i]); success = true; } catch (e) {alert("AjaxClient.init EXCEPTION: " + e.message);} } if (!success) { } } */ }, /** method to make a page request * @param string url The page to make the request to * @param string payload What you’re sending if this is a POST request */ makeRequest: function(url,payload) { if (!this.xmlhttp) { this.init(); } this.xmlhttp.open(this.requestType,url,this.isAsync); this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); // set onreadystatechange here since it will be reset after a //completed call in Mozilla var self = this; if(this.isAsync){ this.xmlhttp.onreadystatechange = function() { self._readyStateChangeCallback(); } } try { this.xmlhttp.send(payload); if (!this.isAsync) { return this.xmlhttp.responseText; } } catch(e) { alert("AjaxClient.init EXCEPTION: " + e.message); return null; } }, /* internal method used to handle ready state changes */ _readyStateChangeCallback:function() { switch(this.xmlhttp.readyState) { case 2: break; case 4: if (this.xmlhttp.status == 200) { this.callback(this.xmlhttp.responseText); } else { this.callback(null); } break; } } } // $Id$ function EventManager() { var that = this; //Let the private functions access the object instance. var defaultEventRuleGroupName = "_default"; this._eventRuleGroups = null; this._eventRuleGroupName = defaultEventRuleGroupName; this.getEventRuleGroupName = function() { return this._eventRuleGroupName; } this.setEventRuleGroupName = function(name) { directorTrace('EventManager.setEventRuleGroupName' + ' name: ' + name); this._eventRuleGroupName = name; } this.resetEventRuleGroupName = function() { this._eventRuleGroupName = defaultEventRuleGroupName; } this.addEventRule = function(event,action) { this.addEventRuleToGroup(this._eventRuleGroupName,event,action); } this.addEventRuleToGroup = function(group,event,action) { if (this._eventRuleGroups == null) { this._eventRuleGroups = new Object(); } if (!this._eventRuleGroups[group]) { this._eventRuleGroups[group] = new Object(); } if (!this._eventRuleGroups[group][event]) { this._eventRuleGroups[group][event] = new Object(); } this._eventRuleGroups[group][event][action] = action; //alert('group: ' + group + ' event: ' + event + ' action: ' + action); //this.dumpEventRuleGroup(group); } this.removeEventRule = function(event,action) { this.removeEventRuleFromGroup(this._eventRuleGroupName,event,action); } this.removeEventRuleFromGroup = function(group,event,action) { if (this._eventRuleGroups[group]) { if (this._eventRuleGroup[group][event]) { if (this._eventRuleGroup[group][event][action]) { delete this._eventRuleGroup[group][event][action]; } } } } this.getEventActions = function(event) { return this.getEventActionsFromGroup(this._eventRuleGroupName,event); } this.getEventActionsFromGroup = function(group,event) { var eventActions = null; if (this._eventRuleGroups[group]) { if (this._eventRuleGroups[group][event]) { eventActions = this._eventRuleGroups[group][event]; } } return eventActions; } var excludedEvents = new Object(); // Use an Object as a Hash//'playing_started,playing_progress,playing_end_of_video,playing_stopped,imageDisplayed,nextSegment'; this.excludeEvents = function(eventList) { // replace or initialize exclution hash this.excludedEvents = new Object(); this.addExcludedEvents(eventList); } this.addExcludedEvents = function(eventList){ var eventArray = eventList.split(","); if(eventArray.length > 0){ for (event in eventArray){ this.excludedEvents[event] = event; } } } this.removeExcludedEvents = function(eventList){ var eventArray = eventList.split(","); if(eventArray.length > 0){ for (event in eventArray){ if(isExcludedEvent(event)){ delete this.excludedEvents[event]; } } } } this.isExcludedEvent = function(event) { return (excludedEvents[event]==event); } this._eventDescriptor = null; this.getEventDescriptor = function() { return this._eventDescriptor; } this.invoke = function(event,eventDescriptor) { this._event = event; this._eventDescriptor = eventDescriptor; if (!this.notifyInProgress) { this.notifyDependents(event,eventDescriptor); } //preInit(); //this.trackTransitions(event,eventDescriptor); var actions = this.getEventActions(event); if (actions != null) { var actionFound = false; for (var action in actions) { if (!actionFound) this.invokeEvent(event,eventDescriptor); actionFound = true; if (this.isExcludedEvent(event)) { //text = '[1]Actor.invoke' + ' eventDescriptor: ' + eventDescriptor + ' event: ' + event + ' action: ' + action; //directorTrace(text); //alert(text); } //alert('action: ' + action + ' typeof: ' + (typeof action)); if (action.indexOf('(') !== -1) { //directorTrace('EventManager.invoke action: ' + action + ' typeof action: ' + (typeof action)); if (typeof EventManager.noTryCatch == 'undefined') { if (true && !eventDescriptor.startsWith('playing_stopped') && !eventDescriptor.startsWith('firstFrameReady') ) directorTrace('EventManager.invoke' + ' ruleGroupName: ' + this._eventRuleGroupName + ' eventDescriptor: ' + eventDescriptor + ' action: ' + action); try {eval(action);} catch(err) { alert('EventManager.invoke EXCEPTION: ' + err.description + '\n action: ' + action + '\n event: ' + event + '\n eventDescriptor: ' + eventDescriptor); } } else { if (true && !eventDescriptor.startsWith('playing_stopped') && !eventDescriptor.startsWith('firstFrameReady') ) directorTrace('EventManager.invoke' + ' ruleGroupName: ' + this._eventRuleGroupName + ' eventDescriptor: ' + eventDescriptor + ' action: ' + action); eval(action); } } } if (!actionFound) { //directorTrace('Actor.invoke ACTION NOT FOUND FOR EVENT: ' + event); } } else { if (this.isExcludedEvent(event)) { //directorTrace('[2]Actor.invoke' + ' eventDescriptor: ' + eventDescriptor); } this.invokeEvent(event,eventDescriptor); } } this.invokeEvent = function(event,eventDescriptor) { if ((event != 'init') && (eval('this.' + event) != undefined)) { eval('this.' + event + "(\'" + eventDescriptor + "\')"); } } this.dumpEventRuleGroup = function(group) { alert('group: ' + group); var events = this._eventRuleGroups[group]; for (var event in events) { alert('event: ' + event); for (var action in event) { alert('action: ' + action); } } } var dependents = null; this.addDependent = function(aDependent) { if (dependents === null) { dependents = new Array(); dependents[0] = null; } if (aDependent) { for (var i = 0; i < dependents.length; i++) { if (dependents[i] === null) { dependents[i] = aDependent; return; } } dependents[dependents.length] = aDependent; } } this.removeDependent = function(aDependent) { if (dependents !== null) { for (var i = 0; i < dependents.length; i++) { if (dependents[i] === aDependent) { dependents[i] = null; return; } } } } this.notifyInProgress = false; this.notifyDependents = function(event,eventDescriptor) { if (dependents !== null) { for (var i = 0; i < dependents.length; i++) { dependent = dependents[i]; if (dependent !== null) { this.notifyInProgress = true; try {dependent.invoke(event,eventDescriptor);} catch(err) { if (false) { directorTrace('EventManager.notifyDependents EXCEPTION: ' + err.description + '\n dependent: ' + dependent + '\n event: ' + event + '\n eventDescriptor: ' + eventDescriptor); } } this.notifyInProgress = false; } } } } this.fireEventDescriptor = function(eventDescriptor) { //directorTrace('EventManager.fireEventDescriptor eventDescriptor: ' + eventDescriptor); this.notifyDependents(ContextEventDescriptor.getEvent(eventDescriptor),eventDescriptor); } } // meClipDescriptor.js //var clipDescriptorList = null; //var clipDescriptorArray = null; var _clipDescriptor = new ClipDescriptor(); ClipDescriptor.cdaIndex = 0; ClipDescriptor.clipDescriptorArray = null; ClipDescriptor.clipDescriptorList = null; ClipDescriptor.sdlList = null; function ClipDescriptor(sdlBase, sdlPrefix, sdl, width, height, autoplay, noAudio, convertSegments, volume, foreground, scenes, vdc, vic, adc, aic, auditPlayState, auditPointer, autoBandwidth, syncBandwidth, codeBaseOverride) { if (!sdl || (sdl === null)) return; this._sdlBase = sdlBase; this._sdlPrefix = sdlPrefix; this._sdl = sdl; this._width = width; this._height = height; this._autoplay = autoplay; this._noAudio = noAudio; this._convertSegments = convertSegments; this._volume = volume; this._foreground = foreground; this._scenes = scenes; this._vdc = vdc; this._vic = vic; this._adc = adc; this._aic = aic; this._auditPlayState = auditPlayState; this._auditPointer = auditPointer; this._autoBandwidth = autoBandwidth; this._syncBandwidth = syncBandwidth; this._codeBaseOverride = codeBaseOverride; this.setSdlBase = function(sdlBase) {this._sdlBase = sdlBase;} this.getSdlBase = function() {return this._sdlBase;} this.setSdlPrefix = function(sdlPrefix) {this._sdlPrefix = sdlPrefix;} this.getSdlPrefix = function() {return this._sdlPrefix;} this.setSdl = function(sdl) {this._sdl = sdl;} this.getSdl = function() {return this.getSdlBase() + this.getSdlPrefix() + this._sdl;} this.setWidth = function(width) {this._width = width;} this.getWidth = function() {return this._width;} this.setHeight = function(height) {this._height = height;} this.getHeight = function() {return this._height;} this.setAutoplay = function(autoplay) { this._autoplay = (isString(autoplay)) ? (autoplay.toLowerCase() == 'true') : autoplay; directorTrace('meClipDescriptor.setAutoplay' + ' autoplay: ' + autoplay); //alert('meClipDescriptor.setAutoplay' + ' autoplay: ' + autoplay); } this.getAutoplay = function() {return this._autoplay;} this.setNoAudio = function(noAudio) { this._noAudio = (isString(noAudio)) ? (noAudio.toLowerCase() == 'true') : noAudio;; } this.getNoAudio = function() {return this._noAudio;} this.setConvertSegments = function(ConvertSegments) {this._convertSegments = convertSegments;} this.getConvertSegments = function() {return this._convertSegments;} this.setVolume = function(volume) {this._volume = volume;} this.getVolume = function() {return this._volume;} this.setForeground = function(foreground) {this._foreground = foreground;} this.isForeground = function() {return this._foreground;} this.setScenes = function(scenes) {this._scenes = scenes;} this.getScenes = function() {return this._scenes;} this.setVideoDataCacheSize = function(vdc) {this._vdc = vdc;} this.getVideoDataCacheSize = function() {return this._vdc;} this.setVideoIndexCacheSize = function(vic) {this._vic = vic;} this.getVideoIndexCacheSize = function() {return this._vic;} this.setAudioDataCacheSize = function(adc) {this._adc = adc;} this.getAudioDataCacheSize = function() {return this._adc;} this.setAudioIndexCacheSize = function(aic) {this._aic = aic;} this.getAudioIndexCacheSize = function() {return this._aic;} this.setAuditPlayState = function(auditPlayState) {this._auditPlayState = auditPlayState;} this.getAuditPlayState = function() {return this._auditPlayState;} this.setAuditPointer = function(auditPointer) {this._auditPointer = auditPointer;} this.getAuditPointer = function() {return this._auditPointer;} this.isAuditPointer = function() {return this._auditPointer;} this.setAutoBandwidth = function(autoBandwidth) {this._autoBandwidth = autoBandwidth;} this.getAutoBandwidth = function() {return this._autoBandwidth;} this.setSyncBandwidth = function(syncBandwidth) {this._syncBandwidth = syncBandwidth;} this.getSyncBandwidth = function() {return this._syncBandwidth;} this.setCodeBaseOverride = function(codeBaseOverride) {this._codeBaseOverride = codeBaseOverride;} this.getCodeBaseOverride = function() {return this._codeBaseOverride;} if (ClipDescriptor.clipDescriptorList == null) { ClipDescriptor.clipDescriptorList = new Object(); } var subscript = ''; if (ClipDescriptor.clipDescriptorArray == null) { ClipDescriptor.clipDescriptorArray = new Array(); ClipDescriptor.cdaIndex = 0; } var listEntry = ''; if (this.getSdlPrefix().indexOf('/') != -1) { var path = this.getSdlPrefix().split('/'); for (var i = 0; i < path.length; i++) { if (path[i].length > 0) { subscript += '[\'' + path[i] + '\']'; if (!eval('ClipDescriptor.clipDescriptorList' + subscript) && (i < (path.length-2))) { listEntry = 'ClipDescriptor.clipDescriptorList' + subscript + '=new Object()'; eval(listEntry); ClipDescriptor.clipDescriptorArray[ClipDescriptor.cdaIndex++] = listEntry; } } } } else { subscript += '[\'' + this.getSdlPrefix() + '\']'; } listEntry = 'ClipDescriptor.clipDescriptorList' + subscript + '=this'; eval(listEntry); ClipDescriptor.clipDescriptorArray[ClipDescriptor.cdaIndex++] = listEntry; this.getExtendedClipHandle = function() { return '/' + this.getSdlPrefix().substring(0,this.getSdlPrefix().length); } this.toString = function() { return (' ClipDescriptor' + '\n location.href: ' + location.href + '\n sdlBase: ' + this._sdlBase + ' sdlPrefix: ' + this._sdlPrefix + '\n sdl: ' + this._sdl + ' volume: ' + this._volume + ' width: ' + this._width + ' height: ' + this._height + '\n codeBaseOverride: ' + this._codeBaseOverride + '\n autoplay: ' + this._autoplay + ' noAudio: ' + this._noAudio + ' convertSegments: ' + this._convertSegments + ' foreground: ' + this._foreground + '\n vdc: ' + this._vdc + ' vic: ' + this._vic + ' adc: ' + this._adc + ' aic: ' + this._aic + '\n auditPlayState: ' + this._auditPlayState + ' auditPointer: ' + this._auditPointer + ' autoBandwidth: ' + this._autoBandwidth + ' syncBandwidth: ' + this._syncBandwidth + '\n scenes: ' + this._scenes); } if (ClipDescriptor.sdlList === null) { ClipDescriptor.sdlList = new Object(); } ClipDescriptor.sdlList[this.getSdl()] = this; this.cloneBasicParameters = function(aCd) { //this._width = aCd._width; //this._height = aCd._height; //this._autoplay = aCd._autoplay; this._noAudio = aCd._noAudio; this._convertSegments = aCd._convertSegments; this._volume = aCd._volume; this._foreground = aCd._foreground; this._scenes = aCd._scenes; this._vdc = aCd._vdc; this._vic = aCd._vic; this._adc = aCd._adc; this._aic = aCd._aic; this._auditPlayState = aCd._auditPlayState; this._auditPointer = aCd._auditPointer; this._autoBandwidth = aCd._autoBandwidth; this._syncBandwidth = aCd._syncBandwidth; //this._codeBaseOverride = aCd._codeBaseOverride; } } function getClipDescriptorList() { return ClipDescriptor.clipDescriptorList; } function getClipDescriptorListAsString() { return 'ClipDescriptor.clipDescriptorList'; } function dumpCda() { return; for (var i = 0; i < ClipDescriptor.clipDescriptorArray.length; i++) { directorTrace('i: ' + i + ' ' + ClipDescriptor.clipDescriptorArray[i]); } } ClipDescriptor.findClipDescriptor = function(anSdl) { //alert('meClipDescriptor.findClipDescriptor anSdl: ' + anSdl); var cd = null; if ((ClipDescriptor.sdlList !== null) && (ClipDescriptor.sdlList[anSdl])) { cd = ClipDescriptor.sdlList[anSdl]; } return cd; } // meChat.js function Chat(chatApplet) { var url = EVME_CHAT_PATH; var cm = new ChannelManager(url); if (!chatApplet) { chatApplet = vChatDocument; } this.chatApplet = chatApplet; this.videoRTP = 0; this.videoRTCP = 0; this.audioRTP = 0; this.audioRTCP = 0; this.callId = -1; this.openChannel = function(userName,direction) // USER API { // direction == 0 == Chat.incoming; // direction > 0 == Chat.outgoing (selfview, too) if (this.callId !== -1) { this.closeChannel(); } this.direction = direction; if (userName && isString(userName) && (userName.length > 0)) { var channels = this.acquireChannelsFor(userName); if (channels === null) { directorTrace('Chat.openChannel UNABLE TO GET CHANNELS FOR userName: ' + userName); return null; } this.videoRTP = channels.videoRTP; this.videoRTCP = channels.videoRTCP; this.audioRTP = channels.audioRTP; this.audioRTCP = channels.audioRTCP; } else { directorTrace('Chat.openChannel INVALID userName: ' + userName); return null; } this.callId = this.chatApplet.ep_openMulticastChannel(direction, this.videoRTP,this.videoRTCP, this.audioRTP,this.audioRTCP); directorTrace('Chat.openChannel' + this); return this.callId; } this.closeChannel = function() // USER API { if (this.callId > -1) { directorTrace('Chat.closeChannel' + this); this.chatApplet.ep_closeMulticastChannel(this.callId); this.callId = -1; this.releaseChannels(); } } this.toString = function() { return ('\n userName: ' + this.userName + ' callId: ' + this.callId + ' direction: ' + ((this.direction == Chat.outgoing)? 'outgoing' : 'incoming') + '\n audioRTP: ' + this.audioRTP + ' [0x' + this.d2h(this.audioRTP) + ']' + ' audioRTCP: ' + this.audioRTCP + ' [0x' + this.d2h(this.audioRTCP) + ']' + '\n videoRTP: ' + this.videoRTP + ' [0x' + this.d2h(this.videoRTP) + ']' + ' videoRTCP: ' + this.videoRTCP + ' [0x' + this.d2h(this.videoRTCP) + ']'); } this.userName = ''; this.acquireChannelsFor = function(userName) { var channels = null; if (userName && isString(userName) && (userName.length > 0)) { this.userName = userName; if (this.resolvedChannels[this.userName] && (this.resolvedChannels[this.userName] !== null)) { channels = this.resolvedChannels[this.userName]; } else { channels = cm.registerChannels(this.userName); if (!channels) { channels = null; } else { this.resolvedChannels[this.userName] = channels; } } } return channels; } this.releaseChannels = function() { var response = null; if (this.userName.length > 0) { //var myHttpRequest = new HttpRequest(); //myHttpRequest.sendRequest("GET",url,new Array("name="+this.userName,"mode=sendAndDelete"),false); //response = myHttpRequest.responseText.parseJSON(); //response = cm.deregisterChannels(this.userName); this.userName = ''; } return response; } this.d2h = function(d) { var hD="0123456789ABCDEF"; var h = hD.substr(d&15,1); while(d>15) {d>>=4;h=hD.substr(d&15,1)+h;} return h; } this.startChat = function(disableAudio, vxnServerAddress, vxnServerPort) // USER API { this.disableAudio = (disableAudio) ? disableAudio : Chat.defaultDisableAudio; this.vxnServerAddress = (vxnServerAddress) ? vxnServerAddress : Chat.defaultVxnServerAddress; this.vxnServerPort = (vxnServerPort) ? vxnServerPort : Chat.defaultVxnServerPort; directorTrace('Chat.startChat ' + this.vxnServerAddress + ':' + this.vxnServerPort); this.chatApplet.ep_startup(this.disableAudio,this.vxnServerAddress,this.vxnServerPort); } this.resolvedChannels = new Array(); this.startAudio = function() {this.chatApplet.ep_startAudioCapture();}; this.stopAudio = function() {this.chatApplet.ep_stopAudioCapture();}; this.setAudioRate = function(bytesPerSecond) {this.chatApplet.ep_setAudioCaptureRate(bytesPerSecond);}; this.configureAudioRate = function(bytesPerSecond,audioOn) { if (typeof audioOn == 'undefined') audioOn = true; if (audioOn) this.stopAudio(); this.setAudioRate(bytesPerSecond); if (audioOn) this.startAudio(); }; } Chat.outgoing = 1; Chat.incoming = 0; Chat.remoteView = new Array(); Chat.selfView = null; Chat.defaultDisableAudio = false; Chat.defaultVxnServerAddress = '64.62.211.155'; Chat.defaultVxnServerPort = 443; Chat.play = function(chatActor,member) { if (chatActor) { //directorTrace('Chat.play' + ' chatActor._name: ' + chatActor._name + ' member: ' + member); chatActor.setChatApplet(vChatDocument); chatActor.play(member); } else { directorTrace('Chat.play chatActor NOT DEFINED'); } } Chat.publish = function(member) { if (Chat.selfView != null) { //directorTrace('Chat.publish' + ' Chat.selfView._name: ' + Chat.selfView._name + ' member: ' + member); Chat.selfView.setChatApplet(vChatDocument); Chat.selfView.publish(member); } else { directorTrace('Chat.publish Chat.selfView NULL'); } } Chat.allocateView = function(viewType,maxRemoteViewsAllocated) { //directorTrace('meChat.allocateView remoteView ' + Chat.remoteView + ' viewType: ' + viewType); maxRemoteViewsAllocated = maxRemoteViewsAllocated || Chat.maxRemoteViewsAllocated; if ((typeof Chat.remoteView[viewType] != 'undefined') && !Chat.areMaxRemoteViewsAllocated(maxRemoteViewsAllocated)) { for (var actorName in Chat.remoteView[viewType]) { var actor = Chat.remoteView[viewType][actorName]; if ((typeof actor.chatViewAllocated == 'undefined') || !actor.chatViewAllocated) { actor.chatViewAllocated = true; return actor; } } } else { directorTrace('Chat.allocateView no views available for viewType: ' + viewType); } return null; } Chat.releaseView = function(actorName,viewType) { var actor = getActorByName(actorName); viewType = (viewType != null) ? viewType : '' + actor.getClipWidth() + 'x' + actor.getClipHeight(); if (typeof Chat.remoteView[viewType] != 'undefined') { if (typeof Chat.remoteView[viewType][actorName] != 'undefined') { Chat.remoteView[viewType][actorName].chatViewAllocated = false; Chat.remoteView[viewType][actorName].chatProxy.callId = -1; } } else { directorTrace('Chat.releaseView viewType not found: ' + viewType); } } Chat.getSelfView = function() { return Chat.selfView; } Chat.getRemoteView = function(viewId) { return Chat.remoteView[viewId]; } Chat.isRemoteActive = function() { for (var viewId in Chat.remoteView) { var view = Chat.remoteView[viewId]; if ((typeof view.chatViewAllocated != 'undefined') && view.chatViewAllocated) { return true; } } return false; } Chat.maxRemoteViewsAllocated = 3; Chat.areMaxRemoteViewsAllocated = function(maxRemoteViewsAllocated) { var currentAllocated = 0; for (var viewType in Chat.remoteView) { for (var actorName in Chat.remoteView[viewType]) { var actor = Chat.remoteView[viewType][actorName]; if (actor.chatViewAllocated) { currentAllocated++; } } } return currentAllocated >= maxRemoteViewsAllocated; } Chat.startAudioCapture = function() { if (Chat.selfView != null) { Chat.selfView.getChatProxy().startAudio(); } else { directorTrace('Chat.startAudioCapture Chat.selfView NULL'); } } Chat.stopAudioCapture = function() { if (Chat.selfView != null) { Chat.selfView.getChatProxy().stopAudio(); } else { directorTrace('Chat.stopAudioCapture Chat.selfView NULL'); } } Chat.setAudioCaptureRate = function(bytesPerSecond) { if (Chat.selfView != null) { Chat.selfView.getChatProxy().setAudioRate(bytesPerSecond); } else { directorTrace('Chat.setAudioCaptureRate Chat.selfView NULL'); } } Chat.configureAudioCaptureRate = function(bytesPerSecond) { if (Chat.selfView != null) { Chat.selfView.getChatProxy().configureAudioRate(bytesPerSecond); } else { directorTrace('Chat.configureAudioCaptureRate Chat.selfView NULL'); } } function MeException(_message) { this.message = _message; this.name = "MeException"; } function Scene() { var that = this; // acquire parametermanager capabilites this.PMgr = ParameterManager; this.PMgr("general"); var ctx = arguments[0]; this.container = ctx; if( this.container){ if(ControlData == this.container.constructor) { var pLen = arguments.length; var sName,cFromName,ctx,cToName,fromFrame,toFrame; this.nameValidator = function (group, name, _value) { meLogger.write('Scene name Validator Called', 1); if(_value == null || _value == ""){ //return false; var ex = new MeException('Scene => '+ _value + '<= is not a valid scene name'); throw ex; } if(ctx.getScene(_value)) { //meLogger.write('Scene =>' + _value + '<= already exists',3); //return false; var ex = new MeException('Scene =>' + _value + '<= already exists'); throw ex; } else { //meLogger.write('adding scene...' + _value); } meLogger.write('valid scene name is used=>' + _value, 2); return true; } this.fromToClipValidator = function (_group,_name,_value) { if((_name == 'fromClip') || (_name == 'toClip')){ var currentClip = ctx.getClip(_value); if(!(currentClip)) { var ex = new MeException('Clip =>' + _value + '<= does not exist'); throw ex; } try{ var tempToClip = that.getParameter(_group,'toClip'); var tempFromClip = that.getParameter(_group,'fromClip'); if(_name == 'fromClip'){ if ((tempToClip) && (_value != tempToClip)){ if ((currentClip.equals(ctx.getClip(tempToClip))) > 0) { throw new MeException('Clip =>' + _value + ' is after clip =>'+ tempToClip); } } } else if (_name == 'toClip'){ if ((tempFromClip) && (_value != tempFromClip)){ if ((currentClip.equals(ctx.getClip(tempFromClip))) < 0) { throw new MeException('Clip =>' + _value + ' is before clip =>'+ tempFromClip); } } } } catch(e) { //meLogger.write(e.name + ':= ' + e.message, 3); alert("Scene.fromToClipValidator EXCEPTION: " + e.message); throw(e); //return false; } meLogger.write('valid clip name is used=>' + _value, 2); return true; } return false; } //addScene(ctx,name, clipName) //addScene(ctx,name, startingClipName, endingClipName) //addScene(ctx,name, startingClipName, startingFrame, endingClipName,endingFrame) if (pLen == 6) { sName = arguments[1]; cFromName = arguments[2]; fromFrame =arguments[3]; cToName = arguments[4]; toFrame = arguments[5]; try{ this.setProperty('general', 'name', 'validator', this.nameValidator); this.setProperty('general', 'fromClip', 'validator', this.fromToClipValidator); this.setProperty('general', 'toClip', 'validator', this.fromToClipValidator); this.setParameter('general','name', sName); this.setParameter('general','fromClip',cFromName); this.setParameter('general','toClip',cToName); this.setParameter('general','fromFrame', fromFrame); this.setParameter('general','toFrame', toFrame); } catch(e) { meLogger.write(e.name + ':= ' + e.message, 3); throw(e); } } else { throw new MeException('Error initializing Scene object.'); } this.remove = function() { (this.container).removeScene(this); } this.rename = function(_name) { this.setParameter('general','name',_name); } } else { throw new MeException('Scene can not be initialized out side of ControlData context. Error initializing.'); } } else { throw new MeException('Attempting to initialize sceneError initializing Scene object.'); } this.encodeScene = function () { ; //TODO } this.createDocumentFragment = function (xmlDocument) { xmlDocument = xmlDocument || xutil.getDomDocument(); var fragment = xmlDocument.createDocumentFragment(); var node = xmlDocument.createElement('scene'); node.appendChild(this._createDocumentFragment(xmlDocument)); fragment.appendChild(node); return fragment; }; this.toXML = null; this.toXML = function (xmlDocument) { xmlDocument = xmlDocument || xutil.getDomDocument(); var xmlString = xutil.serializeToString(this.createDocumentFragment(xmlDocument)); return xmlString; } ; } // Supporting classes /** * **/ function SceneCollection(){ this.Col = MeCollection; this.Col(); //Other collection functions go here } function Sdl() { if (typeof Sdl.instance == 'undefined') { Sdl.instance = this; } this.start = function(encoder) { this.encoder = encoder; this.encodeRequest = encoder.getEncodeRequest(); if (Sdl.writer == null) { Sdl.writer = Actor.getSdlWriterActor(); Sdl.writer.addDependent(this); Sdl.writer.addEventRule('sdlWriteComplete','Sdl.writeComplete()'); } if (Sdl.writer.isWriteInProgress()) { directorTrace('Sdl.start write in progress'); this.encoder.setAppletState2('errored'); } else { Sdl.writer.setVideoFile(this.encodeRequest.getParameter('sdlFile')); Sdl.writer.startSdlWriter(); } } } Sdl.writer = null; Sdl.writeComplete = function() { //directorTrace('Sdl.writeComplete'); if (typeof Sdl.instance != 'undefined') { Sdl.instance.encoder.setAppletState2('completed'); } else { directorTrace('Sdl.writeComplete NO INSTANCE'); alert('Sdl.writeComplete NO INSTANCE'); } } Sdl.theInstance = function() { if (typeof Sdl.instance == 'undefined') { new Sdl(); } return Sdl.instance; } var nbrOfContexts = 0; var ctxReady = null; var ctxPlaying = null; var allContextsReady = false; var clipMsgLocalVideo = false; var clipDirectorInitialized = false; function waitForClipDirectorInitialized() { if (clipDirectorInitialized) return; if (!clipDirector || (clipDirector == null)) { // COMMENTED OUT BY DON SMITH -- Replacing with callback from AppletManager //setClipDirector(dr.getInstance()); //alert('meMgmt.waitForClipDirectorInitialized clipDirector: ' + clipDirector); setTimeout('waitForClipDirectorInitialized()',2000); return; } // alert('meMgmt.waitForClipDirectorInitialized clipDirector DEFINED'); // directorTrace('meMgmt.waitForClipDirectorInitialized clipDirector DEFINED'); var tmp; var i = 0; try { if (nbrOfContexts == 0) { tmp = parseInt(clipDirector.ep_invokeAndWait('1,,ep_getMaxContextIndex')); if ((typeof tmp == "undefined") || (tmp === 0)) { setTimeout('waitForClipDirectorInitialized()',500); return; } directorTrace('meMgmt.waitForClipDirectorInitialized nbrOfContexts: ' + tmp); nbrOfContexts = tmp; } if (ctxReady === null) ctxReady = new Array(nbrOfContexts+1); if (ctxPlaying === null) ctxPlaying = new Array(nbrOfContexts+1); //setTimeout('waitForAllContextsReady()',1000); } catch(err) { alert('waitForClipDirectorInitialized EXCEPTION: ' + err.description); setTimeout('waitForClipDirectorInitialized()',1000); } clipDirectorInitialized = true; // directorTrace('meMgmt.waitForClipDirectorInitialized INITIALIZED'); } var monitorsStarted = false; function waitForAllContextsReady() { if (!clipDirectorInitialized) { directorTrace('meMgmt.waitForAllContextsReady clipDirector not initialized'); setTimeout('waitForAllContextsReady()',2000); return; } //try { waitForAllContextsReady2(); } //catch(err) //{ //directorTrace('waitForAllContextsReady EXCEPTION: ' + err.description); //setTimeout('waitForAllContextsReady()',1000); //} } function waitForAllContextsReady2() { var actorName = ""; var isPrimary = ""; var ctxIsPlaying = ""; var waitForView = ""; var isAutoplay = ""; var allSegmentsReady = ""; var i = 0; var allReady = true; for (i = 1; i <= nbrOfContexts; i++) { if (!ctxReady[i]) { isPrimary = clipDirector.ep_invokeAndWait(i.toString() + ',,ep_isPrimary'); ctxIsPlaying = isPlaying(i) ? 'true' : 'false'; waitForView = clipDirector.ep_invokeAndWait(i.toString() + ',,ep_isWaitForView'); isAutoplay = clipDirector.ep_invokeAndWait(i.toString() + ',,ep_isAutoplay'); allSegmentsReady = clipDirector.ep_invokeAndWait(i.toString() + ',,ep_areAllSegmentsReady'); if (false) { directorTrace('meMgmt.waitForAllContextsReady2' + '\n i: ' + i + '\n isPrimary: ' + isPrimary + '\n ctxIsPlaying: ' + ctxIsPlaying + '\n waitForView: ' + waitForView + '\n isAutoplay: ' + isAutoplay + '\n allSegmentsReady: ' + allSegmentsReady); } // check status of primaries if (isPrimary == 'true') { if ((ctxIsPlaying == 'true') || ((isAutoplay == 'false') && (allSegmentsReady == 'true'))) { if (waitForView == 'true') { // if (!isMsgActor(i)) { //directorTrace('waitForAllContextsReady make primary actor visible. Context:' + i); getActorByIndex(i).invoke('readyToPlay','readyToPlay;meMgmt'); // actorName = clipDirector.ep_invokeAndWait(i.toString() + ',,ep_getActorName'); // document.getElementById(actorName).style.visibility = "visible"; } } ctxReady[i] = true; } else { allReady = false; } continue; } // check status of secondaries if ( (ctxIsPlaying == 'true') || ((waitForView == 'false') && (allSegmentsReady == 'true')) || ((waitForView == 'true') && (allSegmentsReady == 'true') && (isAutoplay == 'false')) ) { // if (waitForView == 'true') // { // if (!isMsgActor(i)) // { // getActorByIndex(i).invoke('readyToPlay','readyToPlay;meMgmt'); // directorTrace('waitForAllContextsReady make secondary actor visible. Context: ' + i + ' actor: ' + actorName); // actorName = clipDirector.ep_invokeAndWait(i.toString() + ',,ep_getActorName'); // document.getElementById(actorName).style.visibility = "visible"; // } // } ctxReady[i] = true; if (chatOnly) allReady = true; continue; } allReady = false; } // if (!ctxReady[i]) else { //allReady = true; //break; } } // for if (!allReady) { setTimeout('waitForAllContextsReady()',1000); return; } if ((typeof processMainMouseClicksEnabled === 'undefined') ||processMainMouseClicksEnabled) { // directorTrace('meMgmt.waitForAllContextsReady enable mouse click events'); for (i = 1; i <= nbrOfContexts; i++) { enableMouseClickEvents(i,'true'); // clipDirector.ep_invoke(i + ',,ep_enableMouseClickEvents,true'); } } for (i = 1; i <= nbrOfContexts; i++) { if (clipDirector.ep_invokeAndWait(i.toString() + ',,ep_isSecondary')) { getActorByIndex(i).invoke('readyToPlay','readyToPlay;meMgmt'); } } allContextsReady = true; //directorTrace('allContextsReady: ' + allContextsReady); if (!monitorsStarted) { // directorTrace('meMgmt.waitForAllContextsReady start monitors'); setTimeout('clipMonitor()',250); setTimeout('auditCtxPlaying()',5000); setTimeout('checkForMsgWaiting()',2000); monitorsStarted = true; } clipMsgLocalVideo = isClipLocal(); // directorTrace('meMgmt.waitForAllContextsReady READY'); // dumpStringList(getClipDescriptorList()); dumpCda(); } var lastSeg = 0; function clipMonitor() { var eventDescriptor = ''; // try // { for (var i = 1; i <= nbrOfContexts; i++) { while ((eventDescriptor = clipDirector.ep_invokeAndWait(i.toString() + ',,ep_removeEvent')) != 'null') { invoke(eventDescriptor.split(";",1),i,eventDescriptor); } } setTimeout('clipMonitor2()',200); // } // catch(err) // { // directorTrace('clipMonitor EXCEPTION: ' + err.description + '\n eventDescriptor: ' + eventDescriptor); // setTimeout('clipMonitor()',1000); // } } function clipMonitor2() { var eventDescriptor; var eventFound = true; var eventCtr = 0; while (eventFound) { eventFound = false; for (var i = 1; i <= nbrOfContexts; i++) { eventDescriptor = clipDirector.ep_invokeAndWait(i.toString() + ',,ep_removeEvent'); if (eventDescriptor != 'null') { //directorTrace('meMgmt.clipMonitor2 eventDescriptor: ' + eventDescriptor); eventFound = true; eventCtr++; invoke(eventDescriptor.split(";",1),i,eventDescriptor); } } } //if (eventCtr > 0) directorTrace('clipMonitor2' + ' eventCtr: ' + eventCtr); setTimeout('clipMonitor2()',200); } var eventDescriptorSplit = ''; var segFrameSplit = ''; var transitionRequested = true; function auditCtxPlaying() { var status = false; if (allContextsReady) { if (transitionRequested) { setTransitionRequested(false); } else { try { for (var i = 1; i <= nbrOfContexts; i++) { if (isAuditPlayState(i)) { status |= coerceCtxPlayState(i); } } } catch(err) { directorTrace('auditCtxPlaying EXCEPTION: ' + err.description); } if (!status) { status = auditAllActors(); } if (status) setTransitionRequested(true); } } setTimeout('auditCtxPlaying()',2000); } function coerceCtxPlayState(ctxId) { var status = false; if (allContextsReady) { // if (!isMsgActor(ctxId)) if (isAuditPlayState(ctxId)) { if (isContextIdle(ctxId)) { if (isContextPlaying(ctxId)) { if (!ctxPlaying[ctxId]) { pauseContext(ctxId); status = true; } } else { if (ctxPlaying[ctxId]) { if (!isPlayFromToStarting(ctxId)) { // directorTrace('meMgmt.coerceCtxPlayState play: ' + ctxId); playContext(ctxId); status = true; } } } } else { // directorTrace('meMgmt.coerceCtxPlayState ctxId not idle: ' + ctxId); } } } return status; } function isContextPlaying(ctxId) { if (!isPlaying(ctxId)) { return false; } return (clipDirector.ep_invokeAndWait(ctxId + ',,ep_isPaused') == 'false'); } function playActor(ctxId,actorName) { if (allContextsReady) { clipDirector.ep_invoke(',' + actorName + ',ep_requestPlay'); setCtxPlaying(ctxId,true); } else { directorTrace('meMgmt.playActor ctxId: ' + ctxId + ' actorName: ' + actorName + ' BLOCKED'); } } function pauseActor(ctxId,actorName) { clipDirector.ep_invoke(',' + actorName + ',ep_requestPause'); setCtxPlaying(ctxId,false); } function switchContext(actorName,fromCtx,toCtx) { directorTrace('meMgmt.switchContext' + ' actorName: ' + actorName + ' fromCtx: ' + fromCtx + ' toCtx: ' + toCtx); clipDirector.ep_invoke(',' + actorName + ',ep_switchContext,' + toCtx); setCtxPlaying(toCtx,true); setCtxPlaying(fromCtx,false); } function playClip(ctxId,vUrl,aUrl) { // directorTrace('meMgmt.playClip' + '\n ctxId: ' + ctxId + '\n vUrl: ' + vUrl + '\n aUrl: ' + aUrl); try { clipDirector.ep_invoke(ctxId + ',,ep_playClip,' + vUrl + ',' + aUrl); setCtxPlaying(ctxId,true); } catch(err) { directorTrace('playClip EXCEPTION: ' + err.description); } } function playClipWithSdl(ctxId,vUrl,aUrl,anSdl) { try { playClipFromTo(ctxId,1,0,-1,-1,false,anSdl); setCtxPlaying(ctxId,true); } catch(err) { directorTrace('playClip EXCEPTION: ' + err.description); } } function playClipFromTo(ctxId,fromSeg,fromFrame,toSeg,toFrame,pauseAtEnd,sdl) { try { clipDirector.ep_invoke(ctxId + ',,ep_playClipFromTo,' + fromSeg + ',' + fromFrame + ',' + toSeg + ',' + toFrame + ',' + pauseAtEnd + ',' + sdl); setCtxPlaying(ctxId,true); } catch(err) { directorTrace('playClipFromTo EXCEPTION: ' + err.description); } } function bufferClipFromTo(ctxId,fromSeg,fromFrame,toSeg,toFrame,pauseAtEnd,sdl) { try { clipDirector.ep_invoke(ctxId + ',,ep_bufferClipFromTo,' + fromSeg + ',' + fromFrame + ',' + toSeg + ',' + toFrame + ',' + pauseAtEnd + ',' + sdl); setCtxPlaying(ctxId,false); } catch(err) { directorTrace('bufferClipFromTo EXCEPTION: ' + err.description); alert('bufferClipFromTo EXCEPTION: ' + err.description); } } function pauseContext(ctxId) { clipDirector.ep_invoke(ctxId + ',,ep_requestPause'); if (!isMsgActor(ctxId)) { setCtxPlaying(ctxId,false); } setTransitionRequested(true); } function playContext(ctxId) { if (allContextsReady) { // directorTrace('meMgmt.playContext ctxId: ' + ctxId); clipDirector.ep_invoke(ctxId + ',,ep_requestPlay'); if (!isMsgActor(ctxId)) { setCtxPlaying(ctxId,true); } setTransitionRequested(true); } else { directorTrace('meMgmt.playContext ctxId: ' + ctxId + ' BLOCKED'); } } function stopContext(ctxId) { clipDirector.ep_invoke(ctxId + ',,ep_stop'); if (!isMsgActor(ctxId)) { setCtxPlaying(ctxId,false); } setTransitionRequested(true); } function isPlayFromToStarting(ctxId) { return false; //return (clipDirector.ep_invokeAndWait(ctxId + ',,ep_isPlayFromToStarting') == 'true'); } function directorTrace(traceText) { if (_TRACE && clipDirector && (clipDirector != null)) { try {clipDirector.ep_invoke('1,,ep_trace,' + '[JAVASCRIPT][' + getTicks() + '] ' + traceText);} //try {clipDirector.ep_trace_('[JAVASCRIPT][' + getTicks() + '] ' + traceText);} catch(err) { alert('directorTrace EXCEPTION: ' + err.description + '\n traceText: ' + traceText + '\n clipDirector: ' + clipDirector); } } } var nextMsgClip = ''; var makeMsgDivVisible = true; var msgImageDisplayed = false; function checkForMsgWaiting() { if (msgsEnabled) { if (!ctxFullScreenMode && allContextsReady) { var actorName = ''; if (isMsgWaiting()) { // if (makeMsgDivVisible && msgImageDisplayed) if (msgImageDisplayed) { // actorName = clipDirector.ep_invokeAndWait(cidMsg + ',,ep_getActorName'); // document.getElementById(actorName).style.visibility = "visible"; getActorByIndex(cidMsg).show(); makeMsgDivVisible = false; } if (isContextPlaying(cidMsg)) { showMsgDiv(); } else { hideMsgDiv(); displayImage(cidMsg,msgWaitingImageSpec); } } else { if (!isContextPlaying(cidMsg)) { hideMsgDiv(); displayImage(cidMsg,stoppedImageSpec); } } } setTimeout('checkForMsgWaiting()',2000); } } function deleteMsg() { directorTrace('deleteMsg segmentNumber: ' + cidMsgSegmentNumber); stopMsg(); db_delete(cidMsgSegmentNumber); nextMsgClip = ''; } var cidMsgSegmentNumber = 1; function isMsgWaiting() { if ((nextMsgClip.length == 0) || clipMsgLocalVideo) { if (clipMsgLocalVideo && (clipMsgDefaultNextMsg.length > 0)) { if (doesUrlExist(cidMsg,clipMsgDefaultNextMsg + "video_s1.dat")) { nextMsgClip = clipMsgDefaultNextMsg; } else { nextMsgClip = ''; } } } return (nextMsgClip.length > 0); } function showMsgDiv() { if (!clipMsgLocalVideo) { hide('recordstartdiv'); show('deletemsgdiv'); } if (isMsgWaiting()) { // var actorName = clipDirector.ep_invokeAndWait(cidMsg + ',,ep_getActorName'); // document.getElementById(actorName).style.visibility = "visible"; getActorByIndex(cidMsg).show(); makeMsgDivVisible = false; } } function hideMsgDiv() { return; if (!clipMsgLocalVideo) { hide('deletemsgdiv'); show('recordstartdiv'); } if (!isMsgWaiting()) { // var actorName = clipDirector.ep_invokeAndWait(cidMsg + ',,ep_getActorName'); // document.getElementById(actorName).style.visibility = "hidden"; getActorByIndex(cidMsg).hide(); makeMsgDivVisible = true; change_message(''); } else { change_message('Video Messaging'); } } function getNbrOfSegments(ctxId) { return parseInt(clipDirector.ep_invokeAndWait(ctxId + ',,ep_getNbrOfSegments')); } function setCtxPlaying(ctxId,state) { setTransitionRequested(true); ctxPlaying[ctxId] = state; } function stopMsg() { stopContext(cidMsg); hideMsgDiv(); } function coerceAfterStop(ctxId) { return; directorTrace('meMgmt.coerceAfterStop ctxId: ' + ctxId); eval('restartAfterStop=restartClosure(' + ctxId + '); setTimeout(restartAfterStop,1000)'); setTransitionRequested(true); } function setTransitionRequested(state) { transitionRequested = state; //directorTrace('setTransitionRequested: ' + transitionRequested); } var ctxFullScreenMode = false; function isCtxFullScreenMode() {return ctxFullScreenMode;} var restartAtInProgressTicks = 0; var restartAtStatus = false; function restartAtInProgress(ctxId,eventDescriptor) { restartAtInProgressTicks = getTicks() + 5000; restartAtStatus = true; } function restartAtComplete(ctxId,eventDescriptor) { restartAtStatus = false; restartAtInProgressTicks = 0; } function isRestartAtInProgress() { if (getTicks() > restartAtInProgressTicks) { restartAtStatus = false; } return restartAtStatus; } var msbStartTicks = (new Date()).getTime(); function getTicks() { var time = new Date(); var ticks = time.getTime(); if (msbStartTicks == 0) { msbStartTicks = ticks; } return ticks - msbStartTicks; } function restartClosure(ctxId) {return (function() {coerceCtxPlayState(ctxId);});} var restartAfterStop = null; function isMousePresent(ctxId) { return (clipDirector.ep_invokeAndWait(ctxId + ',,ep_isMousePresent') == 'true'); } function doesUrlExist(ctxId, urlSpec) { return (clipDirector.ep_invokeAndWait(ctxId + ',,ep_doesUrlExist,' + urlSpec) == 'true'); } function invoke(event,ctxId,eventDescriptor) { // try // { var anActor = getActorByIndex(ctxId); if ((anActor !== null) && (event != 'invoke')) { anActor.invoke(event,eventDescriptor); } // } // catch(err) // { // directorTrace('meMgmt.invoke EXCEPTION: ' + err.description + '\n event: ' + event + ' ctxId: ' + ctxId + ' eventDescriptor: ' + eventDescriptor); // } } function displayImage(ctxId,imageUrl) { clipDirector.ep_invoke(ctxId + ',,ep_displayImage,' + imageUrl); } function switchClip(actorName,fromHandle,toHandle) { var anActor = getActorByName(actorName); if (anActor !== null) { anActor.switchClip(actorName,fromHandle,toHandle); } } function getViewCtxId(actorName) { return (clipDirector !== null) ? (clipDirector.ep_invokeAndWait(',' + actorName + ',ep_getCurrentCtxId')) : 0; } function enableMouseClickEvents(ctxId,state) { clipDirector.ep_invoke(ctxId.toString() + ',,ep_enableMouseClickEvents,' + state); } function getPosition(ctxId,actorName) { return (clipDirector.ep_invokeAndWait(ctxId + ',' + actorName + ',ep_getPosition')); } function getLastSliderPosition(ctxId,actorName) { return (clipDirector.ep_invokeAndWait(ctxId + ',' + actorName + ',ep_getLastSliderPosition')); } function preload() { jActorInit(0,'preload',0,0,'preload'); } function beep() { if (clipDirector !== null) { clipDirector.ep_invoke('1,,ep_beep'); } } function clearEventQueue(ctxId) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_clearEventQueue'); } function abortContext(ctxId) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_abort'); if (!isMsgActor(ctxId)) { setCtxPlaying(ctxId,false); } setTransitionRequested(true); } function resetAllClips() { clipDirector.ep_invokeAndWait('1,,ep_resetAllClips'); } function isContextIdle(ctxId) { return (clipDirector != null) ? (clipDirector.ep_invokeAndWait(ctxId + ',,ep_isTransitionInProgress') == 'false') : true; } function clearInvokeQueue(ctxId) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_clearInvokeQueue'); } function isContextRestarting(ctxId) { return (clipDirector != null) ? (clipDirector.ep_invokeAndWait(ctxId + ',,ep_isRestarting') == 'true') : false; } function isContextSwitching(ctxId) { return (clipDirector.ep_invokeAndWait(ctxId + ',,ep_isContextSwitching') == 'true'); } function isPlaying(ctxId) { return (clipDirector.ep_invokeAndWait(ctxId + ',,ep_isPlaying') == 'true'); } function playing(ctxId) { return (clipDirector.ep_invokeAndWait(ctxId + ',,ep_playing') == 'true'); } function clearBackground(ctxId) { clipDirector.ep_invoke(ctxId + ',,ep_clearBackground'); } function resetContext(ctxId) { if (clipDirector != null) { clipDirector.ep_invoke(ctxId + ',,ep_reset'); } } function isContextStopped(ctxId) { return (clipDirector != null) ? (clipDirector.ep_invokeAndWait(ctxId + ',,ep_isStopped') == 'true') : true; } function getVideoFps(ctxId) { return parseInt(clipDirector.ep_invokeAndWait(ctxId + ',,ep_getVideoFps')); } function getLastRawRecNum(ctxId,segment) { var lrn = clipDirector.ep_invokeAndWait(ctxId + ',,ep_getLastRawRecNum,' + segment); // directorTrace('meMgmt.getLastRawRecNum' + // ' ctxId: ' + ctxId + // ' segment: ' + segment + // ' lastRawRecNum: ' + lrn); return parseInt(lrn); } function getLastRecNum(ctxId,segment) { return clipDirector.ep_invokeAndWait(ctxId + ',,ep_getLastRecNum,' + segment); } function getRecNumRatio(ctxId,segment) { var actualAndRawRecNum = getLastRecNum(ctxId,segment); // directorTrace('meMgmt.getRecNumRatio' + ' ctxId: ' + ctxId + ' segment: ' + segment + ' actualAndRaw: ' + actualAndRawRecNum); var actualRecNum = parseInt(actualAndRawRecNum.split(',')[0]); var rawRecNum = parseInt(actualAndRawRecNum.split(',')[1]); var ratio = 1; if (actualRecNum > 0) { ratio = rawRecNum/actualRecNum; } // directorTrace('meMgmt.getRecNumRatio' + ' ctxId: ' + ctxId + ' segment: ' + segment + ' actualAndRaw: ' + actualAndRawRecNum + ' actual: ' + actualRecNum + ' raw: ' + rawRecNum + ' ratio: ' + ratio); return ratio; } function isClipLocal() { return (location.href.indexOf('file:') != -1); //alert('meMgmt.isClipLocal clipDirector: ' + clipDirector); //return (clipDirector != null) ? (clipDirector.ep_invokeAndWait('1,,ep_isClipLocal') == 'true') : false; } /** * @fileoverview This class manages Applet lifecycle and display behaviours * * * * * */ function AppletManager() { var that = this; var queue = new Array(); var state = "blocked" ; var processqueuetimeout = null; var appletlist = new Array(); this.eventapplets = new Array(); /** * * This property determines the install location on the users system. * */ this.appfolder = '${user.home}/eviewEngine'; if("undefined" == typeof AppletManager.instance) { AppletManager.instance = this; // define the singleton } if(this != AppletManager.instance) return AppletManager.instance; // return the singleton if it already exists /** * * @private * @see ParameterManager */ this.PMgr = ParameterManager; // From ParameterManager.js (JavaScript file) this.PMgr("applets"); /** * Sets internal state for applet creation. * @private * */ this.setState = function (_state) { state = _state; } /** * * Set the file path for Applets with installable files. * @param {String} path The file path where to install dependent files. * */ this.setAppFolder = function (path) { this.appfolder = path; } /** * * * */ this.startApplet = function() { var appletSpecInstance; var callbackMethod; var target = null; if (arguments.length == 2) { appletSpecInstance = arguments[0]; callbackMethod = arguments[1]; } else if (arguments.length == 3) { appletSpecInstance = arguments[0]; callbackMethod = arguments[1]; target = arguments[2]; } else { return false; } appletSpecInstance.addParameter("APP_FOLDER",this.appfolder); var name = appletSpecInstance.getParameter("applet","name"); appletlist[appletlist.length] = name; this.defineParameter("applets", name, "value", ""); this.setProperty("applets",name,"callback",callbackMethod); this.setProperty("applets",name,"appletspec",appletSpecInstance); if (target != null) { this.setProperty("applets",name,"targetTag",target); } queue.push(name); if (processqueuetimeout == null) { setTimeout(function() { processQueue(); },100); // TODO: Research this problem that requires this timeout. Falied on R-Systems machines. } return true; } this.destroyApplet = function(_name) { try { if (typeof this.getProperty("applets",_name,"targetTag") != "undefined") { var parent = document.getElementById(this.getProperty("applets",_name,"targetTag")); var child = document.getElementById(this.getProperty("applets",_name,"positionElement")); parent.removeChild(child); } var container = document.getElementById(this.getProperty("applets",_name,"containerElement")); document.body.removeChild(container); if(typeof that.getProperty("applets",_name,"validator") != "undefined") { clearInterval(that.getProperty("applets",_name,"validator")); } this.removeParameter("applets",_name); } catch (err) { alert("AppletManager.destroyApplet EXCEPTION: " + err.message); return false; } return true; } this.setDisplay = function(applet_name, display) { this.setProperty("applets",applet_name,"display",display); } this.getDisplay = function(applet_name) { return this.getProperty("applets",applet_name,"display"); } this.setVisibility = function(applet_name, visible) { this.setProperty("applets",applet_name,"visible",visible); } this.getVisibility = function(applet_name) { return this.getProperty("applets",applet_name,"visible"); } this.resize = function(applet_name, width, height) { this.setProperty("applets",applet_name,"height",height); this.setProperty("applets",applet_name,"width",width); //this.getApplet(applet_name).height = height; //this.getApplet(applet_name).width = width; this.getApplet(applet_name).ep_setSize(width,height); } this.setHeight = function(applet_name, height) { this.setProperty("applets",applet_name,"height",height); this.getApplet(applet_name).height = height; } this.setWidth = function(applet_name, width) { this.setProperty("applets",applet_name,"width",width); this.getApplet(applet_name).width = width; } //Function to retrieve the height this.getHeight = function(applet_name) { return this.getProperty("applets",applet_name,"height"); } //Function to retrieve the Width this.getWidth = function(applet_name) { return this.getProperty("applets",applet_name,"width"); } function processQueue() { processqueuetimeout = null; if (state == 'blocked') { processqueuetimeout = setTimeout(function() { processQueue() },50); return; } else if (state == 'busy') { processqueuetimeout = setTimeout(function() { processQueue() },50); return; } else if (queue.length == 0) { state = 'idle'; return; } state = 'busy'; var name = queue.shift(); var appspec1 = that.getProperty("applets",name,"appletspec"); that.setProperty("applets",name,"positionElement",that.getUniqueElementID()); that.setProperty("applets",name,"containerElement",that.getUniqueElementID()); var show = that.getProperty("applets",name,"appletspec").getParameter("applet","visible"); if (show == "true") { that.setProperty("applets",name,"visible",true); } else { that.setProperty("applets",name,"visible",false); } that.setProperty("applets",name,"height",appspec1.getParameter("height")); that.setProperty("applets",name,"width",appspec1.getParameter("width")); var containerElement = document.createElement("metag"); containerElement.id = that.getProperty("applets",name,"containerElement"); document.body.appendChild(containerElement); containerElement.style.position = "absolute"; containerElement.style.top = -(that.getHeight(name) - 1); containerElement.style.left = -(that.getWidth(name) -1); if (typeof that.getProperty("applets",name,"targetTag") != "undefined") { if (document.getElementById(that.getProperty("applets",name,"targetTag")) == null) {alert('AppletManager.processQueue cannot find element name: ' + name);return;} var positionElement = document.createElement("div"); positionElement.id = that.getProperty("applets",name,"positionElement"); document.getElementById(that.getProperty("applets",name,"targetTag")).appendChild(positionElement); if (that.getDisplay(name)) { positionElement.style.height = that.getHeight(name) + "px"; positionElement.style.width = that.getWidth(name) + "px"; } else { positionElement.style.height = "0px"; positionElement.style.width = "0px"; } } that.getProperty("applets",name,"appletspec").startApplet(that.getProperty("applets",name,"containerElement")); } this.handleLifeCycle = function(appletID, name, elementType) { if (typeof this.getParameter(name) != "undefined") { this.setProperty("applets",name,"appletID",appletID); this.setProperty("applets",name,"elementType",elementType); setTimeout("AppletManager.theInstance().doCallback('" + name + "');",100); this.getApplet(name).height = this.getHeight(name); this.getApplet(name).width = this.getWidth(name); var containerElement = document.getElementById(that.getProperty("applets",name,"containerElement")); var appspec1 = that.getProperty("applets",name,"appletspec"); containerElement.style.top = -(appspec1.getParameter("height") + 10); containerElement.style.left = -(appspec1.getParameter("width") + 10); if (typeof that.getProperty("applets",name,"targetTag") != "undefined") { MeAddEvent(window, 'resize', function() { AppletManager.theInstance().validateLater(name);}); var positionElement = document.getElementById(that.getProperty("applets",name,"positionElement")); setEvents(positionElement,name); this.eventapplets[this.eventapplets.length] = name; this.setProperty("applets",name,"validatestatus",false); /* if (containerElement.style.setExpression) { var positionElement = document.getElementById(that.getProperty("applets",name,"positionElement")); positionElement.onmove = "AppletManager.theInstance().validate('" + name + "');"; positionElement.onpropertychange = "AppletManager.theInstance().validate('" + name + "');"; positionElement.onlayoutcomplete = "AppletManager.theInstance().validate('" + name + "');"; } else { var tm = setInterval("AppletManager.theInstance().validate('" + name + "')",1000); that.setProperty("applets",name,"validator",tm); } */ } state = "idle"; if (processqueuetimeout == null) { setTimeout(function() { processQueue()},100);} } else { //Error Condition } } this.doCallback = function(name) { if (this.getProperty("applets",name,"callback") !== null) { this.getProperty("applets",name,"callback")(this.getApplet(name)); } } this.getApplet = function (name) { var id = this.getProperty("applets",name,"appletID"); if (id != '') { if((instance = eval("document." + id))) { } else if (document.all) { instance = document.all(id); } else if (document.getElementById) { instance = document.getElementById(id); } return instance; } else { return false; } } this.getUniqueElementID = function () { var tmp = ""; do { tm = new Date(); //hex_md5() - From md5.js (JavaScript File) tmp = "div" + hex_md5(String((Math.random()) * tm.getTime())); } while(document.getElementById(tmp)); return tmp; } this.getAbsoluteLeft = function(objectId) { // Get an object left position from the upper left viewport corner // Tested with relative and nested objects o = document.getElementById(objectId) oLeft = o.offsetLeft // Get left position from the parent object if (o.offsetParent !== null) { while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element oParent = o.offsetParent // Get parent object reference if (o.clientLeft) { oLeft += oParent.offsetLeft + o.clientLeft; } else { oLeft += oParent.offsetLeft // Add parent left position } o = oParent } // Return left postion return oLeft; } else { return "error"; } } this.getAbsoluteTop = function(objectId) { // Get an object top position from the upper left viewport corner // Tested with relative and nested objects o = document.getElementById(objectId) oTop = o.offsetTop // Get top position from the parent object if (o.offsetParent !== null) { while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element oParent = o.offsetParent // Get parent object reference if (o.clientTop) { oTop += oParent.offsetTop + o.clientTop // Add parent top position } else { oTop += oParent.offsetTop // Add parent top position } o = oParent } // Return top position return oTop; } else { } return "error"; } this.validate = function() { var applet_name; if (arguments.length == 1) { applet_name = arguments[0]; if (typeof this.getParameter(applet_name) != "undefined") { var positionElementID = this.getProperty("applets",applet_name,"positionElement"); var containerElementID = this.getProperty("applets",applet_name,"containerElement"); var positionElement = document.getElementById(positionElementID); var containerElement = document.getElementById(containerElementID); var state = 'visible'; if (this.getDisplay(applet_name) == false) { state = 'hidden'; } else if (this.getVisibility(applet_name) == false) { state = 'none'; } else if (getElementDisplay(positionElement) == false) { state = 'none'; } else if (getStyle(positionElement,"visibility") != "visible") { state = 'hidden'; } //debugout("AppletManager.validate('" + applet_name + "')","","state: " + state); if (state == 'visible') { var positionElement = document.getElementById(positionElementID); var containerElement = document.getElementById(containerElementID); positionElement.style.height = this.getHeight(applet_name) + "px"; positionElement.style.width = this.getWidth(applet_name) + "px"; var atop = this.getAbsoluteTop(positionElementID); var aleft = this.getAbsoluteLeft(positionElementID); if (!isNaN(atop)) { containerElement.style.top = atop; } if (!isNaN(aleft)) { containerElement.style.left = aleft; } positionElement.style.height = this.getHeight(applet_name) + "px"; positionElement.style.width = this.getWidth(applet_name) + "px"; } else if (state == 'hidden') { containerElement.style.top = -(this.getHeight(applet_name) + 10); containerElement.style.left = -(this.getWidth(applet_name) + 10); positionElement.style.height = this.getHeight(applet_name) + "px"; positionElement.style.width = this.getWidth(applet_name) + "px"; } else if (state == 'none') { containerElement.style.top = -(this.getHeight(applet_name) + 10); containerElement.style.left = -(this.getWidth(applet_name) + 10); positionElement.style.height = "0px"; positionElement.style.width = "0px"; } setTimeout("AppletManager.theInstance().setValidateStatus('" + applet_name + "',false)",1); } } else { //alert(this.eventapplets.join('|')); /* try { for(var i = 0;i < this.eventapplets.length - 1;i++) { setTimeout("AppletManager.theInstance().validateLater('" + this.eventapplets[i] + "')",500); } return true; } catch(e) { return false; } */ } } function getStyle(el,styleProp) { var x = el; if (x.currentStyle) var y = x.currentStyle[styleProp]; else if (window.getComputedStyle) var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp); //window.status = styleProp + ' = ' + y; if (y == "inherit") { y = getStyle(x.parentNode,styleProp); } return y; } function getElementDisplay(el) { var display = true; while(el.parentNode) { if (el.currentStyle) { if (el.currentStyle['display'] == 'none') { display = false; } } else if (window.getComputedStyle) { if (document.defaultView.getComputedStyle(el,null).getPropertyValue('display')){ display = false; } } if (!display) { break; } el = el.parentNode; } return display; } function setEvents(el,name) { while(el.parentNode) { // Parse the parent hierarchy up to the document element MeAddEvent(el, 'propertychange', function() { AppletManager.theInstance().validateLater(name); } ); if (el.onresizeend) { MeAddEvent(el, 'resizeend', function() { AppletManager.theInstance().validateLater(name); } ); } else { MeAddEvent(el, 'resize', function() { AppletManager.theInstance().validateLater(name); } ); } var sib = el.nextSibling; while(sib) { MeAddEvent(sib, 'propertychange', function() { AppletManager.theInstance().validateLater(name); } ); if (el.onresizeend) { MeAddEvent(el, 'resizeend', function() { AppletManager.theInstance().validateLater(name); } ); } else { MeAddEvent(el, 'resize', function() { AppletManager.theInstance().validateLater(name); } ); } sib = sib.nextSibling; } elParent = el.parentNode // Get parent object reference el = elParent } return true; } this.validateLater = function(name) { if (this.getDisplay(name) == true || this.getVisibility(name) == true) { if (this.getValidateStatus(name) === false) { this.setValidateStatus(name,true); setTimeout("AppletManager.theInstance().validate('" + name + "');",1); } } } this.getValidateStatus = function(name) { return this.getProperty("applets",name,"validatestatus"); } this.setValidateStatus = function(name,status) { this.setProperty("applets",name,"validatestatus",status); } } // End of AppletManager AppletManager.theInstance = function(){ if("undefined" == typeof AppletManager.instance){ return new AppletManager(); } return AppletManager.instance; } MeAddEvent(window, 'load', function() { AppletManager.theInstance().setState('idle');}); function HostingAgent() { var that = this; if("undefined" == typeof HostingAgent.instance) { HostingAgent.instance = this; // define the singleton } if(this != HostingAgent.instance) return HostingAgent.instance; // return the singleton if it already exists var tm = null; var state = "blocked"; var queue = new Array(); var uploadRequest = null; // in process upload request holder var url = EVME_HOSTING_PATH; var namespace = "default"; var error = ""; var maxSize = 0; var progess = 0; var hostSize = 0; var nsCount = 0; var nsProCount = 0; var ProResCount = 0; this.http = HttpRequest; this.http(); var uploadApplet = null; // *** function getHostURL for testing this.getHostURL = function () { return url; } // *** function setHostURL this.setHostURL = function (_url) { if (this.isValidURL(_url)) { url = _url; return true; } else { return false; } } // *** function getNamespace for testing this.getNamespace = function () { return namespace; } // *** function setNamespace this.setNamespace = function (_namespace) { namespace = _namespace; return true; } // function createNamespace this.createNamespace = function (_namespace) { if (url != null) { var response = this.sendRequest("GET", url, Array("action=createNamespace","name=" + _namespace), false); if (response != "" && response != null) { try { return JSON.parse(response)['ACTIONSTATUS']; } catch(err) { alert("HostingAgent.createNamespace EXCEPTION: " + err.message); return false; } } else { return false; } } else { return false; } } // function renameNamespace (currentName,newName) this.renameNamespace = function () { var curName; var newName; if (arguments.length == 1) { curName = namespace; newName = arguments[0]; } else if (arguments.length == 2) { curName = arguments[0]; newName = arguments[1]; } else { return false; } if (url != null) { var response = this.sendRequest("GET", url, Array("action=renameNamespace","name=" + curName,"newname=" + newName), false); if (response != "" && response != null) { try { return JSON.parse(response)['ACTIONSTATUS']; } catch(err) { alert("HostingAgent.renameNamespace EXCEPTION: " + err.message); return false; } } else { return false; } } else { return false; } } // function deleteNamespace this.deleteNamespace = function () { var ns = ""; if (arguments.length == 1) { ns = arguments[0]; } else if (arguments.length == 0) { ns = this.getNamespace(); } if (url != null) { var response = this.sendRequest("GET", url,Array("action=deleteNamespace","name=" + ns), false); if (response != "" && response != null) { try { return JSON.parse(response)['ACTIONSTATUS']; } catch(err) { alert("HostingAgent.deleteNamespace EXCEPTION: " + err.message); return false; } } else { return false; } } else { return false; } } // TODO: NOT YET IMPELMENTED this.getMaxPostSize = function (_size) { return maxSize; } // TODO: NOT YET IMPELMENTED this.setMaxPostSize = function (_size) { if (isNaN(_size) || (_size > 1024)) { return false; } else { maxSize = _size; } } this.deleteProject = function () { var _path = ''; var ns = ''; if (arguments.length == 1) { _path = arguments[0]; ns = this.getNamespace(); } else if (arguments.length == 2) { ns = arguments[0]; _path = arguments[1]; } else { return false; } if (url != null) { target = url + ns + "/" + _path + "/"; var response = this.sendRequest("GET", target, Array("action=deleteProject"), false); if (response != "" && response != null) { try { return JSON.parse(response)['ACTIONSTATUS']; } catch(err) { alert("HostingAgent.deleteProject EXCEPTION: " + err.message); return false; } } else { return false; } } else { return false; } } // function renameProject this.renameProject = function () { var ns = ''; var newPath = ''; var oldPath = ''; if (arguments.length == 2) { oldPath = arguments[0]; newPath = arguments[1]; ns = this.getNamespace(); } else if (arguments.length == 3) { ns = arguments[0]; oldPath = arguments[1]; newPath = arguments[2]; } else { return false; } if (url != null) { target = url + ns + "/" + oldPath + "/"; var response = this.sendRequest("GET", target, Array("action=renameProject","newpath=" + newPath), false); if (response != "" && response != null) { try { return JSON.parse(response)['ACTIONSTATUS']; } catch(err) { alert("HostingAgent.renameProject EXCEPTION: " + err.message); return false; } } else { return false; } } else { return false; } } this.upload = function (_uploadRequest) { meLogger.write("Hosting Agent upload called."); if (!_uploadRequest) {return false;}; // empty upload request rejected!! if (url != null) { if (uploadApplet == null && tm == null) { var appSpec = new AppletSpec("uploader"); appSpec.setParameter("name","uploadApplet"); appSpec.setParameter("visible",false); AppletManager.theInstance().startApplet(appSpec,setAppletReadyState); } //meLogger.write("Url valid."); queue.push(_uploadRequest); //will get progress if (tm == null) { tm = setTimeout(processQueue, 50); } return true; // successfully posted request } else { return false; // unable to post request } } function setAppletReadyState(applet) { uploadApplet = applet; //alert(uploadApplet); setState('idle'); } function processQueue() { tm = null; meLogger.write("ProcessQueue: " + state); if (state == 'blocked') { tm = setTimeout(processQueue,50); return; } else if (state == 'busy') { tm = setTimeout(processQueue,50); return; } else if (queue.length == 0) { setState('idle'); return; } // must be idle and queue.length > 0; so process a request setState('busy'); uploadRequest = queue.shift(); var params = "action,upload,default," + uploadRequest.getMappedName(); var mfiles = uploadRequest.getManifestFiles(); meLogger.write("Number of files to be read :" + mfiles.length); for (var i = 0; i < mfiles.length; i++) { var buffer = mfiles[i].split('|'); if(i == 0) { tmp = buffer[0]; } else { tmp += "," + buffer[0]; } } files = tmp; target = url + escape(uploadRequest.getNameSpace()) + "/" + escape(uploadRequest.getName()) + "/"; meLogger.write("Target: " + target + " File: " + files + " Params: " + params); setState("uploading"); uploadApplet.ep_upload(target,files,params); meLogger.write('Upload started ....'); queryState(); //uploadApplet.ep_upload("http://sandbox2.espre.local:9002/hosting/test/jvo/","C:/Documents and Settings/jvo.ESPRE/eViewEngine/video.dat","action,upload"); } // add callback functions for status, progress, etc. function queryState() { uploadTimeout = null; var currentState = uploadApplet.ep_getUploadState(); meLogger.write("Query State: " + currentState + " " + that.getProgress() + "%"); if (currentState == "uploading") { uploadRequest.updateProgress(that.getProgress()); uploadTimeout = window.setTimeout(queryState,500); return; } if (currentState == "completed") { uploadRequest.updateProgress(that.getProgress()); setState(currentState); uploadRequest = null; } else if (currentState == "errored") { uploadRequest.setErrors(that.getErrors()); uploadRequest.updateProgress(that.getProgress()); setState(currentState); uploadRequest = null; } } this.getProgress = function(){ if(state == "uploading") { return (uploadApplet.ep_getProgress()); } if(state == "completed") return 100; return 0; } this.getErrors = function(){ if(state == "errored") return uploadApplet.ep_getErrors(); return ""; } this.isCompleted = function(){ if(uploadRequest == null && state == "completed") return true; return false; } this.isUploading = function(){ if(uploadRequest != null) return true; return false; } this.isError = function(){ if(uploadRequest == "errored") return true; return false; } //************************************************ /* this.getHostingInfo = function () { if (url === null) return false; param = new Array("action=query","ns.where.name==*","ns.columns=*","ns.created.show=true"); this.sendRequest("POST", url, param, "undefined", false); return this.responseText.parseJSON(); //return this.responseText; // for testing } this.getHostingInfoDetail = function () { if (url === null) return false; if (_namespace != null) { param = new Array("action=query","ns.where.name==*","ns.columns=*","ns.create.show=true","ns.detail.show=true"); } else { param = new Array("action=query","","ns.columns=*","ns.create.show=true","ns.detail.show=true"); } this.sendRequest("POST", url, param, "undefined", false); return this.responseText.parseJSON(); //return this.responseText; // for testing } */ this.getNamespaceList = function () { if (url === null) return false; var response = this.sendRequest("GET", url, Array("action=query","ns.columns=name"), false); if (response != "" && response != null) { try { var data = JSON.parse(response); if (data['ACTIONSTATUS'] == true) { return data['RESPONSEDATA']; } else { return null; } } catch(err) { alert("HostingAgent.getNamespaceList EXCEPTION: " + err.message); return null; } } else { return null; } } //getNamespaceInfo(String name) ?? should be namespace list? //the request to the server needs to look like this: //param = "action=query,ns.where.name=" + escape("=" + name) + ",ns.columns=*,ns.created.show=true"); //HTTPRequest.sendRequest("POST", url, param, "undefined", false); /* this.getNamespaceInfo = function (_namespace) { if (url === null) return false; if (_namespace != null) { param = new Array("action=query","ns.where.name==" + _namespace,"ns.columns=*","ns.create.show=true"); } else { param = new Array("action=query","ns.where.name==" + this.getNamespace(),"ns.columns=*","ns.create.show=true"); } this.sendRequest("POST", url, param, "undefined", false); return this.responseText.parseJSON(); //return this.responseText; // for testing } this.getNamespaceCount = function (_namespace) { if (url === null) return false; if (!_namespace) return false; param = new Array("action=query","","ns.name.show=false","ns.created.show=false"); this.sendRequest("POST", url, param, "undefined", false); for (var i = 0; i < this.getNamespaceList().length; i++){ nsCount++; } return nsCount; //return this.responseText; } this.getNamespaceInfoDetail = function (_namespace) { if (url === null) return false; if (_namespace != null) { param = new Array("action=query","ns.where.name==" + _namespace,"ns.columns=*","ns.create.show=true","ns.detail.show=true"); } else { param = new Array("action=query","","ns.columns=*","ns.create.show=true","ns.detail.show=true"); } this.sendRequest("POST", url, param, "undefined", false); //return this.responseText.parseJSON(); return this.responseText; // for testing } */ this.getDefaultFile = function () { var _namespace = "default"; var _groupname; if(arguments.length == 0) return ""; //BAD!! if(arguments.length == 1) { _groupname = arguments[0]; } else { _namespace = arguments[0]; _groupname = arguments[1]; } var requestUrl = url; if (url === null) return ""; requestUrl += _namespace + "/" + _groupname + "/"; var param = new Array(""); return this.sendRequest("GET", requestUrl, param, false); //return this.responseText; } /* // Don's initiative codes this.getNamespaceProjectsList = function () { if (url === null) return false; if (arguments.length == 1) { param = new Array("action=query","ns.where.name==" + arguments[0],"group.columns=*","ns.columns=*"); } else { param = new Array("action=query","ns.where.name==default","group.columns=*","ns.columns=*"); } this.sendRequest("POST", url, param, "undefined", false); return this.responseText.parseJSON(); } */ this.getProjectList = function () { var ns = ''; if (arguments.length == 0) { ns = this.getNamespace(); } else if (arguments.length == 1) { ns = arguments[0]; } else { return false; } if (url === null) return false; target = url + ns + "/"; var response = this.sendRequest("GET", target, Array("action=query","ns.columns=*","ns.where.name=='" + ns + "'","group.columns=*"), false); if (response != "" && response != null) { try { var data = JSON.parse(response); if (data['ACTIONSTATUS'] == true) { return data['RESPONSEDATA']; } else { return null; } } catch(err) { alert("HostingAgent.getProjectList EXCEPTION: " + err.message); return null; } } else { return null; } } this.getMatchingProjectList = function () { var ns = ''; var path = ''; if (arguments.length == 1) { ns = this.getNamespace(); path = arguments[0] } else if (arguments.length == 2) { ns = arguments[0]; path = arguments[1] } else { return false; } if (url === null) return false; target = url + ns + "/" + path + "/"; var response = this.sendRequest("GET", target, Array("action=query","ns.where.name=='" + ns +"'","group.where.fqpath=LIKE '" + path + "'","group.columns=*"), false); if (response != "" && response != null) { try { var data = JSON.parse(response); if (data['ACTIONSTATUS'] == true) { return data['RESPONSEDATA']; } else { return null; } } catch(err) { alert("HostingAgent.getMatchingProjectList EXCEPTION: " + err.message); return null; } } else { return null; } } /* this.getNamespaceProjectsCount = function (_namespace) { if (url === null) return false; if (_namespace != null) { param = new Array("action=query","ns.where.name==" + _namespace,"group.*.show=false","ns.*.show=false"); } else { param = new Array("action=query","ns.where.name==default","group.*.show=false","ns.*.show=false"); } this.sendRequest("POST", url, param, "undefined", false); //return this.responseText.parseJSON(); //parseJSON() gives error return this.responseText; } this.getProjectInfo = function (_project) { if (url === null) return false; if (_project != null) { param = new Array("action=query","proj.name.where==" + _proj,"ns.columns=*","proj.create.show=true"); } else { param = new Array("action=query","","proj.name.show=true","proj.create.show=true"); } this.sendRequest("POST", url, param, "undefined", false); //return this.responseText.parseJSON(); return this.responseText; // for testing } this.getProjectInfoDetail = function (_project) { if (url === null) return false; if (_project != null) { param = new Array("action=query","proj.name.where==" + _proj,"ns.columns=*","proj.create.show=true"); } else { param = new Array("action=query","","proj.name.show=true","proj.create.show=true"); } this.sendRequest("POST", url, param, "undefined", false); //return this.responseText.parseJSON(); return this.responseText; // for testing } */ this.getProjectResourceList = function () { var ns = ''; var path = ''; if (arguments.length == 1) { ns = this.getNamespace(); path = arguments[0]; } else if (arguments.length == 2) { ns = arguments[0]; path = arguments[1]; } else { return false; } if (url === null) return false; target = url + ns + "/" + path + "/"; var response = this.sendRequest("GET", url, Array("action=query","ns.where.name=='" + ns + "'","group.where.fqpath=='" + path + "'","resource.columns=name"), false); if (response != "" && response != null) { try { var data = JSON.parse(response); if (data['ACTIONSTATUS'] == true) { return data['RESPONSEDATA']; } else { return null; } } catch(err) { alert("HostingAgent.getProjectResourceList EXCEPTION: " + err.message); return null; } } else { return null; } } /* this.getProjectResourceCount = function (proPath) { if (this.isValidURL(url) == false) { return false; } else { for (var i = 0; i < proPath.length; i++) { proResCount++; } return proResCount; } } this.getResourceInfo = function (resList) { //var resList = new Array(); if (this.isValidURL(url) == false) { return false; } else { for (var i = 0; i < proj.length; i++) { resList[i] = new Array( new Array("resource", resource) ); } return resList; } } this.getResourceInfoDetail = function (resList) { //var resListDet = new Array(); if (this.isValidURL(url) == false) { return false; } else { for (var i = 0; i < resList.length; i++) { resListDetail[i] = new Array( new Array("project", resource), new Array("desc", "description"), new Array("detail", "detail") ); } return resListDetail; } } */ function setState(_state){ var oldState = state; if (_state != state){ state = _state; if(uploadRequest != null){ uploadRequest.updateState(state); } meLogger.write('HostingAgent: '+ oldState + ' -> ' + state); } } } // End of Hosting Agent HostingAgent.theInstance = function(){ if("undefined" == typeof HostingAgent.instance){ new HostingAgent(); } return HostingAgent.instance; } // SdlWriter.js function SdlWriter(myActor) { this.myActor = (myActor) ? myActor : null; this.myName = myActor.getName(); /* this.myElementId = this.myName + 'element'; // Don Smith: Not Needed. Applet Manager will handle. this.myAppletName = this.myName + 'applet'; */ var that = this; this.appspec = null; this.applet = null; this.myAppletStarted = false; this.videoFile = null; this.audioFile = null; this.codeBase = null; this.writeInProgress = false; this.isWriteInProgress = function() { return this.writeInProgress; } this.getVideoFile = function() // USER API { return this.videoFile; } this.setVideoFile = function(videoFile) // USER API { if (this.writeInProgress) { //alert('SdlWriter already in-progress'); // Don Smith: Souldn't we return false here instead of popping an alert? return false; } this.videoFile = null; if (videoFile && isString(videoFile) && (videoFile.length > 0)) { var endOfVideoFile = videoFile.lastIndexOf('.dat'); if (endOfVideoFile != -1) { this.videoFile = videoFile.substring(0,endOfVideoFile); if (this.codeBase == null) { this.codeBase = videoFile.substring(0,videoFile.lastIndexOf('/') + 1); } if (this.audioFile == null) { this.audioFile = this.codeBase + 'audio_s1'; } } else { //alert('SdlWriter.setVideoFile videoFile INVALID:' + videoFile); // Don Smith: Souldn't we return false here instead of popping an alert? return false; } } else { //alert('SdlWriter.setVideoFile videoFile INVALID:' + videoFile); // Don Smith: Souldn't we return false here instead of popping an alert? return false; } } this.getAudioFile = function() // USER API { return this.audioFile; } this.setAudioFile = function(audioFile) // USER API { if (this.writeInProgress) { //alert('SdlWriter already in-progress'); // Don Smith: Souldn't we return false here instead of popping an alert? return false; } this.audioFile = null; if (audioFile && isString(audioFile) && (audioFile.length > 0)) { var endOfAudioFile = audioFile.lastIndexOf('.dat'); if (endOfAudioFile != -1) { this.audioFile = audioFile.substring(0,endOfAudioFile); if (this.codeBase == null) { this.codeBase = audioFile.substring(0,audioFile.lastIndexOf('/') + 1); } if (this.videoFile == null) { this.videoFile = this.codeBase + 'video_s1'; } } else { //alert('SdlWriter.setAudioFile audioFile INVALID:' + audioFile);// Don Smith: Souldn't we return false here instead of popping an alert? return false; } } else { //alert('SdlWriter.setAudioFile audioFile INVALID:' + audioFile); // Don Smith: Souldn't we return false here instead of popping an alert? return false; } } this.startSdlWriter = function() // USER API { if (this.writeInProgress) { //alert('SdlWriter already in-progress'); return false; // Don Smith: Souldn't we return false here instead of popping an alert? } //directorTrace('SdlWriter.startSdlWriter\n' + this.sdlWriterToString()); var _this = this; if (this.videoFile != null) { this.writeInProgress = true; //enableHourGlass(); /* * Don Smith: Should we continue supporting this as user feedback? * No other code does so, plus it takes control of presentation which is a no-no. */ if (!this.myAppletStarted) { this.createSdlWriterApplet(); } setTimeout(monitorSdlWriteBegin,2000); } else { //alert('SdlWriter.createSdlWriter videoFile NULL');// Don Smith: Souldn't we return false here instead of popping an alert? return false; } } this.createSdlWriterApplet = function() { if (false) directorTrace('SdlWriter.createSdlWriterApplet' + ' videoFile: ' + this.videoFile + ' audioFile: ' + this.audioFile); //if (this.appspec !== null) { //directorTrace('SdlWriter.createSdlWriterApplet CREATING SDL APPLET'); this.appspec = new AppletSpec('sdlWriter'); //this.applet.archive = archiveList; this.appspec.setParameter('name','sdlWriter'); this.appspec.setParameter("visible", "false"); this.appspec.scriptable = 'true'; this.appspec.mayscript = 'true'; this.appspec.addParameter('autoplay','true'); this.appspec.addParameter('sdlAudio','true'); this.appspec.addParameter('initialMute','true'); this.appspec.addParameter('url',this.videoFile); this.appspec.addParameter('urlAudio',this.audioFile); this.appspec.addParameter('codeBaseOverride',this.codeBase); //} AppletManager.theInstance().startApplet(this.appspec, setSdlApplet); //this.myAppletStarted = true; // Will be set by Applet Manager once Applet is started. //directorTrace('SdlWriter.createSdlWriterApplet SDL APPLET CREATED'); } function setSdlApplet(_applet) { that.applet = _applet; that.myAppletStarted = true; } function monitorSdlWriteBegin(args) { //var _this = this; //var swa = this.getSdlWriterApplet(); if (!that.myAppletStarted) { setTimeout(monitorSdlWriteBegin,2000); return;} var swa = that.applet; if (swa.ep_getState) { if (swa.ep_isSdlReadyToWrite() == 'true') { //directorTrace('SdlWriter.monitorSdlWriteBegin SDL WRITE BEGIN'); swa.ep_updateLocalSdl(); setTimeout(monitorSdlWriteComplete,2000); return; } else { directorTrace('SdlWriter.monitorSdlWriteBegin sdl write NOT READY'); } } else { directorTrace('SdlWriter.monitorSdlWriteBegin APPLET NOT READY'); } setTimeout(monitorSdlWriteBegin,2000); } function monitorSdlWriteComplete(args) { if (!that.myAppletStarted) { setTimeout(monitorSdlWriteComplete,2000); return;} var swa = that.applet; if (swa.ep_isSdlWriteComplete() == 'true') { //directorTrace('SdlWriter.monitorSdlWriteComplete SDL WRITE COMPLETE'); swa.ep_stop(); if (that.myActor != null) { that.myActor.invoke('sdlWriteComplete','sdlWriteComplete;SdlWriter.monitorSdlWriteComplete'); } that.resetSdlWriter(); that.writeInProgress = false; //disableHourGlass(); /* * Don Smith: Should we continue supporting this as user feedback? * No other code does so, plus it takes control of presentation which is a no-no. */ return; } else { directorTrace('SdlWriter.monitorSdlWriteComplete sdl write NOT COMPLETE'); } setTimeout(monitorSdlWriteComplete,2000); } this.sdlWriterToString = function() { return (' SdlWriter' + '\n myName: ' + this.myName + '\n myElementId: ' + this.myElementId + '\n myAppletName: ' + this.myAppletName + '\n codeBase: ' + this.codeBase + '\n videoFile: ' + this.videoFile + '\n audioFile: ' + this.audioFile); } this.resetSdlWriter = function() { //directorTrace('SdlWriter.resetSdlWriter'); this.videoFile = null; this.audioFile = null; this.codeBase = null; if (AppletManager.theInstance().destroyApplet('sdlWriter')) { this.applet = null; this.writeInProgress = false; this.myAppletStarted = false; } else { return false; } //document.getElementById(this.myElementId).innerHTML = "
"; } SdlWriter.instance = this; } function setAutoplay(ctxId,state) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_setAutoplay,' + state); } function setNoAudio(ctxId,state) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_setNoAudio,' + state); } function setConvertSegments(ctxId,state) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_setConvertSegments,' + state); } function setVolume(ctxId,volume) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_setVolume,' + volume); } function setVideoDataCacheSize(ctxId,size) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_setVideoDataCacheSize,' + size); } function setVideoIndexCacheSize(ctxId,size) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_setVideoIndexCacheSize,' + size); } function setAudioDataCacheSize(ctxId,size) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_setAudioDataCacheSize,' + size); } function setAudioIndexCacheSize(ctxId,size) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_setAudioIndexCacheSize,' + size); } function getActorNameByIndex(ctxId) { return clipDirector.ep_invokeAndWait(ctxId.toString() + ',,ep_getActorName'); } var pointerNotPresent = -1; var pointerPresentNotSupported = 0; var pointerPresent = 1; function isPointerPresent(ctxId) { return pointerPresentNotSupported; //return (clipDirector != null) ? clipDirector.ep_invokeAndWait(ctxId.toString() + ',,ep_isPointerPresent') : false; } function setRgbSrcIdx(ctxId,idx) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_setRgbSrcIdx,' + idx); } function setAutoBandwidth(ctxId,state) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_setAutoBandwidth,' + state); } function setSyncBandwidth(ctxId,state) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_setSyncBandwidth,' + state); } function setCodeBaseOverride(ctxId,path) { if (path != null) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_setCodeBaseOverride,' + path); } else { directorTrace('meIntfc.setCodeBaseOverride path is NULL'); } } function setSceneMergeTmpDir(ctxId,tmpDir) { clipDirector.ep_invokeAndWait(ctxId + ',,ep_setSceneMergeTmpDir,' + tmpDir); } /* * © Copyright ESPRE Solutions, Inc., 2006. All rights are reserved. */ function ManifestFactory() { var that = this; //Let the private functions access the object instance. if("undefined" == typeof ManifestFactory.instance) { ManifestFactory.instance = this; // define the singleton } if(this != ManifestFactory.instance) return ManifestFactory.instance; // return the singleton if it already exists this.getEncodeArtifacts = function (_encodeXML) { var xmlDoc = xutil.load(_encodeXML); var vDataOutnodes = xmlDoc.selectNodes("/mediaClip/subclip/videoParameters/dataOut/text()"); //camelCase ?? subclip var vIndexOutnodes = xmlDoc.selectNodes("/mediaClip/subclip/videoParameters/indexOut/text()"); var aDataOutnodes = xmlDoc.selectNodes("/mediaClip/subclip/audioParameters/dataOut/text()"); var aIndexOutnodes = xmlDoc.selectNodes("/mediaClip/subclip/audioParameters/indexOut/text()"); var totalFiles = vDataOutnodes.length + vIndexOutnodes.length + aDataOutnodes.length + aIndexOutnodes.length ; var fileList = []; if((totalFiles % 4) == 0 && (totalFiles >= 4)) { meLogger.write('Encode file looks legit...'); meLogger.write("Root :[ " + xmlDoc.documentElement.nodeName + "] there should be a total of : " + totalFiles + " files."); //first add the required sdl file to the file list fileList.push((vDataOutnodes[0].nodeValue).replace(/\\/g, "/") + ".sdl"); for( var count =0; count < vDataOutnodes.length; count++) { fileList.push((vDataOutnodes[count].nodeValue).replace(/\\/g, "/")); } for( var count =0; count < vIndexOutnodes.length; count++) { fileList.push((vIndexOutnodes[count].nodeValue).replace(/\\/g, "/")); } for( var count =0; count < aDataOutnodes.length; count++) { fileList.push((aDataOutnodes[count].nodeValue).replace(/\\/g, "/")); } for( var count =0; count < aIndexOutnodes.length; count++) { fileList.push((aIndexOutnodes[count].nodeValue).replace(/\\/g, "/")); } //meLogger.write(fileList.join(', ')); return fileList; } else { meLogger.write("Encoding artifacts don\'t look valid.", 3); throw new MeException("Successful Encoding required before an upload "); } } } ManifestFactory.theInstance = function(){ if("undefined" == typeof ManifestFactory.instance){ return new ManifestFactory(); } return ManifestFactory.instance; }; // $Id: ParameterManager.js 50 2007-01-24 21:47:47Z plin $ function ParameterManager (common) { var that = this; // let the private functions access the object. //acquire ParameterMap capabilities this.PMap = ParameterMap; this.PMap(common); this.normalizeArgs = function(args) { var inputs = (args.length < args.callee.length)? [null] : []; inputs = inputs.concat (that.asArray(args)); return inputs; } this.setParameter = function (group, name, value) { var inputs = this.normalizeArgs(arguments); var _group = inputs[0]; var _name = inputs[1]; var _value = inputs[2]; if(typeof inputs[2] == "string"){ _value = _value.replace(/^\s+|\s+$/g,""); //trim whitespace on strings } var setter = this.getProperty (_group, _name, 'setter'); if ('function' == typeof setter) { return setter (_group, _name, _value); } var validator = this.getProperty (_group, _name, 'validator'); if ('function' == typeof validator) { if (validator(_group, _name, _value)) { return this._setParameter (_group, _name, _value); } else { // throw new Error ('Invalid input: ' + _group + ":" + _name + ":" + _value); return false; } } return this._setParameter (_group, _name, _value); } this.getParameter = function (group, name) { var inputs = this.normalizeArgs(arguments); var _group = inputs[0]; var _name = inputs[1]; var getter = this.getProperty (_group, _name, 'getter'); if ('function' == typeof getter) { return getter (_group, _name); } var value = this._getParameter (_group, _name); if ('undefined' == typeof value) { value = this.getProperty (_group, _name, 'defaultValue'); } return value; } this.removeParameter = function (group, name) { var inputs = this.normalizeArgs(arguments); var _group = inputs[0]; var _name = inputs[1]; var defaultValue = this.getProperty(_group, _name, 'defaultValue'); if('undefined' != typeof value) return true; return this._removeParameter(_group, _name); } this.resetParameter = function (group, name) { var inputs = this.normalizeArgs(arguments); var _group = inputs[0]; var _name = inputs[1]; var defaultValue = this.getProperty(_group, _name, 'defaultValue'); if('undefined' == typeof defaultValue) return false; return this.setParameter(_group, _name, defaultValue); } this.getActiveParameters = function (group) { return this._getActiveParameters.apply (this, this.normalizeArgs(arguments)); } this._toXPath = function(prePend){ prePend = prePend || ""; var result = ""; var groups = this.getSupportedGroups(); if(groups.length == 0)return result; for (gindex in groups){ var group = groups[gindex]; var parameters = this.getActiveParameters(group); if(parameters.length == 0) continue; for (pindex in parameters){ var parameter = parameters[pindex]; result = result.concat (prePend + "/"+group + "/"+parameter + ":" + this.getParameter(group,parameter) + "\n"); } } return result; } } CameraCapture.useAVDevice = true; function CameraCapture(captureApplet) { if(CameraCapture.instance != null) return CameraCapture.instance; // Singleton only if(CameraCapture.useAVDevice) { //alert('meCameraCapture.CameraCapture captureApplet: ' + captureApplet + '\n cameraCaptureDocument: ' + cameraCaptureDocument); // if ((!captureApplet || (captureApplet == null)) && cameraCaptureDocument) // { // captureApplet = cameraCaptureDocument; // } this.captureApplet = captureApplet; //we don't use this, but its in the interface this.setCaptureApplet = function(applet) { // alert('meCameraCapture.setCaptureApplet' + '\n applet: ' + applet + '\n cameraCaptureDocument: ' + cameraCaptureDocument); this.captureApplet = applet; } var avDevice = new AVDevice(); //uses default video and audio devices var pendingAVDevice = null; // used to hold new device while current device is capturing or previewing. // avDevice can be changed if not capturing and not previewing var updateAVDevice = function(){ if(pendingAVDevice !== null){ avDevice = pendingAVDevice; pendingAVDevice = null; } } this.startCapture = function() // USER API { avDevice.startCapture(); } this.stopCapture = function() // USER API { avDevice.stopCapture(); updateAVDevice(); } this.startPreview = function() // USER API { avDevice.startPreview(); } this.stopPreview = function() // USER API { avDevice.stopPreview(); updateAVDevice(); } this.getCapturePath = function() // USER API { var path = null; try {path = avDevice.getParameter("outputfile");} catch (e) { alert('CameraCapture.getCapturePath EXCEPTION: ' + e.message); path = null; } if ((path != null) && isString(path) && (path.length > 0)) { path = path.replace(/\\/g,"/"); } else { path = null; } return path; } this.setCapturePath = function(aPath) // USER API { avDevice.setParameter("outputfile", aPath); } this.getCaptureApplet = function() { return this.captureApplet; } this.getAVDevice = function() { return avDevice; } this.setAVDevice = function(anAVDevice) { if(anAVDevice === null) return; if(! anAVDevice instanceof AVDevice) return; if(avDevice.isCapturing() || avDevice.isPreviewing()){ pendingDevice = anAVDevice; } else{ avDevice = anAVDevice; } } } else //old style direct access { //alert('meCameraCapture.CameraCapture captureApplet: ' + captureApplet + '\n cameraCaptureDocument: ' + cameraCaptureDocument); if ((!captureApplet || (captureApplet == null)) && cameraCaptureDocument) { captureApplet = cameraCaptureDocument; } this.captureApplet = captureApplet; this.setCaptureApplet = function(applet) { // alert('meCameraCapture.setCaptureApplet' + '\n applet: ' + applet + '\n cameraCaptureDocument: ' + cameraCaptureDocument); this.captureApplet = applet; } this.startCapture = function() // USER API { //camCapApp.getInstance().startCapture(); this.getCaptureApplet().ep_startCapture(120); // TODO GLM need to restore previously working method } this.stopCapture = function() // USER API { this.getCaptureApplet().ep_stopCapture(); } this.startPreview = function() // USER API { this.getCaptureApplet().ep_setPreview(true); } this.stopPreview = function() // USER API { this.getCaptureApplet().ep_setPreview(false); } this.getCapturePath = function() // USER API { var path = null; try {path = this.getCaptureApplet().ep_getCapturePath();} catch (e) { alert('CameraCapture.getCapturePath EXCEPTION: ' + e.message); path = null; } if ((path != null) && isString(path) && (path.length > 0)) { path = path.replace(/\\/g,"/"); } else { path = null; } return path; } this.setCapturePath = function(aPath) // USER API { this.getCaptureApplet().ep_setCapturePath(aPath); } this.getCaptureApplet = function() { //alert('meCameraCapture.getCaptureApplet applet: ' + camCapApp.getInstance()); return this.captureApplet; //return camCapApp.getInstance(); } } //alert('meCameraCapture. this: ' + this); CameraCapture.instance = this; } CameraCapture.instance = null; CameraCapture.startCapture = function() { if (CameraCapture.instance != null) { CameraCapture.instance.startCapture(); } else { directorTrace('CameraCapture.startCapture NO INSTANCE'); alert('CameraCapture.startCapture NO INSTANCE'); } } CameraCapture.stopCapture = function() { if (CameraCapture.instance != null) { CameraCapture.instance.stopCapture(); } else { directorTrace('CameraCapture.stopCapture NO INSTANCE'); alert('CameraCapture.stopCapture NO INSTANCE'); } } CameraCapture.startPreview = function() { if (CameraCapture.instance != null) { CameraCapture.instance.startPreview(); } else { directorTrace('CameraCapture.startPreview NO INSTANCE'); alert('CameraCapture.startPreview NO INSTANCE'); } } CameraCapture.stopPreview = function() { if (CameraCapture.instance != null) { CameraCapture.instance.stopPreview(); } else { directorTrace('CameraCapture.stopPreview NO INSTANCE'); alert('CameraCapture.stopPreview NO INSTANCE'); } } CameraCapture.getCapturePath = function() // USER API { if (CameraCapture.instance != null) { return CameraCapture.instance.getCapturePath(); } else { directorTrace('CameraCapture.getCapturePath NO INSTANCE'); alert('CameraCapture.getCapturePath NO INSTANCE'); } } CameraCapture.setCapturePath = function(aPath) // USER API { if (CameraCapture.instance != null) { CameraCapture.instance.setCapturePath(aPath); } else { directorTrace('CameraCapture.stopPreview NO INSTANCE'); alert('CameraCapture.stopPreview NO INSTANCE'); } } CameraCapture.setCaptureApplet = function(applet) { if (CameraCapture.instance != null) { CameraCapture.instance.setCaptureApplet(applet); } else { directorTrace('CameraCapture.setCaptureApplet NO INSTANCE'); alert('CameraCapture.setCaptureApplet NO INSTANCE'); } } function UploadRequest(_nspace,_name) { var that = this; //Let the private functions access the object instance. //acquire ParameterManager capabilities this.PMgr = ParameterManager; this.PMgr("general"); var host = HostingAgent.theInstance(); // get the singleton. var requestState = "idle"; // use this to track the request // states are: idle, uploading, completed, errored, cancelled this.integerStringValidator = function (group, name, _value) { //meLogger.write('Integer String Validator Called', 1); if(isNaN(parseInt(_value)))return false; return true; } // define the progress parameters this.defineParameter("general","progress","defaultValue","0","validator",this.integerStringValidator); var nspace = _nspace; var target = ""; var name = _name; var mappedName = ""; var manifestFiles = []; /** This will have a return type that looks like: C:\metest\anonymous\video_s1.dat| 219010| Mon Feb 12 10:46:32 CST 2007, C:\metest\anonymous\video_s2.dat| 219010| Mon Feb 12 10:46:32 CST 2007, C:\metest\anonymous\video_s3.dat| 257716| Mon Feb 12 10:46:32 CST 2007, C:\metest\anonymous\video_s1.idx| 18000| Mon Feb 12 10:46:32 CST 2007, C:\metest\anonymous\video_s2.idx| 18000| Mon Feb 12 10:46:32 CST 2007, C:\metest\anonymous\video_s3.idx| 18000| Mon Feb 12 10:46:32 CST 2007, C:\metest\anonymous\audio_s1.dat| 188308| Mon Feb 12 10:46:32 CST 2007, C:\metest\anonymous\audio_s2.dat| 188308| Mon Feb 12 10:46:32 CST 2007, C:\metest\anonymous\audio_s3.dat| 188308| Mon Feb 12 10:46:32 CST 2007, C:\metest\anonymous\audio_s1.idx| 6444| Mon Feb 12 10:46:32 CST 2007, C:\metest\anonymous\audio_s2.idx| 6444| Mon Feb 12 10:46:32 CST 2007, C:\metest\anonymous\audio_s3.idx| 6444| Mon Feb 12 10:46:32 CST 2007 The order is FileName(path)|Size|Creation Date */ this.toString = function(){ var myString = []; for(var i = 0; i < manifestFiles.length; i++){ myString.push(manifestFiles[i]); } var tempString = myString.join(', '); return tempString; } this.setManifestFiles = function(_manifestFiles){ manifestFiles = _manifestFiles; if(_manifestFiles.length>0){ // extract "map to" filename mappedName = _manifestFiles[0]; mappedName = mappedName.replace(/^.*\//,""); //meLogger.write(mappedName); } setCorrespondingAttributes(); } this.getManifestFiles = function(){ return manifestFiles; } this.setName = function(_name){ name = _name; } this.getName = function(){ return name; } this.setMappedName = function(_name){ mappedName = _name; } this.getMappedName = function(){ return mappedName; } this.setTarget = function(_target){ target = _target; } this.getTarget = function(){ return target; } this.getNameSpace = function(){ return nspace; } function setCorrespondingAttributes(){ if (manifestFiles.length > 0){ for(var mCnt = 0; mCnt < manifestFiles.length; mCnt++) { manifestFiles[mCnt] = getManifestAttributes(manifestFiles[mCnt]); } } } // Assuming the HostingAgent class have implemented the following methods. this.upload = function() { var result = host.upload(this); if(result == true) setRequestState("uploading"); return result; // true indicates that the request has been posted } this.start = this.upload; this.getProgress = function(){ if(requestState == "uploading") return this.getParameter("progress"); if(requestState == "completed") return 100; return 0; } this.getErrors = function(){ if(requestState == "errored") return this.getParameter("errors"); return ""; } this.isCompleted = function(){ if(requestState == "completed" || requestState == "cancelled") return true; return false; } this.isUploading = function(){ if(requestState == "uploading") return true; return false; } this.isError = function(){ if(requestState == "errored") return true; return false; } // Private functions function setRequestState(_state){ var oldState = requestState; if (_state != requestState){ requestState = _state; meLogger.write('UploadRequest: '+ oldState + ' -> ' + requestState); } } // add public callback functions for status, progress, etc. this.updateProgress = function(_value) { this.setParameter("progress",_value); } this.updateState = function(_state){ if(_state == "initializing" || _state == "ready" || _state == "busy" || _state == "blocked") return; if(_state == "errored"){ this.setParameter("errors",host.getErrors()); meLogger.write(host.getErrors(), 3); } setRequestState(_state); } } function FileUtil() { var that = this; //Let the private functions access the object instance. if("undefined" == typeof FileUtil.instance) { FileUtil.instance = this; // define the singleton } if(this != FileUtil.instance) return FileUtil.instance; // return the singleton if it already exists var fileUtilApplet = null; // created when needed. var appletState = null; // use this to track fso Applet // states are: initializing, ready //Continue with the singleton's construction //User API functions this.install = function(){ if(appletState === null){ startFileUtilApplet(); } }; this.isInitialized = function(){ if(appletState === null){return false;} if(appletState != "initializing") return true; return false; }; this.fileDelete = function(_file) { if(!this.isInitialized()) return false; // not yet available var result = fileUtilApplet.ep_fileDelete(_file); return (result == "1"? true: false); }; this.getHome = function() { if(!this.isInitialized()) return ""; // not yet available return (new String(fileUtilApplet.ep_getUserHome())).toString(); }; this.writeToFilePath = function(fileAsAString,filePathName, overwrite) { if(!this.isInitialized()) return false; // not yet available var re = /\\[^\\]+$/; var base = filePathName.replace(re,""); var _folderExists = this.doesFolderExist(base) ; //alert("Base: " + base); return fileUtilApplet.ep_writeToFilePath(fileAsAString.replace(/"/g, "'"),filePathName); }; this.writeToFile = function(fileAsAString,base, projRelPath, fileName, overwrite) { if(!this.isInitialized()) return false; // not yet available //alert (fileAsAString.replace(/\"/g, "\'")); return fileUtilApplet.ep_writeToFile(fileAsAString.replace(/"/g, "'"),base, projRelPath, fileName, overwrite); }; this.fileExists = function(fileName) { if(!this.isInitialized()) return false; // not yet available return ((fileUtilApplet.ep_fileExists(fileName) == '1')? true : false); }; this.doesFolderExist = function(dirName) { if(!this.isInitialized()) return false; // not yet available return ((fileUtilApplet.ep_folderExists(dirName) == '1')? true : false); }; this.getManifestAttributes = function(fileName) { if(!this.isInitialized()) return ""; // not yet available return (new String(fileUtilApplet.ep_getManifestAttributes(fileName))).toString(); }; this.deleteFile = function(fileName) { if(!this.isInitialized()) return false; // not yet available return ((fileUtilApplet.ep_fileDelete(fileName) == '1')? true : false); }; this.copyFile = function(sourceFile, destPath) { if(!this.isInitialized()) return false; // not yet available return ((fileUtilApplet.ep_fileCopy(sourceFile, destPath) == '1')? true : false); }; this.getBase = function(fileName) { if(!this.isInitialized()) return ""; // not yet available return (new String(fileUtilApplet.ep_getBase(fileName))).toString(); }; this.doesFileExist = function(fileName){ if(!this.isInitialized()) return false; // not yet available return ((fileUtilApplet.ep_fileExists(fileName) == '1')? true : false); }; this.readFile = function(fileName){ if(!this.isInitialized()) return ""; // not yet available return (new String(fileUtilApplet.ep_readFile(fileName))).toString(); }; // Private functions function startFileUtilApplet(){ setAppletState("initializing"); // Start Applet Here// var fakeIt = false; // to test w/o applet if(!fakeIt){ var appspec = new AppletSpec('fileUtil'); appspec.setParameter("name","fileUtil"); appspec.setParameter("visible",false); AppletManager.theInstance().startApplet(appspec,setAppletReadyState); } else { //FakeOut Applet start meLogger.write('Faking applet start in 5 seconds!!'); window.setTimeout(setAppletReadyState,5000); } } function setAppletReadyState(applet){ fileUtilApplet = applet; setAppletState("ready"); } function setAppletState(_state){ var oldState = appletState; if (_state != appletState){ appletState = _state; meLogger.write('FileUtil: ' + oldState + " -> "+ appletState); } } //auto start the instance; startFileUtilApplet(); return FileUtil.instance; } FileUtil.theInstance = function(){ if("undefined" == typeof FileUtil.instance){ new FileUtil(); } return FileUtil.instance; }; FileUtil.isInitialized = function(){ return FileUtil.theInstance().isInitialized(); }; if (!meLogger){ var meLogger = new Object(); } meLogger.write = function (){ // jstracer.write.apply(jstracer,arguments); if(arguments.length > 1 && arguments[1] == 3) alert(arguments[0]); }; function deleteProject(_projectPath) { var result = false; var tempFile = ""; try{ if(doesFolderExist(_projectPath)){ // Handle Project.xml var filePath = toPath(_projectPath, "Project.xml") ; if(doesFileExist(filePath)){ result = fileDelete(filePath); } result = true; // success if we delete the Project.xml // Handle Encode.xml filePath = toPath(_projectPath, "Encode.xml"); if(doesFileExist(filePath)){ result = result && fileDelete(filePath); } //Delete idx/dat files audio_s1.dat var audioF= "audio_s"; var videoF = "video_s"; var counter = 1; // debugger; while(true) { tempFile = audioF + counter + ".idx"; filePath = toPath(_projectPath, tempFile ); if(doesFileExist(filePath)){ result = result && fileDelete(filePath); } else { //Looks like all the idx/dat files are cleaned up break; } tempFile = audioF + counter + ".dat"; filePath = toPath(_projectPath, tempFile); if(doesFileExist(filePath)){ result = result && fileDelete(filePath); } tempFile = videoF + counter + ".idx"; filePath = toPath(_projectPath, tempFile); if(doesFileExist(filePath)){ result = result && fileDelete(filePath); } tempFile = videoF + counter + ".dat"; filePath = toPath(_projectPath, tempFile); if(doesFileExist(filePath)){ result = result && fileDelete(filePath); } counter++; } //Delete SDL File tempFile = "video_s1.dat.sdl"; filePath = toPath(_projectPath, tempFile); if(doesFileExist(filePath)){ result = result && fileDelete(filePath); } if (!result) { meLogger.write("Some files could not be deleted.", 3); } // Handle scene files //TBD return result; } return true; } catch(e) { alert("Utilities.deleteProject EXCEPTION: " + e.message); meLogger.write(e.name + " :->>>>>" + e.message, 3); } return result; } function fileDelete(_file) { return FileUtil.theInstance().fileDelete(_file); } //This is a stub function toPath(t1, t2) { if((t1.charAt(t1.length - 1) == "\\") && (t2.charAt(0) == "\\")){ t1 = t1.substring(0,t1.length - 1) ; //Removing the last \ } if((t1.charAt(t1.length - 1) == "\\") || (t2.charAt(0) == "\\")){ return t1 + t2 ; } return t1 +"\\" + t2 ; } function getHome() { return FileUtil.theInstance().getHome(); } function writeToFilePath(fileAsAString,filePathName, overwrite) { return FileUtil.theInstance().writeToFilePath(fileAsAString, filePathName, overwrite); } function writeToFile(fileAsAString, base, projRelPath, fileName, overwrite) { return FileUtil.theInstance().writeToFile(fileAsAString, base, projRelPath, fileName, overwrite); } function fileExists(fileName) { return FileUtil.theInstance().fileExists(fileName); } function doesFolderExist(dirName) { return FileUtil.theInstance().doesFolderExist(dirName); } function getManifestAttributes(fileName) { return FileUtil.theInstance().getManifestAttributes(fileName); } function deleteFile(fileName) { return FileUtil.theInstance().deleteFile(fileName); } function copyFile(sourceFile, destPath) { return FileUtil.theInstance().copyFile(sourceFile, destPath); } function getBase(fileName) { return FileUtil.theInstance().getBase(fileName); } function doesFileExist(fileName){ return FileUtil.theInstance().doesFileExist(fileName); } function readFile(fileName){ return FileUtil.theInstance().readFile(fileName); } /** * This is a generic method that will load the xml file into a DOM Object * Loading an XML file is possible in most of the major browsers unlike writing an XML to a file. */ function loadXML(sourceFile) { var xmlDoc; // alert(sourceFile); if (window.ActiveXObject) { //I don't know what the difference would be between these two implementations... xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); ///xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0"); } else if (document.implementation && document.implementation.createDocument) { xmlDoc = document.implementation.createDocument("", "", null); //Day:The first parameter, "", defines the namespace used for the XML document. //The second parameter, "", is the XML root element in the XML file. //The third parameter, null, is always null because it is not implemented yet. } else { throw new MeException("Your browser can\'t handle this script"); //return; } try{ xmlDoc.async=false; xmlDoc.load(sourceFile); //we might need to escape } catch (e){ alert("Utilities.loadXML EXCEPTION: " + e.message); if (window.ActiveXObject && xmlDoc.parseError.errorCode !== 0) { alert("Error code: " + xmlDoc.parseError.errorCode + " Error Reason: " + xmlDoc.parseError.reason + +" Error Line: " + xmlDoc.parseError.line); } return null; } return(xmlDoc); } var xutil = {}; xutil._is_IE = (document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1); xutil._is_MOZ = (document.implementation && document.implementation.createDocument && document.implementation.hasFeature); xutil.getDomDocument = function (nspace, nodeName) { var oDomDoc = null; if (xutil._is_IE) { oDomDoc = new ActiveXObject("Microsoft.XMLDOM"); oDomDoc.loadXML('<' + nodeName + " />"); } else if (xutil._is_MOZ) { oDomDoc = document.implementation.createDocument(nspace, nodeName, null); } else { throw new Error("This browser is not supported."); } if (oDomDoc && (nspace || nodeName) && !oDomDoc.documentElement){ oDomDoc.appendChild(oDomDoc.createElementNS(nspace, nodeName)); } return oDomDoc; }; xutil.serializeToString = function(node) { var xmlString = null; if (xutil._is_IE) { xmlString = node.xml; return xmlString; } else if (xutil._is_MOZ) { xmlString = new XMLSerializer().serializeToString(node); return xmlString; } else { throw new MeException("This browser is not supported."); } }; // Parse an XML string xutil.parseFromString = function (text) { var doc = null; if (window.ActiveXObject) { // code for IE doc = new ActiveXObject("Microsoft.XMLDOM"); doc.async = false; doc.loadXML(text); } else { // code for Mozilla, Firefox, Opera, etc. var parser = new DOMParser(); doc = parser.parseFromString(text,"text/xml"); } // var x = doc.documentElement; return doc; }; // Load XML file xutil.load = function () { var forReading = 1, forWriting = 2, forAppending = 8; var xmlDoc = null; if (window.ActiveXObject) { // code for IE xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); } else if (document.implementation && document.implementation.createDocument) { // code for Mozilla, Firefox, Opera, etc. xmlDoc = document.implementation.createDocument("","",null); xmlDoc.loadXML = xmlDoc.load; //CHEAT!! } else { throw new Error("This browser is not supported."); } try{ xmlDoc.async = false; if ((arguments.length == 2) && (arguments[1] == 'SERVER')){ xmlDoc.load(arguments[0]); } else{ //alert("About to readFile: " + arguments[0]); var file = readFile(arguments[0]); // alert("file: " + file); if(file != "-1"){ // xmlDoc.loadXML(file.replace(/\"/g, "\'")); xmlDoc = xutil.parseFromString(file.replace(/\"/g, "\'")); } else { throw new MeException(arguments[0] + " File is empty."); } } } catch(e) { alert("Utilities.xutil.load EXCEPTION: " + e.message); meLogger.write(e.name + " :_[ " + e.message + "]", 3); } return xmlDoc; }; // return xml string xutil.xslt = function (documentFrom, filenameXSL, xmlDocument) { xmlDocument = xmlDocument || xutil.getDomDocument(); var _filenameXSL = (typeof EVME_XSL_PATH == "undefined")? filenameXSL : EVME_XSL_PATH + filenameXSL; var xsl = xutil.load(_filenameXSL,"SERVER"); //fromServer is set to true if (xutil._is_IE) { return documentFrom.transformNode(xsl); } else if (xutil._is_MOZ) { var processor = new XSLTProcessor(); processor.importStylesheet(xsl); var frag = processor.transformToFragment(documentFrom, xmlDocument); return xutil.serializeToString(frag); } }; if (!MeFactory) { var MeFactory = new Object(); } /** * This Function is used to create the collection object. **/ MeFactory.CreateCollection = function(ClassName) { var obj=new Array(); eval("var t=new "+ClassName+"()"); for(_item in t) { eval("obj."+_item+"=t."+_item); } return obj; }; MeFactory.sortByOrder = function (clip1, clip2) { if (clip1 instanceof Clip && clip2 instanceof Clip) { if(clip1.getOrder() > clip2.getOrder()){ return 1; } if(clip1.getOrder() < clip2.getOrder()){ return -1; } if(clip1.getOrder() == clip2.getOrder()){ return 0; } } throw new MeException("Could not compare Clips."); }; function MeCollection(){ this.add=function(obj) { this.push(obj); }; this.remove = function (obj) { var i = this.indexOf(obj); if (i != -1) { this.splice(i, 1); } }; this.indexOf = function (obj, fromIndex) { if (!fromIndex) { fromIndex = 0; } else if (fromIndex < 0) { fromIndex = Math.max(0, this.length + fromIndex); } for (var i = fromIndex; i < this.length; i++) { if((this[i]).getParameter('general','name') == obj.getParameter('general','name')){ return i; } } return -1; }; //Other collection functions go here var _createDocumentFragment = function (_xmlDocument) { var xmlDocument = _xmlDocument || xutil.getDomDocument(); var fragment = xmlDocument.createDocumentFragment(); for (var i = 0, item; item = this[i]; i++) { var node = item.createDocumentFragment(xmlDocument); fragment.appendChild(node); } return fragment; }; this.createDocumentFragment = _createDocumentFragment; // test code this.toXML = function (_xmlDocument) { xmlDocument = _xmlDocument || xutil.getDomDocument(); var xmlString = xutil.serializeToString(this.createDocumentFragment(xmlDocument)); return xmlString; }; } function MeAddEvent(obj, evType, fn){ if (obj.addEventListener) { obj.addEventListener(evType, fn, false); return true; } else if (obj.attachEvent) { var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } //Include this script to use selectNodes in IE, NS & FF: /* Prefix-correcting evaluate statement from http://www.faqts.com/knowledge_base/view.phtml/aid/34022/fid/119 */ if( document.implementation.hasFeature("XPath", "3.0") ){ XMLDocument.prototype.selectNodes = function(cXPathString, xNode){ if( !xNode ) { xNode = this; } var defaultNS = this.defaultNS; var aItems = this.evaluate(cXPathString, xNode,{ normalResolver: this.createNSResolver(this.documentElement), lookupNamespaceURI : function (prefix) { switch (prefix) { case "dflt": return defaultNS; default: return this.normalResolver.lookupNamespaceURI(prefix); } } },XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null); var aResult = []; for( var i = 0; i < aItems.snapshotLength; i++){ aResult[i] = aItems.snapshotItem(i); } return aResult; } Element.prototype.selectNodes = function(cXPathString){ if(this.ownerDocument.selectNodes){ return this.ownerDocument.selectNodes(cXPathString, this); }else{ throw "For XML Elements Only"; } } /* set the SelectionNamespaces property the same for NN or IE: */ XMLDocument.prototype.setProperty = function(p,v){ if(p=="SelectionNamespaces" && v.indexOf("xmlns:dflt")==0){ this.defaultNS = v.replace(/^.*=\'(.+)\'/,"$1"); } } XMLDocument.prototype.defaultNS; } var JSON = function () { var m = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\' }, s = { 'boolean': function (x) { return String(x); }, number: function (x) { return isFinite(x) ? String(x) : 'null'; }, string: function (x) { if (/["\\\x00-\x1f]/.test(x)) { x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) { var c = m[b]; if (c) { return c; } c = b.charCodeAt(); return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16); }); } return '"' + x + '"'; }, object: function (x) { if (x) { var a = [], b, f, i, l, v; if (x instanceof Array) { a[0] = '['; l = x.length; for (i = 0; i < l; i += 1) { v = x[i]; f = s[typeof v]; if (f) { v = f(v); if (typeof v == 'string') { if (b) { a[a.length] = ','; } a[a.length] = v; b = true; } } } a[a.length] = ']'; } else if (x instanceof Object) { a[0] = '{'; for (i in x) { v = x[i]; f = s[typeof v]; if (f) { v = f(v); if (typeof v == 'string') { if (b) { a[a.length] = ','; } a.push(s.string(i), ':', v); b = true; } } } a[a.length] = '}'; } else { return; } return a.join(''); } return 'null'; } }; return { copyright: '(c)2005 JSON.org', license: 'http://www.JSON.org/license.html', /* Stringify a JavaScript value, producing a JSON text. */ stringify: function (v) { var f = s[typeof v]; if (f) { v = f(v); if (typeof v == 'string') { return v; } } return null; }, /* Parse a JSON text, producing a JavaScript value. It returns false if there is a syntax error. */ parse: function (text) { try { return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test( text.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + text + ')'); } catch (e) { alert("JSON.parse EXCEPTION: " + e.message); return false; } } }; }(); // meActorUtil.js function getActorByIndex(index) { return (contextDefinitionMap[index] && contextDefinitionMap[index].getActor()) ? contextDefinitionMap[index].getActor() : null; } function getActorByName(name) { return (actorNameMap[name]) ? actorNameMap[name]['instance'] : null; //return (actorNameMap[name]) ? actorNameMap[name]['instance'].getActor() : null; } function isMsgActor(ctxId) { var anActor = getActorByIndex(ctxId); return (anActor !== null) ? anActor.areMsgsEnabled() : false; } function stopAll() { // directorTrace('meActorUtil.stopAll'); if ((contextDefinitionMap !== null) && (contextIdx > 0)) { for (var i = 1; i <= contextIdx; i++) { getActorByIndex(i).hide(); stopContext(i); displayImage(i,stoppedImageSpec); //clearEventQueue(i); } transitionInProgress(); } } function auditAllActors() { // directorTrace('meActorUtil.auditAllActors'); var status = false; if ((actorInstanceMap !== null) && (actorInstanceCtr > 1)) { for (var i = 1; i <= actorInstanceCtr; i++) { status |= actorInstanceMap[i].auditBackgroundContexts(); } } return status; } var reconfigurationInProgress = false; var reconfigurationComplete = true; function reconfigureMpcsClosure(method,arg) {return (function() {requestMpcReconfiguration(method,arg);});} var reconfigureMpcs = null; function waitForStopAllClosure(method,arg) {return (function() {waitForStopAll(method,arg);});} var waitForStopAll_ = null; function reconfigureMpcsClosure2(method,arg) {return (function() {requestMpcReconfiguration2(method,arg);});} var reconfigureMpcs2 = null; var reconfigureRetryCtr = 0; var reconfigureRetryCtrMax = 60; var reconfigureStartTicks = 0; function requestMpcReconfiguration(method,arg) { if ((!reconfigurationComplete || areContextsActive()) && !override) { directorTrace('meActorUtil.requestMpcReconfiguration REQUEST BLOCKED'); displayContextStateSummary(); beep(); return; } if (reconfigurationInProgress) { directorTrace('meActorUtil.requestMpcReconfiguration DEFERRING REQUEST method: ' + method + ' arg: ' + arg); reconfigureMpcs = reconfigureMpcsClosure(method,arg); setTimeout(reconfigureMpcs,5000); return; } reconfigureStartTicks = getTicks(); enableHourGlass(); allContextsReady = false; ctxReady = new Object(); reconfigurationInProgress = true; reconfigurationComplete = false; clearAllInvokeQueues(); stopAll(); waitForStopAll_ = waitForStopAllClosure(method,arg); setTimeout(waitForStopAll_,1000); setTimeout('monitorAllContextsReady()',1100); } function waitForStopAll(method,arg) { // if (reconfigurationComplete) return; //if (!clipDirector || (clipDirector === null)) //{ //waitForStopAll_ = waitForStopAllClosure(method,arg); //setTimeout(waitForStopAll_,500); //return; //} var contextsStopped = areContextsStopped(); var contextsActive = areContextsActive(); if (contextsStopped && !contextsActive) { // directorTrace('meActorUtil.waitForStopAll ALL STOPPED AND IDLE'); //abortAll(); reconfigureMpcs2 = reconfigureMpcsClosure2(method,arg); setTimeout(reconfigureMpcs2,1000); } else { directorTrace('meActorUtil.waitForStopAll REISSUE' + ' stopped: ' + contextsStopped + ' active: ' + contextsActive); displayContextStateSummary(); if (!contextsStopped) { stopAll(); } waitForStopAll_ = waitForStopAllClosure(method,arg); setTimeout(waitForStopAll_,500); } } function requestMpcReconfiguration2(method,arg) { // directorTrace('meActorUtil.requestMpcReconfiguration2 EVAL REQUEST method: ' + method + ' arg: ' + arg); //if (method && (method !== null)) //{ eval(method + '(\'' + arg + '\')'); //} setTimeout('waitForAllContextsReady()',100); // setTimeout('monitorAllContextsReady()',1000); } var override = false; function monitorAllContextsReady() { if (allContextsReady) { // directorTrace('meActorUtil.monitorAllContextsReady RECONFIGURATION COMPLETE: ' + (getTicks() - reconfigureStartTicks)); setTimeout('actorsReady()',100); } else { reconfigureRetryCtr++; if (reconfigureRetryCtr > reconfigureRetryCtrMax) { alert('meActorUtil.monitorAllContextsReady reset state'); directorTrace('meActorUtil.monitorAllContextsReady reset state'); allContextsReady = true; reconfigureRetryCtr = 0; resetAllContexts(); override = true; actorsReady(); } else { setTimeout('monitorAllContextsReady()',1000); } } } function waitCursor() { document.body.style.cursor = 'wait'; } function autoCursor() { document.body.style.cursor = 'auto'; } function enableHourGlass() { return; waitCursor(); setStatusClockEnabled(true); } function disableHourGlass() { return; hourGlassActive = false; autoCursor(); setStatusClockEnabled(false); } function areContextsStopped() { // directorTrace('meActorUtil.areContextsStopped'); if ((contextDefinitionMap !== null) && (contextIdx > 0)) { for (var i = 1; i <= contextIdx; i++) { var stopped = isContextStopped(i); // directorTrace('meActorUtil.areContextsStopped' + ' i: ' + i + ' stopped: ' + stopped); if (!stopped) return false; } } return true; } function areContextsIdle() { // directorTrace('meActorUtil.areContextsIdle'); if ((contextDefinitionMap !== null) && (contextIdx > 0)) { for (var i = 1; i <= contextIdx; i++) { if (!isContextIdle(i)) { // transitionInProgress(); return false; } } } return true; } function abortAll() { // directorTrace('meActorUtil.abortAll'); if ((contextDefinitionMap !== null) && (contextIdx > 0)) { for (var i = 1; i <= contextIdx; i++) { abortContext(i); } resetAllClips(); if ((contextDefinitionMap !== null) && (contextIdx > 0)) { for (i = 1; i <= contextIdx; i++) { clearEventQueue(i); } } } } function clearAllInvokeQueues() { if ((contextDefinitionMap !== null) && (contextIdx > 0)) { for (var i = 1; i <= contextIdx; i++) { clearInvokeQueue(i); } } // directorTrace('meActorUtil.clearAllInvokeQueues'); } function areContextsRestarting() { // directorTrace('meActorUtil.areContextRestarting'); if ((contextDefinitionMap !== null) && (contextIdx > 0)) { for (var i = 1; i <= contextIdx; i++) { if (isContextRestarting(i)) { // transitionInProgress(); return true; } } } return false; } function areContextsSwitching() { directorTrace('meActorUtil.areContextSwitching'); if ((contextDefinitionMap !== null) && (contextIdx > 0)) { for (var i = 1; i <= contextIdx; i++) { if (isContextSwitching(i)) return true; } } return false; } function isTransitionActive() { var ticks = getTicks(); var isActive = ticks < transitionTicks; if (isActive) { // directorTrace('meActorUtil.isTransitionActive' + // ' ticks: ' + ticks + // ' transitionTicks: ' + transitionTicks); } return isActive; } var statusClockEnabled = false; function setStatusClockEnabled(state) { statusClockEnabled = state; if (statusClockEnabled) { statusClockCtr = 0; statusClock(); } } var statusClockCtr = 0; function statusClock() { if (statusClockEnabled) { waitCursor(); windowStatus(statusClockCtr); setTimeout('statusClock()',1000); statusClockCtr++; } } function isBackground(ctxId) { return !isForeground(ctxId); } function isForeground(ctxId) { return foregroundMap[ctxId]; } // assumes elements start off hidden var elementShowState = null; function initElementShowState(element) { if (elementShowState == null) { elementShowState = new Object(); } if (typeof elementShowState[element] == 'undefined') { elementShowState[element] = false; } } function isElementShowing(element) { initElementShowState(element); // directorTrace('meActorUtil.isElementShowing' + ' element: ' + element + ' state: ' + elementShowState[element]); return elementShowState[element]; } function isElementHidden(element) { return !isElementShowing(element); } function showElement(element) { var el = document.getElementById(element); if ((el != null) && isElementHidden(element)) { el.style.visibility = "visible"; elementShowState[element] = true; } } function hideElement(element) { var el = document.getElementById(element); if (el != null) { initElementShowState(element); el.style.visibility = "hidden"; elementShowState[element] = false; } } function actorsReady() { if (areContextsActive() && !override) { directorTrace('meActorUtil.actorsReady almost ready...'); displayContextStateSummary(); setTimeout('actorsReady()',1000); } else { // directorTrace('meActorUtil.actorsReady RECONFIGURATION COMPLETE: ' + (getTicks() - reconfigureStartTicks) + ' override: ' + override); fireMeEvent('allActorsReady','allActorsReady;meActorUtil.actorsReady'); directorTrace('ready'); reconfigurationComplete = true; reconfigurationInProgress = false; reconfigureRetryCtr = 0; override = false; disableHourGlass(); } } function resetAllContexts() { directorTrace('meActorUtil.resetAll'); if ((contextDefinitionMap !== null) && (contextIdx > 0)) { for (var i = 1; i <= contextIdx; i++) { resetContext(i); } } } function areContextsActive() { var transitionActive = isTransitionActive(); var contextsRestarting = areContextsRestarting(); var restartAtInProgress = isRestartAtInProgress(); var contextsIdle = areContextsIdle(); var backgroundContextsPlaying = false; // areBackgroundContextsPlaying(); var contextsActive = transitionActive || contextsRestarting || restartAtInProgress || !contextsIdle || backgroundContextsPlaying; if (false && contextsActive) { alert('meActorUtil.areContextsActive ACTIVE' + '\n transitionActive: ' + transitionActive + '\n contextsRestarting: ' + contextsRestarting + '\n restartAtInProgress: ' + restartAtInProgress + '\n contextsIdle: ' + contextsIdle + '\n backgroundContextsPlaying: ' + backgroundContextsPlaying); } return contextsActive; } var transitionTicks = 0; var transitionInterval = 2000; function transitionInProgress() { transitionTicks = getTicks() + transitionInterval; // directorTrace('meActorUtil.transitionInProgress transitionTicks: ' + transitionTicks); } function displayContextStateSummary() { if (false) { var transitionActive = isTransitionActive(); var contextsRestarting = areContextsRestarting(); var restartAtInProgress = isRestartAtInProgress(); var contextsStopped = areContextsStopped(); var contextsIdle = areContextsIdle(); var backgroundPlaying = areBackgroundContextsPlaying(); directorTrace('\n meActorUtil.displayContextStateSummary' + ' transition: ' + transitionActive + ' restarting: ' + contextsRestarting + ' restartAtInProgress: ' + restartAtInProgress + ' stopped: ' + contextsStopped + ' idle: ' + contextsIdle + ' backgroundPlaying: ' + backgroundPlaying + ' override: ' + override); } } function areBackgroundContextsPlaying() { // directorTrace('meActorUtil.areBackgroundContextsPlaying'); if ((contextDefinitionMap !== null) && (contextIdx > 0)) { for (var i = 1; i <= contextIdx; i++) { if (isBackground(i) && isContextPlaying(i)) { directorTrace('meActorUtil.areBackgroundContextsPlaying' + ' name: ' + getActorNameByIndex(i) + ' index: ' + i); return true; } } } return false; } function getCtxIdByName(actorName) { return getViewCtxId(actorName); } function isAuditPlayState(ctxId) { var auditPlayState = false; if (contextDefinitionMap[ctxId]) { var ctxDef = contextDefinitionMap[ctxId]; if (ctxDef != null) { auditPlayState = ctxDef.getClipDescriptor().getAuditPlayState(); } } return auditPlayState; } String.prototype.trim = function() { return this.replace(/^\s*|\s*$/g,''); } function isArray(array) { return ((array != null) && (typeof array == "object") && (array.constructor == Array)); } function dumpStringArray(array) { directorTrace(array); if (isArray(array)) { for (var i = 0; i < array.length; i++) { if (isArray(array[i])) { dumpStringArray(array[i]); } else { directorTrace(array[i]); } } } } function dumpStringList(list) { for (var e1 in list) { directorTrace('e1: ' + e1 + ' typeof e1: ' + (typeof e1) + ' typeof list: ' + (typeof list)); if (list[e1] && (typeof list[e1] == 'object')) { dumpStringList(list[e1]); } } } var onClickTicks = 0; var onClickInterval = 1000; function isOnClickAllowed() { var clickAllowed = false; var ticks = getTicks(); var onClickInProgress = ticks < onClickTicks; if (!onClickInProgress) { var contextsActive = areContextsActive(); clickAllowed = allContextsReady && reconfigurationComplete && !contextsActive; // if (!clickAllowed) // { // directorTrace('meActorUtil.isOnClickAllowed onClick NOT allowed' + // '\n allContextsReady: ' + allContextsReady + // ' reconfigurationComplete: ' + reconfigurationComplete + // ' contextsActive: ' + contextsActive); // } } else { // directorTrace('meActorUtil.isOnClickAllowed onClick IN PROGRESS' + // ' ticks: ' + ticks + // ' onClickTicks: ' + onClickTicks); } return clickAllowed; } var onClickBusy = false; function onClickClosure(method,arg) {return (function() {onClickClosureTarget(method,arg);});} var onClickClosureRequest = null; var onClickRequestCtr = 0; function onClickWdtClosure(method,arg) {return (function() {onClickWdtClosureTarget(method,arg);});} function retryOnClickRequest(method,arg) { var status = false; if (!onClickBusy) { onClickBusy = true; status = true; enableHourGlass(); onClickClosureRequest = onClickClosure(method,arg); setTimeout(onClickClosureRequest,200); onClickWdtRequest = onClickWdtClosure(method,arg); setTimeout(onClickWdtRequest,5000); } return status; } function onClickClosureTarget(method,arg) { if (onClickBusy) { onClickRequestCtr++; if (isOnClickAllowed()) { eval(method + '(\'' + arg + '\')'); resetOnClick(); } else { enableHourGlass(); // directorTrace('onClick.onClickClosureTarget RETRY'); onClickClosureRequest = onClickClosure(method,arg); setTimeout(onClickClosureRequest,200); } } else { // directorTrace('onClick.onClickClosureTarget onClickBusy CLEARED'); } } function onClickWdtClosureTarget(method,arg) { if (onClickBusy && (onClickClosureRequest !== null)) { // directorTrace('onClick.onClickWdtClosureTarget WDT TIMEDOUT'); resetOnClick(); } } function resetOnClick() { onClickRequestCtr = 0; onClickClosureRequest = null; onClickBusy = false; disableHourGlass(); } function requestOnClick(method,arg) { var status; if (isOnClickAllowed()) { if (eval(method + '(\'' + arg + '\')')) { resetOnClick(); } status = 1; // method executed onClickTicks = getTicks() + onClickInterval; } else { if (retryOnClickRequest(method,arg)) { status = 0; // method queued for a retry (i.e., in-progress) onClickTicks = getTicks() + onClickInterval; } else { status = -1; // method blocked } } return status; } var pacifyToggle = true; var pacifyCtr = 0; var actorsStarted = false; function startActors() { if (!actorsStarted) { if (videoChat && !jChatInstallationComplete) { pacifyToggle = !pacifyToggle; if (pacifyToggle) { windowStatus("[" + pacifyCtr + "] PLEASE WAIT... INITIALIZING"); pacifyCtr += 2; } else { windowStatus(" "); } setTimeout("startActors();",2000); return; } actorsStarted = true; startActors2(); } } function isAuditPointer(ctxId) { return auditPointerMap[ctxId]; } function pauseAll() { if ((contextDefinitionMap !== null) && (contextIdx > 0)) { for (var i = 1; i <= contextIdx; i++) { pauseContext(i); } transitionInProgress(); } } function fireMeEvent(event,eventDescriptor) { if ((contextDefinitionMap !== null) && (contextIdx > 0)) { for (var i = 1; i <= contextIdx; i++) { getActorByIndex(i).invoke(event,eventDescriptor); } } } String.prototype.startsWith = function(aString) { return this.indexOf(aString) == 0; } function isString(o) { return typeof o == 'string'; } function windowStatus(text) { //return; window.status = text; } function HttpRequest () { var client; this.sendRequest = function () { if (arguments.length == 4) { var type = arguments[0]; var url = arguments[1]; var param = arguments[2]; var isAsync = arguments[3]; var files = null; } else if (arguments.length == 5) { var type = arguments[0]; var url = arguments[1]; var param = arguments[2]; var files = arguments[3]; var isAsync = arguments[4]; } else { return null; } if (files === null) { client = new AjaxClient(); client.init(); client.requestType = type; client.isAsync = isAsync; if (type == "GET") { var qs = param.join('&'); if (qs.length > 0) { url += "?" + qs; } return client.makeRequest(url,null); } else { return client.makeRequest(url,param.join(',')); } } else { return null; meLogger.write("HttpRequest Called."); } } this.isValidURL = function (urlIn) { var urlregex = /https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w\/_\.]*(\?\S+)?)?)?/; //var checkSpace = urlIn.value; if (urlregex.test(urlIn)) { for (var i = 0; i < urlIn.length; i++) { ch = urlIn.charAt(i); if (ch == " ") { return (false); break; } } return (true); } else { return (false); } } }// ContextEventDescriptor.js function ContextEventDescriptor() { // example format 'mergeFinalized;1,et.main;success' // 'event;ctxId,htmlElementName;optionalArgs } ContextEventDescriptor.getEvent = function(eventDescriptor) { var event = null; if (ContextEventDescriptor.validate(eventDescriptor)) { event = eventDescriptor.split(';')[0]; } return event; } ContextEventDescriptor.getCtxId = function(eventDescriptor) { var ctxId = null; if (ContextEventDescriptor.validate(eventDescriptor)) { ctxId = eventDescriptor.split(';')[1].split(',')[0]; } return ctxId; } ContextEventDescriptor.getHtmlElement = function(eventDescriptor) { var element = null; if (ContextEventDescriptor.validate(eventDescriptor)) { element = eventDescriptor.split(';')[1].split(',')[1]; } return element; } ContextEventDescriptor.getOptionalArgs = function(eventDescriptor) { var args = null; if (ContextEventDescriptor.validate(eventDescriptor)) { args = eventDescriptor.split(';')[2]; } return args; } ContextEventDescriptor.validate = function(eventDescriptor) { var status = (eventDescriptor && isString(eventDescriptor) && (eventDescriptor.length > 0)); if (!status) { directorTrace('ContextEventDescriptor.validate INVALID DESCRIPTOR: ' + eventDescriptor); } return status; } ContextEventDescriptor.create = function(event,ctxId,actorName,optionalArgs) { var descriptor = null; if (typeof event != 'undefined') { if (typeof ctxId == 'undefined') { ctxId = 'null'; } if (typeof actorName == 'undefined') { actorName = 'null'; } if (typeof optionalArgs == 'undefined') { optionalArgs = 'null'; } descriptor = event + ';' + ctxId + ',' + actorName + ';' + optionalArgs; } return descriptor; } /** * © Copyright ESPRE Solutions, Inc., 2007. All rights are reserved. * @author __USER__ * @version 2.0 */ Project.projectDefaultBasePath = "c:\\meprojects\\"; function Project() { try{ var that = this; var projectBasePath = Project.projectDefaultBasePath; var projectLocalPath = ""; // i.e. thisProject(as provided by user) var projectFullPath = ""; //i.e. c:\myproject\thisProject var projectXMLPath = ""; // c:\myproject\thisProject\Project.xml var encodeXMLPath = ""; // c:\myproject\thisProject\Encode.xml var model = null; var encodeRequest = null; //is null an encode is requested then holds the request object var uploadRequest = null; //is null until an upload is requested then holds the request object //Private API var initialize = function(){ projectLocalPath = ""; projectFullPath = ""; projectXMLPath = ""; encodeXMLPath = ""; model = null; encodeRequest = null; uploadRequest = null; }; var createProjectPaths = function(){ if(arguments.length > 0){ projectLocalPath = arguments[0]; } projectLocalPath = Project.TrimPath(projectLocalPath); projectFullPath = Project.CreateFullProjectPath(projectBasePath,projectLocalPath); projectXMLPath = toPath(projectFullPath,"Project.xml"); encodeXMLPath = toPath(projectFullPath,"Encode.xml"); }; //Public API this.setProjectBasePath = function(_path){ if((_path !== null) && (typeof _path == "string")){ // check is a valid path style (i.e. n:\xx) var re = /^([a-z|A-Z]:){1}/; // pattern to find e.g. C: if(_path.search(re) != -1){ projectBasePath = _path; return true; } } return false; }; this.getProjectBasePath = function(){ return projectBasePath; }; this.resetProjectBasePath = function(){ projectBasePath = Project.projectDefaultBasePath; return true; }; this.isOpen = function() { if(model !== null) {return true;} return false; }; this.create = function () { if(this.isOpen()) return null; // don't disturb an open project if(arguments.length > 0){ projectLocalPath = arguments[0]; } // Check filesystem createProjectPaths(); try { if((projectLocalPath === "") || !doesFileExist(projectXMLPath)){ model = new ControlData(this,projectLocalPath); //projectLocalPath is default or temp name this.save(); return this; } else { meLogger.write("Project [" + projectLocalPath + "] exists." , 3); this.close(); //force reinit return null; } } catch(e) { // meLogger.write(e.name + ' : ' + e.message, 3); alert("Project.create EXCEPTION: " + e.message); meLogger.write("Project [" + projectLocalPath + "] may not be saved as this browser doesn\'t support this functionality.", 2); if (!model) model = new ControlData(this, projectLocalPath); return this; } }; // aProject.open("location") this.open = function() { if(this.isOpen()) return null; // don't disturb an open project var _projectLocation = (arguments.length === 0) ? "" : arguments[0]; createProjectPaths(_projectLocation); if (!doesFileExist(projectXMLPath)){ meLogger.write("open: Project not found",2); this.close(); //force reinit return null; //throw new MeException("Project not found."); } model = new ControlData(this); if (model.populate(projectXMLPath)){ return this; } else{ this.close(); //force reinit meLogger.write("open: Unable to populate project",2); return null; } }; this.remove = function() { if(!this.isOpen()) return true; // not open, nothing to be done. var myLocation = projectFullPath; this.close(); //force reinit return Project.RemoveProject(myLocation); }; /** * */ this.addClip = function () { if ((!model) || (arguments.length === 0)){ return null; } return model.addClip.apply(model,arguments); }; this.reorderClips = function () {return ((model) ? model.reorderClips(arguments[0]) : false);};//TODO:; this.reOrderClips = this.reorderClips;//TODO: Deprecated function, documented as reorderClips(); this.removeClip = function () {return ((model) ? model.removeClipByName(arguments[0]) : false);};//TODO:; this.removeScene = function () {return ((model) ? model.removeSceneByName(arguments[0]) : false);};//TODO:; this.getClip = function () {return ((model) ? model.getClip(arguments[0]) : null);};//TODO:; this.getScene = function () {return ((model) ? model.getScene(arguments[0]) : null);};//TODO:; this.getName = function () {return ((model) ? model.getParameter('general', 'name') : null);};//TODO:; this.addScene = function () { if ((!model) || (arguments.length === 0)){ return null; } return model.addScene.apply(model,arguments); }; this.getClipNames = function () {return ((model) ? model.getClipNames(arguments) : []);};//TODO: this.getSceneNames = function () {return ((model) ? model.getSceneNames(arguments) : []);};//TODO: this.saveAs = function () { if(!this.isOpen()){ return false ;// Nothing TODO } if(arguments.length >0 && arguments[0] !== "") { var curName = model.getParameter('general','name'); var curPath = projectLocalPath; try{ meLogger.write("saveAs: current name = " + curName); if(curName === ""){ model._setParameter('general','name',arguments[0]); } projectLocalPath = arguments[0]; createProjectPaths(); return saveTo(projectXMLPath); } catch (e) { //revert changes alert("Project.saveAs EXCEPTION: " + e.message); model._setParameter('general','name',curName); createProjectPaths(curPath); meLogger.write(e.name + ' :' + e.message,3); return false; } } else { //TODO: This may not be quite right meLogger.write("saveAs: No valid location provided",3); } return false; }; this.save = function () { try{ return saveTo(projectXMLPath); } catch(e){ alert("Project.save EXCEPTION: " + e.message); return false; }; }; var saveTo = function (_XMLPath) { if(!that.isOpen()) { return false ; //nothing TODO; } try{ if (writeToFilePath(model.toXML(),_XMLPath ,true)) { meLogger.write('Control XML Saved to ' + _XMLPath) ; } } catch (e) { alert("Project.saveTo EXCEPTION: " + e.message); meLogger.write(e.name + ' :' + e.message,3); throw(e); } return true; }; this.close = function() { if(this.isOpen()){meLogger.write('Project is now closed.');}; initialize(); return true; }; // Manage encoding process this.prepare4Encoding = function(){ meLogger.write('Preparing to encode....'); var success = true; //assume success if(!this.isOpen()) return false; if(!model.hasClips()) return false; if(encodeRequest !== null && encodeRequest.isEncoding()) return false; // don't step on current encode.xml this.save(); success &= model.prepare4Encoding(projectFullPath); if(success){ saveTo(encodeXMLPath); } model.revertFromEncoding(); return success; }; this.executeEncoding = function(){ if(!this.isOpen()) return false; if(encodeRequest !== null && encodeRequest.isEncoding()) return false; //don't step on a current encoding if(!doesFileExist(encodeXMLPath)) return false; encodeRequest = new EncodeRequest(); encodeRequest.setParameter('xmlFile',encodeXMLPath); encodeRequest.setParameter('sdlFile',this.getSDL()); return encodeRequest.start(); }; this.encode = function() { //TODO meLogger.write("Inside Encode....."); if(!this.prepare4Encoding()) return false; if(!this.executeEncoding()) return false; return true; }; this.encodeScene = function() { //TODO: return false; }; this.cancelEncode = function(){ if(encodeRequest === null || encodeRequest.isCompleted()) return true; encodeRequest.cancel(); return true; }; this.getEncodeProgress = function(){ if(encodeRequest === null)return 0; return encodeRequest.getProgress(); }; this.getEncodeVideoProgress = function(){ if(encodeRequest === null)return 0; return encodeRequest.getVideoProgress(); }; this.getEncodeAudioProgress = function(){ if(encodeRequest === null)return 0; return encodeRequest.getAudioProgress(); }; this.getEncodeErrors = function(){ if(encodeRequest === null)return ""; return encodeRequest.getErrors(); }; this.isEncodeCompleted = function(){ if(encodeRequest === null)return false; return encodeRequest.isCompleted(); }; this.isEncoding = function(){ if(encodeRequest === null)return false; return encodeRequest.isEncoding(); }; this.isEncodeError = function(){ if(encodeRequest === null)return false; return encodeRequest.isError(); }; this.getSDL = function() { if(!this.isOpen()) return ""; var anSDL = model.getSDL("file:/" + projectFullPath); // fix back slashes to forward slashes anSDL = anSDL.replace(/\\/g,"/"); return anSDL; }; this.getSdlPath = function() { if(!this.isOpen()) return ""; return model.getSDL(projectFullPath);; }; //Manage upload process this.uploadAs = function (_name){ meLogger.write("UploadAs called....."); if(!this.isOpen()) return false; if(_name === null || _name === ""){return false;}; //fail if name not supplied if(uploadRequest !== null && uploadRequest.isUploading()){return false;}; //meLogger.write(encoderXML); var _manifestFiles = ManifestFactory.theInstance().getEncodeArtifacts(encodeXMLPath); meLogger.write("Number of files to be uploaded: " + _manifestFiles.length); for (i=0;i<_manifestFiles.length;i++){ if(!doesFileExist(_manifestFiles[i])){ //fail if all files not present meLogger.write("Upload request failed: file not found - " + _manifestFiles[i]); return false; } } var _nspace = model.getParameter('general', 'nameSpace'); uploadRequest = new UploadRequest(_nspace,_name); meLogger.write("Upload object created....."); uploadRequest.setManifestFiles(_manifestFiles); meLogger.write(uploadRequest.toString()); var result = uploadRequest.start(); //TODO: uploadRequest is the object that Don may be interested // uploadRequest can be queried: getName(), getTarget(), getNSpace(), getManifestFiles() //where the return type of the last one being an array and the rest be a regular string. return result; }; this.upload = function () { meLogger.write("Upload called....."); if(!this.isOpen()) return false; var _name = model.getParameter('general', 'name'); meLogger.write("upload: Trying to upload " + _name); if(_name === ""){return false;}; return this.uploadAs(_name); }; this.getUploadProgress = function(){ if(uploadRequest === null)return 0; return uploadRequest.getProgress(); }; this.getUploadErrors = function(){ if(uploadRequest === null)return ""; return uploadRequest.getErrors(); }; this.isUploadCompleted = function(){ if(uploadRequest === null)return false; return uploadRequest.isCompleted(); }; this.isUploading = function(){ if(uploadRequest === null)return false; return uploadRequest.isUploading(); }; this.isUploadError = function(){ if(uploadRequest === null)return false; return uploadRequest.isError(); }; this.getProjectFullPath = function(){ return projectFullPath; } // For Test purpose only this.getModel = function() { return ((model) ? model : null); }; } catch(e) { alert("Project. EXCEPTION: " + e.message); meLogger.write(e.name + ':= ' + e.message, 3); }; // Delegate the Parameter management to ControlData this.getSupportedGroups = function () {return ((model) ? model.getSupportedGroups() : []);};//TODO: this.getActiveParameters = function () {return ((model) ? model.getActiveParameters.apply(model,arguments): []);};//TODO: this.setParameter = function () {return ((model) ? model.setParameter.apply(model,arguments): false);};//TODO: this.resetParameter = function () {return ((model) ? model.resetParameter.apply(model,arguments): false);};//TODO: this.getParameter = function () {return ((model) ? model.getParameter.apply(model,arguments): null);};//TODO: this.removeParameter = function () {return ((model) ? model.removeParameter.apply(model,arguments): false);};//TODO: // End of Parameter management API }; //Class methods Project.CreateProject = function () { var result = null; var project = new Project(); if(arguments.length > 0){ result = project.create(arguments[0]); } else { result = project.create(); } if(!result)meLogger.write("Error Creating Project.", 3); return result; }; Project.OpenProject = function (name) { var result = null; var project = new Project(); try { result = project.open(name); } catch(e) { alert("Project.OpenProject EXCEPTION: " + e.message); meLogger.write(e.name + ' : ' + e.message, 3); return null; } if(!result)meLogger.write("Error Opening Project.", 3); return result; }; Project.RemoveProject = function (_projectLocation) { if(_projectLocation === null || _projectLocation === ""){ return false; }; // remove the project's files (and directories?????) we may need to remove other artifacts too. try{ var myLocation = Project.TrimPath(_projectLocation); var fullPath = Project.CreateFullProjectPath(Project.projectDefaultBasePath, myLocation); return deleteProject(fullPath); } catch(e) { alert("Project.RemoveProject EXCEPTION: " + e.message); meLogger.write(e.name + ":- " + e.message, 3); } return true ; }; Project.TrimPath = function(_location){ //Trim any beginning or ending whitespace var re = /(^\s*)|(\s*$)/g; _location = _location.replace(re,""); // fix forward slashs to back slashs re = /\//g; _location = _location.replace(re,"\\"); //if xml filename provided, trim it re = /\\project.xml$|\\encode.xml$/i; _location = _location.replace(re,"\\"); // remove trailing backslash re = /\\$/; return _location.replace(re,""); }; Project.CreateFullProjectPath = function(_basePath,_location){ //if projectLocalPath is absolute, just use it var re = /^([a-z|A-Z]:){1}/; // pattern to find e.g. C: if(_location.search(re) != -1){ // found drive letter return _location; } else{ return toPath(_basePath, _location); } }; Project.SetProjectDefaultBasePath = function(_path){ if(_path !== null && (typeof _path == "string")){ // check is a valid path style (i.e. n:\xx) var re = /^([a-z|A-Z]:){1}/; // pattern to find e.g. C: if(_path.search(re) != -1){ Project.projectDefaultBasePath = _path; return true; } } return false; }; Project.Install = function(){ var anEncoder = Encoder.theInstance(); anEncoder.install(); }; Project.isInstalled = function(){ var anEncoder = Encoder.theInstance(); return anEncoder.isInitialized(); }; // Media Engine Actor var chatOnly = false; var dr = null; // Don Smith: This will become the new AppletSpec. var clipDirector = null; var contextIdx = 0; var contextDefinitionMap = null; var actorNameMap = null; var actorInstanceMap = null; var actorPrimary = null; var actorInstanceCtr = 0; var foregroundMap = null; var auditPointerMap = null; var cidMsg = -1000; var cameraCaptureDocument = null; var videoChat = false; var videoMessage = false; var msgsEnabled = false; var _TRACE = false; function Actor() { // args: name,tag,clipWidth, clipHeight var that = this; var name; var tag; var clipWidth; var clipHeight; if (arguments.length == 1) { name = arguments[0]; tag = ""; clipWidth = ""; clipHeight = ""; } else if (arguments.length == 2) { name = arguments[0]; tag = arguments[1]; clipWidth = ""; clipHeight = ""; } else if (arguments.length == 3) { name = arguments[0]; tag = ""; clipWidth = arguments[1]; clipHeight = arguments[2]; } else if (arguments.length == 4) { name = arguments[0]; tag = arguments[1]; clipWidth = arguments[2]; clipHeight = arguments[3]; } this.eventManager = EventManager; this.eventManager(); if (dr === null) dr = jDirectorInit(); if (actorInstanceMap === null) { actorInstanceMap = new Object(); } actorInstanceMap[++actorInstanceCtr] = this; if (foregroundMap === null) foregroundMap = new Object(); if (auditPointerMap === null) auditPointerMap = new Object(); var defaultAutoMute = 'false'; var defaultAutoplay = 'false'; var defaultClipActorsEnabled = 'true'; var defaultControlsVisible = 'false'; var defaultGestures = 'true'; var defaultHeight = '240'; var defaultLoop = 'false'; var defaultPrimary = 'true'; var defaultVolume = '90'; var defaultWaitForView = 'true'; var defaultWidth = '320'; var defaultPauseViaStall = 'true'; var defaultConvertSegments = 'false'; var defaultMsgsEnabled = false; var defaultRgbSrcEnabled = false; var defaultRgbSrcIdx = -1; this._autoMute = defaultAutoMute; this._autoplay = defaultAutoplay; this._clipActorsEnabled = defaultClipActorsEnabled; this._controlsVisible = defaultControlsVisible; this._gestures = defaultGestures; this._height = defaultHeight; this._loop = defaultLoop; this._primary = defaultPrimary; this._volume = defaultVolume; this._waitForView = defaultWaitForView; this._width = defaultWidth; this._pauseViaStall = defaultPauseViaStall; this._convertSegments = defaultConvertSegments; this._name = name; this._mpc = null; //this._tag = tag; this._tag = Actor.getTagPrefix() + name; this._divId = Actor.getDivIdPrefix() + name; this._currentClipHandle = null; this._previousClipHandle = null; this._msgsEnabled = defaultMsgsEnabled; this.setMsgsEnabled = function(state) { this._msgsEnabled = state; } this.areMsgsEnabled = function() {return this._msgsEnabled;} this._rgbSrcEnabled = defaultRgbSrcEnabled; this.setRgbSrcEnabled = function(state) { this._rgbSrcEnabled = state; } this.isRgbSrcEnabled = function() {return this._rgbSrcEnabled;} this._rgbSrcIdx = defaultRgbSrcIdx; this.setRgbSrcIdx = function(idx) { this._rgbSrcIdx = idx; } this.getRgbSrcIdx = function() {return this._rgbSrcIdx;} this._contextConfigured = new Object(); this.setMpc = function(mpc) { this._mpc = mpc; this.initMpc(); } this.initMpc = function() { return; this._contextConfigured = new Object(); setTransitionRequested(true); this.resetClipHandles(); // this.stopMyContexts(); allContextsReady = false; // this.removeMyContexts(); foregroundMap = null; auditPointerMap = null; } this.getMpc = function() {return this._mpc;} this.setTag = function(tag) {this._tag = tag;} this.getTag = function() { if (this._tag == '') { return this._divId; } else { return this._tag; } } this.setDivId = function(divId) {this._divId = divId;} this.getDivId = function() {return this._divId;} this.setLoop = function(loop) {this._loop = loop;} this.setPrimary = function(primary) {this._primary = primary;} this.setSecondary = function(secondary) {this._primary = !secondary;} this.isPrimary = function() {return this.primary;} this.isSecondary = function() {return !this.primary;} this.initPlayOrBufferClip = function(clipHandle,wfv,ap) { //this.validateHtml(); preInit(); contextIdx++; this.addContext(contextIdx); if (this.areMsgsEnabled()) {cidMsg = contextIdx;} // TODO GLM var aClipDescriptor = ClipDescriptor.findClipDescriptor(clipHandle); if (aClipDescriptor === null) { var resolvedClip = this.resolveClip(clipHandle); if (resolvedClip !== null) { aClipDescriptor = this.addSdl(resolvedClip); if (aClipDescriptor != null) { aClipDescriptor.setForeground(wfv || hasView); } //alert('meActor.initPlayOrBufferClip resolvedClip: ' + resolvedClip); } } //if (!wfv && !ap) debugger; aClipDescriptor = this.processClipDescriptor(this,contextIdx,clipHandle); wfv = wfv || this.areMsgsEnabled() || aClipDescriptor.isForeground() || hasView; if (wfv) { jActorInit(contextIdx, this.getTag(), this.getClipWidth(), //aClipDescriptor.getWidth(), this.getClipHeight(), //aClipDescriptor.getHeight(), this._divId, this.isChat()); } jDirCtxt(dr,contextIdx,'waitForView' ,wfv); jDirCtxt(dr,contextIdx,'autoplay' ,(hasView ? false : aClipDescriptor.getAutoplay())); jDirCtxt(dr,contextIdx,'sdl' ,aClipDescriptor.getSdl()); jDirCtxt(dr,contextIdx,'noAudio' ,aClipDescriptor.getNoAudio()); jDirCtxt(dr,contextIdx,'convertSegments' ,aClipDescriptor.getConvertSegments()); jDirCtxt(dr,contextIdx,'videoDataCacheSize' ,aClipDescriptor.getVideoDataCacheSize()); jDirCtxt(dr,contextIdx,'videoIndexCacheSize',aClipDescriptor.getVideoIndexCacheSize()); jDirCtxt(dr,contextIdx,'audioDataCacheSize' ,aClipDescriptor.getAudioDataCacheSize()); jDirCtxt(dr,contextIdx,'audioIndexCacheSize',aClipDescriptor.getAudioIndexCacheSize()); jDirCtxt(dr,contextIdx,'volume' ,aClipDescriptor.getVolume()); jDirCtxt(dr,contextIdx,'codeBaseOverride' ,aClipDescriptor.getCodeBaseOverride()); jDirCtxt(dr,contextIdx,'defined' ,'true'); jDirCtxt(dr,contextIdx,'primary' ,this._primary); jDirCtxt(dr,contextIdx,'autoMute' ,this._autoMute); jDirCtxt(dr,contextIdx,'loop' ,this._loop); jDirCtxt(dr,contextIdx,'pauseViaStall' ,this._pauseViaStall); jDirCtxt(dr,contextIdx,'rgbSrcEnabled' ,this._rgbSrcEnabled); jDirCtxt(dr,contextIdx,'rgbSrcIdx' ,this._rgbSrcIdx); if (this.areMsgsEnabled()) { jDirCtxt(dr,contextIdx,'autoBandwith','false'); jDirCtxt(dr,contextIdx,'syncBandwith','false'); jDirCtxt(dr,contextIdx,'dumpSdl' ,'false'); } else { jDirCtxt(dr,contextIdx,'syncBandwith',aClipDescriptor.getSyncBandwidth()); } this.processHtmlParams(dr,contextIdx); if (this._mpc == null) { this.initMpc(); } this._contextConfigured[contextIdx] = true; //alert('meActor.initPlayOrBufferClip' + ' contextIdx: ' + contextIdx + ' tag: ' + this.getTag() + ' foreground: ' + wfv); } this.switchClip = function(fromHandle,toHandle) { switchContext(this.getTag(),this.getIndexOf(fromHandle),this.getIndexOf(toHandle)); transitionInProgress(); } function preInit() { if (dr === null) { dr = jDirectorInit(); } if (!clipDirector || (clipDirector === null)) { // COMMENTED OUT BY DON SMITH -- Replacing with callback from AppletManager //setClipDirector(dr.getInstance()); //alert('meActor.preInit clipDirector: ' + clipDirector); } return allContextsReady; } this.initialized = false; this.init = function() { if (!this.initialized) { // TODO GLM this.invoke('init',''); this.initialized = true; } } this.playInitialized = false; this.initPlay = function(clipHandle) { var aClipDescriptor = ClipDescriptor.findClipDescriptor(clipHandle); if (aClipDescriptor === null) { var resolvedClip = this.resolveClip(clipHandle); if (resolvedClip !== null) { var playCd = this.addSdl(resolvedClip); //directorTrace('meActor.initPlay resolvedClip: ' + resolvedClip); if (this._bufferClipHandle != null) { var bufferedCd = this.getClipDescriptor(this._bufferClipHandle); if (bufferedCd != null) { var ctxId = this.getContextIndex(); //directorTrace('meActor.initPlay' + ' ctxId: ' + ctxId + ' bufferedCd: \n' + bufferedCd); //alert('meActor.initPlay' + ' ctxId: ' + ctxId + ' bufferedCd: \n' + bufferedCd); playCd.cloneBasicParameters(bufferedCd); this.reconfigureContextCommon(ctxId,playCd); this._contextConfigured[ctxId] = false; // configuration finalized on first 'play' } } } } if (!this.playInitialized && !this.bufferInitialized) { this.initPlayOrBufferClip(clipHandle,true,true); this.playInitialized = true; //this.bufferInitialized = true; return true; } return false; } this.bufferInitialized = false; this.initBuffer = function(clipHandle) { if (!this.bufferInitialized || (this.getEvent() == 'init')) { //debugger; this.initPlayOrBufferClip(clipHandle,false,false); this.bufferInitialized = true; //this.playInitialized = true; return true; } //debugger; return false; } this.hide = function() { // directorTrace('meActor.hide'); //hideElement(this.getTag()); //directorTrace('Actor.hide getTag: ' + this.getTag()); //AppletManager.theInstance().setVisibility(this.getTag(),false); document.getElementById(this.getTag()).style.visibility = 'hidden'; } this.show = function() { // directorTrace('meActor.show'); //showElement(this.getTag()); //directorTrace('Actor.show getTag: ' + this.getTag()); //AppletManager.theInstance().setVisibility(this.getTag(),true); document.getElementById(this.getTag()).style.visibility = 'visible'; } this.playDeferred = false; this._playClipHandle = null; this.play = function(clipHandle) { if (!Actor.started) { this.playDeferred = true; if (clipHandle) { this._playClipHandle = clipHandle; } var _this = this; setTimeout(_this.play._bind(_this,clipHandle),1000); return; } if (!clipHandle) { clipHandle = this._playClipHandle; } //debugger; if (this.chatRemoteView) { this.playChat(clipHandle); } else { var resolvedClip = this.resolveClip(clipHandle); if (resolvedClip !== null) { this.play2(resolvedClip,1,0,'-1','-1',true); } else { this.actorTrace('meActor.play UNRESOLVED CLIP: ' + clipHandle); } } this.playDeferred = false; } this.play2 = function(clipHandle,fromSegment,fromFrame,toSegment,toFrame,pauseAtEnd) { if (this.initPlay(clipHandle)) { this.trackClipHandle(clipHandle); this.playDeferred = false; meInit(); } else { // if (!reconfigurationComplete) return; var viewId = this.getContextIndex(); //this.actorTrace('meActor.play2 indexOf: ' + viewId); if ( ((clipHandle != this._playClipHandle) && (clipHandle != this._bufferClipHandle)) || ((this._currentClipHandle != clipHandle) && (this._bufferClipHandle === null)) ) { directorTrace('meActor.play2 reset contextConfigured' + '\n clipHandle : ' + clipHandle + '\n playClipHandle : ' + this._playClipHandle + '\n bufferClipHandle: ' + this._bufferClipHandle); this._contextConfigured[viewId] = false; } if ( (this._currentClipHandle !== null) && (this._currentClipHandle != clipHandle) && this._contextConfigured[viewId] && !this.isDefaultStartUp() ) { this.actorTrace('meActor.play2 switchClip' + '\n _currentClipHandle: ' + this._currentClipHandle + '\n clipHandle: ' + clipHandle + '\n playClipHandle : ' + this._playClipHandle + '\n bufferClipHandle: ' + this._bufferClipHandle); this.switchClip(this._currentClipHandle,clipHandle); this.trackClipHandle(clipHandle); } else { if (this._contextConfigured[viewId] && !this.isDefaultStartUp()) { this.actorTrace('meActor.play2 playContext' + '\n clipHandle: ' + clipHandle + '\n indexOf(clipHandle): ' + this.getIndexOf(clipHandle)); playContext(this.getIndexOf(clipHandle)); this.trackClipHandle(clipHandle); } else { // TODO GLM reprovision other html parameters // this.processClipDescriptor(this,viewId,clipHandle); this.actorTrace('meActor.play2 playClipFromTo' + '\n viewId: ' + viewId + '\n clipHandle: ' + clipHandle); this._contextConfigured[viewId] = false; this.reconfigureContext(this,viewId,clipHandle); playClipFromTo(viewId,fromSegment,fromFrame,toSegment,toFrame,pauseAtEnd,this.getClipDescriptor(clipHandle).getSdl()); this._contextConfigured[viewId] = true; this.trackClipHandle(clipHandle); } } } // this.setDefaultStartUp(false); } this.bufferDeferred = false; this._bufferClipHandle = null; var callbackbuffer = null; function callbuffer() { that.buffer(); } this.buffer = function() { var clipHandle = this._bufferClipHandle; if (arguments.length == 1) { clipHandle = arguments[0];} //alert('buffer 1:<' + clipHandle + '><' + this._bufferClipHandle + '>'); //var _this = this; if (!Actor.started || this.playDeferred) { this.bufferDeferred = true; if (clipHandle !== null) { this._bufferClipHandle = clipHandle; } setTimeout(callbuffer,1000); return; } //alert('buffer 2:<' + clipHandle + '><' + this._bufferClipHandle + '>'); //debugger; var resolvedClip = this.resolveClip(clipHandle); if (resolvedClip !== null) clipHandle = resolvedClip; //directorTrace('buffer 3 clipHandle: <' + clipHandle + '>' + ' _bufferClipHandle: <' + this._bufferClipHandle + '>' + ' resolvedClip: <' + resolvedClip + '>'); this._bufferClipHandle = clipHandle; if (this.initBuffer(clipHandle) && !hasView) { // TODO GLM //if (chatOnly) meInit(); this.bufferDeferred = false; } else { if (hasView) { this.buffer2(); return; } var ci = this.getIndexOf(clipHandle); //if (ci == 0) //{ //this.addSdl(clipHandle); //ci = this.getIndexOf(clipHandle); //debugger; //} this.processClipDescriptor(this,ci,clipHandle); bufferClipFromTo(ci,1,0,1,0,true,this.getClipDescriptor(clipHandle).getSdl()); this._contextConfigured[ci] = true; } } this.trackClipHandle = function(clipHandle) { this._previousClipHandle = this._currentClipHandle; // if (this._currentClipHandle === null) foregroundMap[this.getIndexOf(clipHandle)] = true; // foregroundMap[this.getIndexOf(clipHandle)] = (this._currentClipHandle === null); this._currentClipHandle = clipHandle; } this.resetClipHandles = function() { this._previousClipHandle = null; this._currentClipHandle = null; } this.getIndexOf = function(clipHandle) { var ctxId = 0; var ctxDef = this.getContextDefinitionByClipHandle(clipHandle); if (ctxDef != null) { ctxId = ctxDef.getIdx(); } if (ctxId == 0) directorTrace('meActor.getIndexOf' + ' clipHandle: ' + clipHandle + ' ctxId: ' + ctxId); return ctxId; } this.setAutoMute = function(autoMute) {this._autoMute = autoMute;} this.playPause = function(forcePlay) { // if (!reconfigurationComplete) return; forcePlay = forcePlay || false; var idx = (this._currentClipHandle != null) ? this.getIndexOf(this._currentClipHandle) : this.getContextIndex(); if (isContextPlaying(idx) && !forcePlay) { pauseContext(idx); } else { // directorTrace('meActor.playPause ctxId: ' + idx); playContext(idx); } } this.stop = function() { // if (!reconfigurationComplete) return; stopContext(this.getContextIndex()); } this.setMpcReference = function(mpcReference) { this._mpcReference = mpcReference; var path = mpcReference.split('/'); var i; var subscript = ''; for (i = 0; i < path.length; i++) { if (path[i].length > 0) { subscript += '[\'' + path[i] + '\']'; } } this.setMpc(eval(getClipDescriptorListAsString() + subscript)); } this.playing_stopped = function(eventDescriptor) { // var myId = eventDescriptor.split(';')[1].split(',')[0]; // if (this.areMsgsEnabled()) { // displayImage(myId,stoppedImageSpec); // hideMsgDiv(); // } // else { // // directorTrace('meActor.playing_stopped coerce: ' + myId); // // coerceAfterStop(myId); // } } this.nextSegment = function(eventDescriptor) { if (this.areMsgsEnabled()) { cidMsgSegmentNumber = eventDescriptor.split(";")[2].split(",")[0]; // directorTrace('meActor.nextSegment eventDescriptor: ' + eventDescriptor + ' cidMsgSegmentNumber:' + cidMsgSegmentNumber); var nbrOfSegments = getNbrOfSegments(this.getContextIndex()); if (nbrOfSegments === 0) nbrOfSegments = 1; if (cidMsgSegmentNumber > nbrOfSegments) nbrOfSegments = cidMsgSegmentNumber; change_message('Video Message ' + cidMsgSegmentNumber + ' of ' + nbrOfSegments); } } this.pause = function() { // if (!reconfigurationComplete) return; pauseContext(this.getContextIndex()); } this.resume = function() { // if (!reconfigurationComplete) return; // directorTrace('meActor.resume viewCtxId: ' + this.getContextIndex()); playContext(this.getContextIndex()); } this.promote = function(anActor,clipHandle,marker) { marker = (typeof marker == 'undefined') ? null : marker; var resolvedClip = this.resolveClip(clipHandle); if (resolvedClip != null) { if (this.getClipDescriptor(clipHandle) == null) { this.addSdl(resolvedClip); } } else { alert('meActor.promote unable to resolve: ' + clipHandle); return; } anActor.updateHistoryList(); this.promoteRestoreCommon(anActor,resolvedClip,(marker == null) ? this._eventDescriptor.split(";")[2] : marker); } this.promoteRestoreCommon = function(anActor,clipHandle,marker) { var viewId = getViewCtxId(anActor.getTag()); directorTrace('meActor.promoteRestoreCommon' + ' this.name: ' + this._name + ' anActor.name: ' + anActor._name + ' marker: ' + marker + ' source viewId: ' + this.getContextIndex() + ' target viewId: ' + viewId + ' clipHandle: ' + clipHandle + '\n sourceFps: ' + getVideoFps(this.getContextIndex()) + ' targetFps: ' + getVideoFps(viewId)); this.reconfigureContext(anActor,viewId,clipHandle); playClipFromTo(viewId,this.getMarkerSegment(marker),this.getMarkerRecNum(marker),'-1','-1',true,this.getClipDescriptor(clipHandle).getSdl()); transitionInProgress(); anActor.disableAudit = 2; } this.restartAtInProgress = function(eventDescriptor) {restartAtInProgress(-1,eventDescriptor);} this.restartAtComplete = function(eventDescriptor) {restartAtComplete(-1,eventDescriptor);} this.imageDisplayed = function(eventDescriptor) {msgImageDisplayed = true;} this.playMsg = function() { // if (!reconfigurationComplete) return; if (isMsgWaiting()) { var viewId = this.getContextIndex(); if (isContextPlaying(viewId)) { stopMsg(); } else { showMsgDiv(); // directorTrace('meActor.playMsg' + '\n video: ' + nextMsgClip + 'video_s1' + '\n audio: ' + nextMsgClip + 'audio_s1'); playClip(viewId,nextMsgClip+'video_s1',nextMsgClip+'audio_s1'); nextMsgClip = ''; } } } this.fullScreen = function(eventDescriptor) { // directorTrace('meActor.fullScreen'); ctxFullScreenMode = true; } this.exitFullScreen = function(eventDescriptor) { // directorTrace('meActor.exitFullScreen'); ctxFullScreenMode = false; } this.processClipDescriptor = function(anActor,index,clipHandle) { var aClipDescriptor = this.getClipDescriptor(clipHandle); //directorTrace('meActor.processClipDescriptor' + ' index: ' + index + ' clipHandle: ' + clipHandle); this._width = aClipDescriptor.getWidth(); this._height = aClipDescriptor.getHeight(); if (contextDefinitionMap === null) { contextDefinitionMap = new Object(); } var anActor = (getActorByIndex(index) != null) ? getActorByIndex(index) : this; var ctxDef = new ContextDefinition(anActor,index,clipHandle,aClipDescriptor); contextDefinitionMap[index] = ctxDef; // directorTrace('meActor.processClipDescriptor' + ' index: ' + index + ' auditPlayState: ' + ctxDef.getClipDescriptor().getAuditPlayState()); if (actorNameMap === null) { actorNameMap = new Object(); } if (!actorNameMap[this._name]) { actorNameMap[this._name] = new Object(); } // if (!actorNameMap[this._name]['instance']) // { actorNameMap[this._name]['instance'] = this; // } actorNameMap[this._name][clipHandle] = ctxDef; actorNameMap[this._name][ctxDef.getClipDescriptor().getExtendedClipHandle()] = ctxDef; if (foregroundMap === null) { foregroundMap = new Object(); } foregroundMap[index] = aClipDescriptor.isForeground(); if (auditPointerMap === null) { auditPointerMap = new Object(); } auditPointerMap[index] = aClipDescriptor.isAuditPointer(); return aClipDescriptor; } this.removeMyContexts = function() { this.myContextCtr = 0; this.myContexts = null; } this.myContextCtr = 0; this.myContexts = null; this.addContext = function(ctxId) { if (this.myContexts === null) { this.myContextCtr = 0; this.myContexts = new Object(); } this.myContexts[this.myContextCtr] = ctxId; this.myContextCtr++; } this.stopMyContexts = function() { if (this.myContexts !== null) { for (var i = 0; i < this.myContextCtr; i++) { var ctxId = this.myContexts[i]; stopContext(ctxId); //clearEventQueue(ctxId); } } } this.disableAudit = 0; this.auditBackgroundContexts = function() { var status = false; if (this.myContexts !== null) { if (this.disableAudit <= 0) { if (this.auditPointerPresent() == pointerPresentNotSupported) { for (var i = 0; i < this.myContextCtr; i++) { var ctxId = this.myContexts[i]; if (isBackground(ctxId) && isAuditPlayState(ctxId)) { var playing = isContextPlaying(ctxId); if (isMousePresent(ctxId)) { if (!playing) { directorTrace('meActor.auditBackgroundContexts mousePresent and not playing'); this.invoke('mouseEntered','audit:' + ctxId); status = true; } } else { if (playing) { directorTrace('meActor.auditBackgroundContexts mousePresent not present and playing'); this.invoke('mouseExited','audit:' + ctxId); status = true; } } } } } } } return status; } this.addEventRule('mouseExited','this.disableAudit--'); this.trackTransitions = function(event,eventDescriptor) { if (event.length > 0) { var evt = event.toString(); if ( (evt.indexOf('mouse') != -1) || (evt.indexOf('restart') != -1) ) { transitionInProgress(); // directorTrace('meActor.trackTransitions' + ' evt: ' + evt + ' ticks: ' + transitionTicks); } } } this.playRelativeScene = function(relativeSceneIndex,sourceActor,clipHandle,playToEnd) { var resolvedClip = this.resolveClip(clipHandle); if (resolvedClip !== null) clipHandle = resolvedClip; var pte = (playToEnd == undefined) ? false : playToEnd; var rsi = parseInt(relativeSceneIndex); var status = false; var sourceActorId = getCtxIdByName(sourceActor.getTag()); var ctxId = getCtxIdByName(this.getTag()); var clipHandleId = this.getIndexOf(clipHandle); var sdl = this.getClipDescriptor(clipHandle).getSdl(); var marker = getPosition(sourceActorId,''); var currentSceneIndex = this.convertMarkerToSceneIndex(sourceActorId,marker); // directorTrace('meActor.playRelativeScene' + // ' relativeSceneIndex: ' + rsi + // ' sourceActorId: ' + sourceActorId + // ' ctxId: ' + ctxId + // ' clipHandleId: ' + clipHandleId + // ' marker: ' + marker + // ' currentSceneIndex: ' + currentSceneIndex); var sceneIndex = -1; var scene = null; if (currentSceneIndex >= 0) { sceneIndex = currentSceneIndex + rsi; scene = this.getSceneByIndex(sourceActorId,sceneIndex); if (scene != null) { // directorTrace('meActor.playRelativeScene' + // '\n currentClipHandle: ' + this._currentClipHandle + // '\n clipHandle: ' + clipHandle + // '\n relativeSceneIndex: ' + rsi + // '\n marker: ' + marker + // '\n sceneIndex: ' + sceneIndex + // '\n scene: ' + scene + // '\n sourceActorId: ' + sourceActorId + // '\n ctxId: ' + ctxId + // '\n clipHandleId: ' + clipHandleId); var playId = ctxId; stopContext(playId); if ((clipHandleId != 0) && (clipHandleId != ctxId)) { this.switchClip(this._currentClipHandle,clipHandle); playId = clipHandleId; } this.playScene(playId,scene,sdl,clipHandle,pte); status = true; } } if (scene == null) { beep(); } if (!status) { directorTrace('meActor.playRelativeScene' + '\n status: ' + status + '\n currentClipHandle: ' + this._currentClipHandle + '\n clipHandle: ' + clipHandle + '\n relativeSceneIndex: ' + rsi + '\n marker: ' + marker + '\n sceneIndex: ' + sceneIndex + '\n scene: ' + scene + '\n sourceActorId: ' + sourceActorId + '\n ctxId: ' + ctxId + '\n clipHandleId: ' + clipHandleId); } return status; } this.convertMarkerToSceneIndex = function(ctxId,marker) { // marker == 'segment,recNum' var sceneIndex = -1; var sceneDatabase = this.getSceneDatabase(ctxId); if (sceneDatabase != null) { var searchSegment = this.getMarkerSegment(marker); var searchRecNum = this.getMarkerRecNum(marker); var fromSegment = 1; var fromRecNum = 0; var toSegment = 1; var toRecNum = 0; for (var i = 0; i < sceneDatabase.length; i++) { var scene = this.getScene(sceneDatabase,i); if (scene != null) { fromSegment = this.getSceneFromSegment(scene); fromRecNum = this.getSceneFromRecNum(scene); toSegment = this.getSceneToSegment(scene); toRecNum = this.getSceneToRecNum(scene); if ((searchSegment < fromSegment) || (searchSegment > toSegment)) continue; if ((searchSegment == fromSegment) && (searchRecNum < fromRecNum)) continue; if ((searchSegment == toSegment) && (searchRecNum > toRecNum)) continue; sceneIndex = i; break; } } } else { directorTrace('meActor.convertMarkerToSceneIndex' + ' ctxId: ' + ctxId + ' sceneDatabase NULL'); } // directorTrace('meActor.convertMarkerToSceneIndex' + // '\n ctxId: ' + ctxId + // '\n scene: ' + scene + // '\n sceneIndex: ' + sceneIndex + // '\n searchSegment: ' + searchSegment + // ' searchRecNum: ' + searchRecNum + // '\n fromSegment: ' + fromSegment + // ' fromRecNum: ' + fromRecNum + // '\n toSegment: ' + toSegment + // ' toRecNum: ' + toRecNum); return parseInt(sceneIndex); } this.getSceneDatabase = function(ctxId) { var sceneDatabase = null; if (contextDefinitionMap[ctxId]) { var ctxDef = contextDefinitionMap[ctxId]; if (ctxDef != null) { sceneDatabase = ctxDef.getClipDescriptor().getScenes(); } } return sceneDatabase; } this.getScene = function(sceneDatabase,sceneIndex) { return (sceneDatabase[sceneIndex]) ? sceneDatabase[sceneIndex] : null; // 'sceneName;startSegment,startRecNum:endSegment,endRecNum' } this.getSceneByIndex = function(ctxId,sceneIndex) { var sceneDatabase = this.getSceneDatabase(ctxId); return (sceneDatabase != null) ? this.getScene(sceneDatabase,sceneIndex) : null; } this.getSdlByIndex = function(ctxId) { var sdl = null; if (contextDefinitionMap[ctxId]) { var ctxDef = contextDefinitionMap[ctxId]; // directorTrace('meActor.getSdlByIndex' + ' ctxId: ' + ctxId + ' ctxDef: ' + ctxDef); if (ctxDef != null) { var cd = ctxDef.getClipDescriptor(); sdl = cd.getSdl(); } } return sdl; } this.playScene = function(ctxId,scene,sdl,clipHandle,playToEnd) { var resolvedClip = this.resolveClip(clipHandle); if (resolvedClip !== null) clipHandle = resolvedClip; var pte = (typeof playToEnd == 'undefined') ? false : playToEnd; var fromSegment = this.getSceneFromSegment(scene); var fromRecNum = this.getSceneFromRecNum(scene); var toSegment = this.getSceneToSegment(scene); var toRecNum = this.getSceneToRecNum(scene); if (pte) { toSegment = -1; toRecNum = -1; } if (sdl == null) { sdl = this.getSdlByIndex(ctxId); } if (clipHandle != null) { this.reconfigureContext(this,ctxId,clipHandle); setNoAudio(ctxId,false); } // directorTrace('meActor.playScene' + ' ctxId: ' + ctxId + ' scene: ' + scene + ' playToEnd: ' + pte + // '\n fromSegment: ' + fromSegment + ' fromRecNum: ' + fromRecNum + ' toSegment: ' + toSegment + ' toRecNum: ' + toRecNum); playClipFromTo(ctxId,fromSegment,fromRecNum,toSegment,toRecNum,true,sdl); } this.getMarkerSegment = function(marker) { var segment = 1; if (marker && (marker.length > 0)) { segment = marker.split(',')[0]; } return parseInt(segment); } this.getMarkerRecNum = function(marker) { var recNum = 0; if (marker && (marker.length > 0)) { recNum = marker.split(',')[1]; } return parseInt(recNum); } this.getSceneName = function(scene) { var sceneName = null; if (scene && (scene.length > 0)) { sceneName = scene.split(';')[0]; } return sceneName; } this.getSceneFromSegment = function(scene) {// 'sceneName;fromSegment,fromRecNum:toSegment,toRecNum' var segment = 1; if (scene && (scene.length > 0)) { segment = scene.split(';')[1].split(':')[0].split(',')[0]; } return parseInt(segment); } this.getSceneFromRecNum = function(scene) {// 'sceneName;fromSegment,fromRecNum:toSegment,toRecNum' var recNum = 0; if (scene && (scene.length > 0)) { recNum = scene.split(';')[1].split(':')[0].split(',')[1]; } return parseInt(recNum); } this.getSceneToSegment = function(scene) {// 'sceneName;fromSegment,fromRecNum:toSegment,toRecNum' var segment = 1; if (scene && (scene.length > 0)) { segment = scene.split(';')[1].split(':')[1].split(',')[0]; } return parseInt(segment); } this.getSceneToRecNum = function(scene) {// 'sceneName;fromSegment,fromRecNum:toSegment,toRecNum' var recNum = 0; if (scene && (scene.length > 0)) { recNum = scene.split(';')[1].split(':')[1].split(',')[1]; } return parseInt(recNum); } this.getContextIndex = function() { return getViewCtxId(this.getTag()); } this.autoRelativeRange = 0; this.relativeRanges = null; this.getRelativeRange = function(rangeNbr) { var range = null; if (this.relativeRanges != null) { range = this.relativeRanges[rangeNbr]; } return range; } this.maxRelativeRange = 9999; this.setMaxRelativeRange = function(max) { this.maxRelativeRange = max; } this.resetMaxRelativeRange = function() { this.setMaxRelativeRange(9999); } this.addRelativeRange = function(sourceActor,rangeName,rangeNbr,timeOffset) { // rangeNbr = 0-9999 or -1 if function is to auto assign. // rangeNbr = text name for range, 'auto' to auto number names // timeOffset = plus or minus seconds if (rangeNbr == -1) { rangeNbr = this.autoRelativeRange; this.autoRelativeRange++; this.autoRelativeRange = this.autoRelativeRange % this.maxRelativeRange; } if (rangeName == 'auto') { rangeName += rangeNbr; } if (this.relativeRanges == null) { this.relativeRanges = new Array(); } var range = this.createRelativeRange(sourceActor,rangeName,timeOffset); if ((range != null) && (range.length > 0)) { this.relativeRanges[rangeNbr] = range; } } this.createRelativeRange = function(sourceActor,rangeName,timeOffset,playToEnd) { var pte = (playToEnd == undefined) ? false : playToEnd; var sourceActorId = getCtxIdByName(sourceActor.getTag()); var marker = getPosition(sourceActorId,''); var sourceSegment = this.getMarkerSegment(marker); var sourceRecNum = this.getMarkerRecNum(marker); var recNumRatio = getRecNumRatio(sourceActorId,sourceSegment); var fps = getVideoFps(sourceActorId) * recNumRatio; var recNumOffset = Math.ceil(fps * timeOffset); var range = ''; if (recNumOffset < 0) { var startSegment = sourceSegment; var startRecNum = sourceRecNum + recNumOffset; while (startRecNum < 0) { if (startSegment == 1) { startRecNum = 0; } else { startSegment--; startRecNum += getLastRawRecNum(sourceActorId,startSegment); } // directorTrace('meActor.createRelativeRange' + // '\n sourceActorId: ' + sourceActorId + // '\n marker: ' + marker + // '\n sourceSegment: ' + sourceSegment + // '\n sourceRecNum: ' + sourceRecNum + // '\n recNumRatio: ' + recNumRatio + // '\n fps: ' + fps + // '\n recNumOffset: ' + recNumOffset + // '\n startSegment: ' + startSegment + // '\n startRecNum: ' + startRecNum); } range = this.constructSceneDescriptor(rangeName,startSegment,startRecNum,sourceSegment,sourceRecNum,pte); } else { var endSegment = sourceSegment; var endRecNum = sourceRecNum + recNumOffset; var lastRecNum = getLastRawRecNum(sourceActorId,endSegment); var finalSegment = getNbrOfSegments(sourceActorId); while (endRecNum > lastRecNum) { if (endSegment == finalSegment) { endRecNum = lastRecNum; } else { endSegment++; endRecNum -= lastRecNum; lastRecNum = getLastRawRecNum(sourceActorId,endSegment); } } range = this.constructSceneDescriptor(rangeName,sourceSegment,sourceRecNum,endSegment,endRecNum,pte); } // directorTrace('meActor.createRelativeRange' + ' marker: ' + marker + ' range: ' + range); return range; } this.constructSceneDescriptor = function(sceneName,startSegment,startRecNum,endSegment,endRecNum,playToEnd) { var pte = (playToEnd == undefined) ? false : playToEnd; if (pte) { endSegment = '-1'; endRecNum = '-1'; } return sceneName + ';' + startSegment + ',' + startRecNum + ':' + endSegment + ',' + endRecNum; } this.playRelativeRange = function(rangeNbr,sourceActor,clipHandle,playToEnd) { var resolvedClip = this.resolveClip(clipHandle); if (resolvedClip !== null) clipHandle = resolvedClip; var pte = (playToEnd == undefined) ? false : playToEnd; var status = false; var range = this.getRelativeRange(rangeNbr); if (range != null) { this.stop(); if (sourceActor != null) { sourceActor.pause(); } var cd = this.getClipDescriptor(clipHandle); // directorTrace('meActor.playRelativeRange' + // ' ctxIndex: ' + this.getContextIndex() + // ' clipHandle: ' + clipHandle + // ' cd: ' + cd); this.playScene(this.getContextIndex(),range,cd.getSdl(),cd.getExtendedClipHandle(),pte); status = true; } else { beep(); } return status; } this.playRelative = function(sourceActor,timeOffset,playToEnd) { var pte = (playToEnd == undefined) ? false : playToEnd; var timOff = parseInt(timeOffset); var ctxId = getCtxIdByName(this.getTag()); var range = this.createRelativeRange(sourceActor,'playRelative',timOff,pte); if (range != null) { if (this != sourceActor) { sourceActor.pause(); } // directorTrace('meActor.playRelative' + ' ctxId: ' + ctxId + ' range: ' + range + ' playToEnd: ' + pte); this.playScene(ctxId,range,null,null,pte); } else { beep(); } } this.getClipDescriptor = function(clipHandle) { var cd = null; if (clipHandle && (clipHandle.length > 0)) { clipHandle = clipHandle.trim(); if (clipHandle.indexOf('/') == 0) { var subscript = ''; var path = clipHandle.split('/'); for (i = 0; i < path.length; i++) { if (path[i].length > 0) { subscript += '[\'' + path[i] + '\']'; } } cd = eval(getClipDescriptorListAsString() + subscript); } else { if ((this._mpc !== null) && (this._mpc[clipHandle])) { cd = this._mpc[clipHandle]; } } if (cd === null) { cd = ClipDescriptor.findClipDescriptor(clipHandle); } } return cd; } this.getContextDefinitionByClipHandle = function(clipHandle) { var ctxDef = null; if (actorNameMap[this._name][clipHandle]) { ctxDef = actorNameMap[this._name][clipHandle]; } else { var cd = this.getClipDescriptor(clipHandle); if (cd != null) { if (actorNameMap[this._name][cd.getExtendedClipHandle()]) { ctxDef = actorNameMap[this._name][cd.getExtendedClipHandle()]; } } } return ctxDef; } this.getEvent = function() { return this._event; } this.reconfigureContext = function(anActor,ctxId,clipHandle) { var cd = this.processClipDescriptor(anActor,ctxId,clipHandle); this.reconfigureContextCommon(ctxId,cd); this._contextConfigured[ctxId] = false; // configuration finalized on first 'play' } this.reconfigureContextCommon = function(ctxId,cd) { setAutoplay(ctxId,cd.getAutoplay()); setNoAudio(ctxId,cd.getNoAudio()); setConvertSegments(ctxId,cd.getConvertSegments()); if (cd.getVolume() > 0) { setVolume(ctxId,cd.getVolume()); } setVideoDataCacheSize(ctxId,cd.getVideoDataCacheSize()); setVideoIndexCacheSize(ctxId,cd.getVideoIndexCacheSize()); setAudioDataCacheSize(ctxId,cd.getAudioDataCacheSize()); setAudioIndexCacheSize(ctxId,cd.getAudioIndexCacheSize()); setAutoBandwidth(ctxId,cd.getAutoBandwidth()); setSyncBandwidth(ctxId,cd.getSyncBandwidth()); setCodeBaseOverride(ctxId,cd.getCodeBaseOverride()); // directorTrace('meActor.reconfigureContextCommon\n' + cd); } this.macro = function(macroName) { if (macroName.length > 0) { if (macroName.indexOf(')') == -1) { macroName += '()'; } eval(macroName); } } this.restore = function(clipHandle) { var resolvedClip = this.resolveClip(clipHandle); if (resolvedClip !== null) clipHandle = resolvedClip; this.initHistoryList(); this.stop(); var xch = this.getClipDescriptor(clipHandle).getExtendedClipHandle(); // directorTrace('meActor.restore' + ' extendedClipHandle: ' + xch + ' marker: ' + this.historyList[xch]); this.promoteRestoreCommon(this,clipHandle,this.historyList[xch]); } this.updateHistoryList = function() { this.initHistoryList(); var marker = getPosition(this.getContextIndex(),''); var xch = this.getClipDescriptor(this._currentClipHandle).getExtendedClipHandle(); this.historyList[xch] = marker; // directorTrace('meActor.updateHistoryList' + ' extendedClipHandle: ' + xch + ' marker: ' + marker); } this.historyList = null; this.initHistoryList = function() { if (this.historyList == null) { this.historyList = new Object(); } } this.getName = function() { return this._name; } this.auditPointerPresent = function() { return pointerPresentNotSupported; var status = pointerPresentNotSupported; if (this.myContexts !== null) { for (var i = 0; i < this.myContextCtr; i++) { var ctxId = this.myContexts[i]; status = isPointerPresent(ctxId); if (status != pointerPresentNotSupported) { if ((status == pointerNotPresent) && (isBackground(ctxId)) && (isAuditPointer(ctxId)) && (isContextPlaying(ctxId))) { // directorTrace('meActor.auditPointerPresent' + ' mouseExited recovery: ' + ctxId); this.invoke('mouseExited','audit:' + ctxId); } } else { break; } } } return status; } this.displayImage = function(image) { displayImage(this.getContextIndex(),image); } this.start = function(last) { if (!this.isStartUpClipDefined()) { this.actorTrace('meActor.start name: ' + name); this.configure_default(name); } if (last && !Actor.started) { if (this.cameraCaptureMode) { //this.startCameraCaptureMode(); } Actor.configureVmp(); Actor.started = true; requestMpcReconfiguration('meInit',''); } } this.cd_sdlBase = null; this.cd_sdlPrefix = null; this.cd_sdl = 'video_s1.dat.sdl'; this.cd_width = (clipWidth) ? clipWidth : 160; this.setClipWidth = function(width) { this.cd_width = width; } this.getClipWidth = function() { return this.cd_width; } this.cd_height = (clipHeight) ? clipHeight : 128; this.setClipHeight = function(height) { this.cd_height = height; } this.getClipHeight = function() { return this.cd_height; } this.cd_autoplay = true; this.cd_noAudio = false; this.cd_convertSegments = false; this.cd_volume = 90; this.cd_foreground = true; this.cd_scenes = null; this.cd_videoDataCacheSize = 524288*2; this.cd_videoIndexCacheSize = 262144; this.cd_audioDataCacheSize = 262144; this.cd_audioIndexCacheSize = 262144 this.cd_auditPlayState = false; this.cd_auditPointer = false; this.cd_autoBandwidth = false; this.cd_syncBandwidth = false; this.cd_codeBaseOverride = null; this.cdList = null; this.initCdList = function(anSdl) { var resolvedClip = this.resolveClip(anSdl); if (resolvedClip !== null) anSdl = resolvedClip; var cd = null; if (anSdl && (anSdl.length > 0)) { if (this.cdList === null) { this.cdList = new Object(); } else { cd = this.cdList[anSdl]; } if (!cd || (cd === null)) { cd = this.addSdl(anSdl); } } return cd; } this.addSdl = function(anSdl) { var cd = null; if (anSdl && (anSdl.length > 0)) { if (this.cdList === null) { this.cdList = new Object(); } if (this.cdList[anSdl]) { cd = this.cdList[anSdl]; } else { var endOfSdlBase = location.href.lastIndexOf('/')+1; var endOfSdlPrefix = anSdl.lastIndexOf('/')+1; this.cd_sdlBase = location.href.substring(0,endOfSdlBase); var differentBase = (anSdl.indexOf(this.cd_sdlBase) == -1); var absoluteSdl = this.isAbsoluteSdl() || differentBase; if (!absoluteSdl) { this.cd_sdlPrefix = anSdl.substring(endOfSdlBase,endOfSdlPrefix); } else { this.cd_sdlPrefix = ''; this.cd_sdlBase = anSdl.substring(0,endOfSdlPrefix); this.cd_codeBaseOverride = this.cd_sdlBase; directorTrace('meActor.addSdl' + '\n location.href : ' + location.href + '\n codeBaseOverride: ' + this.cd_codeBaseOverride); } if (false) { alert('meActor.addSdl' + '\n location.href : ' + location.href + '\n anSdl : ' + anSdl + '\n isAbsoluteSdl : ' + this.isAbsoluteSdl() + '\n differentBase : ' + differentBase + '\n absoluteSdl : ' + absoluteSdl + '\n cd_sdlBase : ' + this.cd_sdlBase + '\n cd_sdlPrefix : ' + this.cd_sdlPrefix + '\n cd_codeBaseOverride: ' + this.cd_codeBaseOverride); } cd = new ClipDescriptor(this.cd_sdlBase, this.cd_sdlPrefix, anSdl.substring(endOfSdlPrefix,anSdl.length), this.cd_width, this.cd_height, this.cd_autoplay, this.cd_noAudio, this.cd_convertSegments, this.cd_volume, this.cd_foreground, this.cd_scenes, this.cd_videoDataCacheSize, this.cd_videoIndexCacheSize, this.cd_audioDataCacheSize, this.cd_audioIndexCacheSize, this.cd_auditPlayState, this.cd_auditPointer, this.cd_autoBandwidth, this.cd_syncBandwidth, this.cd_codeBaseOverride ); this.cdList[anSdl] = cd; ClipDescriptor.sdlList[anSdl] = cd; // directorTrace('meActor.addSdl ' + cd); } } return cd; } this.setSdlBase = function(anSdl,sdlBase) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setSdlBase(sdlBase); //this.cd_sdlBase = sdlBase; } } this.setSdlPrefix = function(anSdl,sdlPrefix) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setSdlPrefix(sdlPrefix); //this.cd_sdlPrefix = sdlPrefix; } } this.setWidth = function(anSdl,width) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setWidth(width); //this.cd_width = width; } } this.setHeight = function(anSdl,height) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setHeight(height); //this.cd_height = height; } } this.setAutoplay = function(anSdl,autoplay) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setAutoplay(autoplay); //this.cd_autoplay = autoplay; } } this.setNoAudio = function(anSdl,noAudio) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setNoAudio(noAudio); noAudio = cd.getNoAudio(); //this.cd_noAudio = noAudio; if (noAudio) { cd.setVolume = 0; //this.cd_volume = 0; cd.setAudioDataCacheSize = -1; //this.cd_audioDataCacheSize = -1; cd.setAudioIndexCacheSize = -1; //this.cd_audioIndexCacheSize = -1; } } } this.setConvertSegments = function(anSdl,convertSegments) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setConvertSegments(convertSegments); //this.cd_convertSegments = convertSegments; } } this.setVolume = function(anSdl,volume) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setVolume(volume); //this.cd_volume = volume; } } this.setForeground = function(anSdl,foreground) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setForeground(foreground); //this.cd_foreground = foreground; } } this.setScenes = function(anSdl,scenes) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setScenes(scenes); //this.cd_scenes = scenes; } } this.setVideoDataCacheSize = function(anSdl,videoDataCacheSize) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setVideoDataCacheSize(videoDataCacheSize); //this.cd_videoDataCacheSize = videoDataCacheSize; } } this.setVideoIndexCacheSize = function(anSdl,videoIndexCacheSize) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setVideoIndexCacheSize(videoIndexCacheSize); //this.cd_videoIndexCacheSize = videoIndexCacheSize; } } this.setAudioDataCacheSize = function(anSdl,audioDataCacheSize) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setAudioDataCacheSize(audioDataCacheSize); //this.cd_audioDataCacheSize = audioDataCacheSize; } } this.setAudioIndexCacheSize = function(anSdl,audioIndexCacheSize) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setAudioIndexCacheSize(audioIndexCacheSize); //this.cd_audioIndexCacheSize = audioIndexCacheSize; } } this.setAuditPlayState = function(anSdl,auditPlayState) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setAuditPlayState(auditPlayState); //this.cd_auditPlayState = auditPlayState; } } this.setAuditPointer = function(anSdl,auditPointer) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setAuditPointer(auditPointer); //this.cd_auditPointer = auditPointer; } } this.setAutoBandwidth = function(anSdl,autoBandwidth) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setAutoBandwidth(autoBandwidth); } } this.setSyncBandwidth = function(anSdl,syncBandwidth) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setSyncBandwidth(syncBandwidth); } } this.setCodeBaseOverride = function(anSdl,aUrl) { var cd = this.initCdList(anSdl); if (cd !== null) { cd.setCodeBaseOverride(aUrl); } } this.clips = null; this.resolveClip = function(clipHandle) { if (Actor.UserNameSpace != null) { if (!clipHandle.startsWith(Actor.UserNameSpace) && !clipHandle.startsWith('http://') && !clipHandle.startsWith('https://') && !clipHandle.startsWith('file:/')) { var rc = this.resolveClip2(Actor.UserNameSpace + clipHandle); if (rc != null) return rc; } } return this.resolveClip2(clipHandle); } this.resolveClip2 = function(clipHandle) { var resolvedClip = null; if (clipHandle && (clipHandle.length > 0)) { if (clipHandle.startsWith('http://') || clipHandle.startsWith('https://') || clipHandle.startsWith('file:/')) { resolvedClip = clipHandle; } else { if (this.clips === null) { this.initClips(); } // check if it is in the cache if (this.clips[clipHandle] && (this.clips[clipHandle] !== null)) { resolvedClip = this.clips[clipHandle]; } else { // resolve clip using server, then add to clips[] var i; for (i = 0; i < 10; i++) { resolvedClip = HostingAgent.theInstance().getDefaultFile(clipHandle); if ((resolvedClip == null) || (resolvedClip == "")) { continue; } if (resolvedClip.startsWith('http://') || resolvedClip.startsWith('https://') || resolvedClip.startsWith('file:/')) { break; } var eTxt = "[" + i + "]Actor.resolveClip INVALID RESOLVE: " + resolvedClip; windowStatus(eTxt); alert(eTxt); } if ((resolvedClip == "") || (resolvedClip == null)){ resolvedClip = null; if (!this.isChat()) directorTrace("meActor.resolveClip UNABLE TO RESOLVE clip: " + clipHandle); //alert("meActor.resolveClip UNABLE TO RESOLVE clip: " + clipHandle); } else{ //resolvedClip = unescape(resolvedClip); //directorTrace('meActor.resolveClip resolvedClip: ' + resolvedClip); this.clips[clipHandle] = resolvedClip; // add to cache } } } } //directorTrace('Actor.resolveClip resolvedClip: ' + resolvedClip); return resolvedClip; } this.unresolveClip = function(clipHandle) { if (clipHandle && (clipHandle.length > 0)) { if (this.clips !== null) { if (this.clips[clipHandle]) { this.clips[clipHandle] = null; } } } } this.forceClipResolve = function() { } this.initClips = function() { this.clips = new Object(); // TODO GLM TEMP hardcode clip translation until server stuff available //this.clips['MI2_TEASER'] = 'http://www.eviewworld.com/devel/test1/clips/MI2/teaser/video_s1.dat.sdl'; //this.clips['MI2_TEASER_EXPANSION'] = 'http://www.eviewworld.com/devel/test1/clips/MI2/teaserExpansion/video_s1.dat.sdl'; } this.isDeferred = function() { return this.playDeferred || this.bufferDeferred; } this.chatProxy = null; this.getChatProxy = function() {return this.chatProxy;} this.chatApplet = null; this.setChatApplet = function(chatApplet) { if (chatApplet) { this.chatApplet = chatApplet; } else { this.chatApplet = null; } } this.chatCaller = ''; this.publish = function(chatCaller) { this.chatCaller = chatCaller; if (this.chatApplet === null) { this.chatApplet = vChatDocument; } if (this.chatProxy === null) { this.chatProxy = new Chat(this.chatApplet); } // var channels = this.chatProxy.acquireChannelsFor(this.chatCaller); // directorTrace('meActor.publish' + // ' userName: ' + this.chatCaller + // ' videoRTP: ' + channels.videoRTP + // ' videoRTCP: ' + channels.videoRTCP + // ' audioRTP: ' + channels.audioRTP + // ' audioRTCP: ' + channels.audioRTCP); var _this = this; setTimeout(_this.publish2._bind(_this),100); } this.publish2 = function() { this.chatRgbIdx = this.chatProxy.openChannel(this.chatCaller,Chat.outgoing); if ((this.chatRgbIdx == null) || (this.chatRgbIdx < 0)) { this.openChannelRetryCtr++; if (this.openChannelRetryCtr < this.maxOpenChannelRetryCtr) { directorTrace('meActor.publish2 unable to open channel for ' + ' chatCaller: ' + this.chatCaller + '. RETRYING'); var _this = this; setTimeout(_this.publish2._bind(_this),1000); } else { directorTrace('meActor.publish2 unable to open channel. chatRgbIdx: ' + this.chatRgbIdx); } return; } var idx = (this._currentClipHandle != null) ? this.getIndexOf(this._currentClipHandle) : this.getContextIndex(); playContext(idx); } this.chatCallee = ''; this.chatRgbIdx = -1; this.maxOpenChannelRetryCtr = 10; this.openChannelRetryCtr = 0; this.playChat = function(chatCallee,switchSession) { this.chatCallee = chatCallee; this.switchSession = switchSession || false; if (this.chatApplet === null) { this.chatApplet = vChatDocument; } if (this.chatProxy === null) { this.chatProxy = new Chat(this.chatApplet); } this.openChannelRetryCtr = 0; var _this = this; setTimeout(_this.playChat2._bind(_this),100); } this.playChat2 = function() { if (!this.switchSession) { this.chatRgbIdx = this.chatProxy.openChannel(this.chatCallee,Chat.incoming); if ((this.chatRgbIdx == null) || (this.chatRgbIdx < 0)) { this.openChannelRetryCtr++; if (this.openChannelRetryCtr < this.maxOpenChannelRetryCtr) { directorTrace('meActor.playChat unable to open channel for ' + ' chatCallee: ' + this.chatCallee + '. RETRYING'); var _this = this; setTimeout(_this.playChat2._bind(_this),1000); } else { directorTrace('meActor.playChat unable to open channel. chatRgbIdx: ' + this.chatRgbIdx); } return; } } if ((this.chatRgbIdx == null) || (this.chatRgbIdx < 0)) { directorTrace('meActor.playChat unable to open channel. chatRgbIdx: ' + this.chatRgbIdx); } else { var idx = (this._currentClipHandle != null) ? this.getIndexOf(this._currentClipHandle) : this.getContextIndex(); playContext(idx); setRgbSrcIdx(getCtxIdByName(this.getTag()),this.chatRgbIdx); } } var meDefaultClip1 = 'meDefaultClip1'; this.getMeDefaultClip1 = function() { if (meDefaultClip1 == 'meDefaultClip1') { var componentFactory = new ComponentFactory(); meDefaultClip1 = componentFactory.codebase + "clips/meDefaultClip1/video_s1.dat.sdl"; } return meDefaultClip1; } var meDefaultClip2 = 'meDefaultClip2'; this.getMeDefaultClip2 = function() { if (meDefaultClip2 == 'meDefaultClip2') { var componentFactory = new ComponentFactory(); meDefaultClip2 = componentFactory.codebase + "clips/meDefaultClip2/video_s1.dat.sdl"; } return meDefaultClip2; } this.chatSelfView = false; this.configureChatSelfView = function(primary) { primary = (typeof primary == 'undefined') ? true : primary; this.chatSelfView = true; this.setSecondary('true'); this.setRgbSrcEnabled(true); this.setRgbSrcIdx(0); // selfview is always 0 (zero) this.buffer(this.getMeDefaultClip1()); this.setAutoplay(this.getMeDefaultClip1(),false); this.setNoAudio(this.getMeDefaultClip1(),true); if (primary) Chat.selfView = this; // primary starts first. can be swapped out for a secondary } this.chatRemoteView = false; this.chatViewType = null; this.getChatViewType = function() {return this.chatViewType;} this.configureChatRemoteView = function(primary) { primary = (typeof primary == 'undefined') ? true : primary; this.chatRemoteView = true; this.setSecondary('true'); this.setRgbSrcEnabled(true); this.setRgbSrcIdx((enableMulticast) ? -1 : 1); // starting off with -1 blocks processing until connected this.buffer(this.getMeDefaultClip2()); this.setAutoplay(this.getMeDefaultClip2(),false); this.chatViewType = ChatViews.createViewType(this.getClipWidth(),this.getClipHeight()); if (typeof Chat.remoteView[this.chatViewType] == 'undefined') { Chat.remoteView[this.chatViewType] = new Array(); } //alert('Actor.configureChatRemoteView' + ' chatViewType: ' + this.chatViewType + ' name: ' + this._name); Chat.remoteView[this.chatViewType][this._name] = this; // allow multiple remote views at different resolutions } this.closeChat = function() { //directorTrace('meActor.closeChat'); if (this.chatProxy != null) { this.chatProxy.closeChannel(); } } this.startChat = function(disableAudio,vxnServerAddress,vxnServerPort) { //directorTrace('meActor.startChat'); if (this.chatApplet === null) { this.chatApplet = vChatDocument; } if (this.chatProxy === null) { this.chatProxy = new Chat(this.chatApplet); } this.chatProxy.startChat(disableAudio,vxnServerAddress,vxnServerPort); } // CAMERA CAPTURE this.cameraCaptureMode = false; this.cameraCapture = null; if (cameraCaptureDocument != null) { this.captureApplet = cameraCaptureDocument; //alert('meActor.' + '\n captureApplet: [' + this.captureApplet + ']' + '\n cameraCaptureDocument: [' + cameraCaptureDocument + ']'); } else { this.captureApplet = null; } this.getCaptureHandle = function() { return this.getMeDefaultClip1(); } this.getDefaultHandle = function() { return this.getMeDefaultClip2(); } this.configureCameraCapture = function(name) { this.configure_capture(name); } this.configure_capture = function(name) { //alert('meActor.configure_capture' + ' name: ' + name); var handle = this.getCaptureHandle(); this.cameraCaptureMode = true; this.buffer(handle); this.setSecondary('true'); this.setAutoplay(handle,false); this.setNoAudio(handle,true); this.startCameraCaptureMode(); } // if (name && isString(name) && (name.length > 0)) // { // if (name.toLowerCase().startsWith('capture')) // { // this.configureCameraCapture(name); // } // } this.startCameraCaptureMode = function() { //alert('[1]meActor.startCameraCaptureMode' + '\n cameraCapture: ' + this.cameraCapture + '\n captureApplet: ' + this.captureApplet); if (this.cameraCapture === null) { if (this.captureApplet !== null) { //alert('[2]meActor.startCameraCaptureMode' + '\n cameraCapture: ' + this.cameraCapture + '\n captureApplet: ' + this.captureApplet); this.cameraCapture = CameraCapture; this.cameraCapture(this.captureApplet); } else { directorTrace('meActor.startCameraCaptureMode captureApplet NULL'); } } } this.setCaptureApplet = function(captureApplet) { //debugger; /* if (captureApplet) { this.captureApplet = captureApplet; AVDevice.deviceApplet = this.captureApplet; } else { this.captureApplet = null; } */ } this.defaultStartUp = false; this.isDefaultStartUp = function () { return this.defaultStartUp; } this.setDefaultStartUp = function(state) { this.defaultStartUp = state; } this.configure_meutil = function(name) { this.configure_default(name); } this.configure_default = function(name) { //debugger; this.actorTrace('meActor.configure_default name: ' + name); var handle = this.getDefaultHandle(); this.cd_convertSegments = false; this.buffer(handle); this.setDefaultStartUp(true); this.setSecondary(true); this.setAutoplay(handle,false); this.setAutoBandwidth(handle,false); this.setSyncBandwidth(handle,false); } this.configure_sdlwriter = function(name) { var handle = this.getDefaultHandle(); this.cd_convertSegments = false; this.buffer(handle); this.setDefaultStartUp(true); this.setSecondary('true'); this.setAutoplay(handle,false); this.setAutoBandwidth(handle,false); this.setSyncBandwidth(handle,false); this.sdlWriter = SdlWriter; this.sdlWriter(this); } this.configure_scenemerge = function(name) { var handle = this.getDefaultHandle(); this.cd_convertSegments = false; this.buffer(handle); this.setDefaultStartUp(true); this.setSecondary('true'); this.setAutoplay(handle,false); this.setAutoBandwidth(handle,false); this.setSyncBandwidth(handle,false); this.addEventRule('videoMergeClipComplete','SceneMerge.instance.mergeClipComplete(SceneMerge.instance.getContextIndex(),SceneMerge.instance.getEventDescriptor())'); this.addEventRule('audioMergeClipComplete','SceneMerge.instance.mergeClipComplete(SceneMerge.instance.getContextIndex(),SceneMerge.instance.getEventDescriptor())'); this.scenemerge = SceneMerge; this.scenemerge(this); } this.validateHtml = function() { if (document.getElementById(this._divId) === null) { alert('meActor.validateHtml' + '\n CANNOT FIND HTML ELEMENT FOR ACTOR: ' + this._name); } } this.isChat = function() { return this.chatSelfView || this.chatRemoteView; } this.isAbsoluteSdl = function() { return ((typeof Actor.sdlPathType !== 'undefined') && isString(Actor.sdlPathType) && (Actor.sdlPathType.toLower() == 'absolute')) } this.isStartUpClipDefined = function() { this.actorTrace('meActor.isStartUpClipDefined' + '\n bufferDeferred: ' + this.bufferDeferred + '\n bufferInitialized: ' + this.bufferInitialized + '\n playDeferred: ' + this.playDeferred + '\n playInitialized: ' + this.playInitialized); return (this.bufferDeferred || this.bufferInitialized || this.playDeferred || this.playInitialized); } this.actorTrace = function(text) { var msg = '[' + this.getContextIndex() + '][' + this.getName() + '][' + this.getTag() + '][' + this.getDivId() + ']\n'; directorTrace(msg + text); } this.ep_invoke = function(args) { try {clipDirector.ep_invoke(args);} catch (err) {directorTrace('Actor.ep_invoke args: ' + args + ' EXCEPTION: ' + err.description);} } this.ep_invokeAndWait = function(args) { try {clipDirector.ep_invokeAndWait(args);} catch (err) {directorTrace('Actor.ep_invokeAndWait args: ' + args + ' EXCEPTION: ' + err.description);} } var htmlParams = new Array(); var htmlParamDelimiter = '|'; this.addHtmlParam = function(name,value) { htmlParams[htmlParams.length] = '' + name + htmlParamDelimiter + value; } this.processHtmlParams = function(dr,ctxId) { try { for (var i = 0; i < htmlParams.length; i++) { var args = htmlParams[i].split(htmlParamDelimiter); jDirCtxt(dr,ctxId,args[0],args[1]); } } catch (err) {directorTrace('Actor.processHtmlParams dr: ' + dr + ' ctxId: ' + ctxId + ' args: ' + args + ' EXCEPTION: ' + err.description);} } // 'sceneName;fromSegment,fromRecNum:toSegment,toRecNum' var previousSceneClipHandle = null; this.playScene2 = function(scene,clipHandle) { var sceneName = this.getSceneName(scene); var fromSegment = this.getSceneFromSegment(scene); var fromRecNum = this.getSceneFromRecNum(scene); var toSegment = this.getSceneToSegment(scene); var toRecNum = this.getSceneToRecNum(scene); var resolvedClip = this.resolveClip(clipHandle); this.actorTrace('Actor.playScene2' + ' scene: ' + scene + ' clipHandle: ' + clipHandle + '\n resolvedClip: ' + resolvedClip + '\n sceneName: ' + sceneName + ' fromSegment: ' + fromSegment + ' fromRecNum: ' + fromRecNum + ' toSegment: ' + toSegment + ' toRecNum: ' + toRecNum); if (resolvedClip !== null) { if (clipHandle != previousSceneClipHandle) { previousSceneClipHandle = clipHandle; this.play2(resolvedClip,fromSegment,fromRecNum,toSegment,toRecNum,true); } else { this.playFromTo(fromSegment,fromRecNum,toSegment,toRecNum); } } else { this.actorTrace('meActor.playScene2 UNRESOLVED CLIP: ' + clipHandle); } return true; } this.playFromTo = function(fromSegment,fromRecNum,toSegment,toRecNum) // must be preceded by an actor.play(...) { this.actorTrace('Actor.playFromTo' + ' fromSegment: ' + fromSegment + ' fromRecNum: ' + fromRecNum + ' toSegment: ' + toSegment + ' toRecNum: ' + toRecNum + '\n clipHandle: ' + previousSceneClipHandle); if (clipDirector != null) { clipDirector.ep_invoke('' + this.getContextIndex() + ',,ep_playFromTo,' + fromSegment + ',' + fromRecNum + ',' + toSegment + ',' + toRecNum + ',true,true'); } else { alert('Actor.playFromTo clipDirector NULL'); } } //this.fullScreen = function() //{ //if (clipDirector != null) //{ //clipDirector.ep_invoke('' + this.getContextIndex() + ',,ep_fullScreen'); //} //else //{ //alert('Actor.fullScreen clipDirector NULL'); //} //} this.refresh = function() { if (clipDirector != null) { clipDirector.ep_invoke('' + this.getContextIndex() + ',,ep_refresh') } else { alert('Actor.refresh clipDirector NULL'); } } this.resize = function(width,height) { if (clipDirector != null) { AppletManager.theInstance().resize(this.getTag(),width,height); //clipDirector.ep_invoke('' + this.getContextIndex() + ',,ep_setSize,' + width + ',' + height); } else { alert('Actor.resize clipDirector NULL'); } } this.switchChatSession = function(fromActor, toActor) { if (fromActor.chatRgbIdx != -1) { if (fromActor.chatProxy != null) { if (fromActor.chatCallee != '') { toActor.chatRgbIdx = fromActor.chatRgbIdx; toActor.chatProxy = new CloneIt(fromActor.chatProxy); toActor.chatCallee = fromActor.chatCallee; toActor.chatReceiveName = fromActor.chatCallee; fromActor.stop(); setRgbSrcIdx(getCtxIdByName(fromActor.getTag()),-1); Chat.releaseView(fromActor.getName()); this.playChat(toActor.chatCallee,true); setTimeout(fromActor.getName() + '.stop()',5000); } else { directorTrace('Actor.switchChat chat not active. chatCallee: ' + fromActor.chatCallee); alert('Actor.switchChat chat not active. chatCallee: ' + fromActor.chatCallee); } } else { directorTrace('Actor.switchChat chat not active. chatProxy: ' + fromActor.chatProxy); alert('Actor.switchChat chat not active. chatProxy: ' + fromActor.chatProxy); } } else { directorTrace('Actor.switchChat chat not active. chatRgbIxd: ' + fromActor.chatRgxIdx); alert('Actor.switchChat chat not active. chatRgbIxd: ' + fromActorChatRgxIdx); } } this.resetContextConfigured = function() { this._contextConfigured[this.getContextIndex()] = false; } this.isPlaying = function() { var idx = (this._currentClipHandle != null) ? this.getIndexOf(this._currentClipHandle) : this.getContextIndex(); return isContextPlaying(idx); } var hasView = false; this.setHasView = function(_hasView) { hasView = _hasView; } function callBuffer2() { that.buffer2(); } this.buffer2 = function() { this.bufferDeferred = false; if (clipDirector == null) { setTimeout(callBuffer2,1000); return; } var clipHandle = this._bufferClipHandle; var ci = this.getIndexOf(clipHandle); this.processClipDescriptor(this,ci,clipHandle); bufferClipFromTo(ci,1,0,1,0,true,this.getClipDescriptor(clipHandle).getSdl()); this._contextConfigured[ci] = true; } // ***************************************************** // *****always keep this section of code at the end***** // ***************************************************** if (name && isString(name) && (name.length > 0)) { var lcName = name.toLowerCase(); if (eval('this.configure_' + lcName)) { eval('this.configure_' + lcName + "(\'" + name + "\')"); } } // ***************************************************** // ***************************************************** } Actor.started = false; Function.prototype._bind = function(o) { //debugger; var _this = this; return function() {return _this.apply(o,arguments);}; } // begin name translation support Actor.xlatNameToChannels = function(name) { //var mgr = new ChannelManager(location.href.substring(0,location.href.lastIndexOf('/')+1)+"ChannelManager.php"); //return mgr.xlatNameToChannels(name); // Don Smith: This API no longer exists in ChannelManager. } // end name translation support function setClipDirector(cd) { //debugger; clipDirector = cd; } Actor.getTagPrefix = function() { return (typeof Actor.tagPrefix === 'undefined') ? 'et.' : Actor.tagPrefix; } Actor.setTagPrefix = function(prefix) { Actor.tagPrefix = prefix; } Actor.getDivIdPrefix = function() { return (typeof Actor.divIdPrefix === 'undefined') ? 'ed.' : Actor.divIdPrefix; } Actor.setDivIdPrefix = function(prefix) { Actor.divIdPrefix = prefix; } var archiveList = ''; Actor.setAppletType = function(appletType) { if (typeof ComponentFactory !== 'undefined') { var cf = new ComponentFactory(); var parameters = cf.getAppletInformation(appletType); if (parameters && parameters['cache_archive']) { archiveList = parameters['cache_archive']; } Actor.setTagPrefix('et'); Actor.setDivIdPrefix('ed'); } } Actor.sdlWriterActor = null; Actor.getSdlWriterActor = function() { return Actor.sdlWriterActor; } Actor.cameraCaptureActor = null; Actor.getCameraCaptureActor = function() { return Actor.cameraCaptureActor; } Actor.vmpEnabled = false; // VideoMessageProducer Actor.setVideoMessagesEnabled = function(state) { Actor.vmpEnabled = state; } Actor.configureVmp = function() { if (Actor.vmpEnabled) { Actor.sdlWriterActor = Actor.sdlWriterActor == null ? new Actor('sdlwriter') : Actor.sdlWriterActor; Actor.cameraCaptureActor = Actor.cameraCaptureActor == null ? new Actor('capture') : Actor.cameraCaptureActor; } } function CloneIt(original) {for (var i in original) {this[i] = original[i];}} Actor.UserNameSpace = null; Actor.parseUserNameSpace = function(clipName) { var ns = null; if (Actor.UserNameSpace != null) { if (clipName.startsWith(Actor.UserNameSpace)) { ns = clipName.substring(0,Actor.UserNameSpace.length - 1); } } return ns; } Actor.parseClipName = function(clipName) { var cn = clipName; if (Actor.UserNameSpace != null) { if (cn.startsWith(Actor.UserNameSpace)) { cn = clipName.substring(Actor.UserNameSpace.length); } } return cn; } function AppletSpec(appletType) { var that = this; this.PMgr = ParameterManager; // From ParameterManager.js (JavaScript file) this.PMgr("applet"); var componentFactory = new ComponentFactory(); var type = appletType; this.setParameter("type",type); if (appletType != "undefined" || appletType !== "") { //AppletFactory for getting Parameter Information for Ecoder and Upload Applets //An Array of Applet Information (Encoder, Capture, and Upload Applets) var appletInfo = componentFactory.getAppletInformation(appletType); } if (!appletInfo) { appletInfo = new Array(); appletInfo['code'] = ''; appletInfo['archive'] = ''; } appletInfo['codebase'] = componentFactory.codebase; if (appletInfo['package_spec']) { this.setParameter("user","PACKAGE_SPEC",appletInfo['package_spec']); } if("undefined" == typeof appletInfo['cache_version']){ appletInfo['cache_version'] = ''; } this.setParameter("objectclassid","clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"); this.setParameter("objectcodebase", "http://java.sun.com/update/1.5.0/jinstall-1_5_0_11-windows-i586.cab"); this.setParameter("name", ""); this.setParameter("code", appletInfo['code'] !== '' ? appletInfo['code'] : ''); this.setParameter("codebase", appletInfo['codebase'] !== '' ? appletInfo['codebase'] : ''); this.setParameter("cache_archive", appletInfo['cache_archive'] !== '' ? appletInfo['cache_archive'] : ''); this.setParameter("cache_version", appletInfo['cache_version'] !== '' ? appletInfo['cache_version'] : ''); this.setParameter("width", "1"); this.setParameter("height", "1"); this.setParameter("hspace", ""); this.setParameter("vspace", ""); this.setParameter("align", ""); //this.setParameter("embedtype", "application/x-java-applet:;version=1.4"); // ** TO BE RESOLVED: NOT WORKING IN FOREFOX ** this.setParameter("embedtype", "application/x-java-applet;version=1.5"); this.setParameter("embedpluginspage", "http://www.java.com"); this.setParameter("scriptable", "true"); this.setParameter("mayscript", "true"); this.setParameter("visible", "true"); this.startApplet = function (target) { var tmpStr=""; tmpStr = this.appletToString(); if(tmpStr !== ""){ this.write(tmpStr, target); } else{ //alert("StartApplet tags empty"); }; }; this.startAppletWithAppletTag = function (target) { var tmpStr=""; tmpStr = this.appletTagOnlyToString(); if(tmpStr !== ""){ this.write(document,target,tmpStr); } else { //alert("StartAppletWithAppletTag tags empty"); }; }; this.addParameter = function (name, value) { switch (name.toUpperCase()) { case "NAME": return false; break; case "ID": return false; break; default: break; }; this.setParameter("user",name, value); return true; }; this.getUserParameters = function (type) { var tmpStr=""; var params = this.getActiveParameters("user"); var i; switch(type) { case "OBJECT": for(i = 0;i < params.length;i++) { tmpStr += '\n'; } break; case "EMBED": for(i = 0;i < params.length;i++) { tmpStr += params[i] + ' = \"' + this.getParameter("user",params[i]) + '\"\n'; } break; case "APPLET": for(i = 0;i < params.length;i++) { tmpStr += '\n'; } break; default: break; } return tmpStr; }; this.write = function (strhtml, tagid) { var htmlElement; //alert("AppletSpec.write : strhtml " + strhtml + " tagid " + tagid); if (document.layers && (document.layers[tagid].document !== null)) { htmlElement = document.layers[tagid].document; htmlElement.open(); htmlElement.write(strhtml); htmlElement.close(); } else if (document.all && (document.all(tagid) !== null)) { htmlElement = document.all(tagid); htmlElement.innerHTML = strhtml; } else if (document.documentElement && (document.getElementById(tagid) !== null)) { htmlElement = document.getElementById(tagid); htmlElement.innerHTML = strhtml; } }; this.appletToString = function () { var tmpStr = ""; //added Object ID var objid = this.getUniqueElementID(); var embedid = this.getUniqueElementID(); tmpStr = '\n'; if(this.getParameter("applet","cache_version") !== null && this.getParameter("applet","cache_version") !== ''){ tmpStr += '\n'; tmpStr += '\n'; } else{ tmpStr += '\n'; } tmpStr += '\n'; tmpStr += '\n'; if (this.getParameter("applet", "codebase") !== "") { tmpStr += '\n'; } tmpStr += '\n'; //added eval_start_exit for OBJECT tmpStr += '\n'; tmpStr += this.getUserParameters("OBJECT"); tmpStr += '\n'; tmpStr += '\n'; tmpStr += '\n'; //added eval_start_exit for APPLET tmpStr += '\n'; tmpStr += '0) document.form1.NewName.focus(); else document.form1.S1.focus(); } } else{ } } var cntr=0; var upgradeMsg = "Performing software upgrade"; function initInstall() { var st; try { if (enableChatInstall) { st = iChatDocument.getDownloadState(); appHome = String(iChatDocument.getEvmHome()); } else { st = 2; appHome = ' '; } if((appHome !='') && (appHome != 'undefined')) { if(st==1 || st==2) callbackFunction(); announceTermination(st); if(st==9) self.close(); } else { updateStatusWithDots(""); setTimeout('initInstall()',1000); } } catch(sError) { alert("jChatFb.initInstall EXCEPTION: " + sError.message); setTimeout('initInstall()',1000); } } function announceInstall(){ updateStatusWithDots(upgradeMsg); try { iChatDocument.startInstall(); setTimeout('initInstall()',500); } catch(sError) { alert("jChatFb.announceInstall EXCEPTION: " + sError.message); updateStatus("Upgrade fail: installer access"); } } var compMsg = "Software upgrade complete"; function announceTermination(st){ switch(st){ case 1: case 2: updateStatus(compMsg); break; case 3: updateStatus("Upgrade fail: authorization"); break; case 4: updateStatus("Upgrade fail: download"); break; case 5: updateStatus("Upgrade fail: library unpacking"); break; case 6: updateStatus("Upgrade fail: file access"); break; case 7: updateStatus("Upgrade fail: registry update"); break; case 8: updateStatus("Upgrade fail: NIC install"); break; case 9: updateStatus("Initialization fail: too many instances"); break; default: updateStatus("Upgrade fail: unknown cause"); } } function highLevelState(low){ var high; switch(low){ case 'in-call': high='busy'; break; case 'originating': high='busy'; break; case 'terminating': high='busy'; break; case 'guarding': high='busy'; break; default: high=low; } return high; } function init() { var st; if (callback == '') { setTimeout('init()',50); } else { try { if (enableChatInstall) { st = iChatDocument.getDownloadState(); } else { st=2; } if(st) { if(st==1){ compMsg = "Software upgrade complete"; announceInstall(); return; } // announceTermination(st); setTimeout('initInstall()',100); compMsg = "Software version verified"; return; } else { setTimeout('init()',500); } } catch(sError) { //alert("jChatFb.init EXCEPTION: " + sError.message); setTimeout('init()',3000); } } } function callbackFunction() { setTimeout(callback, 50); } function placeMeInCall() { var myCall; //var hisCall; if(myIPaddress) { myCall = findCallForIP(myIPaddress); if(myCall.state=="in-call") return; //javaTrace('jChatFb.placeMeInCall' + '\n myIPaddress: ' + myIPaddress + '\n ownerName: ' + ownerName + ' myCall: ' + myCall); myCall.setState("in-call"); startVideoCapture(); if (enableMulticast) { Chat.publish(ownerName); } } } function requestTimeout(){ timingRequestDone = true; } function videoPlaying(){ try{ return playerDocument.ep_isPlaying(); } catch (sError){ alert("jChatFb.videoPlaying EXCEPTION: " + sError.message); return false; } return false; } var pv=-1; var posTime; function reposition(){ return; if(!capturingVideo) return; // if(!keepOnTop) return; if(++pv>3){ pv=-1; updateStatus("repositioned"); return; } if(pv==0) setViewOrigin(0,0,0); if(pv==1) setViewOrigin(1,0,400); if(pv==2) bringToTop(0); if(pv==3)bringToTop(1); setTimeout('reposition()',500); } function Call(){ this.name = ""; this.state = ""; this.view = ""; this.ipAddress = ""; this.viewStatus = ""; this.cmd = ""; this.role = ""; this.resolution = ""; this.xPos = ""; this.yPos = ""; this.width = ""; this.height = ""; this.top = false; this.callType="OneWay"; this.reqOrig = false; this.reqTerm = false; this.stateTimer = 0; this.videoStarted = false; this.init = function (){ this.state = "offline"; this.view = ""; this.name = ""; this.ipAddress = ""; this.viewStatus = "offline"; this.resolution = "default"; this.xPos = "default"; this.yPos = "default"; this.height = "default"; this.width = "default"; this.top = false; this.autoSize=false; this.video = ""; this.previousVideo = ""; this.reqOrig = false; this.reqTerm = false; this.videoStarted = false; } this.toString = function() { return ('\n CALL name: ' + this.name + ' ipAddress: ' + this.ipAddress + ' state: ' + this.state + '\n callType: ' + this.callType + ' autoSize: ' + this.autoSize + ' top: ' + this.top + ' cmd: ' + this.cmd + ' role: ' + this.role + ' stateTimer: ' + this.stateTimer + '\n height: ' + this.height + ' width: ' + this.width + ' resolution: ' + this.resolution + ' xPos: ' + this.xPos + ' yPos: ' + this.yPos + '\n reqOrig: ' + this.reqOrig + ' reqTerm: ' + this.reqTerm + '\n videoStarted: ' + this.videoStarted + ' video: ' + this.video + ' previousVideo: ' + this.previousVideo + '\n view: ' + this.view + ' viewStatus: ' + this.viewStatus); } this.setCallType = function (tp){ var old = gCallType; this.callType = tp; gCallType = tp; if(old =="All" && gCallType == "OneWay"){ updateStatus("Changing global call type: "+gCallType); gDropCalls = true; setTimeout("allowCalls()",5000); } } this.bringBackToTop = function (){ this.top = false; } this.setResolution = function (val){ if(val==this.resolution) return; this.resolution = val; if(this.name == myName){ switch(val){ case 'small': sz = 0; break; case 'medium': sz = 1; break; case 'large': sz = 2; break; case 'xlarge': sz = 3; break; case 'default': sz = 0; break; default: sz = 0; } // setVideoCaptureSize(sz); } } this.setWidth = function (val){ return; } this.setHeight = function (val){ return; } this.setXpos = function (val){ this.xPos = val; return; } this.setVideo = function (val){ // updateStatus('t1'); if(this.video==""||this.video=="none"){ // updateStatus('t2: '+playingVideo); if(!playingVideo){ updateStatus('requested to play video: '+this.video); this.previousVideo = ""; this.video = val; playingVideo = true; } } } this.setYpos = function (val){ var ind; this.yPos = val; if(this.xPos == 'default') return; if(this.yPos == 'default') return; if(this.name == myName) ind = 0; else ind = getCallIndex(this.ipAddress); if(ind < 0) return; // setViewOrigin(ind,parseInt(this.xPos),parseInt(this.yPos)); return; } this.setCmd = function (cmd){ this.cmd = cmd; } this.setRole = function (role){ return; if(this.ipAddress == myIPaddress) return; this.setState(role); this.role = role; } this.setIp = function (ip){ this.ipAddress = ip; } this.getState = function (){ // this.validateState(); return this.state; } this.setState = function (state){ if (this.state != state) { /* javaTrace('jChatFb.setState ' + ' CALL STATE CHANGE.' + ' member: ' + this.name + ' previous: ' + this.state + ' current: ' + state); */ } // if(this.stateTimer>0&&this.state==state){ // this.stateTimer--; // if(this.stateTimer>0) return; // } // this.stateTimer=5; if(this.setStateNoNotify(state)){ if(this.name == myName){ db_setState(this.name,this.state); } } } this.setStateNoNotify = function (state){ if(this.name=="") return false; if(state==this.state) return; if(this.state=="in-call"&&state=="offline"){ hide('ep.EndCall'); hide('ep.Calling'); hide('ep.ChatTitle'); hide('ep.ChatArea'); hide('ep.SendButton'); show('ep.ContactName'); // show('ep.body_text5'); //javaTrace('1:setStateNoNotify show ep.ContactName'); // updateStatus("got request to go offline"); this.terminate(); return false; } if(state=="requested") return false; if((this.state=="terminating"||this.state=="guarding")&&state=="offline") return false; if(state=="busy") return false; if(state=="offline"&&this.state!="available"&&this.name==myName) return false; if(state=="in-call"&&this.state!="in-call"&&this.name!=myName){ /* updateStatus("in call with: "+conferee); document.form1.CallName.value = myName; conferee = this.name; hide('ep.Calling'); hide('ep.ContactName'); if(!playingVideo){ writeChatProperties(); show('ep.SendButton'); } show('ep.ChatTitle'); show('ep.ChatArea'); show('ep.EndCall'); // setVideoOptions();*/ announcedInCall = false; if(this.name!=myName)lastContactSelected = this; } if(this.state=="in-call"&&state!="in-call"&&this.name==myName&&state!="busy"&&state!="available"){ hide('ep.EndCall'); hide('ep.Calling'); show('ep.ContactName'); //javaTrace('2:setStateNoNotify show ep.ContactName'); // hide('ep.ChatTitle'); // hide('ep.ChatArea'); // hide('ep.SendButton'); if(this.name!=myName)lastContactSelected = this; // db_initConf(); } // updateStatus("Changing state simple of: "+this.name+"from: "+this.state+"to: "+state); /* if(this.state!="in-call"&&state=="in-call"&&this.name!=myName){ if(showVideoValue!=""){ updateStatus('requesting video: '+showVideoValue +' for: '+vidConferee); if(vidConferee!="") db_setProperty(vidConferee,'video',showVideoValue); showVideoValue = ""; } }*/ this.state = state; return true; } this.updateViewStatus = function (status){ this.viewStatus = status; // updateStatus(status); } this.originate = function (){ //debugger; this.state = "originating"; originateACall(this.ipAddress); // updateStatus("originatingTrace: "+this.ipAddress); } this.reqOriginate = function (){ //debugger; this.reqTerm = false; this.reqOrig = true; // updateStatus("reqOriginate: "+this.name+" ip: "+this.ipAddress); if(this.ipAddress=="") db_bring(this.name); setTimeout("requestTimeout()",5000); timingRequestDone = false; } this.reqTermination = function (){ this.reqTerm = true; } this.removeGuard = function (){ this.setState("available"); this.updateViewStatus("removing guard"); } this.terminate = function (){ this.state = "terminating"; endACall(this.ipAddress); hide('ep.Calling'); hide('ep.EndCall'); hide('ep.ChatTitle'); hide('ep.ChatArea'); hide('ep.SendButton'); show('ep.ContactName'); //javaTrace('terminate show ep.ContactName'); } var origCount = 0; this.validateState = function (){ var tc; if(this.name == "") return; if(this.name == "undefined") return; if(this.previousVideo != this.video && this.state=='in-call'){ if(this.video!='none'&&this.video!="") updateStatus("video showing: "+this.video); this.previousVideo = this.video; if(this.video == "" || this.video=="none"){ writeChatProperties(); show('ep.ChatTitle'); show('ep.ChatArea'); show('ep.SendButton'); playingVideo = false; } else { this.previousVideo = this.video; this.videoStarted = false; playingVideo = true; hide('ep.ChatTitle'); hide('ep.ChatArea'); hide('ep.SendButton'); jPlayerInit(this.video); } } else { if(this.video != "" && this.video !="none"){ if(!videoPlaying()){ if(this.videoStarted){ updateStatus("video complete"); this.video = "none"; playingVideo = false; } } else{ if(!this.videoStarted) show('ep.ChatArea'); // updateStatus("video started"); this.videoStarted=true; } } } if(this.name!=myName){ if(this.state!='available'||this.state!='offline'){ if(this.ipAddress=="") this.setState("available"); } } switch(this.state) { case "offline": if(this.name==myName) { this.setState("available"); } break; case "available": if(gDropCalls) break; origCount = 0; //if(capturingVideo) setViewOrigin(0,2000,2000); keepOnTop = false; if(this.name!=myName&&requestOrig==this.name) { this.reqOriginate(); requestOrig = ""; break; } if(this.ipAddress=="") break; if(this.ipAddress && this.ipAddress == myIPaddress) { if(capturing&&capturingVideo) { if(!this.top) { bringToTop(0); setWindowText(0,this.name); this.top = true; //setViewOrigin(0,2000,2000); //reposition(); } } if(callList.length>0) { origCount = 0; this.top=false; capturing = true; placeMeInCall(); } break; } if(autoAdding) break; if(!timingVideoDone || !timingRequestDone) break; if(this.ipAddress!="" && this.ipAddress != myIPaddress && myName==confModerator &&!this.reqTerm&&this.reqOrig)//&&timingVideoDone&&timingRequestDone) { //javaTrace('jChatFb.validateState [1]' + '\n this.ipAddress: ' + this.ipAddress + '\n myIPaddress: ' + myIPaddress + '\n myName: ' + myName + //'\n confModerator: ' + confModerator + '\n this.reqTerm: ' + this.reqTerm + '\n timingVideoDone: ' + timingVideoDone + '\n timingRequestDone: ' + timingRequestDone); this.originate(); this.reqOrig = false; //updateStatus("originating call to: "+this.name); this.setState("originating"); origCount = 0; //placeMeInCall(); } else { //javaTrace('jChatFb.validateState [2]' + '\n this.ipAddress: ' + this.ipAddress + '\n myIPaddress: ' + myIPaddress + '\n myName: ' + myName + //'\n confModerator: ' + confModerator + '\n this.reqTerm: ' + this.reqTerm + '\n timingVideoDone: ' + timingVideoDone + '\n timingRequestDone: ' + timingRequestDone); if(this.ipAddress!=myIPaddress&&isCalled(this.ipAddress)) { this.setState("in-call"); this.top=false; origCount = 0; updateStatus("received call from: "+this.name); } else { if(gCallType=="All") { this.originate(); origCount = 0; this.setState("originating"); placeMeInCall(); this.top=false; //updateStatus("originating call to: "+this.name); break; } } } break; // end case "available": case "originating": if(this.ipAddress!=myIPaddress){ if(isCalled(this.ipAddress)){ this.setState("in-call"); this.top=false; // updateStatus("in call with: "+this.ipAddress+" "+origCount.toString()); origCount = 0; } if(origCount++ > 15){ // this.setState("available"); } break; } origCount = 0; call.setState("in-call"); break; case "in-call": if(origCount<100) origCount++; if(!keepOnTop){ keepOnTop = true; reposition(); } view = getCallIndex(this.ipAddress); if(this.name==myName) view=0; else view=1; if(!this.top){ setWindowText(view,this.name); // reposition(); this.top = true; } if(origCount<10) break; // updateStatus("view: "+view+" ip: "+this.ipAddress+" name: "+this.name); if(this.ipAddress != myIPaddress){ if(!isCalled(this.ipAddress)){ this.guardTimer = 5; this.setState("guarding"); stopVideo(); this.updateViewStatus("call terminated: "+this.ipAddress); break; } } if((this.reqTerm ||gDropCalls) && this.name!=myName){ hangUpCall(1); updateStatus("hanging up on: "+this.name); this.setState("guarding"); this.guardTimer = 5; } var inAcall = (calls[0] && (calls[0].state == 'in-call')); var forceAnnounceInCall = (inAcall && !announcedInCall); if (forceAnnounceInCall && false) { javaTrace('jChatFb.validateState' + '\n this.name: ' + this.name + '\n myName: ' + myName + '\n announcedInCall: ' + announcedInCall + '\n inAcall: ' + inAcall + '\n forceAnnounceInCall: ' + forceAnnounceInCall); } if((this.name!=myName&&(!announcedInCall)) || forceAnnounceInCall){ // updateStatus("in call with: "+conferee); document.form1.CallName.value = this.name; conferee = this.name; //javaTrace('validateState conferee: ' + conferee); announcedInCall = true; hide('ep.Calling'); hide('ep.ContactName'); if(!playingVideo){ writeChatProperties(); show('ep.SendButton'); } show('ep.ChatTitle'); show('ep.ChatArea'); show('ep.EndCall'); disableHourGlass(); // Pause videos... // game.pause(); // downs.pause(); // replays.pause(); // setVideoOptions(); if(showVideoValue!=""){ updateStatus('requesting video: '+showVideoValue +' for: '+vidConferee); if(vidConferee!="") db_setProperty(vidConferee,'video',showVideoValue); showVideoValue = ""; } } if(callList.length==0){ this.setState("terminating"); // updateStatus("no calls active..origCount: "+origCount); } break; case "terminating": if(callList.length==0){ this.guardTimer = 5; this.setState("guarding"); this.updateViewStatus("outgoing termination complete: "+this.ipAddress); } break; case "guarding": if(this.guardTimer-- == 0){ this.setState("available"); stopVideo(); this.reqTerm = false; this.updateViewStatus("removing guard"); } else { this.updateViewStatus("guarding...."); } break; case "busy": break; } } } // end of Call Object function allowCalls(){ gDropCalls = false; } var doc; function handleResponse(){ if(startupApp) return; doc = uriResponse(); if(isNull(doc)||isUndefined(doc)){ // setTimeout('handleResponse()',500); return; } //if(dataArrived) return; dataReturned = doc; dataArrived = true; // setTimeout('handleResponse()',500);//test } //var BaseURL = 'test4.php'; //var URL = 'test4.php'; var BaseURL = 'test7.php'; var URL = 'test7.php'; var myLoc=""; var lastReq = ""; var uriReqBusy = false; function callToServer(encodedValue){ var eUri; if(startupApp) return; if(myLoc==""){ var me = self.location.href; var li=me.lastIndexOf('/'); myLoc=me.substr(0,li+1); memberListDir = 'confFV/'; } eUri = encodeURI(myLoc+memberListDir+URL) + (encodedValue || ''); // eUri = myLoc+URL; /* request a page load */ testUriRequest(eUri); } var uriTid = null; var req = 0; var reqs = new Array(); var last_eUri = null; function testUriRequest(eUri){ if(!uriReqBusy){ last_eUri = eUri; uriRequest(eUri); // if (ownerName == 'greg') directorTrace("sending uri: "+eUri); lastReq = URL; uriReqBusy = true; uriTid = setTimeout("clearUriReq();",5000); } // else setTimeout("testUriRequest('"+eUri+"')",100); else { reqs[reqs.length] = eUri; } } var uriTimeoutMode = false; function clearUriReq(){ if (uriReqBusy) { uriTimeoutMode = true; directorTrace('uriTimeout' + ' eUri: ' + last_eUri + '\n reqs.length: ' + reqs.length); if (reqs.length > 0) { for (req in reqs) { directorTrace(' req: ' + reqs[req]); } } } else { directorTrace('uriTimeout' + ' uriReqBusy: ' + uriReqBusy); } uriReqBusy = false; uriTid = null; popUriReqs(); } function popUriReqs(){ if(reqs.length){ var temp = reqs[0]; reqs = reqs.slice(1); testUriRequest(temp); } else { if(loggingIn && !loginFailed) callToServer(); } } var gettingData = false; var dataArrived = false; var dataReturned = ""; var dataReceived = false; var responseTimer; var db_elements; var db_elementsFull; var msgWaiting = "no msgs"; var loggingIn = true; var previousDbElementsFull = null; function db_getConfData(){ if(lastReq == URL && !uriReqBusy && !monitorDone) { db_monitor(); monitorDone = true; setTimeout("monitorDone = false",2000); } dataReceived = false; handleResponse(); if(!dataArrived) return; gettingData = false; if(isUndefined(dataReturned)||dataReturned=="") return; if(traceDataReturned) updateStatus(dataReturned); // debugger; // dataReturned contains all data from server if (false && uriTimeoutMode) directorTrace('jChatFb.db_getConfData URI TIME OUT MODE. dataReturned: ' + dataReturned); db_elementsFull = dataReturned.split("{{"); if (false && (db_elementsFull.toString() != previousDbElementsFull)) { javaTrace('jChatFb.db_getConfData db_elementsFull: ' + db_elementsFull + '\n announcedInCall: ' + announcedInCall); } previousDbElementsFull = db_elementsFull; dataArrived = false; dataReceived = true; uriReqBusy = false; if(uriTid != null) { uriTimeoutMode = false; clearTimeout(uriTid); uriTid = null; popUriReqs(); } if(db_elementsFull[1].split("}}")[0] == "err"){ if(loggingIn) db_loginFail(); db_updateStatus("Server Returned Error"); return; } db_elements = db_elementsFull[1].split(":"); conferId = db_elements[1]; if(conferId=="timeout"){ // self.close(); db_updateStatus("Server Returned Error"); return; } confModerator = db_elements[2]; confereeList = db_elements[3]; ipList = db_elements[4]; stateList = db_elements[5]; cmdList = db_elements[6]; // if(cmdList != ",,,"&&cmdList!="") directorTrace("incoming: "+cmdList); tx = db_elements[7]; if(isUndefined(tx) || isNull(tx) || tx.length < 8) textChat = ""; else textChat = tx.substring(4,tx.length-3); groupNames = db_elements[8]; groupStates = db_elements[9]; groupConferences = db_elements[10]; msgWaiting = db_elements[11]; if (false && (msgWaiting != 'no msgs')) directorTrace('jChatFb.db_getConfData msgWaiting: ' + msgWaiting); db_getConferees(); db_getIPaddresses(); db_getConfereeStates(); db_getConfereeCmds(); db_getGroupNames(); db_getGroupStates(); db_getGroupConferences(); db_getMessages(); if(loggingIn) { if(isMember(myName)){ loggingIn = false; } } if(stopAfter && enableStopAfter) alert("stop"); return; } var conferId=""; function db_getConfId(){ return conferId; } var monitorDone = false; var confereeList; var conferees = new Array(); function db_getConferees(){ if(isUndefined(confereeList)) return; if(isNull(confereeList)) return; if(confereeList.length <= 1) conferees = new Array(); else{ confereeList = confereeList.substr(0,confereeList.length-1); conferees = confereeList.split(","); } return; } var groupNames; var groupMembers = new Array(); function db_getGroupNames(){ if(isNull(groupNames)||isUndefined(groupNames)) groupMembers = new Array(); else groupMembers = groupNames.split(","); return; } function db_getMessages(){ if(isNull(msgWaiting)||isUndefined(msgWaiting)) msgList = new Array(); else msgList = msgWaiting.split(","); return; } var groupStates; var groupMemberStates = new Array(); var previousGroupMemberStates = new Array(); function db_getGroupStates(){ if (groupMemberStates) { previousGroupMemberStates = groupMemberStates; } if(isNull(groupStates)||isUndefined(groupStates)) groupMemberStates = new Array(); else groupMemberStates = groupStates.split(","); for (var j = 0; (j < groupMemberStates.length) && (j < previousGroupMemberStates.length); j++) { if (groupMemberStates[j] != previousGroupMemberStates[j]) { javaTrace('jChatFb.db_getGroupStates GROUP STATE CHANGE.' + ' member: ' + groupMembers[j] + ' previous: ' + previousGroupMemberStates[j] + ' current: ' + groupMemberStates[j]); } } return; } var groupConferences; var groupMemberConfer = new Array(); function db_getGroupConferences(){ if(isNull(groupConferences)||isUndefined(groupConferences)) groupMemberConfer = new Array(); else groupMemberConfer = groupConferences.split(","); return; } var ipList; var ipAddresses = new Array(); function db_getIPaddresses(){ if(isNull(ipList)||isUndefined(ipList)) ipAddresses = new Array(); else ipAddresses = ipList.split(","); return; } var stateList; var confStates = new Array(); function db_getConfereeStates(){ if(isNull(stateList)||isUndefined(stateList)) confStates = new Array(); else confStates = stateList.split(","); return; } var cmdList; var confCmds = new Array ("","","",""); function db_getConfereeCmds(){ if(isNull(cmdList)||isUndefined(cmdList)) return; tmp = cmdList.split(","); for(var i=0; i
Text Chat Log:"+textChat; writeStatus(st); // setPageFocus(); } function replaceUpdateMsg(status){ localLog = lastLocalLog; updateOwnerStatus(status); } var reqNum=1; /*function db_updateMe(myIpAddress){ if(joinFlag) return; myName = ""; if(document.form1.OwnerName) myName = document.form1.OwnerName.value; strNum = reqNum+''; reqNum++; if(myName){ URL = BaseURL + "?confereeId=" + myName + "&confereeIP=" + myIpAddress + "&req=" + strNum; } }*/ var tags = new Array(); function hiding(tag){ for(var tg in tags){ if(tg == tag) return (tags[tg]=='hide'); } return null; } function showing(tag){ for(var tg in tags){ if(tg == tag) return (tags[tg]=='show'); } return null; } function hide(tag){ var st=hiding(tag); if(!isNull(st)&&st) return; var el=document.getElementById(tag); if (el == null) return; el.style.display="none"; tags[tag] = 'hide'; if(tag=='ep.ContactName'&&!playingVideo){ writeChatProperties(); hide('ep.ChatTitle'); hide('ep.ChatArea'); hide('ep.SendButton'); } } function show(tag){ if(tag=='ep.ContactName'||tag=='ep.OwnerName') return; var st=showing(tag); if(!isNull(st)&&st) return; var el=document.getElementById(tag); if (el == null) return; el.style.display="block"; tags[tag] = 'show'; if(tag=='ep.ContactName'&&!true){ var call=findCallForName(myName); writeCallProperties(call); show('ep.ChatTitle'); show('ep.ChatArea'); hide('ep.SendButton'); } } function db_startConference2(name){ AppOwnerName = name; myName = AppOwnerName; ownerName = myName; db_startConference(); } function db_startConference(){ if(!videoMessage) return; if(!installed) { setTimeout("db_startConference()",1000); return; } directorTrace("startConference"); stepped = false; // if(conferenceStarted) return; //javaTrace('jChatFb.db_startConference'); db_createConf(""); if(ownerName=="") return; if(myName=="") return; gettingOwner = false; conferenceStarted = true; //window.resizeTo(720+reservedWidth,720+reservedHeight); if(!loginFailed) pageLoad(); } var loginFailed = false; function isMember(nm){ for(var i=0;i"); writeChatProperties(); if(!isNull(lastContactSelected)) who = lastContactSelected.name; else who="all"; URL = BaseURL + "?cmd=text" + "&confID=" + confID + "&confereeId=" + who + "&data=" + ct; callToServer();//test // db_getConfData(); // alert(URL); } function db_chatRevert(){ writeChatProperties(); hide('ep.RevertChat'); show('ep.SendButton'); } function db_monitor(){ if(loggingIn) return; strNum = reqNum+''; reqNum++; URL = BaseURL + "?cmd=monitor" + "&confID=" + confID + "&confereeId=" + ownerName + "&confereeIP=" + myIPaddress + "&data=" + lastState; callToServer();//test } /* function db_upload(){ strNum = reqNum+''; reqNum++; URL = BaseURL + "?cmd=upload" + "&confID="+ confID + "&req=" + strNum; callToServer();//test } */ function db_delete(ext){ strNum = reqNum+''; reqNum++; URL = BaseURL + "?cmd=delete" + "&confID="+ confID + "&data=" + ext + "&req=" + strNum; callToServer();//test } function db_send(ext,userName){ if ((typeof confID != 'undefined') && (typeof ext != 'undefined') && isString(ext) && (ext.length > 0)) { var tmp = (memberName != "") ? memberName : ownerName; if (isString(tmp) && (tmp.length > 0)) { if ((typeof userName != 'undefined') && userName.length>0) tmp = userName; strNum = reqNum+''; reqNum++; URL = BaseURL + "?cmd=send" + "&confID="+ confID + "&confereeId=" + tmp + "&data=" + ext + "&req=" + strNum; directorTrace('jChatFb.db_send ext: ' + ext + ' URL: ' + URL); callToServer();//test } else { directorTrace('jChatFb.db_send memberName: ' + memberName + ' ownerName: ' + ownerName + ' ext: ' + ext + ' tmp: ' + tmp + ' isString(tmp): ' + isString(tmp) + ' typeof tmp: ' + (typeof tmp)); } } else { directorTrace('jChatFb.db_send confID: ' + confID + ' ext: ' + ext); } } function db_uploadStarted(){ } function db_uploadComplete(){ } var lastState = 'available'; function db_setState(name,state){ if(name == myName) lastState = state; URL = BaseURL + "?cmd=setState" + "&confID=" + confID + "&confereeId=" + name + "&confereeIP=" + myIPaddress + "&data=" + state; //javaTrace('jChatFb.db_setState name: ' + name + ' state: ' + state + '\n URL: ' + URL); callToServer(); } function db_addUser(name,pass){ URL = BaseURL + "?cmd=addUser" + "&confID=" + confID + "&confereeId=" + name + "&data=" + pass; callToServer(); } function db_removeUser(name){ URL = BaseURL + "?cmd=removeUser" + "&confID=" + confID + "&confereeId=" + name; callToServer(); } var trace=false; function db_setProperty(conferee,propName,propValue){ trace=true; URL = BaseURL + "?cmd=setProp" + "&confID=" + confID + "&confereeId=" + conferee + "&mode=" + propName + "&data=" + propValue; directorTrace('jChatFb.db_setProperty URL: ' + URL); callToServer(); // db_getConfData(); } var prop2Busy = false; function db_setProperty2(conferee,propName,encodedPropValue){ trace=true; URL = BaseURL + "?cmd=setProp" + "&confID=" + confID + "&confereeId=" + conferee + "&mode=" + propName + "&data="; directorTrace('jChatFb.db_setProperty URL: ' + URL); callToServer(encodedPropValue); // db_getConfData(); } var myName; var confID; function db_joinConference(name,reqId){ myName = name; ownerName = name; // alert(myName); // alert(reqId); confID = reqId; joinFlag = true; visibleFlag = false; // window.moveBy(3000,3000); // window.toolbar.visible=false; // window.locationbar.visible=false; db_startConference(); } function db_joinConf(confID) { if ((myName != "") && (confID != "")) { //javaTrace('jChatFb.db_joinConf' + ' confID: ' + confID + findCallForName(confID)); strNum = reqNum+''; reqNum++; strNum += "-"+(""+uplink)+"-"+(""+downlink); conferee = confID; //javaTrace('db_joinConf conferee: ' + conferee); vidConferee = conferee; URL = BaseURL + "?cmd=join" + "&confID=" + myName + "&confereeId=" + confID + "&confereeIP=" + myIPaddress + "&req=" + strNum; callToServer(); if (enableMulticast) { var aRemoteView = Chat.allocateView(); if (aRemoteView != null) { Chat.play(aRemoteView,conferee); } else { directorTrace('jChatFb.db_joinConf UNABLE TO ALLOCATE A REMOTE VIEW'); } } } } function db_bring(conferee){ if(myName!=""&&conferee!=""){ strNum = reqNum+''; reqNum++; URL = BaseURL + "?cmd=bring" + "&confID=" + myName + "&confereeId=" + conferee + "&confereeIP=" + myIPaddress + "&req=" + strNum; callToServer(); } } function db_uploadStart(){ return } function db_uploadComplete(){ return } function jChatInstall(){ if(!pageLoaded){ setTimeout('jChatInstall()',500); return; } if (enableChatInstall) { var componentFactory = new ComponentFactory(); iChat = new AppletSpec("evcInstaller"); iChat.setParameter("name","EvcInstaller"); iChat.setParameter("codebase", iChat.getParameter("codebase") + "conf/EVC/"); iChat.setParameter("visible","false"); iChat.addParameter("quiet","true"); // iChat.addParameter("main.Size","0"); // iChat.addParameter("main.Date","0"); AppletManager.theInstance().startApplet(iChat,iChat_startAppletCallback); }else{ setTimeout('init();',1000); setPageFocus(); } } function iChat_startAppletCallback(applet){ iChatDocument = applet; setTimeout('init();',1000); setPageFocus(); } // init jChat processing var jChatInstallationComplete = false; var jChatInitComplete = false; function jChatInit(){ if (jChatInitComplete) return; var i; calls = new Array(4); // if(!ad&&videoChat) changeState("preLoginConnection"); else changeState("acquireGroup"); changeState("acquireGroup"); for(i=0;i 0) { vPlay.addParameter('viewName',viewName); vPlay.addParameter('viewId',context); vPlay.addParameter('pels',width); vPlay.addParameter('lines',height); vPlay.addParameter('chatView',chatView); } AppletManager.theInstance().startApplet(vPlay,null,tag); } function msg(out){ if(!alertFlag){ alertFlag = true; alert(out); } } function getState(){ return JChatState; } function updateStatus(status){ windowStatus(status); if(stopPressed&&traceDataReturned) return; updateOwnerStatus(status); javaTrace('updateStatus status: ' + status); } var lastStatusReq = ""; function updateStatusWithDots(status){ if(status==""){ if(noDots) return; dots+="."; if(dots.length > 6) dots = "."; } else{ dots = ""; lastStatusReq = status; } if(noDots) updateStatus(lastStatusReq+dots); else replaceUpdateMsg(lastStatusReq+dots); } var lastLocalLog = ""; function updateLocalLog(update){ if(update=='') return; lastLocalLog = localLog; localLog += "
"+update; } function changeState(newState){ JChatState = newState; updateStatus("jchat state change: "+newState); } function getIPaddress(){ return myName; // gm return myIPaddress; } function bringBackToTop(){ for(i=0;i= 0) { hangUpCall(indx); } } function getCurrentIdx(){ var indx; indx = document.form1.View.value; return indx; } var bandwidthTestFile = ""; function bandwidthTest(fl){ bandwidthTestFile = fl; return; vChatDocument.ep_bandwidthTest(fl); } function getUploadRate(){ return vChatDocument.ep_getUploadRate(); } function getDownloadRate(){ return vChatDocument.ep_getDownloadRate(); } function getVPN(){ var ipAddress; if(!isVPNConnected()){ alert("not connected yet"); return null; } ipAddress = getVPNAddress(); if(document.form1.SelfIP) document.form1.SelfIP.value = ipAddress; return; } function shutdown() { vChatDocument.ep_shutdown(); } function getCD() { document.form1.FrameRate.value = getFrameRate(); document.form1.KFrameRate.value = getKeyFrameRate(); document.form1.Bandwidth.value = getBandwidth(); } // also is the self-view size function getCaptureWidth() { return vChatDocument.ep_getCaptureWidth(); } function getCaptureHeight() { return vChatDocument.ep_getCaptureHeight(); } function getTotalBandwidth() { return vChatDocument.ep_getTotalBandwidth(); } function getSendBandwidth() { return vChatDocument.ep_getSendVideoBandwidth(); } function getRcvVideoBandwidth() { return vChatDocument.ep_getRcvVideoBandwidth(); } function getFrameRate() { return vChatDocument.ep_getFrameRate(); } function getKeyFrameRate() { return vChatDocument.ep_getKeyFrameRate(); } function getIQP() { return vChatDocument.ep_getIQP(); } function getMinIQP() { return vChatDocument.ep_getMinIQP(); } function usingDeblocking() { return vChatDocument.ep_usingDeblocking(); } // Set the cutoff limit in seconds for all call round trip delay tests function setCallRoundTripLimit(seconds) { vChatDocument.ep_setMaxRoundTripLimit(seconds); } // Get the cutoff limit for the call round-trip delay test function getCallRoundTripLimit() { return vChatDocument.ep_getMaxRoundTripLimit(); } // Get the current number of consecutive call round-trip delay tests that // exceed the cutoff limit -- Counter is automatically reset when any // round-trip test completes under the cutoff limit -- For a specific call. function getCurrentRoundTripTimeouts(indx) { return vChatDocument.ep_getCurrentNumRoundTripTimeouts(indx); } // Get the total number of call round-trip delay tests that // exceed the cutoff limit over the entire call period. -- Counter only reset // when new call starts. -- For a specific call. function getHWRoundTripTimeouts(indx) { return vChatDocument.ep_getHWNumRoundTripTimeouts(indx); } // Reset the RT stats function resetRTStats(indx) { vChatDocument.ep_resetTOStats(indx); } // Get the current number of received audio messages for a call. // Counter is never reset -- it just rolls over -- used to check to make // sure that audio messages are being received from a particular party function getNumRcvdAudioMsgs(indx) { return vChatDocument.ep_GetNumRcvAudioMsgs(indx); } // Get the current number of received video messages for a call. // Counter is never reset -- it just rolls over -- used to check to make // sure that video messages are being received from a particular party function getNumRcvdVideoMsgs(indx) { return vChatDocument.ep_GetNumRcvVideoMsgs(indx); } // Drop the call and indicate that the call is dropped due to a timeout function dropCallDueToTimeout(indx) { vChatDocument.ep_DropCallDueToTimeout(indx); } var width; var height; var totlBW; var sndBW; var rcvBW; var fr; var kfr; var iqp; var rcmode; var useDeblocking=0; var widthOverride = 0; // 160 var heightOverride = 0; // 120? 128? check with Collins function setCapParm() { // if(!capturingVideo) return; var w = (widthOverride > 0) ? widthOverride : width; var h = (heightOverride > 0) ? heightOverride : height; directorTrace('jChatFb.setCapParm' + ' w: ' + w + ' h: ' + h + ' totlBW: ' + totlBW + ' sndBW: ' + sndBW + ' rcvBW: ' + rcvBW + ' fr: ' + fr + ' iqp: ' + iqp + ' rcmode: ' + rcmode + ' kfr: ' + kfr + ' useDeblocking: ' + useDeblocking); vChatDocument.ep_setVideoParameters(w, h, totlBW, sndBW, rcvBW, fr, kfr, iqp, rcmode, useDeblocking); } function getCapParm() { //if(!capturingVideo) return; width = (widthOverride > 0) ? widthOverride : getCaptureWidth(); height = (heightOverride > 0) ? heightOverride : getCaptureHeight(); totlBW = getTotalBandwidth(); sndBW = getSendBandwidth(); rcvBW = getRcvVideoBandwidth(); fr = getFrameRate(); kfr = getKeyFrameRate(); iqp = getIQP(); rcmode = getMinIQP(); useDeblocking = usingDeblocking(); } function getRTStats() { if (getCurrentIdx() >= 0) { document.form1.RCTO.value = getCurrentRoundTripTimeouts(getCurrentIdx()); document.form1.RHWTO.value = getHWRoundTripTimeouts(getCurrentIdx()); document.form1.RNRAM.value = getNumRcvdAudioMsgs(getCurrentIdx()); document.form1.RNRVM.value = getNumRcvdVideoMsgs(getCurrentIdx()); } } function undef(arg){ if(isUndefined(arg)) return ""; else return arg; } var optionArray; function nameAdj(name){ var tm=""; var adj = 30-name.length; if(adj>0){ for(var i=0;i= lastConferee) return; if(isUndefined(conferees[second])||conferees[second]=="") return; call = findCallForName(conferees[second]); if(isNull(call)) optionState = ""; else optionState = call.state; optionIP = undef(ipAddresses[second]); if(optionIP=="") optionIP = "none"; optionName = undef(conferees[second]); // if(optionName) optionName += " IP: " + optionIP; optionArray[1] = optionName + nameAdj(optionName) + optionState; if(second >= lastConferee) return; if(isUndefined(conferees[third])||conferees[third]=="") return; call = findCallForName(conferees[third]); if(isNull(call)) optionState = ""; else optionState = call.state; optionIP = undef(ipAddresses[third]); if(optionIP=="") optionIP = "none"; optionName = undef(conferees[third]); // if(optionName) optionName += " IP: " + optionIP; optionArray[2] = optionName + nameAdj(optionName) + optionState; if(third >= lastConferee) return; if(isUndefined(conferees[fourth])||conferees[fourth]=="") return; call = findCallForName(conferees[fourth]); if(isNull(call)) optionState = ""; else optionState = call.state; optionIP = undef(ipAddresses[fourth]); if(optionIP=="") optionIP = "none"; optionName = undef(conferees[fourth]); // if(optionName) optionName += " IP: " + optionIP; optionArray[3] = optionName + nameAdj(optionName) + optionState; } /* function generateCallProps(call){ var props = '


'; props += 'CALL PROPERTIES:
'; props += ''; props += ' '; props += ''; props += ' '; return props; }*/ /* function generateCallProps(call){ var props = "" return props; } */ var resolutionValue = 1; var showVideoValue = ""; function generateCallProps(call){ /* var props = ''; */ var props = 'You may choose (optionally)
your camera capture resolution
and/or a video to play when
first connected.
'; props +='
'; props +='
'; /* props +='
';*/ return props; } function videoOptionSelected(){ selectedOption = document.form1.videoOptions.selectedIndex; if(selectedOption==-1) return; switch(selectedOption){ case 0: return; case 1: vid = "Ford1"; break; case 2: vid = "Ford2"; break; case 3: vid = "Igonet"; break; case 4: vid = "Days"; break; } // if(!isNull(lastContactSelected)) db_setProperty(lastContactSelected.name,'video',vid); showVideoValue = vid; } function resOptionSelected(){ selectedOption = document.form1.resolutionOptions.selectedIndex; if(selectedOption==-1) return; switch(selectedOption){ case 0: return; case 1://small sz=1; break; case 2://large/excellent sz=2; break; case 3: sz=3;//large/good break; case 4: sz=4;//large/fair break; default: return; } // if(!isNull(lastContactSelected)) db_setProperty(lastContactSelected.name,'resolution',sz); resolutionValue = sz; if(capturing) setVideoFlag=true; } function selectResolutionUsingBandwidth(uplink){ setVideoFlag = true; if(uplink > 700){ resolutionValue = 3; return; } if(uplink > 400){ resolutionValue = 3; return; } if(uplink > 400){ resolutionValue = 3; return; } resolutionValue = 1; } function generateDataAreaTitle(title){ write(document,'dataAreaTitle',title); } var savedDataArea=""; function writeCallProperties(call){ var callProps; generateDataAreaTitle("CALL PROPERTIES"); callProps = generateCallProps(call); write(document,'dataArea',callProps); dataAreaProperties = true; hide('ep.SendButton'); if(encoderMgmtFeature){ generateDataAreaTitle("ENTER ENCODER PARAMETERS"); hide('ep.SendButton'); hide('ep.RevertChat'); show('ep.EncoderParams'); db_getParams; } // show('ep.RevertChat'); } function generateChatProps(){ var props = "" return props; } function writeChatProperties(){ var chatProps; // if(textChatFeature){ generateDataAreaTitle("ENTER TEXT CHAT"); chatProps = generateChatProps(); write(document,'textmsg_input',chatProps); dataAreaProperties = false; // hide('ep.RevertChat'); // show('ep.SendButton'); // } if(encoderMgmtFeature){ generateDataAreaTitle("ENTER ENCODER PARAMETERS"); hide('ep.SendButton'); hide('ep.RevertChat'); show('ep.EncoderParams'); db_getParams; } } var lastContactSelected=null; function contactSelected(){ // alert(document.form1.contacts.selectedIndex); var call; var selectedOption = document.form1.contacts.selectedIndex; if(selectedOption==-1) return; optionName = lastOptionArray[selectedOption].split(" "); call = findCallForName(optionName[0]); if(!call) return; lastContactSelected = call; writeCallProperties(call); dataAreaProperties = true; } function callOptionSelected(){ selectedOption = document.form1.callOptions.selectedIndex; if(selectedOption==-1) return; switch(selectedOption){ case 0: break; case 1://bring to my conf if(!isNull(lastContactSelected)&&lastContactSelected.getState() == "available") lastContactSelected.reqOriginate(); break; case 2://join his break; case 3://drop him db_dropCall(); } } function db_dropCall(){ var call=findCallForName(conferee); updateStatus("dropping call: "+conferee+" state: "+call.getState()); if(!isNull(call)&&call.getState() == "in-call") call.reqTermination(); show('ep.ContactName'); //javaTrace('db_dropCall show ep.ContactName'); // hide('ep.ChatTitle'); // hide('ep.ChatArea'); // hide('ep.SendButton') hide('ep.EndCall'); stopVideo(); //javaTrace('jChatFb.db_dropCall' + '\n calls[0]: ' + calls[0] + '\n calls[1]: ' + calls[1]); } var lastOptionArray; var contactsWritten = false; function writeContacts(){ var i; var status; var diff; if(isUndefined(optionArray)) return; if(optionArray.length <= 0) return; if(!isUndefined(lastOptionArray)){ if(lastOptionArray.length == optionArray.length){ diff=false; for(i=0;i"; for(i=0;i" + optionArray[i] + ""; } status += ""; // write(document,'contactList',status); lastOptionArray = optionArray; contactsWritten = true; } var lastMembersArray; var membersWritten = false; var gettingOwner = true; var activeMemberArray = new Array(); function memberSelected(){ var selectedOption = document.form1.members.selectedIndex; if(selectedOption==-1) return; memberName = '' + activeMemberArray[selectedOption].split(" "); javaTrace('memberSelected selectedOption: ' + selectedOption + ' memberName: ' + memberName + ' gettingOwner: ' + gettingOwner + '\n activeMemberArray: ' + activeMemberArray); if(gettingOwner){ // document.form1.value = memberName; } else{ // ` newName = memberName; // document.form1.NewName.value = memberName; newName = memberName; show('ep.ContactName'); //javaTrace('memberSelected show ep.ContactName'); } } var breakOn = true; var initialWrite=false; var membersReceivingMe = new Array(); var lastReceiving = new Array(); var membersTextingWithMe = new Array(); var lastTexting = new Array(); var lastControls = new Array(); var lastMbrList = null; var lastMbrState = null; function writeMembers(){ var i, gname; var status, hs, memDiff, stateDiff; if(breakNow) debugger; if(isUndefined(groupMembers)) return; if(!groupAcquired)return; if(groupMembers.length <= 0) return; if(!isUndefined(lastMembersArray)){ if(lastMembersArray.length == groupMembers.length){ memDiff = false; stateDiff = false; for(i=0;i'); rowStubs = tableStubs[1].split('%name'); temp = ""; memberSect = (Cvm.isFvMode()) ? document.getElementById("membersarea") : document.getElementById("memberSection"); temp = tableStubs[0]; var statCount = groupMembers.length; sortGroup = groupMembers.slice().sort(); sorted_list123 = groupMembers.slice().sort(); for(i=0;i' + groupMembers[i] + ""; //test += '' + groupMembers[i] + ""; } if (flash) window.document.myFlash.setVariable("member_list1",test); lastMbrList = test; } } membersShowing = statCount; lastMembersArray = groupMembers.slice(); lastMemberStates = groupMemberStates.slice(); for(gname in membersTextingWithMe) lastTexting[gname] = membersTextingWithMe[gname]; for(gname in membersReceivingMe) lastReceiving[gname] = membersReceivingMe[gname]; for(gname in remoteActors) lastControls[gname] = remoteActors[gname]; membersWritten = true; if((!stateDiff)&&initialWrite) return; initialWrite = true; var test3 = ''; for(i=0;i=0) return; if(isUndefined(ipAddresses)) return; if(isNull(ipAddresses)) return; coms = true; // if(ipAddresses[ipIdx] == myIPaddress){ if(isUndefined(confCmds[ipIdx])) coms=false; if(isNull(confCmds[ipIdx])) coms=false; if(confCmds[ipIdx]=="") coms=false; call = findCallForName(conferee); // if(conferee!=myName) updateStatus("u1:"+coms); if(isNull(call)) coms=false; // if(conferee!=myName) updateStatus("u2:"+coms); if(coms){ cmds = confCmds[ipIdx].split("!"); confCmds[ipIdx] = ""; for(i=1;i0){ for(i=0;i 0) currentCalls += ','; currentCalls += calls[j].ipAddress; wasRequested = false; } } else { if ((myState == 'busy') && (theirState == 'busy')) { if (currentCalls.length > 0) currentCalls += ','; currentCalls += calls[j].ipAddress; wasRequested = false; } } if ((myState == 'in-call') && (theirState == 'in-call')) { if (currentCalls.length > 0) currentCalls += ','; currentCalls += calls[j].ipAddress; } } } } if (false && (currentCalls != previousCurrentCalls)) { javaTrace('jChatFb.checkCurrentCalls CHANGE DETECTED' + '\n calls[1].name: ' + calls[1].name + ' .ipAddress: ' + calls[1].ipAddress + ' .state: ' + calls[1].state + '\n theirIdx: ' + theirIdx + '\n theirName by theirIdx: ' + theirName + '\n theirState by theirIdx: ' + theirState + '\n groupMembers: ' + groupMembers + '\n groupMemberState: ' + groupMemberStates); previousCurrentCalls = currentCalls; } } if (currentCalls && (currentCalls!="")) { callList = currentCalls.split(","); } else { callList = new Array(0); } refreshCallList(); updateDocument(); if (false && ((conferees.toString() != previousConferees) || (ipAddresses.toString() != previousIpAddresses) || (confStates.toString() != previousConfStates))) { previousConferees = conferees.toString(); previousIpAddresses = ipAddresses.toString(); previousConfStates = confStates.toString(); javaTrace('jChatFb.checkCurrentCalls' + '\n currentCalls: ' + currentCalls + '\n conferees: ' + conferees + '\n ipAddresses: ' + ipAddresses + '\n confStates: ' + confStates + '\n callList: ' + callList + '\n conferees[0]: ' + conferees[0] + '\n confStates[0]: ' + confStates[0] + '\n calls[0]: ' + calls[0] + '\n calls[1]: ' + calls[1]); } } var respondingToRequest = 0; function checkMyStatus(){ return; if(respondingToRequest) { respondingToRequest--; return; } for(var i=0;i0){ writeMembers(); groupAcquired = true; if(conferenceStarted)checkMyStatus(); } return; } var lastTransmitStatus = null; var lastTransmitStyle = null; function checkTransmitStatus(){ if(!isNull(lastTransmitStatus)){ if(customActive && (lastTransmitStatus == 0)) return; if(!customActive && (lastTransmitStatus == currentRes)) return; } if(customActive) lastTransmitStatus = 0; else lastTransmitStatus = currentRes; clearAllTransmitStateButtons(); setTransmitStateButton(lastTransmitStatus); } function checkTransmitStyle(){ if(!isNull(lastTransmitStyle)){ if(lastTransmitStyle == currentTransmitStyle) return; } lastTransmitStyle = currentTransmitStyle; clearAllTransmitStyleButtons(); setTransmitStyleButton(lastTransmitStyle); } var stateButtonIds = null; var styleButtonIds = null; function initStyleButtons(){ if(!isNull(styleButtonIds)) return; styleButtonIds = new Array(); styleButtonIds['horiz'] = "horizontal,images/buttons/horizontal_static.gif,images/buttons/horizontal_on.gif"; styleButtonIds['vert'] = "vertical,images/buttons/vertical_static.gif,images/buttons/vertical_on.gif"; styleButtonIds['tiled'] = "tiled,images/buttons/tiled_static.gif,images/buttons/tiled_on.gif"; } function clearAllTransmitStyleButtons(){ initStyleButtons(); var st, tag, bid; for(st in styleButtonIds){ bid = styleButtonIds[st].split(","); tag = document.getElementById(bid[0]); if (tag !== null) { tag.src = bid[1]; if(tag.oSrc) tag.oSrc = tag.src; } } } function setTransmitStyleButton(style){ var bid,tag; initStyleButtons(); bid = styleButtonIds[style].split(","); tag = document.getElementById(bid[0]); if (tag !== null) { tag.src = bid[2]; if(tag.oSrc) tag.oSrc = tag.src; } } function initStateButtons(){ if(!isNull(stateButtonIds)) return; stateButtonIds = new Array(); stateButtonIds[0] = "custom_settings21,images/buttons/cs_static.gif,images/buttons/cs_on.gif"; stateButtonIds[1] = "undefined"; stateButtonIds[2] = "undefined"; stateButtonIds[3] = "undefined"; stateButtonIds[4] = "undefined"; stateButtonIds[5] = "undefined"; stateButtonIds[6] = "small_fair21,images/buttons/fair_static.gif,images/buttons/fair_on.gif"; stateButtonIds[7] = "small_good21,images/buttons/good_static.gif,images/buttons/good_on.gif"; stateButtonIds[8] = "small_excellent21,images/buttons/excellent_static.gif,images/buttons/excellent_on.gif"; stateButtonIds[9] = "med_fair21,images/buttons/fair_static.gif,images/buttons/fair_on.gif"; stateButtonIds[10] = "med_good21,images/buttons/good_static.gif,images/buttons/good_on.gif"; stateButtonIds[11] = "med_excellent21,images/buttons/excellent_static.gif,images/buttons/excellent_on.gif"; stateButtonIds[12] = "large_fair21,images/buttons/fair_static.gif,images/buttons/fair_on.gif"; stateButtonIds[13] = "large_good21,images/buttons/good_static.gif,images/buttons/good_on.gif"; stateButtonIds[14] = "large_excellent21,images/buttons/excellent_static.gif,images/buttons/excellent_on.gif"; stateButtonIds[15] = "ex_large_fair21,images/buttons/fair_static.gif,images/buttons/fair_on.gif"; stateButtonIds[16] = "ex_large_good21,images/buttons/good_static.gif,images/buttons/good_on.gif"; stateButtonIds[17] = "ex_large_excellent21,images/buttons/excellent_static.gif,images/buttons/excellent_on.gif"; } function clearAllTransmitStateButtons(){ var i,bid,tag; initStateButtons(); for(i=0;i 0)&&(uplink> 0)) bwTestDone = true; break; } if(isVPNConnected()) changeState("waitingForMyIPaddress"); break; case "waitingForMyIPaddress": myIPaddress = ""+getVPNAddress(); if(myIPaddress!="") { // if(!joinFlag) db_createConf(myIPaddress); else db_joinConf(myIPaddress); call = findCallForName(myName); if(isNull(call)) break; call.ipAddress = myIPaddress; //updateStatus("service connected -- IP address: "+myIPaddress); updateStatus("service connected -- IP address: "+getRawAddress()); if(document.form1.SelfIP) document.form1.SelfIP.value = myIPaddress; if(dataReturned != "" || !automate){ changeState("monitoringCalls"); updateStatus("monitoring calls"); if(uplink>0) selectResolutionUsingBandwidth(uplink); if(uplink>0)updateStatus("uplink rate: "+uplink); if(downlink>0)updateStatus("downlink rate: "+downlink); // setVideoOptions(); if(membersShowing>0) { showContactName = true; enableHourGlass(); // show('ep.ContactName'); // javaTrace('jChatFb.jChatClock show ep.ContactName'); // show('ep.body_text5'); } else monitorList = true; timeCnt = 3; break; } if(automate){ cList = document.form1.NewName.value.split(";"); if(cList.length>0){ autoAdding = true; autoConf = 0; autoConfAdding = 999; changeState("autoAdd"); updateStatus("Auto adding conferees"); timeCnt = 3; } } } updateStatusWithDots(""); break; case "monitoringCalls": if(makeCall){ if(!timingVideoStart){ // setTimeout("videoCaptureTimeout()",5000); // timingVideoStart = true; // timingVideoDone = false; javaTrace("jChatClock monitoringCalls. making call - starting video"); // setVideoOptions(); startVideoCapture(); capturing = true; // break; } // if(!timingVideoDone) break; // setVideoOptions(); makeCall = false; // timingVideoStart = false; // timingVideoDone = false; requestOrig = conferee; updateStatus("calling conferee: " + conferee); } if(monitorList&&membersShowing>0) { //test show('ep.ContactName'); //javaTrace('2:jChatClock show ep.ContactName'); // show('ep.body_text5'); } updateOwnerStatus(""); if(calls[0].state=='in-call'||calls[1].state=='in-call'){ // if(notCapturing) startVideoCapture(); } break; case "autoAdd": if(autoConf != autoConfAdding){ autoConfAdding = autoConf; updateStatus("adding: "+cList[autoConf]); db_addConfFor(cList[autoConf],myIPaddress); } else { if(!isNull(findCallForName(cList[autoConf]))){ autoConf++; if(autoConf >= cList.length){ changeState("monitoringCalls"); updateStatus("monitoring Calls"); autoAdding = false; timeCnt = 3; break; } } if(!gettingData){ checkCurrentCalls(); } updateOwnerStatus(""); } } if(startupApp) {setTimeout("jChatClock();",tmr);return;} if(logon && monitoringServer && timeCnt-- <=0) { db_getConfData(); timeCnt = 1;//test if(dataReceived){ if(!loggingIn) db_updateStatus("Connected"); dataCnt = 30; } if(dataCnt >= 0){ if(--dataCnt < 0){ db_updateStatus("Connecting"); } } } if(loggingIn) {db_getConfData(); timeCnt = 1;setTimeout("jChatClock();",tmr);return;} if(monitoringServer&&!gettingData) { checkCurrentCalls(); checkGroupStatus(); if(!flash)checkTransmitStatus(); if(!flash)checkTransmitStyle(); } updateOwnerStatus(""); if(capturingVideo&&setVideoFlag){ directorTrace("Changing video options with resolution: "+resolutionValue); setVideoOptions(); setVideoFlag=false; } setPageFocus(); setTimeout("jChatClock();",tmr); } function scrollToBottom(tagid){ var htmlElement; var h; htmlElement = document.getElementById(tagid); if (htmlElement == null) return; h = htmlElement.scrollHeight; htmlElement.scrollTop = h; } function write(doc, tagid, strhtml) { //tagid.innerHTML = strhtml; //alert(tagid); var htmlElement; htmlElement = document.getElementById(tagid); if (htmlElement == null) return; if (document.layers) { //htmlElement = doc.layers[tagid].document; htmlElement.open(); htmlElement.write(strhtml); htmlElement.close(); } else if (document.all) { //htmlElement = doc.all(tagid); htmlElement.innerHTML = strhtml; } else if (document.documentElement) { //htmlElement = doc.getElementById(tagid); htmlElement.innerHTML = strhtml; } } var lastStatus=""; function writeStatus(status){ if(lastStatus==status) return; lastStatus=status; //',status); // scrollToBottom('status'); } function Applet() { var componentFactory = new ComponentFactory(); var stdout = ""; var params = new Array(); this.objectclassid = ""; this.objectcodebase = ""; this.name = ""; this.code = ""; this.codebase = componentFactory.codebase; this.width = ""; this.height = ""; this.archive = ""; this.embedtype = ""; this.embedpluginspage = ""; this.scriptable = "false"; this.mayscript = "false"; this.startApplet = StartApplet; this.addParameter = add_Parameter; this.startAppletWithAppletTag = StartAppletWithAppletTag; this.getInstance = GetInstance; function StartApplet(target) { // alert("jChatFb.StartApplet target: " + target); this.startAppletWithAppletTag(target); return; stdout = '\n'; stdout += '\n'; stdout += '\n'; if (this.codebase != "") { stdout += '\n'; } stdout += '\n'; getParameters("OBJECT"); stdout += '\n'; stdout += 'here\"\n'; getParameters("EMBED"); stdout += '>\n'; stdout += '<APPLET valign="top" halign="left" code=\"' + this.code + '\" archive=\"' + this.archive + '\" width=\"' // + this.width + '\" height=\"' + this.height + '\" name=\"' + this.name + '\" MAYSCRIPT=\"' + this.mayscript + '\ + 320 + '\" height=\"' + 240 + '\" name=\"' + this.name + '\" MAYSCRIPT=\"' + this.mayscript + '\ ">\n'; stdout += '<PARAM NAME=\"scriptable\" VALUE=\"' + this.scriptable + '\">\n'; stdout += '<PARAM NAME=\"alt\" VALUE=\"No Java 2 JRE, Standard Edition v 1.4.2 support for applet! ' + 'Please install a Java plug-in so that this applet can work correctly.' + 'If you are not prompted to download a Java plug-in, download J2SE ' + '1.4.2.x JRE manually from <a href=\"http://java.sun.com/j2se/1.4.2/download.html\">here</a>\">\n'; getParameters("APPLET"); stdout += '</APPLET>\n'; stdout += 'No Java 2 JRE, Standard Edition v 1.4.2 support for applet! ' + 'Please install a Java plug-in so that this applet can work correctly.' + 'If you are not prompted to download a Java plug-in, download J2SE ' + '1.4.2.x JRE manually from <a href=\"http://java.sun.com/j2se/1.4.2/download.html\">here</a>\n'; stdout += '\n'; stdout += '\n'; stdout += '\n'; stdout += '\n'; //alert(stdout); write(document,target,stdout); } function StartAppletWithAppletTag (target) { stdout += '\n'; stdout += ' height=\"' + this.height + '\" name=\"' + this.name + '\" id=\"' + this.name + '\" MAYSCRIPT=\"' + this.mayscript + '\" alt=\"No Java 2 JRE, Standard Edition v 1.4.2 support for applet! ' + 'Please install a Java plug-in so that this applet can work correctly.' + 'If you are not prompted to download a Java plug-in, download J2SE ' + '1.4.2.x JRE manually from \">\n'; stdout += '\n'; getParameters("APPLET"); stdout += '\n'; stdout += 'No Java 2 JRE, Standard Edition v 1.4.2 support for applet! ' + 'Please install a Java plug-in so that this applet can work correctly.' + 'If you are not prompted to download a Java plug-in, download J2SE ' + '1.4.2.x JRE manually from here\n'; stdout += '\n'; //alert(target + ' ' + stdout);//show applet detail if (false && (target == 'captureApplet')) { alert('jChatFb.StartAppletWithAppletTag stdout: ' + stdout); } write(document,target,stdout); } function add_Parameter(name, value) { params[params.length] = new Array(name, value); } function getParameters(type) { switch(type) { case "OBJECT": stdout += '\n'; for(var i = 0;i < params.length;i++) { stdout += '\n'; } break; case "EMBED": stdout += 'name = \"' + this.name + '\"\n'; for(var i = 0;i < params.length;i++) { stdout += params[i][0] + ' = \"' + params[i][1] + '\"\n'; } break; case "APPLET": // stdout += 'name = \"' + this.name + '\"\n'; for(var i = 0;i < params.length;i++) { stdout += '\n'; } break; } } function GetInstance() { if (document.layers) { //alert("document.embeds"); return document.embeds[this.name]; } else if (document.all) { //alert("document.all"); return document.all[this.name]; } else if (document.getElementById) { return document.embeds[this.name]; } else { alert('jChatFb.GetInstance cannot find name: ' + this.name); } } } function javaTrace(text) { // alert(text); try { vChatDocument.ep_trace("[CHAT JS] " + text); } catch (err) { try { directorTrace(text); } catch (err) {} } } function javaBeep() { //vChatDocument.ep_beep(); } function pageUnload() { if (ownerName && (ownerName.length > 0)) { db_setState(ownerName,'offline'); } } function isChatStarted() {return vChatDocument.ep_isStarted();} var fvMembers = null; var fvMemberPad = '............'; function fvUpdateMemberStatus(memberList,stateList,element) { if ((memberList != null) && (stateList != null)) { if (false) directorTrace('jChatFb.fvUpdateMemberStatus' + '\n typeof memberList: ' + typeof memberList + '\n typeof stateList: ' + typeof stateList); if (memberList.startsWith(',')) memberList = memberList.substring(1); if (memberList.substring(memberList.length-1) == ',') memberList = memberList.substring(0,memberList.length-1); if (stateList.startsWith(',')) stateList = stateList.substring(1); if (stateList.substring(stateList.length-1) == ',') stateList = stateList.substring(0,stateList.length-1); fvMembers = memberList.split(','); var states = stateList.split(','); if (false) directorTrace('jChatFb.fvUpdateMemberStatus' + '\n fvMembers: ' + fvMembers + '\n fvMembers.length: ' + fvMembers.length + '\n states: ' + states + '\n states.length: ' + states.length); status = ''; status += " 0)) { var endOfCodeBaseOverride = clipSdl.lastIndexOf('/'); if (endOfCodeBaseOverride != -1) { clipCodeBaseOverride = clipSdl.substring(0,endOfCodeBaseOverride+1); } else { alert('SceneMerge.setSceneMergeClipSdl clipSdl INVALID:' + clipSdl); } } else { alert('SceneMerge.setSceneMergeClipSdl clipSdl INVALID:' + clipSdl); } } this.setSceneMergeSceneSdl = function(sdl) // USER API { if (mergeSceneInProgress) { sceneMergeAlreadyInProgress(); return; } sceneSdl = sdl; if (sceneSdl && isString(sceneSdl) && (sceneSdl.length > 0)) { var endOfCodeBaseOverride = sceneSdl.lastIndexOf('/'); if (endOfCodeBaseOverride != -1) { sceneCodeBaseOverride = sceneSdl.substring(0,endOfCodeBaseOverride+1); } else { alert('SceneMerge.setSceneMergeSceneSdl sceneSdl INVALID:' + sceneSdl); } } else { alert('SceneMerge.setSceneMergeSceneSdl sceneSdl INVALID:' + sceneSdl); } //directorTrace('SceneMerge.setSceneMergeSceneSdl' + '\n sceneSdl: ' + sceneSdl + '\n sceneCodeBaseOverride: ' + sceneCodeBaseOverride); } this.setSceneMergeStartSegment = function(seg) // USER API { if (mergeSceneInProgress) { sceneMergeAlreadyInProgress(); return; } originalClipStartSegment = parseInt(seg); } this.setSceneMergeStartRecNum = function(recNum) // USER API { if (mergeSceneInProgress) { sceneMergeAlreadyInProgress(); return; } originalClipStartRawRecNum = parseInt(recNum); } this.setSceneMergeCallback = function(cb) // USER API { if (mergeSceneInProgress) { sceneMergeAlreadyInProgress(); return; } callback = cb; } this.startSceneMerge = function() // USER API { if (mergeSceneInProgress) { sceneMergeAlreadyInProgress(); return; } //directorTrace('SceneMerge.startSceneMerge\n' + this.sceneMergeToString()); if ((mergePhase != 0) || isContextPlaying(getMyContextIndex())) { mergeAbort = true; mergePhase = 0; stopContext(getMyContextIndex()); this.disableMerge(); return; } // this is the first phase. if (sceneStartSegment > 0) { mergeSceneInProgress = true; enableHourGlass(); this.enableMerge(); if (originalClipStartRawRecNum > 0) { // fill in first part from the original clip setCodeBaseOverride(getMyContextIndex(),clipCodeBaseOverride); setSceneMergeTmpDir(getMyContextIndex(),sceneMergeTmpDir); playClipFromTo(getMyContextIndex(),originalClipStartSegment,0,originalClipStartSegment,originalClipStartRawRecNum-1,false,clipSdl); mergePhase = 2; // next merge phase } else { if (originalClipStartRawRecNum == 0) { this.mergePhase2(); } else { directorTrace('SceneMerge.startSceneMerge INVALID START FRAME: ' + originalClipStartRawRecNum); } } } else { directorTrace('SceneMerge.startSceneMerge INVALID START SEGMENT: ' + sceneStartSegment); } } this.mergePhase0 = function() { directorTrace('SceneMerge.nextMergePhase MERGE ABORTED'); this.mergeFinalized(0,''); } this.mergePhase2 = function() { // play scene to be merged in //directorTrace('SceneMerge.mergePhase2' + ' startSegment: ' + sceneStartSegment + ' startRawRecNum: ' + sceneStartRawRecNum); setCodeBaseOverride(getMyContextIndex(),sceneCodeBaseOverride); setSceneMergeTmpDir(getMyContextIndex(),sceneMergeTmpDir); playClipFromTo(getMyContextIndex(),sceneStartSegment,sceneStartRawRecNum,sceneEndSegment,sceneEndRawRecNum,false,sceneSdl); mergePhase = 3; // next merge phase } this.mergePhase3 = function() { mergeClipLastSegment = this.getMergeClipLastSegment(); mergeClipLastRawRecNum = this.getMergeClipLastRawRecNum(); mergeClipLastRecNum = this.getMergeClipLastRecNum(); //directorTrace('SceneMerge.mergePhase3' + ' lastSegment: ' + mergeClipLastSegment + ' lastRawRecNum: ' + mergeClipLastRawRecNum + ' lastRecNum: ' + mergeClipLastRecNum); if ((mergeClipLastSegment > 0) && (mergeClipLastRawRecNum > 0)) { this.updatePostMergeConfig(); var nextSegment = originalClipStartSegment+mergeClipLastSegment-1; setCodeBaseOverride(getMyContextIndex(),clipCodeBaseOverride); setSceneMergeTmpDir(getMyContextIndex(),sceneMergeTmpDir); playClipFromTo(getMyContextIndex(),nextSegment,mergeClipLastRawRecNum+1,nextSegment,-1,false,clipSdl); // play the rest mergePhase = 4; // next merge phase } else { this.mergePhase4(); } } this.mergePhase4 = function() { //directorTrace('SceneMerge.mergePhase4'); this.finalizeMerge(clipSdl,sceneSdl,'video'); } this.nextMergePhase = function() { var phase = 'this.mergePhase' + mergePhase + '()'; try { eval(phase); //directorTrace('SceneMerge.nextMergePhase phase: ' + phase); } catch(err) { directorTrace('SceneMerge.nextMergePhase INVALID PHASE: ' + mergePhase); } } this.setMergeClipEnabled = function(state) { getSceneMergeDirector().ep_invokeAndWait(getMyContextIndex() + ',,ep_setMergeClipEnabled,' + state); } this.setClipWriterEnabled = function(state) { getSceneMergeDirector().ep_invokeAndWait(getMyContextIndex() + ',,ep_setClipWriterEnabled,' + state); } this.enableMerge = function() { this.setMergeClipEnabled(true); this.setClipWriterEnabled(true); } this.disableMerge = function() { this.setMergeClipEnabled(false); this.setClipWriterEnabled(false); } this.mergeClipComplete = function(ctxId,eventDescriptor) { //directorTrace('SceneMerge.mergeClipComplete eventDescriptor:' + eventDescriptor); if (eventDescriptor.indexOf("video") != -1) videoMergeComplete = true; if (eventDescriptor.indexOf("audio") != -1) audioMergeComplete = true; //if (videoMergeComplete && audioMergeComplete) if (videoMergeComplete) { //directorTrace('SceneMerge.mergeClipComplete ctxId: ' + ctxId + ' eventDescriptor: ' + eventDescriptor); sceneMergeEventDescriptor = eventDescriptor; var _this = this; setTimeout(this.nextMergePhase._bind(_this,''),2000); } } this.getMergeClipLastSegment = function() { return parseInt(getSceneMergeDirector().ep_invokeAndWait(getMyContextIndex() + ',,ep_getMergeClipLastSegment')); } this.getMergeClipLastRawRecNum = function() { return parseInt(getSceneMergeDirector().ep_invokeAndWait(getMyContextIndex() + ',,ep_getMergeClipLastRawRecNum')); } this.getMergeClipLastRecNum = function() { return parseInt(getSceneMergeDirector().ep_invokeAndWait(getMyContextIndex() + ',,ep_getMergeClipLastRecNum')); } this.finalizeMerge = function(sdlOfOriginalClip,sdlOfMergeClip,fileType) { setCodeBaseOverride(getMyContextIndex(),clipCodeBaseOverride); getSceneMergeDirector().ep_invoke(getMyContextIndex() + ',,ep_finalizeClipWriterMerge,' + sdlOfOriginalClip + ',' + sdlOfMergeClip + ',' + fileType); } this.mergeFinalized = function(eventDescriptor) { mergePhase = 0; mergeSceneInProgress = false; videoMergeComplete = false; audioMergeComplete = false; this.disableMerge(); if (callback != null) { try { eval(callback + "(\'" + eventDescriptor + "\')"); } catch(err) { directorTrace('SceneMerge.mergeFinalized callback EXCEPTION: ' + err.description); } } if (myActor != null) { myActor.invoke('sceneMergeComplete','sceneMergeComplete;SceneMerge.mergeFinalized'); } var event = ContextEventDescriptor.getEvent(eventDescriptor); var ctxId = ContextEventDescriptor.getCtxId(eventDescriptor); var element = ContextEventDescriptor.getHtmlElement(eventDescriptor); var args = ContextEventDescriptor.getOptionalArgs(eventDescriptor); disableHourGlass(); //directorTrace('SceneMerge.mergeFinalized' + '\n eventDescriptor:' + eventDescriptor + '\n event : ' + event + '\n ctxId : ' + ctxId + '\n element: ' + element + '\n args : ' + args); } this.updatePostMergeConfig = function() { getSceneMergeDirector().ep_invokeAndWait(getMyContextIndex() + ',,ep_updatePostMergeConfig'); } this.isMergeSceneInProgress = function() // USER API { return mergeSceneInProgress; } this.sceneMergeToString = function() { return (' SceneMerge' + '\n myName: ' + myName + ' myContextIndex: ' + getMyContextIndex() + '\n myElementId: ' + myElementId + ' myAppletName: ' + myAppletName + '\n clipSdl : ' + clipSdl + '\n sceneSdl: ' + sceneSdl + '\n clipCodeBaseOverride : ' + clipCodeBaseOverride + '\n sceneCodeBaseOverride: ' + sceneCodeBaseOverride + '\n mergePhase: ' + mergePhase + ' mergeAbort: ' + mergeAbort + ' mergeSceneInProgress: ' + mergeSceneInProgress + '\n originalClipStartSegment: ' + originalClipStartSegment + ' originalClipStartRawRecNum: ' + originalClipStartRawRecNum + '\n sceneStartSegment: ' + sceneStartSegment + ' sceneStartRawRecNum: ' + sceneStartRawRecNum + '\n sceneEndSegment: ' + sceneEndSegment + ' sceneEndRawRecNum: ' + sceneEndRawRecNum + '\n mergeClipLastSegment: ' + mergeClipLastSegment + ' mergeClipLastRawRecNum: ' + mergeClipLastRawRecNum + ' mergeClipLastRecNum: ' + mergeClipLastRecNum + '\n videoMergeComplete: ' + videoMergeComplete + ' audioMergeComplete: ' + audioMergeComplete + '\n callback: ' + callback); } function getMyContextIndex() { return myActor.getContextIndex(); } function getSceneMergeDirector() { return ((sceneMergeDirector != null) ? sceneMergeDirector : clipDirector); } function sceneMergeAlreadyInProgress() { alert('SceneMerge already in-progress'); } SceneMerge.instance = this; } function ControlData(){ var that = this; // acquire parametermanager this.PMgr = ParameterManager; this.PMgr("general"); var project = arguments.length > 0 ? arguments[0] : null; var defaultName = "anonymous"; this.setParameter('general','name', arguments.length > 1 ? arguments[1] : defaultName); var clips = null; var scenes = null; var activeSDLEntity = null; var clipCollection = new MeFactory.CreateCollection("ClipCollection"); var sceneCollection = new MeFactory.CreateCollection("SceneCollection"); this.getClipByFile = getClipByFile; this.getClipCollection = getClipCollection; this.setClipCollection = setClipCollection; this.getSceneCollection = getSceneCollection; this.setSceneCollection = setSceneCollection; this.isClipPartofScene = isClipPartofScene; this.reOrderClips = reorderClips; //deprecated .. function documented as reorderClips this.reorderClips = reorderClips; this.removeSceneByName = removeSceneByName; this.removeScene = removeScene; this.getClip = getClip; this.getScene = getScene; this.getName = getName; this.updateClipPartofScene = updateClipPartofScene; this.update = update; this.addClip = addClip; this.addScene = addScene; this.removeClipByName = removeClipByName; this.removeClip = removeClip; this.getClipNames = getClipNames; this.getSceneNames = getSceneNames; this.prepare4Encoding = prepare4Encoding; this.revertFromEncoding = revertFromEncoding; this.populate = populate; this.getSDL = getSDL; this.hasClips = hasClips; this.getProjectPath = getProjectPath; function setParamDefault() { that.setProperty('general','nameSpace', 'defaultValue','default'); that.setProperty('video','frameRate', 'defaultValue','15'); that.setProperty('video','resolutionWidth', 'defaultValue','160'); that.setProperty('video','resolutionHeight', 'defaultValue','128'); that.setProperty('video','videoQuality', 'defaultValue','4'); that.setProperty('video','rateControlMode', 'defaultValue','0'); that.setProperty('video','targetBitRate', 'defaultValue','200'); that.setProperty('video','minQuantization', 'defaultValue','4'); that.setProperty('video','maxQuantization', 'defaultValue','31'); that.setProperty('video','keyFrameDistance','defaultValue','30'); that.setProperty('video','sceneDetectionEnabled', 'defaultValue','0'); that.setProperty('video','minSceneDetectionDistance', 'defaultValue','15'); //that.setProperty('video','waveletFlag', 'defaultValue','1'); //that.setProperty('video','sceneKeyDelta', 'defaultValue','40'); //that.setProperty('video','scenePrevDelta', 'defaultValue','30'); that.setProperty('audio','sampleRate', 'defaultValue','11025'); that.setProperty('audio','encoding', 'defaultValue','0'); } try{ setParamDefault(); this.setProperty('video', 'resolutionHeight', 'validator', this.validateResolutionHeight); this.setProperty('video', 'resolutionWidth', 'validator', this.validateResolutionWidth); this.setProperty('video', 'frameRate', 'validator', this.validateFrameRate); this.setProperty('video', 'VideoQuality', 'validator', this.validateVideoQuality); this.setProperty('video', 'targetBitRate', 'validator', this.validateTargetBitRate); this.setProperty('video', 'rateControlMode', 'validator', this.validateRateControlMode); }catch(e) { alert("ControlData.constructor EXCEPTION: " + e.message); meLogger.write(e.name + ':= ' + e.message, 3); } function getName() { return this.getParameter('general','name'); } function removeSceneByName(_sceneName) { var _scene = this.getScene(_sceneName); if(_scene === null) return true; return this.removeScene(_scene); } function removeScene(_scene) { meLogger.write('Scene is being removed.....'); this.getSceneCollection().remove(_scene); return true; } function reorderClips(_newOrder) { var cCollection = this.getClipCollection(); for (var i=0, len =_newOrder.length ; i 4){ name = arguments[0]; fromClip = arguments[1]; toClip = arguments[3]; fromFrame = arguments[2]; toFrame = arguments[4]; } var scene1 = null; try { //==================================================== //===== CREATING A NEW Scene AND TRYING TO ADD TO PROJECT //==================================================== meLogger.write('Envoking------ addScene(name, fromClip)'); scene1 = new Scene(that,name,fromClip,fromFrame,toClip,toFrame); sceneCollection.add(scene1); meLogger.write(scene1.toXML()); } catch(e) { alert("ControlData.addScene EXCEPTION: " + e.message); meLogger.write(e.name + ':= ' + e.message, 3); scene1 = null; } } function prepare4Encoding(_base) { var success = true; deleteFile(toPath(_base,'video_s1.dat.sdl'),true); for (var index = 0; index < clipCollection.length; index++){ success &= clipCollection[index].prepare4Encoding(_base); } // delete any trailing artifacts deleteFile(toPath(_base,'video_s' + clipCollection.length + '.dat'),true); deleteFile(toPath(_base,'video_s' + clipCollection.length + '.idx'),true); deleteFile(toPath(_base,'audio_s' + clipCollection.length + '.dat'),true); deleteFile(toPath(_base,'audio_s' + clipCollection.length + '.idx'),true); return success; } /** this would undo the changes done by prepare4Encoding method */ function revertFromEncoding(){ for (var index = 0; index < clipCollection.length; index++){ clipCollection[index].revertFromEncoding(); } } function encodeScene(_sceneName) { // } var _createDocument = function (_xmlDocument) { try{ var xmlDocument = _xmlDocument || xutil.getDomDocument(); var root = xmlDocument.documentElement; root.appendChild(that._createDocumentFragment(xmlDocument)); root.appendChild(clipCollection.createDocumentFragment(xmlDocument)); root.appendChild(sceneCollection.createDocumentFragment(xmlDocument)); } catch(e) { alert("ControlData._createDocument EXCEPTION: " + e.message); meLogger.write( e.name + " : " + e.message, 3); } return root; }; this.createDocument = _createDocument; this.toXML = function (_xmlDocument) { try{ var xmlDocument = _xmlDocument || xutil.getDomDocument("", "mediaClip"); var raw = _createDocument(xmlDocument); var xmlString = xutil.xslt(raw, 'MediaModel.xsl', xmlDocument); } catch(e) { alert("ControlData.toXML EXCEPTION: " + e.message); meLogger.write(e.name + " -:- " + e.message, 3); } return xmlString; }; function populate(_projectXML) { var xmlDoc = xutil.load(_projectXML); try { var x=xmlDoc.documentElement; if (x.nodeType == 1) { var attlist = x.attributes; var name = attlist.getNamedItem("name"); this.setParameter('general','name',name.nodeValue); } meLogger.write("Name of the control is : " + this.getParameter('general','name')); populateParameters(that, 'general', xmlDoc.selectNodes("/mediaClip/general")); populateParameters(that,'video', xmlDoc.selectNodes("/mediaClip/videoParameters")); populateParameters(that, 'audio', xmlDoc.selectNodes("/mediaClip/audioParameters")); var i; var sClips = xmlDoc.selectNodes("/mediaClip/subclip"); if (sClips !== null && sClips.length > 0) { for ( i = 0; i < sClips.length; i++){ addClip(sClips[i].getAttribute('name'),sClips[i].getAttribute('file')); // Get the other parameters populateOtherParams('clip', sClips[i]); } } var sScenes = xmlDoc.selectNodes("/mediaClip/scene"); if (sScenes !== null && sScenes.length > 0) { for ( i = 0; i < sScenes.length; i++){ addScene(sScenes[i].getAttribute('name'),sScenes[i].selectNodes('from')[0].getAttribute('subclip'), sScenes[i].selectNodes('from')[0].getAttribute('frame'), sScenes[i].selectNodes('to')[0].getAttribute('subclip'), sScenes[i].selectNodes('to')[0].getAttribute('frame')); // Get the other parameters populateOtherParams('scene', sScenes[i]); } } meLogger.write(this.toXML()); return true; } catch(e) { alert("ControlData.populate EXCEPTION: " + e.message); meLogger.write(e.name + ":- " + e.message, 3); return false; } } function populateOtherParams(item,_xmlDom){ var curItem = null; if(item == 'clip'){ curItem = getClip(_xmlDom.getAttribute('name')) ; } else if (item == 'scene'){ curItem = getScene(_xmlDom.getAttribute('name')) ; } populateParameters(curItem, 'general', _xmlDom.selectNodes("general")); populateParameters(curItem,'video', _xmlDom.selectNodes("videoParameters")); populateParameters(curItem, 'audio', _xmlDom.selectNodes("audioParameters")); } function populateParameters(item,group, _xmlDOM) { if(_xmlDOM.length === 0){return;} var currentParam = _xmlDOM[0]; var x = null; if (group == 'video') { //Handle special cases, if Node is resolution, ................................. x = currentParam.getElementsByTagName("resolution")[0]; if ( x !== null && x.nodeType == 1) { var attlist = x.attributes; var width = attlist.getNamedItem("width"); var height = attlist.getNamedItem("height"); item.setParameter('video','resolutionWidth',width.value); item.setParameter('video','resolutionHeight',height.value); } } //******************************************************* var params = currentParam.childNodes; if(params !== null){ for (var c = 0; c < params.length; c++){ x = params[c]; if (x !== null && x.hasChildNodes() && (x.childNodes[0].nodeType == 3)) { item.setParameter(group,x.nodeName,x.childNodes[0].nodeValue); } } } return; } function getSDL(_base){ if(clipCollection.length > 0){ return clipCollection[0].getSDL(_base); } return ""; } function hasClips() { return (this.getClipCollection().length > 0); } function getProjectPath(){ if(project !== null){ return project.getProjectFullPath(); } else{ return ""; } } } /* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * Distributed under the BSD License * See http://pajhome.org.uk/crypt/md5 for more info. */ /* * Configurable variables. You may need to tweak these to be compatible with * the server-side, but the defaults work in most cases. */ var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ /* * These are the functions you'll usually want to call * They take string arguments and return either hex or base-64 encoded strings */ function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));} function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));} function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));} function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); } function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); } function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); } /* * Perform a simple self-test to see if the VM is working */ function md5_vm_test() { return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; } /* * Calculate the MD5 of an array of little-endian words, and a bit length */ function core_md5(x, len) { /* append padding */ x[len >> 5] |= 0x80 << ((len) % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for(var i = 0; i < x.length; i += 16) { var olda = a; var oldb = b; var oldc = c; var oldd = d; a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = md5_ff(c, d, a, b, x[i+10], 17, -42063); b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); a = safe_add(a, olda); b = safe_add(b, oldb); c = safe_add(c, oldc); d = safe_add(d, oldd); } return Array(a, b, c, d); } /* * These functions implement the four basic operations the algorithm uses. */ function md5_cmn(q, a, b, x, s, t) { return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); } function md5_ff(a, b, c, d, x, s, t) { return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); } function md5_gg(a, b, c, d, x, s, t) { return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); } function md5_hh(a, b, c, d, x, s, t) { return md5_cmn(b ^ c ^ d, a, b, x, s, t); } function md5_ii(a, b, c, d, x, s, t) { return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); } /* * Calculate the HMAC-MD5, of a key and some data */ function core_hmac_md5(key, data) { var bkey = str2binl(key); if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz); var ipad = Array(16), opad = Array(16); for(var i = 0; i < 16; i++) { ipad[i] = bkey[i] ^ 0x36363636; opad[i] = bkey[i] ^ 0x5C5C5C5C; } var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); return core_md5(opad.concat(hash), 512 + 128); } /* * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. */ function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } /* * Bitwise rotate a 32-bit number to the left. */ function bit_rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); } /* * Convert a string to an array of little-endian words * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. */ function str2binl(str) { var bin = Array(); var mask = (1 << chrsz) - 1; for(var i = 0; i < str.length * chrsz; i += chrsz) bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); return bin; } /* * Convert an array of little-endian words to a string */ function binl2str(bin) { var str = ""; var mask = (1 << chrsz) - 1; for(var i = 0; i < bin.length * 32; i += chrsz) str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); return str; } /* * Convert an array of little-endian words to a hex string. */ function binl2hex(binarray) { var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var str = ""; for(var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); } return str; } /* * Convert an array of little-endian words to a base-64 string */ function binl2b64(binarray) { var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var str = ""; for(var i = 0; i < binarray.length * 4; i += 3) { var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF); for(var j = 0; j < 4; j++) { if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); } } return str; } // $Id$ // Singleton Class - wrappers and manages the encoder applet function Encoder() { var that = this; //Let the private functions access the object instance. if("undefined" == typeof Encoder.instance) { Encoder.instance = this; // define the singleton } if(this != Encoder.instance) return Encoder.instance; // return the singleton if it already exists var encoderApplet = null; // created when needed. var appletState = null; // use this to track encoderApplet // states are: initializing, ready, encoding, completed, errored var encodeRequest = null; // kept null except when encoding or encoding pending this.getEncodeRequest = function() {return encodeRequest;} var startTimeout = null; var encodeTimeout = null; //Continue with the singleton's construction //User API functions this.install = function(){ if(appletState === null){ startEncoderApplet(); } } this.startEncode = function(_encodeRequest){ if(encodeRequest !== null) return false; // only process one file at time. encodeRequest = _encodeRequest; meLogger.write(encodeRequest, 2); processStartEncode(); return true; // indicates that the request has been posted } this.cancelEncode = function(){ if(appletState === null || encodeRequest === null) return; if(startTimeout !== null) { // cancel any pending request window.clearTimeout(startTimeout); startTimeout = null; } if(encodeTimeout !== null){ //cancel any active request window.clearTimeout(encodeTimeout); encodeTimeout = null; } if(appletState == "encoding"){ encoderApplet.ep_cancelEncode(); } encodeRequest = null; return; } this.getProgress = function(){ return (this.getAudioProgress() + this.getVideoProgress())/2; } this.getVideoProgress = function(){ if(appletState === null){return 0}; if(appletState == "encoding"){ var progress = encoderApplet.ep_getVideoProgress(); return progress >= 0 ? progress : 0; } if(appletState == "completed") return 100; return 0; } this.getAudioProgress = function(){ if(appletState === null){return 0}; if(appletState == "encoding"){ var progress = encoderApplet.ep_getAudioProgress(); return progress >= 0 ? progress : 0; } if(appletState == "completed") return 100; return 0; } this.getErrors = function(){ if(appletState === null){return ""}; if(appletState == "errored") return encoderApplet.ep_getErrors(); return ""; } this.isCompleted = function(){ if(appletState === null){return false}; if(encodeRequest === null && appletState == "completed") return true; return false; } this.isEncoding = function(){ if(appletState === null){return false}; if(encodeRequest !== null) return true; return false; } this.isError = function(){ if(appletState === null){return false}; if(appletState == "errored") return true; return false; } this.isInitialized = function(){ if(appletState === null){return false}; if(appletState != "initializing") return true; return false; } // Private functions function processStartEncode(){ startTimeout = null; if(appletState === null){ startEncoderApplet(); } //meLogger.write("processStartEncode: " + appletState); if(appletState == "initializing" || appletState == "encoding"){ //encoding should never happpen! startTimeout = window.setTimeout(deferredStartEncode,500); return; } setAppletState("encoding"); encoderApplet.ep_startEncode(encodeRequest.getParameter("xmlFile")); meLogger.write('Encode started ....'); queryState(); return; } this.setAppletState2 = function(_state){ setAppletState(_state); } function setAppletState(_state){ var oldState = appletState; if (_state != appletState){ appletState = _state; if(encodeRequest !== null){ encodeRequest.updateState(appletState); if(appletState == "completed") encodeRequest = null; } meLogger.write('Encoder: ' + oldState + " -> "+ appletState); } } function deferredStartEncode(){ //meLogger.write('DeferredStartEncode'); processStartEncode(); } function startEncoderApplet(){ setAppletState("initializing"); // Start Applet Here// var fakeIt = false; // to test w/o applet if(!fakeIt){ var appspec = new AppletSpec('encoder'); appspec.setParameter("name","encoder"); appspec.setParameter("visible",false); AppletManager.theInstance().startApplet(appspec,setAppletReadyState); } else { //FakeOut Applet start meLogger.write('Faking applet start in 5 seconds!!'); window.setTimeout(setAppletReadyState,5000); } } function setAppletReadyState(_applet) { //alert("ready ready ready"); encoderApplet = _applet; setAppletState("ready"); } // add callback functions for status, progress, etc. function queryState() { encodeTimeout = null; var currentState = encoderApplet.ep_getEncodingState(); var videoProgress = that.getVideoProgress(); var audioProgress = videoProgress == 100 ? that.getAudioProgress() : 0; var totalProgress = (videoProgress + audioProgress)/2; meLogger.write("Query State: " + currentState + " V" + videoProgress + " A" + audioProgress + " T" + totalProgress + "%"); if(currentState == "encoding"){ encodeRequest.updateVideoProgress(videoProgress); encodeRequest.updateAudioProgress(audioProgress); encodeTimeout = window.setTimeout(queryState,500); return; } if(currentState == "completed" || currentState == "errored"){ encodeRequest.updateVideoProgress(videoProgress); encodeRequest.updateAudioProgress(audioProgress); if (currentState == "completed") { //Sdl.theInstance().start(encodeRequest); Sdl.theInstance().start(that); } else { setAppletState(currentState); } } } } Encoder.theInstance = function(){ if("undefined" == typeof Encoder.instance){ new Encoder(); } return Encoder.instance; } Encoder.Install = function(){ var anEncoder = Encoder.theInstance(); anEncoder.install(); } Encoder.isInstalled = function(){ var anEncoder = Encoder.theInstance(); return anEncoder.isInitialized(); }