Versions Compared

Key

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

...

Realtime stream information can be obtained using STOMP protocol over Websocket API.

STOMP client connection over Websocket to backend server

To connect to backend server for obtaining realtime metric values, do the following:

1. Establish Secure Websocket connection to https://hostname:8090/ws, where hostname is backend server address

2. Establish STOMP connection by sending the message

Code Block
themeRDark
CONNECT
accept-version:1.2
host:hostname

^@

3.Establish Websocket API connection

2. Subscribe to /stream/nodeId/mediaId event by sending the message

Code Block
themeRDark
SUBSCRIBE
id:sub-12
destination:/stream/153/010934f0ca77c700-07668e86-11e9-a9508386-59983a9de3c8dbc3d191a79a
 
^@

Where

  • 15 3 - node identifier in backend database
  • 010934f0ca77c700-07668e86-11e9-a9508386-59983a9de3c8 dbc3d191a79a - stream media session identifier

4. Subscribe to /alarm event for receiving alarms

Code Block
themeRDark
SUBSCRIBE
id:sub-0
destination:/alarm

^@

After that, client starts receiving STOMP messages in plain text

Code Block
themeRDark
"MESSAGE\ndestination
destination:/stream/153/010934f0ca77c700-07668e86-11e9-a950-59983a9de3c8\ncontent8386-dbc3d191a79a
content-type:application/json;charset=UTF-8\nsubscription
subscription:sub-1\nmessage2
message-id:oilwo0os-701\ncontent3-50
content-length:1349\n\n1339

[{\"VIDEO_SYNC\":37546371251971560504547907,\"VIDEO_CODEC\":120119,\"VIDEO_NACK\":180,\"VIDEO_PLI\":0,\"VIDEO_RATE\":478104571616,\"VIDEO_WIDTH\":320,\"VIDEO_HEIGHT\":240,\"VIDEO_FPS\":30,\"timestamp\":15456483255061560504547917},{\"AUDIO_SYNC\":37546371252271560504547890,\"AUDIO_CODEC\":111,\"AUDIO_RATE\":3261626664,\"timestamp\":15456483255581560504547923,\"AUDIO_LOST\":210},{\"AUDIO_SYNC\":37546371253471560504548010,\"AUDIO_CODEC\":111,\"AUDIO_RATE\":3296027040,\"timestamp\":15456483256841560504548040,\"AUDIO_LOST\":210},{\"VIDEO_SYNC\":37546371253971560504548099,\"VIDEO_CODEC\":120119,\"VIDEO_NACK\":180,\"VIDEO_PLI\":0,\"VIDEO_RATE\":504632577416,\"VIDEO_WIDTH\":320,\"VIDEO_HEIGHT\":240,\"VIDEO_FPS\":3130,\"timestamp\":15456483257011560504548119},{\"AUDIO_SYNC\":37546371254671560504548130,\"AUDIO_CODEC\":111,\"AUDIO_RATE\":3304826624,\"timestamp\":15456483258051560504548167,\"AUDIO_LOST\":210},{\"VIDEOAUDIO_SYNC\":37546371255971560504548250,\"VIDEOAUDIO_CODEC\":120111,\"VIDEO_NACK\AUDIO_RATE":27976,"timestamp":181560504548282,\"VIDEOAUDIO_PLI\LOST":0},\{"VIDEO_RATE\SYNC":4956241560504548307,\"VIDEO_WIDTH\CODEC":320119,\"VIDEO_HEIGHT\NACK":2400,\"VIDEO_FPS\PLI":300,\"timestamp\VIDEO_RATE":1545648325911}581968,{\"AUDIOVIDEO_SYNC\WIDTH":3754637125587320,\"AUDIOVIDEO_CODEC\HEIGHT":111240,\"AUDIOVIDEO_RATE\FPS":3304831,\"timestamp\":1545648325921,\"AUDIO_LOST\":211560504548318},{\"AUDIO_SYNC\":37546371257071560504548370,\"AUDIO_CODEC\":111,\"AUDIO_RATE\":3240028128,\"timestamp\":15456483260491560504548404,\"AUDIO_LOST\":210},{\"VIDEO_SYNC\":37546371257961560504548499,\"VIDEO_CODEC\":120119,\"VIDEO_NACK\":180,\"VIDEO_PLI\":0,\"VIDEO_RATE\":480224583032,\"VIDEO_WIDTH\":320,\"VIDEO_HEIGHT\":240,\"VIDEO_FPS\":3231,\"timestamp\":15456483261041560504548506},{\"AUDIO_SYNC\":37546371258271560504548490,\"AUDIO_CODEC\":111,\"AUDIO_RATE\":3304829568,\"timestamp\":15456483261591560504548522,\"AUDIO_LOST\":210}]\u0000"

or in JSON using STOMP.js library

Code Block
languagejs
themeRDark
{
       "command": "MESSAGE",
       "headers": {
               "content-length": "12821339",
               "message-id": "oilwo0os3-92650",
               "subscription": "sub-12",
               "content-type": "application/json;charset=UTF-8",
               "destination": "/stream/153/010934f0ca77c700-07668e86-11e9-a9508386-59983a9de3c8dbc3d191a79a"
       },
       "body": [
        {
           
        {
            "VIDEO_SYNC": 1560504547907,
            "VIDEO_CODEC": 119,
            "VIDEO_NACK": 0,
            "VIDEO_PLI": 0,
            "VIDEO_RATE": 571616,
            "VIDEO_WIDTH": 320,
            "VIDEO_HEIGHT": 240,
            "VIDEO_FPS": 30,
            "timestamp": 1560504547917
        },
        {
            "AUDIO_SYNC": 1560504547890,
            "AUDIO_CODEC": 111,
            "AUDIO_RATE": 26664,
            "timestamp": 1560504547923,
            "AUDIO_LOST": 0
        },
        {
            "AUDIO_SYNC": 1560504548010,
            "AUDIO_CODEC": 111,
            "AUDIO_RATE": 27040,
            "timestamp": 1560504548040,
            "AUDIO_LOST": 0
        },
        {
            "VIDEO_SYNC": 1560504548099,
            "VIDEO_CODEC": 119,
            "VIDEO_NACK": 0,
            "VIDEO_PLI": 0,
            "VIDEO_RATE": 577416,
            "VIDEO_WIDTH": 320,
            "VIDEO_HEIGHT": 240,
            "VIDEO_FPS": 30,
            "timestamp": 1560504548119
        },
        {
            "AUDIO_SYNC": 1560504548130,
            "AUDIO_CODEC": 111,
            "AUDIO_RATE": 26624,
            "timestamp": 1560504548167,
            "AUDIO_LOST": 0
        },
        {
            "AUDIO_SYNC": 1560504548250,
            "AUDIO_CODEC": 111,
            "AUDIO_RATE": 27976,
            "timestamp": 1560504548282,
            "AUDIO_LOST": 0
        },
        {
            "VIDEO_SYNC": 37546372991701560504548307,
                       "VIDEO_CODEC": 120119,
                       "VIDEO_NACK": 200,
                       "VIDEO_PLI": 0,
                       "VIDEO_RATE": 617024581968,
                       "VIDEO_WIDTH": 320,
                       "VIDEO_HEIGHT": 240,
                       "VIDEO_FPS": 2431,
                       "timestamp": 1545648499723
       1560504548318
        },
               {
                       "AUDIO_SYNC": 37546372994821560504548370,
                       "AUDIO_CODEC": 111,
                       "AUDIO_RATE": 3060028128,
                       "timestamp": 15456484997991560504548404,
                       "AUDIO_LOST": 0
        },
        {
            ": 23
        },
        ...
   VIDEO_SYNC": 1560504548499,
            "VIDEO_CODEC": 119,
            "VIDEO_NACK": 0,
            "VIDEO_PLI": 0,
            "VIDEO_RATE": 583032,
            "VIDEO_WIDTH": 320,
            "VIDEO_HEIGHT": 240,
            "VIDEO_FPS": 31,
            "timestamp": 1560504548506
        },
        {
            "AUDIO_SYNC": 1560504548490,
            "AUDIO_CODEC": 111,
            "AUDIO_RATE": 29568,
            "timestamp": 1560504548522,
            "AUDIO_LOST": 0
        }
    ]
}

The messages contain metric values acquired from the node where the stream is published or played.

...

Code Block
themeRDark
UNSUBSCRIBE
id:/stream/15/010934f0-0766-11e9-a950-59983a9de3c8sub-2

^@

Connection setup

Maximum metrics count in one STOMP message is set with the following parameter in wcsoam.properties

Code Block
themeRDark
stomp_max_metrics=10

Metric values are sent to subscriber when metrics change count reaches that parameter value. If metrics change rarely, it is recommended to reduce the parameter value.

Connection timeout is set with the following parameterConnection timeout is set with the following parameter

Code Block
themeRDark
stomp_max_timeout=1000

Metric aquisition rate and messages receiving frequency

A different metrics sets can be aquired to backend server with a different rate defined by profile. If metric value, VIDEO_HEIGHT for example, does not change while stream is published, then messages with this metric will be send to subscriber at least as rate defines. If metric value (VIDEO_RATE) changes, messages with this metric can be send to subscriber upon changes.

For example, if stream data are collected by profile including one static metric VIDEO_WIDTH with rate 30

Code Block
languagejs
themeRDark
https://hostname:8090/api/profile/create
{
  "name": "profile1",
  "rate": "30",
  "metrics": ["2"],
  "rules": ["1"]
}

and maximum metrics count 1 per one message

Code Block
themeRDark
stomp_max_metrics=1

the messages will be send to subscriber near 1 per second.

When changing rate to 600

Code Block
languagejs
themeRDark
https://hostname:8090/api/profile/update
{
  "id": "2",
  "name": "profile1",
  "rate": "600",
  "metrics": ["2"],
  "rules": ["1"]
}

the messages will be send to subscriber near 1 per 20 seconds.

Now, extending metrics set to 4 static metrics VIDEO_WIDTH, VIDEO_HEIGHT, VIDEO_CODEC, AUDIO_CODEC

Code Block
languagejs
themeRDark
https://hostname:8090/api/profile/update
{
  "id": "2",
  "name": "profile1",
  "rate": "600",
  "metrics": ["2","3","9","13"],
  "rules": ["1"]
}

the messages will be send to subscriber near 1 per 5 seconds.

When stream data are collected by profile including two metrics VIDEO_RATE, AUDIO_RATE with rate 30

Code Block
languagejs
themeRDark
https://hostname:8090/api/profile/create
{
  "name": "profile2",
  "rate": "30",
  "metrics": ["4","11"],
  "rules": ["1"]
}

and maximum metrics count 1 per one message

Code Block
themeRDark
stomp_max_timeout=1000metrics=1

for the stream published to WCS using RTMP, the messages will be send to subscriber near 1-2 per second.