Skip to content

Commit 8a0c421

Browse files
Add documentaiton on README
1 parent 72d7ae9 commit 8a0c421

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

Client-Observability-Java/README.md

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,44 @@
11
# Client Observability Java
22

3-
This application provides a completed version of the OpenTok [Client Observability tutorial](https://tokbox.com/developer/tutorials/android/) for Android (differing only in some additional validation checks). Upon deploying this sample application, you should be able to have two-way audio and video communication using OpenTok.
3+
This application, built on top of Basic Video Chat, showcases how to retriebe all statistics from the entire system, being they from session, publisher and/or subscriber level.
44

5-
Main features:
6-
* Connect to an OpenTok session
7-
* Publish an audio-video stream to the session
8-
* Subscribe to another client's audio-video stream
5+
## Code sample - Subscriber Stats
6+
7+
The user can retrieve video stats, conatining information such as ```videoPacketsLost``` and ```videoPacketsReceived``` by implementing listener SubscriberKit.VideoStatsListener.
8+
9+
It is also possible to access estimated sender stats (```currentBitrate``` and ```maxBitrate```). For this it is necessary making sure publisher enables sender statistics track. By default it is not enabled.
10+
11+
12+
```java
13+
14+
publisher = new Publisher.Builder(MainActivity.this).senderStatisticsTrack(true).build();
15+
session.publish(publisher);
16+
17+
18+
...
19+
20+
21+
subscriber = new Subscriber.Builder(MainActivity.this, stream).build();
22+
subscriber.getRenderer().setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
23+
subscriber.setSubscriberListener(subscriberListener);
24+
subscriber.setVideoStatsListener(videoStatsListener);
25+
session.subscribe(subscriber);
26+
27+
...
28+
29+
SubscriberKit.VideoStatsListener videoStatsListener = new SubscriberKit.VideoStatsListener() {
30+
@Override
31+
public void onVideoStats(SubscriberKit subscriber, SubscriberKit.SubscriberVideoStats stats) {
32+
Log.d(LOG_TAG, "onVideoStats: Data received");
33+
Log.d(LOG_TAG, "onVideoStats: Sender Stats currentBitrate" + (stats.senderStats != null ? stats.senderStats.currentBitrate : "NULL"));
34+
Log.d(LOG_TAG, "onVideoStats: Sender Stats maxBitrate" + (stats.senderStats != null ? stats.senderStats.maxBitrate : "NULL"));
35+
Log.d(LOG_TAG, "onVideoStats: videoBytesReceived" + stats.videoBytesReceived);
36+
Log.d(LOG_TAG, "onVideoStats: timeStamp" + stats.timeStamp);
37+
Log.d(LOG_TAG, "onVideoStats: videoPacketsLost" + stats.videoPacketsLost);
38+
Log.d(LOG_TAG, "onVideoStats: videoPacketsReceived" + stats.videoPacketsReceived);
39+
}
40+
};
41+
```
942

1043
# Configure the app
1144
Open the `OpenTokConfig` file and configure the `API_KEY`, `SESSION_ID`, and `TOKEN` variables. You can obtain these values from your [TokBox account](https://tokbox.com/account/#/).

0 commit comments

Comments
 (0)