0 Replies Latest reply on Feb 7, 2011 8:31 AM by mimiche123

    100% cpu load on netstream close

    mimiche123

      Hi everyone,

       

      I have a problem with netstream, under Ubuntu. I give here my source so that problem can be reproduced.

      I have one swf that publish a live stream of micro and camera, and another that subscribe to that stream.

       

      I launch the 2 apps. The publish one automatically publish. I subscribe to the stream in the other app.

      Then I close the publishing app. At this time the subscribing app starts to take 100% of CPU.

       

      I don't know what I do wrong. Have someone encountered the same problem ?

       

      here is client.mxml


       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
         layout="absolute"
         width="640"
         height="480"
         horizontalScrollPolicy="off"
         verticalScrollPolicy="off"
         creationComplete="onStart();">


          <mx:Script>
              <![CDATA[


      public var nc:NetConnection;
      public var subsNS:NetStream;


      public function onStart():void
      {
        nc=new NetConnection();
        nc.connect('rtmfp://stratus.rtmfp.net/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/');
      }


      public function text():void
      {
          subsNS=new NetStream(nc, textf.text);
          subsNS.bufferTime=0;
          subsNS.play("media-client");
      }

              ]]>
          </mx:Script>


        <mx:Button x="0" y="50" label="subscribe" click="text();"/>
        <mx:TextInput id="textf"/>


      </mx:Application>

       


      and here is server.mxml

       

       

       

       

      <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
          creationComplete="init();" layout="absolute" paddingTop="0"
          paddingBottom="0" paddingLeft="0" paddingRight="0"
          horizontalAlign="left"
          horizontalScrollPolicy="off"
          verticalScrollPolicy="off"
          width="640"
          height="505"
          backgroundColor="#666666">

          <mx:TextInput id="textf"/>

          <mx:Script>
              <![CDATA[

      private var pubsNS:NetStream;
      private var RTMFPaddress:String="rtmfp://stratus.rtmfp.net/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/";
      private var nc:NetConnection;

      public function pouet():void
      {
          pubsNS=new NetStream(nc, NetStream.DIRECT_CONNECTIONS);
          var camera:Camera=Camera.getCamera("0");
          var microphone:Microphone=Microphone.getMicrophone(0);
          microphone.codec=SoundCodec.SPEEX;
          microphone.setSilenceLevel(0);
          microphone.setLoopBack(false);
          microphone.setUseEchoSuppression(true);
          pubsNS.bufferTime=0;
          pubsNS.attachCamera(camera);
          pubsNS.attachAudio(microphone);
          pubsNS.publish("media-client");
          textf.text = nc.nearID;
      }


      private function init():void {
          nc=new NetConnection();
          nc.connect(RTMFPaddress);
          setTimeout(pouet, 3000);
      }
              ]]>
          </mx:Script>

      </mx:Application>

       

       

      and Makefile:

      FLEX_PATH=/usr/local/stow/flex_sdk_4.1.0.16076/
      all: client.swf server.swf


      client.swf: client.mxml
          $(FLEX_PATH)bin/mxmlc client.mxml  -compiler.library-path $(FLEX_PATH)/frameworks/libs $(FLEX_PATH)/frameworks/locale/en_US -compiler.locale en_US -compiler.optimize -static-link-runtime-shared-libraries -o client.swf


      server.swf: client.mxml
          $(FLEX_PATH)bin/mxmlc server.mxml  -compiler.library-path $(FLEX_PATH)/frameworks/libs $(FLEX_PATH)/frameworks/locale/en_US -compiler.locale en_US -compiler.optimize -static-link-runtime-shared-libraries -o server.swf


      run:
          flashplayer client.swf &
          flashplayer server.swf &

       

       

      Regards,

      Mimiche