Brought up to date with the private repository (feea4c7)

This commit is contained in:
S committed 2026-10-14 20:57:33 +03:00
1 parent 1aa738d692
commit 1b1df1ae48
7925 files changed
+2617237 -20

No files matched your search

@@ -0,0 +1,101 @@
package org.osmf.utils
{
import flash.events.NetStatusEvent;
import flash.events.TimerEvent;
import flash.net.NetConnection;
import flash.utils.Timer;
public class FCSubscribeHandler
{
private var maxRetry:Number = 5;
private var currentTry:Number = 0;
private var retryTimer:Timer;
private var nc:NetConnection;
private var owner:Object;
public var nsName:String;
public function FCSubscribeHandler()
{
super();
}
public function run(param1:String, param2:String, param3:Object) : void
{
this.nsName = param1;
this.owner = param3;
nc = new NetConnection();
nc.addEventListener("netStatus",netConnectHandler);
nc.client = this;
nc.connect(param2);
}
protected function netConnectHandler(param1:NetStatusEvent) : void
{
trace("NC: " + param1.info.code);
if(param1.info.code == "NetConnection.Connect.Success")
{
fcSubscribeRetry();
}
else if(param1.info.code == "NetStream.Play.UnpublishNotify")
{
trace("publish");
}
else if(param1.info.code == "NetStream.Unpublish.Success")
{
trace("unpublish");
}
}
private function fcSubscribeRetry() : void
{
retryTimer = new Timer(1000,3);
retryTimer.addEventListener("timerComplete",retryFCSubscribe);
retryTimer.start();
}
private function retryFCSubscribe(param1:TimerEvent) : void
{
if(currentTry != maxRetry)
{
nc.call("FCSubscribe",null,nsName);
currentTry = currentTry + 1;
}
else
{
cleanupTimer();
}
}
public function onFCSubscribe(param1:Object) : void
{
trace(param1.code);
if(param1.code != "NetStream.Play.StreamNotFound")
{
if(param1.code == "NetStream.Play.Start")
{
cleanupTimer();
trace("ready to play");
owner.fcSubscribeDone();
}
}
}
public function onFCUnpublish(param1:Object) : void
{
trace("hi");
}
private function cleanupTimer() : void
{
retryTimer.stop();
retryTimer = null;
}
}
}
@@ -0,0 +1,29 @@
package org.osmf.utils
{
import flash.net.URLLoader;
import org.osmf.media.MediaResourceBase;
import org.osmf.traits.LoadTrait;
import org.osmf.traits.LoaderBase;
public class HTTPLoadTrait extends LoadTrait
{
private var _urlLoader:URLLoader;
public function HTTPLoadTrait(param1:LoaderBase, param2:MediaResourceBase)
{
super(param1,param2);
}
public function get urlLoader() : URLLoader
{
return _urlLoader;
}
public function set urlLoader(param1:URLLoader) : void
{
_urlLoader = param1;
}
}
}
@@ -0,0 +1,110 @@
package org.osmf.utils
{
import flash.errors.IOError;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import org.osmf.events.MediaError;
import org.osmf.events.MediaErrorEvent;
import org.osmf.media.MediaResourceBase;
import org.osmf.media.URLResource;
import org.osmf.traits.LoadTrait;
import org.osmf.traits.LoaderBase;
public class HTTPLoader extends LoaderBase
{
public function HTTPLoader()
{
super();
}
override public function canHandleResource(param1:MediaResourceBase) : Boolean
{
var _loc2_:URLResource = param1 as URLResource;
if(_loc2_ == null || _loc2_.url == null || _loc2_.url.length <= 0)
{
return false;
}
var _loc3_:URL = new URL(_loc2_.url);
if(_loc3_.protocol.search(/http$|https$/i) == -1 && _loc3_.protocol != "")
{
return false;
}
return true;
}
override protected function executeLoad(param1:LoadTrait) : void
{
var urlResource:URLResource;
var urlReq:URLRequest;
var loader:URLLoader;
var loadTrait:LoadTrait = param1;
var toggleLoaderListeners:* = function(param1:URLLoader, param2:Boolean):void
{
if(param2)
{
param1.addEventListener("complete",onLoadComplete);
param1.addEventListener("ioError",onIOError);
param1.addEventListener("securityError",onSecurityError);
}
else
{
param1.removeEventListener("complete",onLoadComplete);
param1.removeEventListener("ioError",onIOError);
param1.removeEventListener("securityError",onSecurityError);
}
};
var onLoadComplete:* = function(param1:Event):void
{
toggleLoaderListeners(loader,false);
var _loc2_:HTTPLoadTrait = loadTrait as HTTPLoadTrait;
_loc2_.urlLoader = loader;
updateLoadTrait(loadTrait,"ready");
};
var onIOError:* = function(param1:IOErrorEvent, param2:String = null):void
{
toggleLoaderListeners(loader,false);
updateLoadTrait(loadTrait,"loadError");
loadTrait.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(1,param1 ? param1.text : param2)));
};
var onSecurityError:* = function(param1:SecurityErrorEvent, param2:String = null):void
{
toggleLoaderListeners(loader,false);
updateLoadTrait(loadTrait,"loadError");
loadTrait.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(2,param1 ? param1.text : param2)));
};
updateLoadTrait(loadTrait,"loading");
urlResource = loadTrait.resource as URLResource;
urlReq = new URLRequest(urlResource.url.toString());
loader = createURLLoader();
toggleLoaderListeners(loader,true);
try
{
loader.load(urlReq);
}
catch(ioError:IOError)
{
onIOError(null,ioError.message);
}
catch(securityError:SecurityError)
{
onSecurityError(null,securityError.message);
}
}
override protected function executeUnload(param1:LoadTrait) : void
{
updateLoadTrait(param1,"unloading");
updateLoadTrait(param1,"uninitialized");
}
protected function createURLLoader() : URLLoader
{
return new URLLoader();
}
}
}
@@ -0,0 +1,238 @@
package org.osmf.utils
{
import flash.utils.Dictionary;
public class OSMFStrings
{
public static const COMPOSITE_TRAIT_NOT_FOUND:String = "compositeTraitNotFound";
public static const INVALID_PARAM:String = "invalidParam";
public static const NULL_PARAM:String = "nullParam";
public static const FUNCTION_MUST_BE_OVERRIDDEN:String = "functionMustBeOverridden";
public static const ALREADY_ADDED:String = "alreadyAdded";
public static const UNSUPPORTED_MEDIA_ELEMENT_TYPE:String = "unsupportedMediaElementType";
public static const TRAIT_INSTANCE_ALREADY_ADDED:String = "traitInstanceAlreadyAdded";
public static const TRAIT_RESOLVER_ALREADY_ADDED:String = "traitResolverAlreadyAdded";
public static const CAPABILITY_NOT_SUPPORTED:String = "capabilityNotSupported";
public static const MEDIA_LOAD_FAILED:String = "mediaLoadFailed";
public static const MUST_SET_LOADER:String = "mustSetLoader";
public static const LOADER_CANT_HANDLE_RESOURCE:String = "loaderCantHandleResource";
public static const PAUSE_NOT_SUPPORTED:String = "pauseNotSupported";
public static const ALREADY_READY:String = "alreadyReady";
public static const ALREADY_LOADING:String = "alreadyLoading";
public static const ALREADY_UNLOADED:String = "alreadyUnloaded";
public static const ALREADY_UNLOADING:String = "alreadyUnloading";
public static const INVALID_LAYOUT_RENDERER_CONSTRUCTOR:String = "invalidLayoutRendererConstructor";
public static const ILLEGAL_CONSTRUCTOR_INVOCATION:String = "illegalConstructorInvocation";
public static const DIRECT_DISPLAY_LIST_MOD_ERROR:String = "directDisplayListModError";
public static const NULL_SCRIPT_PATH:String = "nullScriptPath";
public static const STREAMSWITCH_INVALID_INDEX:String = "streamSwitchInvalidIndex";
public static const STREAMSWITCH_STREAM_NOT_IN_MANUAL_MODE:String = "streamSwitchStreamNotInManualMode";
public static const DRM_METADATA_NOT_SET:String = "drmMetadataNotSet";
public static const DVR_MAXIMUM_RPC_ATTEMPTS:String = "dvrMaximumRPCAttempts";
public static const DVR_UNEXPECTED_SERVER_RESPONSE:String = "dvrUnexpectedServerResponse";
public static const F4M_PARSE_PROFILE_MISSING:String = "f4mProfileMissing";
public static const F4M_PARSE_MEDIA_URL_MISSING:String = "f4mMediaURLMissing";
public static const F4M_PARSE_BITRATE_MISSING:String = "f4mBitrateMissing";
public static const IO_ERROR:String = "ioError";
public static const SECURITY_ERROR:String = "securityError";
public static const ASYNC_ERROR:String = "asyncError";
public static const ARGUMENT_ERROR:String = "argumentError";
public static const URL_SCHEME_INVALID:String = "urlSchemeInvalid";
public static const HTTP_GET_FAILED:String = "httpGetFailed";
public static const PLUGIN_VERSION_INVALID:String = "pluginVersionInvalid";
public static const PLUGIN_IMPLEMENTATION_INVALID:String = "pluginImplementationInvalid";
public static const SOUND_PLAY_FAILED:String = "soundPlayFailed";
public static const NETCONNECTION_REJECTED:String = "netConnectionRejected";
public static const NETCONNECTION_APPLICATION_INVALID:String = "netConnectionApplicationInvalid";
public static const NETCONNECTION_FAILED:String = "netConnectionFailed";
public static const NETCONNECTION_TIMEOUT:String = "netConnectionTimeout";
public static const NETSTREAM_PLAY_FAILED:String = "netStreamPlayFailed";
public static const NETSTREAM_STREAM_NOT_FOUND:String = "netStreamStreamNotFound";
public static const NETSTREAM_FILE_STRUCTURE_INVALID:String = "netStreamFileStructureInvalid";
public static const NETSTREAM_NO_SUPPORTED_TRACK_FOUND:String = "netStreamNoSupportedTrackFound";
public static const DRM_SYSTEM_UPDATE_ERROR:String = "drmSystemUpdateError";
public static const DVRCAST_SUBSCRIBE_FAILED:String = "dvrCastSubscribeFailed";
public static const DVRCAST_CONTENT_OFFLINE:String = "dvrCastContentOffline";
public static const DVRCAST_STREAM_INFO_RETRIEVAL_FAILED:String = "dvrCastStreamInfoRetrievalFailed";
public static const MULTICAST_PARAMETER_INVALID:String = "multicastParameterInvalid";
public static const MULTICAST_NOT_SUPPORT_MBR:String = "multicastNotSupportMBR";
public static const F4M_FILE_INVALID:String = "f4MFileINVALID";
private static const resourceDict:Dictionary = new Dictionary();
private static var _resourceStringFunction:Function = defaultResourceStringFunction;
resourceDict["compositeTraitNotFound"] = "There is no composite trait for the given trait type";
resourceDict["invalidParam"] = "Invalid parameter passed to method";
resourceDict["nullParam"] = "Unexpected null parameter passed to method";
resourceDict["functionMustBeOverridden"] = "Function must be overridden";
resourceDict["alreadyAdded"] = "Child has already been added";
resourceDict["unsupportedMediaElementType"] = "The specified media element type is not supported";
resourceDict["traitInstanceAlreadyAdded"] = "An instance of this trait class has already been added to this MediaElement";
resourceDict["traitResolverAlreadyAdded"] = "A trait resolver for the specified trait type has already been added to this MediaElement";
resourceDict["capabilityNotSupported"] = "The specified capability is not currently supported";
resourceDict["mediaLoadFailed"] = "The loading of a MediaElement failed";
resourceDict["mustSetLoader"] = "Must set LoaderBase on a LoadTrait before calling load or unload";
resourceDict["loaderCantHandleResource"] = "LoaderBase unable to handle the given MediaResourceBase";
resourceDict["pauseNotSupported"] = "PlayTrait.pause cannot be invoked when canPause is false";
resourceDict["alreadyReady"] = "Loader - attempt to load an already loaded object";
resourceDict["alreadyLoading"] = "Loader - attempt to load a loading object";
resourceDict["alreadyUnloaded"] = "Loader - attempt to unload an already unloaded object";
resourceDict["alreadyUnloading"] = "Loader - attempt to unload a unloading object";
resourceDict["invalidLayoutRendererConstructor"] = "Unable to construct LayoutRenderer implementation";
resourceDict["illegalConstructorInvocation"] = "Use the static getInstance method to obtain a class instance";
resourceDict["directDisplayListModError"] = "The direct addition or removal of display objects onto a MediaContainer is prohibited.";
resourceDict["nullScriptPath"] = "Operation requires a valid script path";
resourceDict["streamSwitchInvalidIndex"] = "Dynamic Stream Switching - Invalid index requested";
resourceDict["streamSwitchStreamNotInManualMode"] = "Dynamic Stream Switching - stream is not in manual mode";
resourceDict["drmMetadataNotSet"] = "Metadata not set on DRMServices";
resourceDict["dvrMaximumRPCAttempts"] = "Maximum DVRGetStreamInfo RPC attempts (%i) reached";
resourceDict["dvrUnexpectedServerResponse"] = "Unexpected server response: ";
resourceDict["f4mProfileMissing"] = "Profile missing from Bootstrap info tag";
resourceDict["f4mMediaURLMissing"] = "URL missing from Media tag";
resourceDict["f4mBitrateMissing"] = "Bitrate missing from Media tag";
resourceDict["ioError"] = "I/O error when loading media";
resourceDict["securityError"] = "Security error when loading media";
resourceDict["asyncError"] = "Async error when loading media";
resourceDict["argumentError"] = "Argument error when loading media";
resourceDict["urlSchemeInvalid"] = "Invalid URL scheme";
resourceDict["httpGetFailed"] = "HTTP GET failed due to a Client Error (4xx Status Code)";
resourceDict["pluginVersionInvalid"] = "Plugin failed to load due to version mismatch";
resourceDict["pluginImplementationInvalid"] = "Plugin failed to load due to improper or missing implementation of PluginInfo";
resourceDict["soundPlayFailed"] = "Playback failed due to no sound channels being available";
resourceDict["netConnectionRejected"] = "Connection attempt rejected by FMS server";
resourceDict["netConnectionApplicationInvalid"] = "Attempting to connect to an invalid FMS application";
resourceDict["netConnectionFailed"] = "All NetConnection attempts failed";
resourceDict["netConnectionTimeout"] = "Timed-out trying to establish a NetConnection, or timed out due to an idle NetConnection";
resourceDict["netStreamPlayFailed"] = "Playback failed";
resourceDict["netStreamStreamNotFound"] = "Stream not found";
resourceDict["netStreamFileStructureInvalid"] = "File has invalid structure";
resourceDict["netStreamNoSupportedTrackFound"] = "No supported track found";
resourceDict["drmSystemUpdateError"] = "The update of the DRM subsystem failed";
resourceDict["dvrCastSubscribeFailed"] = "DVRCast subscribe failed";
resourceDict["dvrCastContentOffline"] = "DVRCast content is offline and unavailable";
resourceDict["dvrCastStreamInfoRetrievalFailed"] = "Unable to retrieve DVRCast stream info";
resourceDict["multicastParameterInvalid"] = "The groupspec or streamName is null or empty but not both";
resourceDict["multicastNotSupportMBR"] = "Multicast does not support MBR";
resourceDict["f4MFileINVALID"] = "The F4M document contains errors";
resourceDict["missingStringResource"] = "No string for resource {0}";
public function OSMFStrings()
{
super();
}
public static function getString(param1:String, param2:Array = null) : String
{
return resourceStringFunction(param1,param2);
}
public static function get resourceStringFunction() : Function
{
return _resourceStringFunction;
}
public static function set resourceStringFunction(param1:Function) : void
{
_resourceStringFunction = param1;
}
private static function defaultResourceStringFunction(param1:String, param2:Array = null) : String
{
var _loc3_:String = resourceDict.hasOwnProperty(param1) ? String(resourceDict[param1]) : null;
if(_loc3_ == null)
{
_loc3_ = String(resourceDict["missingStringResource"]);
param2 = [param1];
}
if(param2)
{
_loc3_ = substitute(_loc3_,param2);
}
return _loc3_;
}
private static function substitute(param1:String, ... rest) : String
{
var _loc5_:int = 0;
var _loc4_:* = null;
var _loc6_:int = 0;
var _loc3_:String = "";
if(param1 != null)
{
_loc3_ = param1;
_loc5_ = int(rest.length);
if(_loc5_ == 1 && rest[0] is Array)
{
_loc4_ = rest[0] as Array;
_loc5_ = int(_loc4_.length);
}
else
{
_loc4_ = rest;
}
_loc6_ = 0;
while(_loc6_ < _loc5_)
{
_loc3_ = _loc3_.replace(new RegExp("\\{" + _loc6_ + "\\}","g"),_loc4_[_loc6_]);
_loc6_++;
}
}
return _loc3_;
}
}
}
@@ -0,0 +1,60 @@
package org.osmf.utils
{
public class TimeUtil
{
public function TimeUtil()
{
super();
}
public static function parseTime(param1:String) : Number
{
var _loc3_:int = 0;
var _loc4_:Number = 0;
var _loc2_:Array = param1.split(":");
if(_loc2_.length > 1)
{
_loc4_ = _loc2_[0] * 3600;
_loc4_ = _loc4_ + _loc2_[1] * 60;
_loc4_ = _loc4_ + Number(_loc2_[2]);
}
else
{
_loc3_ = 0;
switch(param1.charAt(param1.length - 1))
{
case "h":
_loc3_ = 3600;
break;
case "m":
_loc3_ = 60;
break;
case "s":
_loc3_ = 1;
}
if(_loc3_)
{
_loc4_ = Number(param1.substr(0,param1.length - 1)) * _loc3_;
}
else
{
_loc4_ = Number(param1);
}
}
return _loc4_;
}
public static function formatAsTimeCode(param1:Number) : String
{
var _loc3_:Number = Math.floor(param1 / 3600);
_loc3_ = isNaN(_loc3_) ? 0 : _loc3_;
var _loc4_:Number = Math.floor(param1 % 3600 / 60);
_loc4_ = isNaN(_loc4_) ? 0 : _loc4_;
var _loc2_:Number = Math.floor(param1 % 3600 % 60);
_loc2_ = isNaN(_loc2_) ? 0 : _loc2_;
return (_loc3_ == 0 ? "" : (_loc3_ < 10 ? "0" + _loc3_.toString() + ":" : _loc3_.toString() + ":")) + (_loc4_ < 10 ? "0" + _loc4_.toString() : _loc4_.toString()) + ":" + (_loc2_ < 10 ? "0" + _loc2_.toString() : _loc2_.toString());
}
}
}
+212
View File
@@ -0,0 +1,212 @@
package org.osmf.utils
{
public class URL
{
private var _rawUrl:String;
private var _protocol:String;
private var _userInfo:String;
private var _host:String;
private var _port:String;
private var _path:String;
private var _query:String;
private var _fragment:String;
public function URL(param1:String)
{
super();
_rawUrl = param1;
_protocol = "";
_userInfo = "";
_host = "";
_port = "";
_path = "";
_query = "";
_fragment = "";
if(_rawUrl != null && _rawUrl.length > 0)
{
_rawUrl = _rawUrl.replace(/^\s+|\s+$/g,"");
parseUrl();
}
}
public function get rawUrl() : String
{
return _rawUrl;
}
public function get protocol() : String
{
return _protocol;
}
public function set protocol(param1:String) : void
{
if(param1 != null)
{
_protocol = param1.replace(/:\/?\/?$/,"");
_protocol = _protocol.toLowerCase();
}
}
public function get userInfo() : String
{
return _userInfo;
}
public function set userInfo(param1:String) : void
{
if(param1 != null)
{
_userInfo = param1.replace(/@$/,"");
}
}
public function get host() : String
{
return _host;
}
public function set host(param1:String) : void
{
_host = param1;
}
public function get port() : String
{
return _port;
}
public function set port(param1:String) : void
{
if(param1 != null)
{
_port = param1.replace(/(:)/,"");
}
}
public function get path() : String
{
return _path;
}
public function set path(param1:String) : void
{
if(param1 != null)
{
_path = param1.replace(/^\//,"");
}
}
public function get query() : String
{
return _query;
}
public function set query(param1:String) : void
{
if(param1 != null)
{
_query = param1.replace(/^\?/,"");
}
}
public function get fragment() : String
{
return _fragment;
}
public function set fragment(param1:String) : void
{
if(param1 != null)
{
_fragment = param1.replace(/^#/,"");
}
}
public function toString() : String
{
return _rawUrl;
}
public function getParamValue(param1:String) : String
{
if(_query == null)
{
return "";
}
var _loc3_:RegExp = new RegExp("[/?&]*" + param1 + "=([^&#]*)","i");
var _loc2_:Array = _query.match(_loc3_);
return _loc2_ == null ? "" : _loc2_[1];
}
public function get absolute() : Boolean
{
return protocol != "";
}
public function get extension() : String
{
var _loc1_:int = path.lastIndexOf(".");
if(_loc1_ != -1)
{
return path.substr(_loc1_ + 1);
}
return "";
}
private function parseUrl() : void
{
var _loc3_:RegExp = null;
var _loc5_:Array = null;
var _loc6_:String = null;
var _loc4_:RegExp = null;
var _loc1_:Array = null;
var _loc2_:String = null;
if(_rawUrl == null || _rawUrl.length == 0)
{
return;
}
if(_rawUrl.search(/:\//) == -1 && _rawUrl.indexOf(":") != _rawUrl.length - 1)
{
path = _rawUrl;
}
else
{
_loc3_ = /^(rtmp|rtmp[tse]|rtmpte)(:\/[^\/])/i;
_loc5_ = _rawUrl.match(_loc3_);
_loc6_ = _rawUrl;
if(_loc5_ != null)
{
_loc6_ = _rawUrl.replace(/:\//,"://localhost/");
}
_loc4_ = /^([a-z+\w\+\.\-]+:\/?\/?)?([^\/?#]*)?(\/[^?#]*)?(\?[^#]*)?(\#.*)?/i;
_loc1_ = _loc6_.match(_loc4_);
if(_loc1_ != null)
{
protocol = _loc1_[1];
_loc2_ = _loc1_[2];
path = _loc1_[3];
query = _loc1_[4];
fragment = _loc1_[5];
_loc4_ = /^([!-~]+@)?([^\/?#:]*)(:[\d]*)?/i;
_loc1_ = _loc2_.match(_loc4_);
if(_loc1_ != null)
{
this.userInfo = _loc1_[1];
this.host = _loc1_[2];
this.port = _loc1_[3];
}
}
}
}
}
}
@@ -0,0 +1,38 @@
package org.osmf.utils
{
public class Version
{
private static const _major:String = "1";
private static const _minor:String = "5";
private static const FIELD_SEPARATOR:String = ".";
public function Version()
{
super();
}
public static function get version() : String
{
return "1" + "." + "5";
}
public static function get lastAPICompatibleVersion() : String
{
return "1.0";
}
public static function get FLASH_10_1() : Boolean
{
return true;
}
public static function get LOGGING() : Boolean
{
return false;
}
}
}