Skip to main content
Known Participant
February 27, 2010
Question

How does a client send streams

  • February 27, 2010
  • 1 reply
  • 490 views

I am trying to figure out how a client sends video or audio streams to the server who then sends to other clients.Help pls

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    March 1, 2010

    Workflow is as follows:

    On client side , client takes input from Camera and Microphone available on system. It connect to FMS using NetConnection object. On successful connection , it creates NeyStream which takes input from Camera and Microphone and publishes to connected application over NetConnection to FMS.

    Above explanation is very concise one but i think it will give you idea.

    Participating Frequently
    March 1, 2010

    A Sample AS3 code which does the same:

    import flash.net.NetConnection;

    import flash.net.NetStream;

    import flash.events.*;

    import flash.system.Capabilities;

    import flash.media.Camera;

    import flash.media.Microphone;

    var nc:NetConnection;

    var ns:NetStream;

    var client:Object;

    var camera:Camera;

    var microphone:Microphone;

    nc = new NetConnection();

    nc.addEventListener(NetStatusEvent.NET_STATUS, script_ncStatus);

    camera = Camera.getCamera();

    microphone= Microphone.getMicrophone();

    camera.setMode(160, 120, 6, true);

    function script_ncStatus(event:NetStatusEvent):void{

    var info:Object = event.info;

    trace(info.code);

    if(info.code=="NetConnection.Connect.Success"){

    ns = new NetStream(nc);

    ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

    ns.attachCamera(camera);

    ns.attachAudio(microphone);

    ns.publish("myStream","live");

    }

    }

    function netStatusHandler(event:NetStatusEvent):void

    {

        try

        {

    trace(event.info.code);

        }

        catch (error:TypeError)

        {

            // Ignore any errors.

        }

    }

    nc.connect("rtmp://<server-ip>/live");

    Please note this is plain simple code , you can achieve much more than this