New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android refactoring + rtc stats #58
base: development
Are you sure you want to change the base?
Conversation
Better estimation of availableOutgoingBitrate
} | ||
jitter = rtcStatObject.optDouble(JITTER, -1); | ||
} else if (CANDIDATE_PAIR.equals(statType)) { | ||
boolean isNominated = rtcStatObject.optBoolean(IS_NOMINATED, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think several candidates may be nominated. Why not using the selectedCandidatePairId
from the transport stats?
https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidatePairStats/selected
private AlertDialog dialog; | ||
public class MainActivity extends Activity { | ||
static final String LOGTAG = "quality-stats-demo"; | ||
private static final String SESSION_ID = "YOUR_SESSION_ID"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the most distracted users, let's add some documentation on the README about this. By not being empty anymore the app will no longer alert the user and will try to connect for the duration of the timeout.
mHandler.postDelayed(statsRunnable, TEST_DURATION * 1000); | ||
} | ||
``` | ||
To stop the test, you can call stopTest. If the test is halted before 5 seconds, an error will be triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: change "you can call stopTest" to "you can call NetworkQualityTest.stopTest()"
@@ -1,7 +1,11 @@ | |||
OpenTok Android Network Test Sample | |||
=================================== | |||
|
|||
This sample shows how to use this OpenTok Android SDK to determine the appropriate audio and video | |||
# NetworkQualityTest | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Link to NetworkQualityTest README
|
||
6. **Clean Up** | ||
|
||
To ensure proper resource release, you should handle cleanup when needed. In your `onPause` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken, onPause() is triggered when app goes to the background. Video is off, but audio is still on. Having that in mind, don't know if there is the need to stop the test (of course, knowing without video, the stats will go up). Your call
@@ -9,6 +8,8 @@ | |||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> | |||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WRITE_EXTERNAL_STORAGE permission does not have to be requested on the java side as well? On java side only see camera, internet and audio.
Log.d(LOGTAG, "Audio Packet Lost Ratio " + stats.getAudioPacketLostRatio() * 100 + "%"); | ||
Log.d(LOGTAG, "Video Packet Lost Ratio " + stats.getVideoPacketLostRatio() * 100 + "%"); | ||
Log.d(LOGTAG, "Jitter: " + stats.getJitter()); | ||
Log.d(LOGTAG, "Quality Limitation Reason: " + stats.getQualityLimitationReason()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can change the previous logs with Log.d(LOGTAG, sentVideoInfo);
. In the future if we have to change something, we only have to change it in one place
} | ||
}); | ||
// Start the quality test | ||
networkQualityTest.startTest(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we only start the test when we start publishing? What if the user does not provide the permissions, or takes a lot of time to do so, and the test finishes without even having published? (Based on what I understood, if not explicitly stopped the test only takes 30s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved permission to the MainActivity and only run the test now if the user accepted the permissions.
```java | ||
new NetworkQualityTestCallbackListener() { | ||
@Override | ||
public void onQualityTestResults(String recommendedSetting) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the recommendedSetting
be do not use video
or something similar? If the minimum conditions are not met?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a threshold where the video is not recommended, added it to the docs and comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks great.
I left some comments. The majority are nit.
Tomorrow I will test the app to do a final validation
- `onQualityTestResults`: Receive the final test results and the recommended setting based on quality thresholds. | ||
- `onQualityTestStatsUpdate`: Receive real-time statistics updates during the test. | ||
- `onError`: Handle errors that occur during the test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide more details on the API:
onQualityTestResults()
-- What are the possible values ofrecommendedSetting
, and what do they mean?onQualityTestStatsUpdate()
-- What are the properties ofCallbackQualityStats
, and what do they mean?onError()
-- What are the possible errors, and what do they mean?
* Voice-only -- Your bandwidth is too low for video. | ||
You can configure the following parameters: | ||
|
||
- `sessionId`: The session ID of your OpenTok session. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention that this should be a routed session (right?) And mention that this session should only be used for the test (not for communications).
- `resolution`: The camera capture resolution for the publisher. Defaults to `HIGH` if not specified. | ||
- `testDurationSec`: The duration of the test in seconds. Defaults to `30 sec` if not specified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are possible values for resolution
and testDurationSec
.
The `NetworkQualityTest` class is a utility for testing network quality and gathering statistics | ||
during video streaming sessions using the OpenTok platform. It allows you to monitor various network | ||
and media statistics, such as video bitrate, audio quality, round-trip time, and more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a link to the docs on the callback methods (see my comments on the main README).
Note: A dev branch should be created so we can merge this after review
Complete refactoring of Android code. Using a similar approach of OPENTOK network library JS.
Added
NetworkQualityTest
class is a utility for testing network quality and gathering statistics during video streaming sessions using the OpenTok platform. It allows monitoring various network and media statistics, such as video bitrate, audio quality, round-trip time, and more.The NetworkQualityTest will send regular callbacks which can be handled using NetworkQualityTestCallbackListener.
The
MainActivity
class is a sample that shows how to use this class and how to handle the callback.