Consuming Services As a Subscriber
If you are coming from the previous section then you have a working Red5 Pro cluster in place with at least one stream publishing to it.
Now that the stream is publishing and available subscriber clients may be interested to subscribe to it. However, they don’t know the host address of the edge that they should subscribe to.
Once again Stream Manager comes to the rescue by providing stream information to the subscriber client via REST API call. The subscriber client will need to make a READ STREAM REST call to the stream Manager using a scope name, stream name and the action parameter (subscribe).
Scope name
is the Red5 application/context name that a client connects to. The default scope name to be used is liveStream name
is the name of the publishing streamAction
is a query string parameter that defines the client’s request type:broadcast
orsubscribe
Requesting Stream Subscribe Information
Use stream manager’s READ STREAM REST API to request for an edge server.
The combination of scope name and stream name should be unique for each streaming event.
Request Format
http(s)://{host}:{port}/streammanager/api/<api-version>/event/{scopeName}/{streamName}?action=subscribe
Response Format
{
"name": "<stream-name>",
"scope": "<stream-scope>",
"serverAddress": "<edge-host-address>",
"region": "<region-code>"
}
Connecting To Server To Subscribe
Having received a successful response from Stream Manager with stream subscribe information we can now consume the stream using a subscriber client.
The stream subscribe information received from the REST response can be used by different types of subscribing client(s) as shown below.
Android Client
Property Name | Value |
---|---|
host | |
context | |
port | 8554 |
stream |
iOS Client
Property Name | Value |
---|---|
host | |
context | |
port | 8554 |
stream |
Flash Client
Property Name | Value |
---|---|
Connection URL | rtmp:// |
stream |
WebRTC Stream Manager Proxy Subscribing
WebRTC requires using the Stream Manager proxy feature to bypass the secure origin requirement, to be able to publish.
To learn more about proxy and configuring WebRTC client to work with proxy please see the Stream Manager Proxy Guide.
Example references for subscribers
- WebRTC Stream Manager Proxy Subscribe Example
- Android Stream Manager Subscribe Example
- iOS Stream Manager Subscribe Example
Notes
- You cannot make a subscribe request for a stream if it is not publishing
- If a stream stops publishing the subscribers must re-query the Stream Manager for stream details