This example shows how to easily detect upload bandwidth with Red5 Pro prior to publishing a stream.
Checking the upload bandwidth prior to publishing a stream is relatively simple, requiring only a few pieces of setup.
- One must instantiate an
R5BandwidthDetectioninstance - One must then utilize the
checkUploadSpeedmethod of that instance - Doing so requires passing in:
- The base url (usually the same as the
hostyou would provide to yourR5Configuration) - How long you wish the total bandwidth test to take, in seconds
- Callback blocks for the successful and unsuccessful attempts at checking the bandwidth
- The base url (usually the same as the
A simplified example of this would be:
R5BandwidthDetection detection = new R5BandwidthDetection(this); // Or your listener that implements R5BandwidthDetection.CallbackListener
try {
detection.checkUploadSpeed("your-host-here", 2.5);
} catch (Exception e) {
e.printStackTrace();
}The rest of this example is based on PublishTest.java and ensures that a minimum bandwidth (as defined by the tests.xml file) is met prior to publishing to the stream.