Unified API player statistics
Statistics are provided to the controlling application through a single method called repeatedly at regular intervals. To get statistics from an OTVUPIPlayer
instance, the application must:
Implement an
onStatisticsUpdate()
method as part of theIOTVUPIEventListener
interface, and provide the UPI Player with this implementation.Configure which statistics are reported and at what intervals.
Creating the callback method
As all Unified API events are passed to the application are delivered through the IOTVUPIEventListener
, so should the onStatisticsUpdate()
callback method. In your implementation of IOTVUPIEventListener
, implement the method as follows:
@Override
public void onStatisticsUpdate(OTVUPIStatistics xStatistics, int xEnabledStatistics) {
:
:
// your implementation
:
}
The CONNECT Player SDK provides a default implementation for the entire event listener in OTVUPIEventListener
which outputs to the console the statistics data.
Applying the listener in the player
As described in Unified API playback of clear content, you provide the player with your implemented instance of the listener class.
mIOTVUPIPlayer.setEventListener(new MyUPIEventListener());
Configuring the statistics output
The OTVUPIStatisticsConfig
class is used to configure:
The statistics groups to be reported.
The interval between the updated statistics.
The configuration class is set using the Builder design (see below).
Configuring the reported statistics groups (statistics types)
The statisticsTypes
parameter is a bit-mapped integer, where each bit in the integer represents a reporting group. A bit value of 1 enables a group, and a value of 0 disables it.
@interface StatisticsTypes {}
/** Disable statistics */
public static final int DISABLE_STATISTICS = 0;
/** Enable all statistics */
public static final int ALL_STATISTICS = ~0;
/** Enable rendering statistics */
public static final int RENDERING_STATISTICS = 1;
/** Enable network statistics */
public static final int NETWORK_STATISTICS = 1 << 1;
/** Enable playback statistics */
public static final int PLAYBACK_STATISTICS = 1 << 2;
/** Enable event statistics */
public static final int EVENT_STATISTICS = 1 << 3;
/** Enable DRM security statistics */
public static final int DRM_STATISTICS = 1 << 4;
The statisticsUpdateInterval
parameter is an integer representing the interval length (in ms) between statistics callbacks. The interval must be greater than 0. Otherwise, the default interval (5 seconds) is chosen.
To disable statistics reporting, set statisticsTypes
to OTVUPIStatisticsConfig.DISABLE_STATISTICS
(0
).
To set up statistics, instantiate and build your OTVUPIStatisticsConfig
class and send the configuration to the player.
myUpiPlayer
.setStatisticsConfig(
new OTVUPIStatisticsConfig.Builder()
.statisticsTypes(OTVUPIStatisticsConfig.ALL_STATISTICS)
.statisticsUpdateInterval(10000)
.build());
The callbacks will be invoked at regular intervals through the method specified above.
Receiving the statistics
All statistics are received in a single method parameter in the callback method.
void onStatisticsUpdate(OTVUPIStatistics xStatistics, int xEnabledStatistics)
The OTVUPIStatistics
parameter contains all the statistics requested (see the API documentation for details). the xEnabledStatistics
contains the same bit-map value as specified in the configuration.
The structure of the OTVUPIStatistics
instance remains the same regardless of the groups enabled / disabled in xEnabledStatistics
. However, the values disabled are not guaranteed to be populated with meaningful values.