Skip to main content
Known Participant
November 7, 2009
Answered

FMS Administration api help

  • November 7, 2009
  • 1 reply
  • 1433 views
How to use: getNetStreamStats() Flash Media Server 3.5
actionscript 3 with an example thanks,
my application name is : liveVideo
livefeed name is: livefeedLive
please one example how to make a call for this application
my English is not good
    This topic has been closed for replies.
    Correct answer SE_0208

    Sorry don't have much time to write detailed code, but following is bare minimum which i think should work for you, you can modify and add detail later and customize it to suit your need:

    import flash.net.NetConnection;

    import flash.net.NetStream;

    import flash.events.*;

    import flash.system.Capabilities;

    var nc:NetConnection;

    var resp1:Responder;

    var resp2:Responder;

    function onCallSuccess(resObj):void{

    for(var i in resObj){

    trace("NetStream  Top Level data:"+i);

    trace("NetStream  Top Level value:"+resObj);

    if( i.toString() == "data"){

    for(var j in resObj){

    trace("NetStream  Low Level Data:"+j);

    trace("NetStream   Low Level Value:"+resObj);

    if(resObj != null){

    nc.call("getNetStreamStats",resp2,"live/_definst_",resObj);

    }

    }

    }

    }

    }

    function onCallSuccess2(resObj):void{

    //write similar code as onCallSuccess as per your req

    for(var m in resObj){

    trace("NetStreamStats Top Level Data:"+resObj);

    for(var n in resObj){

    for(var o in resObj){

    trace("NetStreamStats Low Level Data:"+resObj);

    }

    }

    }

    }

    nc = new NetConnection();

    resp1 = new Responder(onCallSuccess,null);

    resp2 = new Responder(onCallSuccess2,null);

    nc.addEventListener(NetStatusEvent.NET_STATUS, script_ncStatus);

    function script_ncStatus(event:NetStatusEvent):void{

    var info:Object = event.info;

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

    nc.call("getNetStreams",resp1,"live/_definst_");

    }

    }

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

    There are lot other codes which you can use to get other statistics in above fashion , like getLiveStreams,getLiveStreamStats - please refer Admin API guide which comes with FMS installation.

    Hope it works for you.

    1 reply

    Participating Frequently
    November 13, 2009

    As of now I will give you example with http and later will try to post AS3 example

    Take your example: You are publishing with name "livefeedLive" to application called "liveVideo" (assuming admin/admin as userid/password for Admin)

    Run this command in browser: http://<server-ip>:1111/admin/getNetStreams?auser=admin&apswd=admin&appInst= liveVideo/_definst_ 

    This will give you below result: (just a sample result)

    <?xml version="1.0" encoding="utf-8" ?>
    - <result>
    <level>status</level>
    <code>NetConnection.Call.Success</code>
    <timestamp>11/13/2009 1:27:11 PM</timestamp>
    <name>_defaultRoot_:_defaultVHost_:::_0</name>
    - <data>
    <_0>ABACAAAA</_0>
    </data>
    </result>
    Now use streamid returned make your getNetStreamStats call as follows:
    http://10.192.22.82:1111/admin/getNetStreamStats?auser=admin&apswd=admin&appInst=liveVideo/_definst_&streamids=ABACAAAA - you will get result as below: (again sample result)
    <?xml  version="1.0" encoding="utf-8" ?>
    - <result>
    <level>status</level>
    <code>NetConnection.Call.Success</code>
    <timestamp>11/13/2009 1:32:19 PM</timestamp>
    - <data>
    - <_0>
    <name>livefeedLive</name>
    <time>11/13/2009 1:26:06 PM</time>
    <type>publishing</type>
    <client>oAACAAAA</client>
    <stream_id>ABACAAAA</stream_id>
    <client_type>normal</client_type>
    </_0>
    </data>
    </result>
    Will try to post AS3 code soon

    CMCadIDAuthor
    Known Participant
    November 13, 2009

    First I want to say thanks for your help

    I sent immediately experiment with the information I've written, and I tell you that everything worked very well, the responses that the server returns me they are very quick and with all the information that interests me

    my afflictions and to make these calls to the server via actionscript 3 to obtain all the information that the server give me little about his condition, and very important for me to see if a flux and online video how many people are watching, etc.
    and then another very important thing, whether the live video feed also has an audio track
    because I saw a live publishing not send metadata
    Thanks again for your useful help
    p.s. excuse
    my English is not very good

    SE_0208Correct answer
    Participating Frequently
    November 13, 2009

    Sorry don't have much time to write detailed code, but following is bare minimum which i think should work for you, you can modify and add detail later and customize it to suit your need:

    import flash.net.NetConnection;

    import flash.net.NetStream;

    import flash.events.*;

    import flash.system.Capabilities;

    var nc:NetConnection;

    var resp1:Responder;

    var resp2:Responder;

    function onCallSuccess(resObj):void{

    for(var i in resObj){

    trace("NetStream  Top Level data:"+i);

    trace("NetStream  Top Level value:"+resObj);

    if( i.toString() == "data"){

    for(var j in resObj){

    trace("NetStream  Low Level Data:"+j);

    trace("NetStream   Low Level Value:"+resObj);

    if(resObj != null){

    nc.call("getNetStreamStats",resp2,"live/_definst_",resObj);

    }

    }

    }

    }

    }

    function onCallSuccess2(resObj):void{

    //write similar code as onCallSuccess as per your req

    for(var m in resObj){

    trace("NetStreamStats Top Level Data:"+resObj);

    for(var n in resObj){

    for(var o in resObj){

    trace("NetStreamStats Low Level Data:"+resObj);

    }

    }

    }

    }

    nc = new NetConnection();

    resp1 = new Responder(onCallSuccess,null);

    resp2 = new Responder(onCallSuccess2,null);

    nc.addEventListener(NetStatusEvent.NET_STATUS, script_ncStatus);

    function script_ncStatus(event:NetStatusEvent):void{

    var info:Object = event.info;

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

    nc.call("getNetStreams",resp1,"live/_definst_");

    }

    }

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

    There are lot other codes which you can use to get other statistics in above fashion , like getLiveStreams,getLiveStreamStats - please refer Admin API guide which comes with FMS installation.

    Hope it works for you.