FAQ
# Basics
# Will the shutdown of P2P service affect the normal play of video?
No. Videos will still play normally without P2P streaming.
# Do I need to replace or change my existing streaming solution / content delivery network (CDN) to use SwarmCloud?
No. SwarmCloud is a hybrid solution that integrates with and extends the capabilities of your existing infrastructure. This allows you to switch the solution on or off if needed and easily revert to your original method of delivery. All you have to do to integrate SwarmCloud, is to add a single library to your code.
# How does P2P works?
When used with streaming video, P2P technology creates a hierarchy of nodes to retrieve and redistribute video segments from an origin video source. A P2P network looks very much like an inverted tree, with root nodes retrieving video segments from the upstream origin server, and downstream nodes retrieving video segments from the upstream nodes, which in turn serve the segments to nodes downstream from them.
A P2P network controller (tracker) forms peer groups of end-user devices as they come online. The groups are based on geographic proximity, making the peers suitable to share content quickly and easily. The tracker can be hosted as a cloud-based service. When a user requests content, the P2P tracker checks the peer group to determine if the content has been previously stored. If a peer is found, the content will be provided without connecting to the original video source.
One of the strongest features of peer-to-peer (P2P) networking is that it needs virtually no infrastructure. The tracker can be deployed in the cloud as easily as anywhere else, since video traffic never passes through it. For the same reason, P2P networks are fast to deploy. As each viewer installs the P2P client on their device, they can join or start a P2P network with little other work required. When using WebRTC-based P2P, no client deployment is necessary and any device with a modern browser can participate in the peer network.
No matter how powerful the CDN, however, an influx of viewers at the most critical moment of the action will always be a challenge. An exciting game in which fans tune in en masse at kick-off, in the final minutes, or even in overtime can create network conditions which drive just as much action off the pitch as on it. For these reasons, we suggest incorporating P2P delivery technology to complete the delivery workflow.
SwarmCloud’s P2P Delivery solution offers wide device coverage across desktop, Android and iOS mobile devices and set-top boxes. Its algorithms take a quality-first approach, using metrics such as rebuffering, CPU, and battery life to adapt delivery to the resources of each device and help improve user experience overall during peak traffic hours.

# Does SwarmCloud work with tokenized streams?
Our products are compatible with tokenized streams. As we require some information about how you tokenize, this needs to be set up by our support team. You will need to provide tokenized sample URLs and if available a URL pattern.
# Do you add additional latency to my stream, or are there other potential problems?
No, SwarmCloud does not add additional latency to your stream. However, low latency environments can cause a drop in saving ratio when using SwarmCloud. We recommend the following setup for your HLS / Dash streaming playlist:
Segment length: at least 3 seconds
Playlist length: at least 6 segments
# What if viewers do not have enough uplink bandwidth?
SwarmCloud comes with an intelligent fallback system. Each end device keeps an open connection to the original content source (the CDN). The SwarmCloud Client SDK measures local bandwidth capacities and decides in real-time whether or not to use a WebRTC connection for content delivery. That means if viewers do not have enough bandwidth capacities to share content, they simply won't.
With this approach, SwarmCloud guarantees the optimal ratio between regular CDN traffic and WebRTC traffic between users. Furthermore, as SwarmCloud adapts to bandwidth changes in real-time, the network will always converge to this optimal state.
# How secure is the SwarmCloud service?
SwarmCloud transfers data between peers using WebRTC data channel, which is secured by SCTP protocols and DTLS encryption. Communication with the backend(tracker and signaling server) is done via HTTPS and secured WebSocket.
# Do you offer a self-hosted solution?
We don’t currently offer an on-premise option.
# How to buy a traffic package?
Log on to https://oms.cdnbye.com and click the Traffic Package on the left side. At present, Alipay and Paypal are supported to pay for the order. Please note that Alipay pays in RMB and Paypal in US dollars.
# How to deduct the traffic after buying the traffic package if multiple domain names/AppId are bound?
If you bind multiple domain names in one account, those which open P2P services share traffic packets together. You can save on packet consumption by shutting down P2P services of one or several domain names in P2P Setting.
# Does SwarmCloud interfere with DRM(Digital Right Management)?
No. P2P transmission is activated only after the user is authorized by the publisher’s server. Importantly, decryption key isn't transferred through the P2P network. The segments shared between peers are the same as what peers receive from the CDN. Also, content is never uploaded or stored in our server.
SwarmCloud works in a network layer to optimize the way segments are distributed between end devices. While doing this, all segments remain decrypted. As each segment is encrypted the same way for each user, there is no problem in exchanging those segments. Once a segment reaches an end device, the DRM service, that runs in a local application layer starts decrypting the segment.
# Will SwarmCloud bring a delay to a user's stream?
No. The first Segment is always downloaded from CDN. Additionally, if a video segment cannot be loaded from peers within the timeout period, our scheduling algorithm will switch to CDN mode in time. That means it works within the delay inherent to the HLS and MPEG-DASH protocols.
# Web SDK
# How does Web SDK work?
SwarmCloud implements WebRTC datachannel to scale live/vod video streaming by p2p network using bittorrent-like protocol. The built-in scheduling algorithm determines whether a peer should load the next segment from p2p network or the publisher’s alternative delivery system. hlsjs-p2p-engine is a hls.js wrapper provided by SwarmCloud for streaming HLS. Today SwarmCloud supports the vast majority of HTML5 players including Hls.js, JWPlayer, Video.js, Clappr, Flowplayer and TCPlayer.
# Is it possible to run SwarmCloud on iOS browsers?
Yes, we provide SDK based on ServiceWorker which can run p2p on iOS Safari.
# What happens if a user‘s browser doesn't support WebRTC?
If that happens, the user will seamlessly fallback to normal HTTP request without any side effect.
# Troubleshooting steps of Web SDK
- Open two or more webpages on the same LAN to play the same video
- It is recommended to configure live streaming according to the P2P optimization guide
- Open the webpage debugging window to view the debug information
- There is usually a warning message, fix it as prompted
- If no abnormality is displayed, please ensure that the m3u8 path does not change dynamically,or you may need to format a common channelId for people watching same content.
- If the above steps do not solve the problem, please contact technical customer service
# Do I need to update the code when a new version is being released?
No. The new versions are being loaded dynamically once you used the official CDN.
# My player is integrated via an iframe
In this case, you need to get access to the iframe’s content. As any Javascript code can not access the content of an iframe, the SwarmCloud web SDK needs to be located within the iframe.
# Native SDK
# Is Android TV supported?
Yes, Android TV is a supported platform for the SDK. Android SDK works with any Android player although we recommend ExoPlayer which we've found to give good playback results.
# Troubleshooting steps of native SDK
- Please make sure to debug on the real device
- Open 2 devices on the same LAN
- iOS
- Search for the keyword "P2P warning" in the xcode console and fix it according to the warning message
- If you still can't troubleshoot the problem, please turn on the log printing function first, as shown below:
let config = SWCP2pConfig.defaultConfiguration() config.logLevel = SWCLogLevel.debug config.logPersistent = true SWCP2pEngine.sharedInstance().start(token: YOUR_TOKEN, p2pConfig: config)
SWCP2pConfig *config = [SWCP2pConfig defaultConfiguration]; config.logLevel = CBLogLevelDebug; config.logPersistent = YES; [[SWCP2pEngine sharedInstance] startWithToken:YOUR_TOKEN andP2pConfig:config];
- Then you can find the log file in Library/Caches/Logs , send it to SwarmCloud technicians
- Android
- Search for the keyword "P2P warning" in the Logcat and fix it according to the warning message
- If you still can't troubleshoot the problem, please set the log level to Debug and save to file, as shown below:
P2pConfig config = new P2pConfig.Builder().logEnabled(true).logLevel(LogLevel.DEBUG).logPersistent(true).build(); P2pEngine.init(this, YOUR_TOKEN, config);
val config = P2pConfig.Builder().logEnabled(true).logLevel(LogLevel.DEBUG).logPersistent(true).build() P2pEngine.init(this, YOUR_TOKEN, config)
- Then you can find the log file in external storage (Environment.getExternalStorageDirectory() -> /Android/data/ , usually on the path "/storage/emulated/0") with file path like logger/logs_0.csv, please send it to SwarmCloud technicians
# Resolve some streams fail with HTTP response code 302 in exoplayer
It's working as intended that ExoPlayer doesn't follow cross-protocol redirects by default. You can enable following of cross-protocol redirects in ExoPlayer by passing allowCrossProtocolRedirects=true to the DefaultHttpDataSourceFactory constructor:
DataSource.Factory dataSourceFactory =
new DefaultHttpDataSourceFactory(
Util.getUserAgent(this, "p2p-engine"),
DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
true /* allowCrossProtocolRedirects */
);
For details, please see official demo (opens new window).
# How to reduce APK size?
SwarmCloud's core library weighs less than 300KB alone, but it uses some large dependencies such as the WebRTC C++ library, which is compiled for different architectures.
- abiFilters
The default behavior of the build system is to include the binaries for each ABI in a single APK, also known as a fat APK. A fat APK is significantly larger than one containing only the binaries for a single ABI; the tradeoff is gaining wider compatibility, but at the expense of a larger APK. To restrict the set of ABIs that your application supports, use abiFilters (opens new window).
android {
...
defaultConfig {
...
ndk {
abiFilters "armeabi-v7a", "armeabi"
}
}
}
- APK Splits
The solution google recommend is to split the builds per CPU architecture (opens new window).
android {
...
splits {
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
enable true
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86 and x86_64.
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include "x86", "x86_64"
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
universalApk false
}
}
}
# How to get Android APP Signature
Use keytool to get your certificate signature:
keytool -v -list -keystore path/to/my-signing-key.keystore
You will get the certificate fingerprint (MD5, SHA1, SHA256), the SHA1 value is what you need.