Skip to content

Media Server API

JavaScript APIs for Room creation, stream mixing, and RTMP streaming.

Create Room

Method: createRoom(options, callback, host)

NameRequiredTypeDescription
optionsYesObjectRoom options
callbackYesfunctionCallback
hostNostringMedia server address
javascript
options = { name: 'test' }

Returns { "id": "roomid" } — use id when joining the meeting.

Add Stream to Mix

Method: mixStream(room, streamid, callback, host)

NameRequiredTypeDescription
roomYesstringRoom id
streamidYesstringStream id
callbackNofunctionCallback
hostYesstringMedia server address

Remove Stream from Mix

Method: removeMixStream(room, streamid, callback, host)

Same parameters as add stream to mix.

Update Mix Resolution

Applied when the room has no participants. Method: updateRoomMixStream(room, options, callback, host)

javascript
options = {
    views: [{
        video: {
            parameters: {
                resolution: { width: 1280, height: 720 }
            },
        }
    }]
}

Start RTMP Streaming

Method: startStreamingOut(room, options, callback, host)

javascript
var options = {
    protocol: 'rtmp',
    url: 'rtmp://',
    media: {
        audio: { from: "streamid" },
        video: { from: "streamid" }
    }
};

Returns { "id": "streamoutid" }.

Stop RTMP Streaming

Method: stopStreamingOut(room, streamOutId, callback, host)

NameRequiredTypeDescription
roomYesstringRoom id
streamOutIdYesstringStream out id from startStreamingOut
callbackYesfunctionCallback
hostNostringMedia server address

微议Pro SDK 开发者文档