Skip to content

Latest commit

 

History

History

BandwidthDetectionDownloadOnly

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Bandwidth Detection (Download) with Red5 Pro

This example shows how to easily detect download bandwidth with Red5 Pro prior to subscribing to a stream.

Example Code

How to Check Bandwidth

Checking the download bandwidth prior to subscribing to a stream is relatively simple, requiring only a few pieces of setup.

  1. One must instantiate an R5BandwidthDetection instance
  2. One must then utilize the checkDownloadSpeed method of that instance
  3. Doing so requires passing in:
    1. The base url (usually the same as the host you would provide to your R5Configuration)
    2. How long you wish the total bandwidth test to take, in seconds
    3. Callback blocks for the successful and unsuccessful attempts at checking the bandwidth

A simplified example of this would be:

let detection = R5BandwidthDetection()

detection.checkDownloadSpeed("your-host", forSeconds: 2.5, withSuccess: { (Kbps) in
    print("Download speed is \(Kbps)Kbps\n")
}) { (error) in
    print("There was an error checking your download speed! \(error?.localizedDescription ?? "Unknown error")")
}

The rest of this example is based on SubscribeTest.swift and ensures that a minimum bandwidth (as defined by the tests.plist file) is met prior to subscribing to the stream.