CDN based on WCS servers can be organized in two ways:
In this section we describe dynamic CDN based on Web Call Server 5.1.
Distributed dynamic content delivery network (CDN) based on WCS 5.1 operates as follows:
Upon startup of the server, a special CDN module starts. The module sends a request to the server specified as the CDN entry point to retrieve from it the list of other servers in the CDN and the list of available streams. If the entry point is not specified or if the specified server is not available, the module waits for a notification from another server in the CDN (for example, if that server was already added to the list of CDN servers on another server, or if it was specified as the entry point). As a result, each active CDN server at any given moment has the up-to-date list of all other CDN servers.
All interaction between nodes of CDN is performed via Websocket.
A server can perform one of two roles
Streams are not distributed by force. An Edge server fetches a specific stream from Origin only upon user request from a browser or a mobile application.
A stream name is unique for every WCS server (and identifies the stream unambiguously), but not for the CDN in a whole. Hence, there are two limitations:
To configure CDN, the following main settings in the flashphoner.properties file are used (see the complete list in the settings file description):
Parameter | Default value | Type | Description |
---|---|---|---|
cdn_enabled | false | Boolean | Enable/disable CDN |
cdn_ip | Empty | String | Server address in CDN |
cdn_nodes_resolve_ip | false | Boolean | Resolve server names to IP addresses |
cdn_point_of_enry | Empty | String | Address of the server, the entry point to CDN for the given server |
cdn_port | 8084 | Int | Port number for CDN |
cdn_role | edge | String | Role of the server in CDN: origin - source of streams for other servers in CDN edge - can receive streams from other servers |
Two servers: Origin (origin.flasphoner.com) and Edge (edge.flasphoner.com)
Origin settings:
cdn_enabled=true cdn_ip=origin.flashponer.com cdn_nodes_resolve_ip=true cdn_role=origin |
Edge settings:
cdn_enabled=true cdn_ip=edge.flashphoner.com cdn_nodes_resolve_ip=true cdn_point_of_entry=origin.flashponer.com cdn_role=edge |
Four servers: Origin1 (origin1.flasphoner.com), Origin2 (origin2.flasphoner.com) and Edge1 (edge1.flasphoner.com), Edge2 (edge2.flasphoner.com)
Origin1 settings:
cdn_enabled=true cdn_ip=origin1.flashponer.com cdn_nodes_resolve_ip=true cdn_role=origin |
Origin2 settings:
cdn_enabled=true cdn_ip=origin2.flashponer.com cdn_point_of_entry=origin1.flashponer.com cdn_nodes_resolve_ip=true cdn_role=origin |
Edge1 settings:
cdn_enabled=true cdn_ip=edge1.flashphoner.com cdn_point_of_entry=origin1.flashponer.com cdn_nodes_resolve_ip=true cdn_role=edge |
Edge2 settings:
cdn_enabled=true cdn_ip=edge2.flashphoner.com cdn_point_of_entry=origin1.flashponer.com cdn_nodes_resolve_ip=true cdn_role=edge |
Obtaining information about the current status of CDN from the WCS command line is performed with these commands:
Command | Description | Example result | |
---|---|---|---|
show cdn-nodes | Displays the list of node servers in CDN: ACTIVE - the server is running, responds to queries and/or sends notifications PASSIVE - the server is stopped or unavailable |
| |
show cdn-routes | Shows the list of active streams in CDN |
|
By default, when server is stopped or unavailable, it will be displayed in CDN nodes list in PASSIVE state until it will be started again or all the CDN will be stopped. The time interval may be set if necessary to remove inactive node from nodes list. This interval should be set in seconds using the following parameter in flashphoner.properties file, for example
cdn_nodes_timeout=60 |
In this case inactive nodes will be removed from CDN nodes list after 60 seconds of inactivity.
In order to avoid excessive transcoding when distributing streams, you need to coordinate codec settings on Origin and Edge servers. Let's take a look at three possible sound encoding configurations in the CDN intended to distribute a stream from the web camera and the RTMP encoder.
1. Distributing a stream captured from browser Chrome
1.1. Origin captures H.264+Opus stream from Chrome.
1.2. Edge pulls stream from Origin via WebRTС using H.264+Opus, there's no transcoding on Origin.
1.3. Subscriber pulls stream from Edge:
1.3.1. using H.264+Opus, there's no transcoding on Origin;
1.3.2. using H.264+AAC, there is transcoding Opus > AAC on Edge.
2. Distributing a stream captured from RTMP encoder
2.1. Origin captures H.264 stream from RTMP encoder:
2.1.1 AAC sound without transcoding:
2.1.2 Speex soind with transcoding to AAC.
2.2. Edge pulls stream from Origin via WebRTС using H.264+AAC.
2.3. Subscriber pulls stream from Edge:
2.3.1. using H.264+Opus, there is transcoding AAC > Opus Edge;
2.3.2. using H.264+AAC, there's no transcoding on Edge.
For this CDN to work, codecs should be configures as follows:
on Origin server
flash_handler_publish.sdp file should be created
v=0 o=- 1988962254 1988962254 IN IP4 0.0.0.0 c=IN IP4 0.0.0.0 t=0 0 a=sdplang:en m=video 0 RTP/AVP 96 a=rtpmap:96 H264/90000 a=fmtp:96 profile-level-id=42e01f;packetization-mode=1 a=sendonly m=audio 0 RTP/AVP 108 a=rtpmap:108 mpeg4-generic/48000/1 a=sendonly |
on Edge server
this parameter shuold be set in flashphoner.properties file
codecs_exclude_cdn=alaw,ulaw,g729,speex16,g722,telephone-event,flv |
and flash_handler_play.sdp file should be created
v=0 o=- 1988962254 1988962254 IN IP4 0.0.0.0 c=IN IP4 0.0.0.0 t=0 0 a=sdplang:en m=video 0 RTP/AVP 96 a=rtpmap:96 H264/90000 a=fmtp:96 profile-level-id=42e01f;packetization-mode=1 a=recvonly m=audio 0 RTP/AVP 108 a=rtpmap:108 mpeg4-generic/48000/1 a=recvonly |
1. Distributing a stream captured from browser Chrome
1.1. Origin captures H.264+Opus stream from Chrome.
1.2. Edge pulls H.264+Opus stream from Origin via WebRTC, there's no transcoding on Origin.
1.3. Subscriber pulls H.264+Opus stream from Edge, there's no transcoding on Edge.
2. Distributing a stream captured from RTMP encoder
2.1. Origin captures H.264 stream from RTMP encoder:
2.1.1 AAC sound with transcoding to Opus:
2.1.2 Speex sound with transcoding to Opus.
2.2. Edge pulls H.264+Opus stream from Origin via WebRTC.
2.3. Subscriber pulls H.264+Opus stream from Edge, there's no transcoding on Edge.
For this CDN to work, codecs should be configures as follows:
on Origin server
codecs setting should be default
on Edge server
this parameter shuold be set in flashphoner.properties file
codecs_exclude_cdn=alaw,ulaw,g729,speex16,g722,mpeg4-generic,telephone-event,flv |
1. Distributing a stream captured from browser Chrome
1.1. Origin captures H.264+Opus stream from Chrome with transcoding Opus > AAC.
1.2. Edge pulls H.264+AAC stream from Origin via WebRTС.
1.3. Subscriber pulls H.264+AAC stream from Edge, there's no transcoding on Edge.
2. Distributing a stream captured from RTMP encoder
2.1. Origin captures H.264 stream from RTMP encoder:
2.1.1 AAC sound without transcoding:
2.1.2 Speex sound with transcoding to AAC.
2.2. Edge pulls H.264+AAC stream from Origin via WebRTС.
2.3. Subscriber pulls H.264+AAC stream from Edge, there's no transcoding on Edge.
For this CDN to work, codecs should be configures as follows:
on Origin server
flash_handler_publish.sdp file should be created
v=0 o=- 1988962254 1988962254 IN IP4 0.0.0.0 c=IN IP4 0.0.0.0 t=0 0 a=sdplang:en m=video 0 RTP/AVP 96 a=rtpmap:96 H264/90000 a=fmtp:96 profile-level-id=42e01f;packetization-mode=1 a=sendonly m=audio 0 RTP/AVP 108 a=rtpmap:108 mpeg4-generic/48000/1 a=sendonly |
on Edge server
this parameter shuold be set in flashphoner.properties file
codecs_exclude_cdn=opus,alaw,ulaw,g729,speex16,g722,telephone-event,flv |
1. For testing we use:
2. For the test, configure CDN in the minimum configuration: one Origin and one Edge server
Origin settings:
cdn_enabled=true cdn_nodes_resolve_ip=true cdn_ip=origin.flashphoner.com cdn_role=origin |
Edge settings:
cdn_enabled=true cdn_nodes_resolve_ip=true cdn_point_of_entry=origin.flashphoner.com cdn_ip=edge.flashphoner.com cdn_role=edge |
Here origin.flashphoner.com and edge.flashphoner.com - are examples names of the WCS servers.
Restart Origin and Edge servers. Enter the command line interface of the Edge server, authorize and enter this command
show cdn-nodes |
The result of the command is as follows:
> show cdn-nodes Ip State --------------------------- origin.flashphoner.com ACTIVE |
3. Open the Two Way Streaming web application on the Origin server. Click the Connect button and specify the name of the broadcast stream testCDN:
4. Click the Publish button. The stream is published from the web camera:
5. Open the Player web application on the Edge server. Specify the name of the stream broadcast to the Origin server, testCDN:
6. Click the Start button. Playing of the testCDN stream starts.
7. In the command line interface of the Edge server enter the command
show cdn-routes |
The result of executing the command is:
> show cdn-routes Route Stream -------------------------------- 0-origin.flashphoner.com-0 testCDN |
8. Click the Stop button on the stream publishing page. Publishing stops:
On the play page of the Edge server playing of the stream also stops and the message "Stopped by publisher stop" displays.
1) Changing codec settings on the Edge server can lead to increased load on the server as a result of enabled transcoding.
Symptoms: when a large number of streams are broadcast, the load on the CPU of the Edge server increases
Solution: configure codec settings on Origin and Edge servers so to reduce excessive transcoding.
For instance, if the codec setting on the Origin server specifies the following set of codecs:
codecs=opus,mpeg4-generic,alaw,ulaw,g729,g722,telephone-event,h264,vp8 |
and the setting on the Edge server is
codecs=opus,speex16,mpeg4-generic,g729,g722,h264,vp8 |
then, when a stream is broadcast through the Edge server, audio transcoding from Speex16 or AAC is activated. With a large number of streams, the load to the CPU of the server can greatly increase.