This repository contains the watchRTC android SDK.
The SDK is geared towards those who want to collect WebRTC related data from an android application, log and analyze it as part of the testRTC environment.
Here is the documentation of the watchRTC sdk.
- The min android version supported by the SDK is Android-7 (Api Level 24).
- The SDK only required Internet permission.
- Kotlin version 1.7.21
- Add dependancy in app module build.gradle file.
implementation 'com.spearline:testrtc-watchrtc-sdk:1.0.0'
- Sync project
- Implement the
RtcDataProvider
interface and their methodgetStats(callback: GetStatsCallback)
The method getStats jobs is to generate webrtc stats report and once the report is avaialble need to callcallback.onStatsAvailable()
. To convert webrtc stats report to RTCStatsReport you can check this function.
private val rtcDataProvider = object : RtcDataProvider {
override fun getStats(callback: GetStatsCallback) {
// get stats report and call callback.onStatsAvailable(com.spearline.watchrtc.model.RTCStatsReport)
}
}
- Initialize WatchRTCConfig with your API Key and room id and other details
- Here is how to create WatchRTC API key
val config = WatchRTCConfig(
"<api-key>",
"<room-id>",
"<peer-id>",
"<keys>" //(optional)
)
- Create WatchRTC object
val watchRTC = WatchRTC(config, rtcDataProvider)
- Connect to watchRTC's servers. The connect() function may throw
IllegalStateException
if the valid config is not set and call this function.
/**
* Please call connect() once the peer connection is active where watchRTCConfig parameter is an optional,
* Please pass this argument only if you would like to use an updated configuration or not passed on constructor.
*/
watchRTC.connect(context, watchRTCConfig?)
-
Log webrtc events to watchRTC server you can use
watchRTC.trace()
function. Here is the sample app code for the same. This function may throw ConnectionException when facing issue to connecting server. Please handle this exception. -
Disconnect the call
//Please call disconnect() once the call have been disconnected.
watchRTC.disconnect()
- To print sdk logs in your application you have to set logger via calling
watchRTC.setLoggerImpl(WatchRTCLoggerImpl())
function. - You can use your custom logs implementation with use of ILogger interface implementation.
watchRTC.setConfig(WatchRTCConfig)
//Set WatchRTC configurationwatchRTC.addKeys(HashMap<String, ArrayList<String>>)
//Will be sent to WatchRTC's backend.watchRTC.setUserRating(Int, String)
//Set user provided rating with an optional comment.watchRTC.log(LogLevel,String)
//Log debug messages to WatchRTC's serverwatchRTC.trace(String, Any?)
: Boolean //Send RTC related events to WatchRTC's backend.watchRTC.addEvent(String, EventType, Any?)
//Send custom events to WatchRTC's backend.watchRTC.setLoggerImpl(iLogger: ILogger)
// To print SDK logs for debug perspective.