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

...

Audio/video mute/unmute notification

Backend server will receive sendStreamEvent, if publisher mutes/unmutes audio/video in the stream

Code Block
languagejs
themeRDark
URL:http://localhost:8081/apps/EchoApp/sendStreamEvent
OBJECT:
{
  "nodeId" : "qg4BeHzYSAtkhUkXgnSMEUZpsshaLPL5@192.168.0.39",
  "appKey" : "defaultApp",
  "sessionId" : "/192.168.0.83:64573/192.168.0.39:8443-a98bb891-aeaf-46a8-8fba-772e07ac035b",
  "mediaSessionId" : "9906b2b0-9c28-11eb-8d20-75f877676678",
  "type" : "audioMuted",
  "origin" : "info"https://wcs:8888"
}

Also, backend will receive StreamEvent per every the stream subscriber

Code Block
languagejs
themeRDark
URL:http://localhost:8081/apps/EchoApp/StreamEvent
OBJECT:
{
  "nodeId" : "qg4BeHzYSAtkhUkXgnSMEUZpsshaLPL5@192.168.0.39",
  "originappKey" : "https://wcs:8888"
}

if publisher mutes the stream.

...

defaultApp",
  "sessionId" : "/192.168.0.83:64573/192.168.0.39:8443-a98bb891-aeaf-46a8-8fba-772e07ac035b",
  "mediaSessionId" : "9fed5c50-9c28-11eb-8d20-75f877676678",
  "type" : "audioMuted"
}

Stream event with data passing notification

If stream event with data is passed from publisher to all the stream subscribers, then backend will receive sendStreamEvent with payload

Code Block
languagejs
themeRDark
URL:http://localhost:8081/apps/EchoApp/sendStreamEvent
OBJECT:
{
  "nodeId" : "qg4BeHzYSAtkhUkXgnSMEUZpsshaLPL5@192.168.0.39",
  "appKey" : "defaultApp",
  "sessionId" : "/192.168.0.83:64573/192.168.0.39:8443-a98bb891-aeaf-46a8-8fba-772e07ac035b",
  "mediaSessionId" : "9906b2b0-9c28-11eb-8d20-75f877676678",
  "type" : "data",
  "payload" : {
    "count" : 23
  },
  "origin" : "https://wcs:8888"
}

Also, backen server wiil receive StreamEvent per every the stream subscriber

Code Block
languagejs
themeRDark
URL:http://localhost:8081/apps/EchoApp/StreamEvent
OBJECT:
{
  "nodeId" : "qg4BeHzYSAtkhUkXgnSMEUZpsshaLPL5@192.168.0.39",
  "appKey" : "defaultApp",
  "sessionId" : "/192.168.0.83:64573/192.168.0.39:8443-a98bb891-aeaf-46a8-8fba-772e07ac035b",
  "mediaSessionId" : "9fed5c50-9c28-11eb-8d20-75f877676678",
  "type" : "audioMuteddata",
  "infopayload" : {
    "count" : 23
  }
}