home *** CD-ROM | disk | FTP | other *** search
/ Canadian Forces: A World of Opportunities / CanadianForces-AWorldOfOpportunities-WinMac.bin / 04_WhatOptions_FR.swf / scripts / __Packages / mx / video / NCManager.as < prev    next >
Text File  |  2006-07-20  |  23KB  |  742 lines

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