The bit rate detection feature determines whether the uplink throughput (bit rate) of the connection meets the minimum requirements of the application.
Pia does not prevent a station from joining a session even if the measured bit rate is below the application's requirements. The handling of such stations is up to the application.
Consult with Nintendo before restricting the ability of users to join a game based on communication factors such as bit rate.
The following code sample shows how to use the bit rate detection feature.
Specify whether you will use the bit rate detection feature when instantiating the Session.
nn::pia::session::Session::Setting sessionSetting;
sessionSetting.bitRateCheckMode = nn::pia::session::BitRateCheck_Enable; // Using the Bit Rate Detection Feature . . . nn::pia::session::Session::CreateInstance(setting); |
You can specify the minimum bit rate required by the application and the IP packet size to use when measuring bit rate when starting up the Session.
When the bit rate detection feature is enabled and you do not want to run bit rate detection without destroying the session instance, you can set the isSkipBitRateCheck member variable to true and skip the bit rate detection processing. When skipping, the bit rate value obtained from GetUplinkBitRate() is not updated, and the value from when bit rate detection was previously run is returned.
Although it is possible to specify the time to perform measurement with the bitRateMeasuringSpan member variable, we recommend that you use the default value. The total required amount of time will be inflated if the time period is set to a value greater than what it takes for the session join process to be completed.
nn::pia::session::Session::StartupSetting startupSetting;
startupSetting.uplinkBitRateLowerLimit = 200 * 1000; // Bit rate required by the application. In bits per second. startupSetting.bitRateCheckPacketSize = 1024; // Size of the IP packets to send when measuring the bit rate. The value is in bytes. startupSetting.isSkipBitRateCheck = false; // Whether to skip the bit rate detection process. startupSetting.bitRateMeasuringSpan = 1000; // Time to spend measuring the bit rate. The units are in milliseconds. . . . nn::pia::session::Session::GetInstance()->Startup(startupSetting); |
After bit rate measurement processing is complete and Session::IsCompleteBitRateCheck() now returns true, call Session::GetUplinkBitRate(). The retrieved bit rate is in bits per second.
A negative value is set if no value could be measured because, for example, the other station did not respond.
nn::pia::session::Session* pSession = nn::pia::session::Session::GetInstance();
if(PIA_IS_VALID_POINTER(pSession)) { if (pSession->IsCompleteBitRateCheck()) { s32 bitRate = 0; nn::Result r = pSession->GetUplinkBitRate(&bitRate); if (r.IsSuccess()) { PIA_BASIC_REPORT("bitRate: %d\n", bitRate); // Prints a negative value if the measured value could not be obtained. } } } |