Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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 realtime metric values obtaining, 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

CONNECT
accept-version:1.2
host:hostname

^@

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

SUBSCRIBE
id:sub-1
destination:/stream/15/010934f0-0766-11e9-a950-59983a9de3c8

^@

Where

  • 15 - node identifier in backend database
  • 010934f0-0766-11e9-a950-59983a9de3c8 - stream mediasession identifier

4. Subscribe to /alarm event for alarms receiving

SUBSCRIBE
id:sub-0
destination:/alarm

^@

After that client starts to receive STOMP messages in plain text

"MESSAGE\ndestination:/stream/15/010934f0-0766-11e9-a950-59983a9de3c8\ncontent-type:application/json;charset=UTF-8\nsubscription:sub-1\nmessage-id:oilwo0os-701\ncontent-length:1349\n\n[{\"VIDEO_SYNC\":3754637125197,\"VIDEO_CODEC\":120,\"VIDEO_NACK\":18,\"VIDEO_PLI\":0,\"VIDEO_RATE\":478104,\"VIDEO_WIDTH\":320,\"VIDEO_HEIGHT\":240,\"VIDEO_FPS\":30,\"timestamp\":1545648325506},{\"AUDIO_SYNC\":3754637125227,\"AUDIO_CODEC\":111,\"AUDIO_RATE\":32616,\"timestamp\":1545648325558,\"AUDIO_LOST\":21},{\"AUDIO_SYNC\":3754637125347,\"AUDIO_CODEC\":111,\"AUDIO_RATE\":32960,\"timestamp\":1545648325684,\"AUDIO_LOST\":21},{\"VIDEO_SYNC\":3754637125397,\"VIDEO_CODEC\":120,\"VIDEO_NACK\":18,\"VIDEO_PLI\":0,\"VIDEO_RATE\":504632,\"VIDEO_WIDTH\":320,\"VIDEO_HEIGHT\":240,\"VIDEO_FPS\":31,\"timestamp\":1545648325701},{\"AUDIO_SYNC\":3754637125467,\"AUDIO_CODEC\":111,\"AUDIO_RATE\":33048,\"timestamp\":1545648325805,\"AUDIO_LOST\":21},{\"VIDEO_SYNC\":3754637125597,\"VIDEO_CODEC\":120,\"VIDEO_NACK\":18,\"VIDEO_PLI\":0,\"VIDEO_RATE\":495624,\"VIDEO_WIDTH\":320,\"VIDEO_HEIGHT\":240,\"VIDEO_FPS\":30,\"timestamp\":1545648325911},{\"AUDIO_SYNC\":3754637125587,\"AUDIO_CODEC\":111,\"AUDIO_RATE\":33048,\"timestamp\":1545648325921,\"AUDIO_LOST\":21},{\"AUDIO_SYNC\":3754637125707,\"AUDIO_CODEC\":111,\"AUDIO_RATE\":32400,\"timestamp\":1545648326049,\"AUDIO_LOST\":21},{\"VIDEO_SYNC\":3754637125796,\"VIDEO_CODEC\":120,\"VIDEO_NACK\":18,\"VIDEO_PLI\":0,\"VIDEO_RATE\":480224,\"VIDEO_WIDTH\":320,\"VIDEO_HEIGHT\":240,\"VIDEO_FPS\":32,\"timestamp\":1545648326104},{\"AUDIO_SYNC\":3754637125827,\"AUDIO_CODEC\":111,\"AUDIO_RATE\":33048,\"timestamp\":1545648326159,\"AUDIO_LOST\":21}]\u0000"

or in JSON using STOMP.js library

{
    "command": "MESSAGE",
    "headers": {
        "content-length": "1282",
        "message-id": "oilwo0os-926",
        "subscription": "sub-1",
        "content-type": "application/json;charset=UTF-8",
        "destination": "/stream/15/010934f0-0766-11e9-a950-59983a9de3c8"
    },
    "body": [
        {
            "VIDEO_SYNC": 3754637299170,
            "VIDEO_CODEC": 120,
            "VIDEO_NACK": 20,
            "VIDEO_PLI": 0,
            "VIDEO_RATE": 617024,
            "VIDEO_WIDTH": 320,
            "VIDEO_HEIGHT": 240,
            "VIDEO_FPS": 24,
            "timestamp": 1545648499723
        },
        {
            "AUDIO_SYNC": 3754637299482,
            "AUDIO_CODEC": 111,
            "AUDIO_RATE": 30600,
            "timestamp": 1545648499799,
            "AUDIO_LOST": 23
        },
        ...
    ]
}

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

To stop receiving metrics in realtime, the following message should be sent to unsubscribe

UNSUBSCRIBE
id:/stream/15/010934f0-0766-11e9-a950-59983a9de3c8

^@

Connection setup

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

stomp_max_metrics=10

Metric values are sent to subscriber when metrics changed count reaches this parameter value. If metrics are rarely change, it is recommenede to reduce this parameter.

Connection timeout is set with the following parameter

stomp_max_timeout=1000
  • No labels