Best Practices for Using Metering APIs

banner art

Metering data collects over time on a device as a user plays tracks on the device.

If the device is away from the personal computer for a long time, a large quantity of metering data can be collected. When this happens, it may take a long time to upload all the metering data from the device. This could negatively impact the user experience when a device docks. It is a good practice to limit the amount of metering data collected in a docking session. Applications can reduce the quantity of metering data collected in a docking session by calling the metering APIs more frequently.

Applications collect metering data by using the IWMDRMDeviceApp::GenerateMeterChallenge method. The metering data returned by IWMDRMDeviceApp::GenerateMeterChallenge must be posted to the metering service URL returned with the pbstrMeterURL argument. On receiving the metering data, the metering service will return a metering response. This response is sent back to the device by using the IWMDRMDeviceApp::ProcessMeterResponse method. The IWMDRMDeviceApp::ProcessMeterResponse will reset the counters for the metering data that was uploaded to the metering service.

Device manufacturers should avoid uploading all the metering data in a single call to IWMDRMDeviceApp::GenerateMeterChallenge. The underlying protocol used to communicate with the device has a request timeout of one minute. As a result, requests for large quantities of metering data may time out while the device is gathering the metering data requested. It is good practice for devices to send the metering data in smaller increments that can be processed well under one minute.

The quantity of metering data returned in each invocation of IWMDRMDeviceApp::GenerateMeterChallenge is regulated by the device. If a small amount of metering data is to be returned, a device may choose to return all the metering data in a single call. Large quantities of metering data might require multiple invocations of IWMDRMDeviceApp::GenerateMeterChallenge. Applications can determine if more metering data remains on the device by checking the pwdFlags argument in IWMDRMDeviceApp::ProcessMeterResponse method. The presence of additional metering data on the device is indicated by the WMDRM_METER_RESPONSE_PARTIAL flag. If all of the metering data has been collected, the WMDRM_METER_RESPONSE_ALL flag is set. Applications should check these flag and may choose to collect the remaining metering data from the device by using further invocations of IWMDRMDeviceApp::GenerateMeterChallenge.

It is acceptable to do a partial upload of metering data. Applications may choose to do this if they have already spent a reasonable amount of time uploading metering data and spending more time would impact the user experience. The device will retain all the remaining metering data till the next upload.

See Also