0 Replies Latest reply on May 30, 2010 4:44 PM by Val_007_abc

    video streaming doesnt work((

    Val_007_abc

      Hello all and thank you for your time!

      I am really a newbie with Stratus and Flex so I am really sorry for the code.

      I wanted to create an application that captures&sends video from one computer to another,and display it on the another computer.

      I couldn't make Video Phone application work((.

      This is my program,

      first one user who sends should click on "register button" and receive his ID as text , and copy the ID received to text file, so I manually

      go to another computer that receives the stream and paste it there. This part goes okay, I receive the ID from Stratus,

      and then i click on "start sending". It then publishes "media" channel.

      Then I go to another computer and run the same program,click "register", then insert the ID that I copied into the INPUTTEX field.

      Than I should see the picture- BUT- ALAS- nothing happen!

       

      And I really don't know why- help very much appreciated!

       

      ===========================================================================

      [CODE]

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application

       

       

      xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

       

      <mx:Script>

      <![CDATA[

       

      import mx.controls.Alert;

       

      import mx.charts.chartClasses.StackedSeries;

       

      import mx.formatters.DateFormatter;

       

      import flash.sampler.Sample;

       

      import mx.events.SliderEvent;

       

      import mx.events.FlexEvent;

       

      import mx.collections.ArrayCollection;

       

      import mx.events.ItemClickEvent;

       

      [

      Bindable] private var connectUrl:String = "rtmfp://stratus.adobe.com";

       

      private const DeveloperKey:String = "58e0cb26b7b7a2188ea8bd14-1ed8f38ca054";

       

      private const WebServiceUrl:String = "http://109.253.7.170/test.php";

       

      private var netConnection:NetConnection;

       

      private var listenerStream:NetStream;

       

      private var controlStream:NetStream;

       

      private var outgoingStream:NetStream;

       

      private var incomingStream:NetStream;

       

      // private var idManager:AbstractIdManager;

       

      private var remoteVideo:Video;

       

       

      private var sendStream:NetStream;

       

       

      private var recvStream:NetStream;

       

      [

      Bindable] private var loginState:int;

       

       

      private const LoginNotConnected:int = 0;

       

      private const LoginConnecting:int = 1;

       

      private const LoginConnected:int = 2;

       

      private const LoginDisconnecting:int = 3;

       

       

      var the_id:String = new String("");

       

       

       

       

       

       

       

       

       

       

       

       

       

       

      private function test():void {

       

      /*var camera:Camera = Camera.getCamera();

      if (camera) {

      videoDisplay.attachCamera(camera);

      } else {

      Alert.show("You don't seem to have a camera.");

      }*/

      }

       

       

      public function alert_the_user():void {

      Alert.show(

      "the lilies are blue");

      }

       

       

       

       

      public function register():void

      {

      netConnection =

      new NetConnection();

      netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnectionHandler);

      netConnection.connect(connectUrl +

      "/" + DeveloperKey);

       

      loginState = LoginConnecting;

       

       

      // Alert.show("Connecting to " + connectUrl + "\n");

       

       

       

      }

       

       

       

      private function netConnectionHandler(event:NetStatusEvent):void

      {

       

      //Alert.show("NetConnection event: " + event.info.code + "\n");

       

       

      switch (event.info.code)

      {

       

      case "NetConnection.Connect.Success":

      Alert.show(netConnection.nearID);

       

       

       

      break;

       

       

       

       

      case "NetConnection.Connect.Closed":

       

      // Alert.show("CONNECTION CLOSED");

       

      break;

       

       

      case "NetStream.Connect.Success":

       

      // we get this when other party connects to our control stream our outgoing stream

       

      // Alert.show("CONNECTION FROM"+ event.info.stream.farID );

       

      break;

       

       

      case "NetConnection.Connect.Failed":

       

      // Alert.show("CANNOT CONNECT");

       

       

      break;

       

       

      case "NetStream.Connect.Closed":

       

      // Alert.show("CLOSED");

       

      break;

      }

      }

       

       

       

       

      private function outgoingStreamHandler(event:NetStatusEvent):void

      {

       

      //status("Outgoing stream event: " + event.info.code + "\n");

       

      switch (event.info.code)

      {

       

      case "NetStream.Play.Start":

       

      outgoingStream.send(

      "onIncomingCall", "khkhjhkjh");

       

       

      break;

      }

      }

       

       

      private function incomingStreamHandler(event:NetStatusEvent):void

      {

       

      //status("Incoming stream event: " + event.info.code + "\n");

       

      switch (event.info.code)

      {

       

      case "NetStream.Play.UnpublishNotify":

      Alert.show(

      "hangup");

       

      break;

      }

      }

       

        

        

        

       

      public function start_send():void

      {

       

       

      //creating a send stream if the registartion has been successfull

      sendStream =

      new NetStream(netConnection, NetStream.DIRECT_CONNECTIONS);

      sendStream.addEventListener(NetStatusEvent.NET_STATUS,outgoingStreamHandler);

      sendStream.publish(

      "media");

      sendStream.attachAudio(Microphone.getMicrophone());

      sendStream.attachCamera(Camera.getCamera());

       

      Alert.show(

      "creating the sending stream");

       

        

      }

       

        

       

      public function start_receive():void

      {

       

       

       

       

       

      Alert.show(

      "start receive");

       

      //recvStream = new NetStream(netConnection,the_id);

       

      recvStream =

      new NetStream(netConnection,the_id);

       

       

      recvStream.addEventListener(NetStatusEvent.NET_STATUS, incomingStreamHandler);

      recvStream.play(

      "media");

       

       

      remoteVideo =

      new Video();

      remoteVideo.width = 320;

      remoteVideo.height = 240;

      remoteVideo.attachNetStream(recvStream);

       

       

      remoteVideoDisplay.addChild(remoteVideo);

       

      //remoteVideoDisplay.play();

       

       

       

      }

       

       

      public function get_id_from_text():void

      {

       

      the_id=get_id_textinput.text;

      Alert.show(the_id.toString());

      }

       

       

      ]]>

      </mx:Script>

       

       

      <mx:Button x="368" y="273" label="Register and get ID" click="register()" id="label2" height="52" width="164"/>

       

      <mx:Button x="25" y="303" label="start sending" id="send_button" click="start_send()"/>

       

      <mx:Button x="178" y="303" label="start receiveing" id="rec_button" click="start_receive()"/>

       

      <mx:TextInput x="351" y="122" width="232" id="get_id_textinput"/>

       

      <mx:Label x="368" y="96" text="the id of we should listen to" width="215"/>

       

      <mx:VideoDisplay x="25" y="23" width="269" height="231" id="remoteVideoDisplay"/>

       

      </mx:Application>

       

       

      [/CODE]

      ======================================================================================