How to reject stream?

Kevin

New Member
I have a simple playback using playStream for WebRTC.
How to reject this stream? For example when user is not authenticated?
 

Max

Administrator
Staff member
Integration Example
1. When you invoke method connect on JavaScript, WCS sends REST / HTTP request to localhost by default:
http://localhost:9091/EchoApp/connect
REST / JSON object (Request):
HTML:
{
  "nodeId" : "GguwnLG6D6CylgCIm5dcRfnsAuLXx5gk@5.5.5.5",
  "appKey" : "defaultApp",
  "sessionId" : "/5.5.5.5:52275/9.9.9.9:8080",
  "sipRegisterRequired" : true,
  "sipLogin" : "10007",
  "sipAuthenticationName" : "10007",
  "sipPassword" : "1234",
  "sipDomain" : "sip.flashphoner.com",
  "sipOutboundProxy" : "sip.flashphoner.com",
  "sipPort" : 5080,
  "sipContactParams" : "0",
  "width" : 640,
  "height" : 480,
  "useProxy" : true,
  "useRTCSessions" : true,
  "useWsTunnel" : false,
  "useBase64BinaryEncoding" : false,
  "mediaProviders" : [ "WebRTC", "Flash" ],
  "status" : "PENDING",
  "urlServer" : "ws://5.5.5.5:8080"
}
The localhost web server answers with similar echo object (Response):
HTML:
{
  "nodeId" : "GguwnLG6D6CylgCIm5dcRfnsAuLXx5gk@5.5.5.5",
  "appKey" : "defaultApp",
  "sessionId" : "/5.5.5.5:52275/9.9.9.9:8080",
  "sipRegisterRequired" : true,
  "sipLogin" : "10007",
  "sipAuthenticationName" : "10007",
  "sipPassword" : "1234",
  "sipDomain" : "sip.flashphoner.com",
  "sipOutboundProxy" : "sip.flashphoner.com",
  "sipPort" : 5080,
  "sipContactParams" : "0",
  "width" : 640,
  "height" : 480,
  "useProxy" : true,
  "useRTCSessions" : true,
  "useWsTunnel" : false,
  "useBase64BinaryEncoding" : false,
  "mediaProviders" : [ "WebRTC", "Flash" ],
  "status" : "PENDING"
}
The same will be with JavaScript playStream method:
http://localhost:9091/EchoApp/playStream

Request:
HTML:
{
  "nodeId" : "7kLZnfd9rYWdvZyitHVA9MNEqPTUk8JE@5.5.5.5",
  "appKey" : "defaultApp",
  "sessionId" : "/6.6.6.6:60929/3.3.3.3:8080",
  "mediaSessionId" : "c5bbcb25-8902-470e",
  "name" : "Piz4lBPvcucks3qZxm1DBqeNnc6pNk",
  "published" : false,
  "hasVideo" : true,
  "status" : "PENDING",
  "sdp" : "...sdp removed...",
  "remoteMediaElementId" : null
}
Response:
HTML:
{
  "nodeId" : "7kLZnfd9rYWdvZyitHVA9MNEqPTUk8JE@5.5.5.5",
  "appKey" : "defaultApp",
  "sessionId" : "/3.3.3.3:60929/4.4.4.4:8080",
  "mediaSessionId" : "c5bbcb25-8902-470e",
  "name" : "Piz4lBPvcucks3qZxm1DBqeNnc6pNk",
  "published" : false,
  "hasVideo" : true,
  "status" : "PENDING",
  "sdp" : "...sdp removed..."
}
Therefore the URL http://localhost:9091/EchoApp receives requests from WCS and answers with echo objects(the same as received). It is default behavior.
You can change this behavior using WCS Command Line Interface:
Example of RestClientConfig
It is a response on ‘connect’ method:
http://localhost:9091/EchoApp/connect
HTML:
{
  "nodeId" : "GguwnLG6D6CylgCIm5dcRfnsAuLXx5gk@5.5.5.5",
  "appKey" : "defaultApp",
  "sessionId" : "/5.5.5.5:52275/9.9.9.9:8080",
  "sipRegisterRequired" : true,
  "sipLogin" : "10007",
  "sipAuthenticationName" : "10007",
  "sipPassword" : "1234",
  "sipDomain" : "sip.flashphoner.com",
  "sipOutboundProxy" : "sip.flashphoner.com",
  "sipPort" : 5080,
  "sipContactParams" : "0",
  "width" : 640,
  "height" : 480,
  "useProxy" : true,
  "useRTCSessions" : true,
  "useWsTunnel" : false,
  "useBase64BinaryEncoding" : false,
  "mediaProviders" : [ "WebRTC", "Flash" ],
  "status" : "PENDING",
  "urlServer" : "ws://2.2.2.2:8080",
  "restClientConfig" : {
      "playStream" : {
        "clientExclude" : "",
        "restExclude" : "",
        "restOnError" : "FAIL",
        "restPolicy" : "NOTIFY",
         "restOverwrite" : ""
      }
   }
}
Make sure your restOnError is set to 'FAIL'
Code:
"restClientConfig" : {
      "playStream" : {
        "clientExclude" : "",
        "restExclude" : "",
        "restOnError" : "FAIL",
        "restPolicy" : "NOTIFY",
         "restOverwrite" : ""
      }
   }
As you can see, we have added restClientConfig JSON object to define policy for method playStream.
So, if your web-server returns 404 Forbidden or another error status, the playStream attempt will be rejected by WCS server with corresponding failure message according this call flow scheme.

Notes
1. When you use method ‘connect’ on JavaScript you have to use connect({appKey:’myAppKey’...}), where myAppKey - is your custom appKey. It is ‘defaultApp’ by default. See WCS CLI docs (show apps command) to get more information.
2. You have to add rest-methods for your custom app if you create a non-default app. See ‘show app-rest-methods’ and ‘add app-rest-method’ in WCS CLI docs.
 
Last edited:
Top