Skip to content

Invoking a REST method

Let us take a look at operation of REST method through the example of the /publishStream method.

A user sends a video stream to the WCS server with Streamer test web application

 

Upon clicking the Start button, the web page invokes the Stream.publish() function that begins broadcasting.

Here is a step-by-step diagram of publishing and invoking the publishStream REST method:

  1. Stream.publish() is invoked on the client side
  2. WCS queries the internal backend server at http://localhost:8081/apps/EchoApp/publishStream
  3. WCS receives 200 OK response from the internal backend server
  4. WCS sends the StreamStatusEvent event to the client with status: "PUBLISHING"

 

The final result is the PUBLISHING status displayed on the web page:

 

Invocation of the /publishStream method (step 2) looks as follows when the HTTP protocol is analyzed in Wireshark:

POST /EchoApp/publishStream HTTP/1.1
Accept: application/json
Content-Type: application/json;charset=UTF-8
User-Agent: Java/1.8.0_45
Host: localhost:8081
Connection: keep-alive
Content-Length: 3622

{ 
   "nodeId":"H4gfHeULtX6ddGGUWwZxhUNyqZHUFH8j@192.168.1.59",
   "appKey":"defaultApp",
   "sessionId":"/192.168.1.38:52791/192.168.1.59:8443",
   "mediaSessionId":"87c5ff20-fb59-11e6-812c-1b28ccb49323",
   "name":"84cac22c",
   "published":true,
   "hasVideo":true,
   "hasAudio":true,
   "status":"PUBLISHING",
   "record":false,
   "width":0,
   "height":0,
   "bitrate":0,
   "quality":0,
   "mediaProvider":"WebRTC"
}
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Sat, 25 Feb 2017 05:51:11 GMT



{ 
   "nodeId":"H4gfHeULtX6ddGGUWwZxhUNyqZHUFH8j@192.168.1.59",
   "appKey":"defaultApp",
   "sessionId":"/192.168.1.38:52791/192.168.1.59:8443",
   "mediaSessionId":"87c5ff20-fb59-11e6-812c-1b28ccb49323",
   "name":"84cac22c",
   "published":true,
   "hasVideo":true,
   "hasAudio":true,
   "status":"PUBLISHING",
   "record":false,
   "width":0,
   "height":0,
   "bitrate":0,
   "quality":0,
   "mediaProvider":"WebRTC"
}