Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
themeRDark
    session.createStream({
        name: streamName,
        display: remoteVideo
        ...
    }).on(STREAM_EVENT, function(streamEvent) {
        switch (streamEvent.type) {
            case STREAM_EVENT_TYPE.DATA:
                console.log(JSON.stringify(streamEvent.payload));
                break;
        }
    }).play();

Receiving mixer incoming stream event

Since build 5.2.966, a subscriber playing mixer output stream, can receive incoming mixer sterams events. In this case, streamName field is added to payload objects to show what stream publisher generated the event

Code Block
languagejs
themeRDark
    session.createStream({
        name: streamName,
        display: remoteVideo,
        ...
    }).on(STREAM_EVENT, function(streamEvent) {
        let mutedName="";
        if(streamEvent.payload !== undefined) {
            mutedName=streamEvent.payload.streamName;
        }
        switch (streamEvent.type) {
            case STREAM_EVENT_TYPE.AUDIO_MUTED:
                $("#audioMuted").text(true + " " + mutedName);
                break;
            case STREAM_EVENT_TYPE.AUDIO_UNMUTED:
                $("#audioMuted").text(false + " " + mutedName);
                break;
            case STREAM_EVENT_TYPE.VIDEO_MUTED:
                $("#videoMuted").text(true + " " + mutedName);
                break;
            case STREAM_EVENT_TYPE.VIDEO_UNMUTED:
                $("#videoMuted").text(false + " " + mutedName);
                break;

        }
        console.log("Received streamEvent ", streamEvent.type);
    }).play();

Stream status detection while subscriber is connecting to a stream

A new subscriber can detect if audio/video track is muted in the stream while connecting to the stream using Stream.getAudioState() and Stream.getVideoState() methiods in STREAM_STATUS.PLAYING handler:

Code Block
languagejs
themeRDark
    session.createStream({
        name: streamName,
        display: remoteVideo,
        ...
    }).on(STREAM_STATUS.PLAYING, function (stream) {
        if (stream.getAudioState()) {
            $("#audioMuted").text(stream.getAudioState().muted);
        }
        if (stream.getVideoState()) {
            $("#videoMuted").text(stream.getVideoState().muted);
        }
        ...
   }).play;

Mixer incoming streams status detection while connecting to a mixer outgoing stream

Since WCS build 5.2.1011, when a new subscriber connects to a mixer outgoing stream, it will receive a set of STREAM_EVENT events per every mixer incoming stream, if audio or video track was muted at least once in any of them. In this case, STREAM_EVENT receiving order is not guaranteed and does not depend on streams addition order to the mixer.

Stream event processing on backend

To process stream events on backend server, sendStreamEvent and StreamEvent methods should be added to the application

Code Block
languagebash
themeRDark
add app-rest-method MyAppKey sendStreamEvent
add app-rest-method MyAppKey StreamEvent

...