PageRenderTime 50ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/plugins/bwcheck/src/actionscript/org/flowplayer/bwcheck/detect/BandwidthDetectorWowza.as

https://github.com/longlho/flowplayer
ActionScript | 60 lines | 39 code | 9 blank | 12 comment | 1 complexity | 211a17b61cc72eaea4111762dfaa52cc MD5 | raw file
Possible License(s): MIT, BSD-3-Clause
  1. /*
  2. * This file is part of Flowplayer, http://flowplayer.org
  3. *
  4. * By: Daniel Rossi, <electroteque@gmail.com>, Anssi Piirainen Flowplayer Oy
  5. * Copyright (c) 2008-2011 Flowplayer Oy *
  6. * Released under the MIT License:
  7. * http://www.opensource.org/licenses/mit-license.php
  8. */
  9. package org.flowplayer.bwcheck.detect {
  10. import flash.net.Responder;
  11. import org.flowplayer.bwcheck.detect.AbstractDetectionStrategy;
  12. /**
  13. * @author danielr
  14. */
  15. public class BandwidthDetectorWowza extends AbstractDetectionStrategy {
  16. private var info:Object = new Object();
  17. public function onBwCheck(obj:Object):Boolean {
  18. return onBWCheck(obj);
  19. }
  20. public function onBWCheck(obj:Object):Boolean {
  21. log.debug("onBWCheck");
  22. dispatchStatus(obj);
  23. return true;
  24. }
  25. public function onBWDone(...args):void {
  26. log.debug("onBWDone, ");
  27. //#47 close the connection or else wowza dispatches two bwcheck events.
  28. connection.close();
  29. var obj:Object = new Object();
  30. var kbitDown:int = args[0];
  31. var deltaDown:int = args[1];
  32. var deltaTime:int = args[2];
  33. var latency:int = args[3];
  34. obj.kbitDown = kbitDown;
  35. obj.delatDown = deltaDown;
  36. obj.deltaTime = deltaTime;
  37. obj.latency = latency;
  38. dispatchComplete(obj);
  39. }
  40. override public function connect(host:String = null):void {
  41. connection.connect(host, true);
  42. }
  43. protected function onStatus(obj:Object):void {
  44. switch (obj.code) {
  45. case "NetConnection.Call.Failed":
  46. dispatchFailed(obj);
  47. break;
  48. }
  49. }
  50. }
  51. }