medooze / media-server-demo-node

Demo application for the Medooze Media Server for Node.js
MIT License
92 stars 48 forks source link

how to act as clients #8

Closed laowangnj closed 6 years ago

laowangnj commented 6 years ago

Need to test performance of the server, so how to use this as clients

murillo128 commented 6 years ago

You can use the following snippet as base to create a connection between two nodes:

    //Create offer
    const offer = endpoint.createOffer({
        audio : {
            codecs      : ["opus"],
            extensions  : ["urn:ietf:params:rtp-hdrext:ssrc-audio-level"]
        },
        video : {
            codecs      : ["vp8","vp9"],
            rtx     : true,
            rtcpfbs     :  [
            { "id": "goog-remb"},
                { "id": "ccm", "params": ["fir"]},
                { "id": "nack"},
                { "id": "nack", "params": ["pli"]}
            ],
            extensions  : [ "urn:3gpp:video-orientation"]
        }
    });

    //Send offer to sever
    const joined = await tm.cmd("view",{
        feedId  : feedId,
        sdp : offer.toString()
    });

    //parse answer
    const answer = SemanticSDP.SDPInfo.process(joined.sdp);

    //Create transport
    const transport = endpoint.createTransport(offer, answer, {disableSTUNKeepAlive: true});

After that you can use the streams as you would normally do.