home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Free Download Manager / fdminst.exe / {app} / player.swf / scripts / __Packages / mx / video / NCManager.as < prev    next >
Encoding:
Text File  |  2012-08-12  |  22.2 KB  |  760 lines

  1. class mx.video.NCManager implements mx.video.INCManager
  2. {
  3.    var _timeoutIntervalId;
  4.    var _tryNCIntervalId;
  5.    var _timeout;
  6.    var _isRTMP;
  7.    var _serverName;
  8.    var _wrappedURL;
  9.    var _portNumber;
  10.    var _appName;
  11.    var _contentPath;
  12.    var _streamName;
  13.    var _streamLength;
  14.    var _streamWidth;
  15.    var _streamHeight;
  16.    var _streams;
  17.    var _autoSenseBW;
  18.    var _payload;
  19.    var _connTypeCounter;
  20.    var _bitrate;
  21.    var _owner;
  22.    var _nc;
  23.    var _protocol;
  24.    var _smilMgr;
  25.    var mc;
  26.    var _ncUri;
  27.    var fallbackServerName;
  28.    var _tryNC;
  29.    static var version = "1.0.0.103";
  30.    var DEFAULT_TIMEOUT = 60000;
  31.    static var RTMP_CONN = [{protocol:"rtmp:/",port:"1935"},{protocol:"rtmp:/",port:"443"},{protocol:"rtmpt:/",port:"80"},{protocol:"rtmps:/",port:"443"}];
  32.    function NCManager()
  33.    {
  34.       this.initNCInfo();
  35.       this.initOtherInfo();
  36.       this._timeoutIntervalId = 0;
  37.       this._tryNCIntervalId = 0;
  38.       this._timeout = this.DEFAULT_TIMEOUT;
  39.    }
  40.    function initNCInfo()
  41.    {
  42.       this._isRTMP = undefined;
  43.       this._serverName = undefined;
  44.       this._wrappedURL = undefined;
  45.       this._portNumber = undefined;
  46.       this._appName = undefined;
  47.    }
  48.    function initOtherInfo()
  49.    {
  50.       this._contentPath = undefined;
  51.       this._streamName = undefined;
  52.       this._streamLength = undefined;
  53.       this._streamWidth = undefined;
  54.       this._streamHeight = undefined;
  55.       this._streams = undefined;
  56.       this._autoSenseBW = false;
  57.       this._payload = 0;
  58.       this._connTypeCounter = 0;
  59.       this.cleanConns();
  60.    }
  61.    function getTimeout()
  62.    {
  63.       return this._timeout;
  64.    }
  65.    function setTimeout(t)
  66.    {
  67.       this._timeout = t;
  68.       if(this._timeoutIntervalId != 0)
  69.       {
  70.          clearInterval(this._timeoutIntervalId);
  71.          this._timeoutIntervalId = setInterval(this,"_onFCSConnectTimeOut",this._timeout);
  72.       }
  73.    }
  74.    function getBitrate()
  75.    {
  76.       return this._bitrate;
  77.    }
  78.    function setBitrate(b)
  79.    {
  80.       if(this._isRTMP == undefined || !this._isRTMP)
  81.       {
  82.          this._bitrate = b;
  83.       }
  84.    }
  85.    function getVideoPlayer()
  86.    {
  87.       return this._owner;
  88.    }
  89.    function setVideoPlayer(v)
  90.    {
  91.       this._owner = v;
  92.    }
  93.    function getNetConnection()
  94.    {
  95.       return this._nc;
  96.    }
  97.    function getStreamName()
  98.    {
  99.       return this._streamName;
  100.    }
  101.    function isRTMP()
  102.    {
  103.       return this._isRTMP;
  104.    }
  105.    function getStreamLength()
  106.    {
  107.       return this._streamLength;
  108.    }
  109.    function getStreamWidth()
  110.    {
  111.       return this._streamWidth;
  112.    }
  113.    function getStreamHeight()
  114.    {
  115.       return this._streamHeight;
  116.    }
  117.    function connectToURL(url)
  118.    {
  119.       this.initOtherInfo();
  120.       this._contentPath = url;
  121.       if(this._contentPath == null || this._contentPath == undefined || this._contentPath == "")
  122.       {
  123.          throw new mx.video.VideoError(mx.video.VideoError.INVALID_CONTENT_PATH);
  124.       }
  125.       var _loc2_ = this.parseURL(this._contentPath);
  126.       if(_loc2_.streamName == undefined || _loc2_.streamName == "")
  127.       {
  128.          throw new mx.video.VideoError(mx.video.VideoError.INVALID_CONTENT_PATH,url);
  129.       }
  130.       if(_loc2_.isRTMP)
  131.       {
  132.          var _loc3_ = this.canReuseOldConnection(_loc2_);
  133.          this._isRTMP = true;
  134.          this._protocol = _loc2_.protocol;
  135.          this._streamName = _loc2_.streamName;
  136.          this._serverName = _loc2_.serverName;
  137.          this._wrappedURL = _loc2_.wrappedURL;
  138.          this._portNumber = _loc2_.portNumber;
  139.          this._appName = _loc2_.appName;
  140.          if(this._appName == undefined || this._appName == "" || this._streamName == undefined || this._streamName == "")
  141.          {
  142.             throw new mx.video.VideoError(mx.video.VideoError.INVALID_CONTENT_PATH,url);
  143.          }
  144.          this._autoSenseBW = this._streamName.indexOf(",") != -1;
  145.          return _loc3_ || this.connectRTMP();
  146.       }
  147.       if(_loc2_.streamName.slice(-4).toLowerCase() == ".flv")
  148.       {
  149.          _loc3_ = this.canReuseOldConnection(_loc2_);
  150.          this._isRTMP = false;
  151.          this._streamName = _loc2_.streamName;
  152.          return _loc3_ || this.connectHTTP();
  153.       }
  154.       this._smilMgr = new mx.video.SMILManager(this);
  155.       return this._smilMgr.connectXML(_loc2_.streamName);
  156.    }
  157.    function connectAgain()
  158.    {
  159.       var _loc2_ = this._appName.indexOf("/");
  160.       if(_loc2_ < 0)
  161.       {
  162.          _loc2_ = this._streamName.indexOf("/");
  163.          if(_loc2_ >= 0)
  164.          {
  165.             this._appName += "/";
  166.             this._appName += this._streamName.slice(0,_loc2_);
  167.             this._streamName = this._streamName.slice(_loc2_ + 1);
  168.          }
  169.          return false;
  170.       }
  171.       var _loc3_ = this._appName.slice(_loc2_ + 1);
  172.       _loc3_ += "/";
  173.       _loc3_ += this._streamName;
  174.       this._streamName = _loc3_;
  175.       this._appName = this._appName.slice(0,_loc2_);
  176.       this.close();
  177.       this._payload = 0;
  178.       this._connTypeCounter = 0;
  179.       this.cleanConns();
  180.       this.connectRTMP();
  181.       return true;
  182.    }
  183.    function reconnect()
  184.    {
  185.       if(!this._isRTMP)
  186.       {
  187.          throw new Error("Cannot call reconnect on an http connection");
  188.       }
  189.       this._nc.onStatus = function(info)
  190.       {
  191.          this.mc.reconnectOnStatus(this,info);
  192.       };
  193.       this._nc.onBWDone = function()
  194.       {
  195.          this.mc.onReconnected();
  196.       };
  197.       this._nc.connect(this._ncUri,false);
  198.    }
  199.    function onReconnected()
  200.    {
  201.       delete this._nc.onStatus;
  202.       delete this._nc.onBWDone;
  203.       this._owner.ncReconnected();
  204.    }
  205.    function close()
  206.    {
  207.       if(this._nc)
  208.       {
  209.          this._nc.close();
  210.       }
  211.    }
  212.    function helperDone(helper, success)
  213.    {
  214.       if(helper != this._smilMgr)
  215.       {
  216.          return undefined;
  217.       }
  218.       if(!success)
  219.       {
  220.          this._nc = undefined;
  221.          this._owner.ncConnected();
  222.          delete this._smilMgr;
  223.          return undefined;
  224.       }
  225.       this._streamWidth = this._smilMgr.width;
  226.       this._streamHeight = this._smilMgr.height;
  227.       var _loc2_ = undefined;
  228.       var _loc4_ = this._smilMgr.baseURLAttr[0];
  229.       if(_loc4_ != undefined && _loc4_ != "")
  230.       {
  231.          _loc2_ = this.parseURL(_loc4_);
  232.          this._isRTMP = _loc2_.isRTMP;
  233.          this._streamName = _loc2_.streamName;
  234.          if(this._isRTMP)
  235.          {
  236.             this._protocol = _loc2_.protocol;
  237.             this._serverName = _loc2_.serverName;
  238.             this._portNumber = _loc2_.portNumber;
  239.             this._wrappedURL = _loc2_.wrappedURL;
  240.             this._appName = _loc2_.appName;
  241.             if(this._appName == undefined || this._appName == "")
  242.             {
  243.                throw new mx.video.VideoError(mx.video.VideoError.INVALID_XML,"Base RTMP URL must include application name: " + _loc4_);
  244.             }
  245.             if(this._smilMgr.baseURLAttr.length > 1)
  246.             {
  247.                _loc2_ = this.parseURL(this._smilMgr.baseURLAttr[1]);
  248.                if(_loc2_.serverName != undefined)
  249.                {
  250.                   this.fallbackServerName = _loc2_.serverName;
  251.                }
  252.             }
  253.          }
  254.       }
  255.       this._streams = this._smilMgr.videoTags;
  256.       var _loc3_ = 0;
  257.       while(_loc3_ < this._streams.length)
  258.       {
  259.          _loc4_ = this._streams[_loc3_].src;
  260.          _loc2_ = this.parseURL(_loc4_);
  261.          if(this._isRTMP == undefined)
  262.          {
  263.             this._isRTMP = _loc2_.isRTMP;
  264.             if(this._isRTMP)
  265.             {
  266.                this._protocol = _loc2_.protocol;
  267.                if(this._streams.length > 1)
  268.                {
  269.                   throw new mx.video.VideoError(mx.video.VideoError.INVALID_XML,"Cannot switch between multiple absolute RTMP URLs, must use meta tag base attribute.");
  270.                }
  271.                this._serverName = _loc2_.serverName;
  272.                this._portNumber = _loc2_.portNumber;
  273.                this._wrappedURL = _loc2_.wrappedURL;
  274.                this._appName = _loc2_.appName;
  275.                if(this._appName == undefined || this._appName == "")
  276.                {
  277.                   throw new mx.video.VideoError(mx.video.VideoError.INVALID_XML,"Base RTMP URL must include application name: " + _loc4_);
  278.                }
  279.             }
  280.          }
  281.          else if(this._streamName != undefined && this._streamName != "" && !_loc2_.isRelative && this._streams.length > 1)
  282.          {
  283.             throw new mx.video.VideoError(mx.video.VideoError.INVALID_XML,"When using meta tag base attribute, cannot use absolute URLs for video or ref tag src attributes.");
  284.          }
  285.          this._streams[_loc3_].parseResults = _loc2_;
  286.          _loc3_ = _loc3_ + 1;
  287.       }
  288.       this._autoSenseBW = this._streams.length > 1;
  289.       if(!this._autoSenseBW)
  290.       {
  291.          if(this._streamName != undefined)
  292.          {
  293.             this._streamName += this._streams[0].parseResults.streamName;
  294.          }
  295.          else
  296.          {
  297.             this._streamName = this._streams[0].parseResults.streamName;
  298.          }
  299.          this._streamLength = this._streams[0].dur;
  300.       }
  301.       if(this._isRTMP)
  302.       {
  303.          this.connectRTMP();
  304.       }
  305.       else
  306.       {
  307.          if(this._autoSenseBW)
  308.          {
  309.             this.bitrateMatch();
  310.          }
  311.          this.connectHTTP();
  312.          this._owner.ncConnected();
  313.       }
  314.    }
  315.    function bitrateMatch()
  316.    {
  317.       var _loc3_ = undefined;
  318.       if(isNaN(this._bitrate))
  319.       {
  320.          _loc3_ = 0;
  321.       }
  322.       else
  323.       {
  324.          var _loc2_ = 0;
  325.          while(_loc2_ < this._streams.length)
  326.          {
  327.             if(isNaN(this._streams[_loc2_].bitrate) || this._bitrate <= this._streams[_loc2_].bitrate)
  328.             {
  329.                _loc3_ = _loc2_;
  330.                break;
  331.             }
  332.             _loc2_ = _loc2_ + 1;
  333.          }
  334.       }
  335.       if(isNaN(_loc3_))
  336.       {
  337.          throw new mx.video.VideoError(mx.video.VideoError.NO_BITRATE_MATCH);
  338.       }
  339.       if(this._streamName != undefined)
  340.       {
  341.          this._streamName += this._streams[_loc3_].src;
  342.       }
  343.       else
  344.       {
  345.          this._streamName = this._streams[_loc3_].src;
  346.       }
  347.       this._streamLength = this._streams[_loc3_].dur;
  348.    }
  349.    function parseURL(url)
  350.    {
  351.       var _loc2_ = new Object();
  352.       var _loc3_ = 0;
  353.       var _loc4_ = url.indexOf(":/",_loc3_);
  354.       if(_loc4_ >= 0)
  355.       {
  356.          _loc4_ += 2;
  357.          _loc2_.protocol = url.slice(_loc3_,_loc4_);
  358.          _loc2_.isRelative = false;
  359.       }
  360.       else
  361.       {
  362.          _loc2_.isRelative = true;
  363.       }
  364.       if(_loc2_.protocol != undefined && (_loc2_.protocol == "rtmp:/" || _loc2_.protocol == "rtmpt:/" || _loc2_.protocol == "rtmps:/"))
  365.       {
  366.          _loc2_.isRTMP = true;
  367.          _loc3_ = _loc4_;
  368.          if(url.charAt(_loc3_) == "/")
  369.          {
  370.             _loc3_ = _loc3_ + 1;
  371.             var _loc7_ = url.indexOf(":",_loc3_);
  372.             var _loc8_ = url.indexOf("/",_loc3_);
  373.             if(_loc8_ < 0)
  374.             {
  375.                if(_loc7_ < 0)
  376.                {
  377.                   _loc2_.serverName = url.slice(_loc3_);
  378.                }
  379.                else
  380.                {
  381.                   _loc4_ = _loc7_;
  382.                   _loc2_.portNumber = url.slice(_loc3_,_loc4_);
  383.                   _loc3_ = _loc4_ + 1;
  384.                   _loc2_.serverName = url.slice(_loc3_);
  385.                }
  386.                return _loc2_;
  387.             }
  388.             if(_loc7_ >= 0 && _loc7_ < _loc8_)
  389.             {
  390.                _loc4_ = _loc7_;
  391.                _loc2_.serverName = url.slice(_loc3_,_loc4_);
  392.                _loc3_ = _loc4_ + 1;
  393.                _loc4_ = _loc8_;
  394.                _loc2_.portNumber = url.slice(_loc3_,_loc4_);
  395.             }
  396.             else
  397.             {
  398.                _loc4_ = _loc8_;
  399.                _loc2_.serverName = url.slice(_loc3_,_loc4_);
  400.             }
  401.             _loc3_ = _loc4_ + 1;
  402.          }
  403.          if(url.charAt(_loc3_) == "?")
  404.          {
  405.             var _loc9_ = url.slice(_loc3_ + 1);
  406.             var _loc6_ = this.parseURL(_loc9_);
  407.             if(_loc6_.protocol == undefined || !_loc6_.isRTMP)
  408.             {
  409.                throw new mx.video.VideoError(mx.video.VideoError.INVALID_CONTENT_PATH,url);
  410.             }
  411.             _loc2_.wrappedURL = "?";
  412.             _loc2_.wrappedURL += _loc6_.protocol;
  413.             if(_loc6_.server != undefined)
  414.             {
  415.                _loc2_.wrappedURL += "/";
  416.                _loc2_.wrappedURL += _loc6_.server;
  417.             }
  418.             if(_loc6_.wrappedURL != undefined)
  419.             {
  420.                _loc2_.wrappedURL += "/?";
  421.                _loc2_.wrappedURL += _loc6_.wrappedURL;
  422.             }
  423.             _loc2_.appName = _loc6_.appName;
  424.             _loc2_.streamName = _loc6_.streamName;
  425.             return _loc2_;
  426.          }
  427.          _loc4_ = url.indexOf("/",_loc3_);
  428.          if(_loc4_ < 0)
  429.          {
  430.             _loc2_.appName = url.slice(_loc3_);
  431.             return _loc2_;
  432.          }
  433.          _loc2_.appName = url.slice(_loc3_,_loc4_);
  434.          _loc3_ = _loc4_ + 1;
  435.          _loc4_ = url.indexOf("/",_loc3_);
  436.          if(_loc4_ < 0)
  437.          {
  438.             _loc2_.streamName = url.slice(_loc3_);
  439.             return _loc2_;
  440.          }
  441.          _loc2_.appName += "/";
  442.          _loc2_.appName += url.slice(_loc3_,_loc4_);
  443.          _loc3_ = _loc4_ + 1;
  444.          _loc2_.streamName = url.slice(_loc3_);
  445.       }
  446.       else
  447.       {
  448.          _loc2_.isRTMP = false;
  449.          _loc2_.streamName = url;
  450.       }
  451.       return _loc2_;
  452.    }
  453.    function canReuseOldConnection(parseResults)
  454.    {
  455.       if(this._nc == undefined || this._nc == null)
  456.       {
  457.          return false;
  458.       }
  459.       if(!parseResults.isRTMP)
  460.       {
  461.          if(!this._isRTMP)
  462.          {
  463.             return true;
  464.          }
  465.          this._owner.close();
  466.          this._nc = null;
  467.          this.initNCInfo();
  468.          return false;
  469.       }
  470.       if(this._isRTMP)
  471.       {
  472.          if(parseResults.serverName == this._serverName && parseResults.appName == this._appName && parseResults.protocol == this._protocol && parseResults.portNumber == this._portNumber && parseResults.wrappedURL == this._wrappedURL)
  473.          {
  474.             return true;
  475.          }
  476.          this._owner.close();
  477.          this._nc = null;
  478.       }
  479.       this.initNCInfo();
  480.       return false;
  481.    }
  482.    function connectHTTP()
  483.    {
  484.       this._nc = new NetConnection();
  485.       this._nc.connect(null);
  486.       return true;
  487.    }
  488.    function connectRTMP()
  489.    {
  490.       clearInterval(this._timeoutIntervalId);
  491.       this._timeoutIntervalId = setInterval(this,"_onFCSConnectTimeOut",this._timeout);
  492.       this._tryNC = new Array();
  493.       var _loc2_ = 0;
  494.       while(_loc2_ < mx.video.NCManager.RTMP_CONN.length)
  495.       {
  496.          this._tryNC[_loc2_] = new NetConnection();
  497.          this._tryNC[_loc2_].mc = this;
  498.          this._tryNC[_loc2_].pending = false;
  499.          this._tryNC[_loc2_].connIndex = _loc2_;
  500.          this._tryNC[_loc2_].onBWDone = function(p_bw)
  501.          {
  502.             this.mc.onConnected(this,p_bw);
  503.          };
  504.          this._tryNC[_loc2_].onBWCheck = function()
  505.          {
  506.             return ++this.mc._payload;
  507.          };
  508.          this._tryNC[_loc2_].onStatus = function(info)
  509.          {
  510.             this.mc.connectOnStatus(this,info);
  511.          };
  512.          _loc2_ = _loc2_ + 1;
  513.       }
  514.       this.nextConnect();
  515.       return false;
  516.    }
  517.    function nextConnect()
  518.    {
  519.       clearInterval(this._tryNCIntervalId);
  520.       this._tryNCIntervalId = 0;
  521.       var _loc4_ = undefined;
  522.       var _loc3_ = undefined;
  523.       if(this._connTypeCounter == 0)
  524.       {
  525.          _loc4_ = this._protocol;
  526.          if(this._portNumber != undefined)
  527.          {
  528.             _loc3_ = this._portNumber;
  529.          }
  530.          else
  531.          {
  532.             var _loc2_ = 0;
  533.             while(_loc2_ < mx.video.NCManager.RTMP_CONN.length)
  534.             {
  535.                if(_loc4_ == mx.video.NCManager.RTMP_CONN[_loc2_].protocol)
  536.                {
  537.                   _loc3_ = mx.video.NCManager.RTMP_CONN[_loc2_].port;
  538.                   break;
  539.                }
  540.                _loc2_ = _loc2_ + 1;
  541.             }
  542.          }
  543.       }
  544.       else
  545.       {
  546.          _loc4_ = mx.video.NCManager.RTMP_CONN[this._connTypeCounter].protocol;
  547.          _loc3_ = mx.video.NCManager.RTMP_CONN[this._connTypeCounter].port;
  548.       }
  549.       var _loc5_ = _loc4_ + (this._serverName != undefined ? "/" + this._serverName + ":" + _loc3_ + "/" : "") + (this._wrappedURL != undefined ? this._wrappedURL + "/" : "") + this._appName;
  550.       this._tryNC[this._connTypeCounter].pending = true;
  551.       this._tryNC[this._connTypeCounter].connect(_loc5_,this._autoSenseBW);
  552.       if(this._connTypeCounter < mx.video.NCManager.RTMP_CONN.length - 1)
  553.       {
  554.          this._connTypeCounter = this._connTypeCounter + 1;
  555.          this._tryNCIntervalId = setInterval(this,"nextConnect",1500);
  556.       }
  557.    }
  558.    function cleanConns()
  559.    {
  560.       clearInterval(this._tryNCIntervalId);
  561.       this._tryNCIntervalId = 0;
  562.       if(this._tryNC != undefined)
  563.       {
  564.          var _loc2_ = 0;
  565.          while(_loc2_ < this._tryNC.length)
  566.          {
  567.             if(this._tryNC[_loc2_] != undefined)
  568.             {
  569.                delete this._tryNC[_loc2_].onStatus;
  570.                if(this._tryNC[_loc2_].pending)
  571.                {
  572.                   this._tryNC[_loc2_].onStatus = function(info)
  573.                   {
  574.                      this.mc.disconnectOnStatus(this,info);
  575.                   };
  576.                }
  577.                else
  578.                {
  579.                   delete this._tryNC[_loc2_].onStatus;
  580.                   this._tryNC[_loc2_].close();
  581.                }
  582.             }
  583.             delete this._tryNC[_loc2_];
  584.             _loc2_ = _loc2_ + 1;
  585.          }
  586.          delete this._tryNC;
  587.       }
  588.    }
  589.    function tryFallBack()
  590.    {
  591.       if(this._serverName == this.fallbackServerName || this.fallbackServerName == undefined || this.fallbackServerName == null)
  592.       {
  593.          delete this._nc;
  594.          this._nc = undefined;
  595.          this._owner.ncConnected();
  596.       }
  597.       else
  598.       {
  599.          this._connTypeCounter = 0;
  600.          this.cleanConns();
  601.          this._serverName = this.fallbackServerName;
  602.          this.connectRTMP();
  603.       }
  604.    }
  605.    function onConnected(p_nc, p_bw)
  606.    {
  607.       clearInterval(this._timeoutIntervalId);
  608.       this._timeoutIntervalId = 0;
  609.       delete p_nc.onBWDone;
  610.       delete p_nc.onBWCheck;
  611.       delete p_nc.onStatus;
  612.       this._nc = p_nc;
  613.       this._ncUri = this._nc.uri;
  614.       if(this._autoSenseBW)
  615.       {
  616.          this._bitrate = p_bw * 1024;
  617.          if(this._streams != undefined)
  618.          {
  619.             this.bitrateMatch();
  620.          }
  621.          else if(this._streamName.indexOf(",") != -1)
  622.          {
  623.             var _loc3_ = this._streamName.split(",");
  624.             var _loc2_ = 0;
  625.             while(_loc2_ < _loc3_.length)
  626.             {
  627.                var _loc4_ = mx.video.NCManager.stripFrontAndBackWhiteSpace(_loc3_[_loc2_]);
  628.                if(_loc2_ + 1 >= _loc3_.length)
  629.                {
  630.                   this._streamName = _loc4_;
  631.                   break;
  632.                }
  633.                if(p_bw <= Number(_loc3_[_loc2_ + 1]))
  634.                {
  635.                   this._streamName = _loc4_;
  636.                   break;
  637.                }
  638.                _loc2_ += 2;
  639.             }
  640.          }
  641.       }
  642.       if(this._streamName.slice(-4).toLowerCase() == ".flv")
  643.       {
  644.          this._streamName = this._streamName.slice(0,-4);
  645.       }
  646.       if(!this._owner.isLive && this._streamLength == undefined)
  647.       {
  648.          var _loc6_ = new Object();
  649.          _loc6_.mc = this;
  650.          _loc6_.onResult = function(length)
  651.          {
  652.             this.mc.getStreamLengthResult(length);
  653.          };
  654.          this._nc.call("getStreamLength",_loc6_,this._streamName);
  655.       }
  656.       else
  657.       {
  658.          this._owner.ncConnected();
  659.       }
  660.    }
  661.    function connectOnStatus(target, info)
  662.    {
  663.       target.pending = false;
  664.       if(info.code == "NetConnection.Connect.Success")
  665.       {
  666.          this._nc = this._tryNC[target.connIndex];
  667.          this._tryNC[target.connIndex] = undefined;
  668.          this.cleanConns();
  669.       }
  670.       else if((info.code == "NetConnection.Connect.Failed" || info.code == "NetConnection.Connect.Rejected") && target.connIndex == mx.video.NCManager.RTMP_CONN.length - 1)
  671.       {
  672.          if(!this.connectAgain())
  673.          {
  674.             this.tryFallBack();
  675.          }
  676.       }
  677.    }
  678.    function reconnectOnStatus(target, info)
  679.    {
  680.       if(info.code == "NetConnection.Connect.Failed" || info.code == "NetConnection.Connect.Rejected")
  681.       {
  682.          delete this._nc;
  683.          this._nc = undefined;
  684.          this._owner.ncReconnected();
  685.       }
  686.    }
  687.    function disconnectOnStatus(target, info)
  688.    {
  689.       if(info.code == "NetConnection.Connect.Success")
  690.       {
  691.          delete target.onStatus;
  692.          target.close();
  693.       }
  694.    }
  695.    function getStreamLengthResult(length)
  696.    {
  697.       this._streamLength = length;
  698.       this._owner.ncConnected();
  699.    }
  700.    function _onFCSConnectTimeOut()
  701.    {
  702.       this.cleanConns();
  703.       this._nc = undefined;
  704.       if(!this.connectAgain())
  705.       {
  706.          this._owner.ncConnected();
  707.       }
  708.    }
  709.    static function stripFrontAndBackWhiteSpace(p_str)
  710.    {
  711.       var _loc1_ = undefined;
  712.       var _loc2_ = p_str.length;
  713.       var _loc4_ = 0;
  714.       var _loc5_ = _loc2_;
  715.       _loc1_ = 0;
  716.       while(true)
  717.       {
  718.          if(_loc1_ < _loc2_)
  719.          {
  720.             switch(p_str.charCodeAt(_loc1_))
  721.             {
  722.                case 9:
  723.                case 10:
  724.                case 13:
  725.                case 32:
  726.                   break;
  727.                default:
  728.                   _loc4_ = _loc1_;
  729.             }
  730.          }
  731.          break;
  732.          _loc1_ = _loc1_ + 1;
  733.       }
  734.       _loc1_ = _loc2_;
  735.       while(true)
  736.       {
  737.          if(_loc1_ >= 0)
  738.          {
  739.             switch(p_str.charCodeAt(_loc1_))
  740.             {
  741.                case 9:
  742.                case 10:
  743.                case 13:
  744.                case 32:
  745.                   break;
  746.                default:
  747.                   _loc5_ = _loc1_ + 1;
  748.             }
  749.          }
  750.          break;
  751.          _loc1_ = _loc1_ - 1;
  752.       }
  753.       if(_loc5_ <= _loc4_)
  754.       {
  755.          return "";
  756.       }
  757.       return p_str.slice(_loc4_,_loc5_);
  758.    }
  759. }
  760.