Export (0) Print
Expand All

Hosting a Metering Aggregation Service

banner art
PreviousNext

Hosting a Metering Aggregation Service

You can host a metering aggregation service to collect metering data as follows:

  1. Create a metering certificate.

    To acquire a metering certificate, the metering aggregation service generates a public-private key pair (for example, by using the WMRMKeys.GenerateSigningKeys method) and sends the public key to Microsoft, along with the URL to the service. Microsoft sends back a signed metering certificate, which contains a metering ID and the URL of the metering aggregation service.

    The metering aggregation service must keep the private key for the metering certificate secure. Metering data that is collected by a media player is encrypted with the public key from the metering certificate and is reported to the metering aggregation service. Only the private key can decrypt this information.

    The metering aggregation service shares the metering certificate with the license issuers who request to use the metering aggregation service.

  2. Provide end users with a metering plug-in for the media player.

    Periodically, metering data should be collected and reported to the metering aggregation service. To request metering data, create a media player application or plug-in that is distributed to consumers. The IWMDRMDeviceApp and IWMDRMDevice interfaces of the Windows Media Device Manager 10 SDK (included with Windows Media Format 9.5 SDK) provide methods to request metering data and to process the metering response from the metering aggregation service.

    Important   Microsoft recommends that you notify end users that you will be collecting metering data.

    When the plug-in or application requests metering data, the DRM component in the media player retrieves the data for a specific metering ID from the data store. The plug-in or application forwards this data as a metering challenge to the corresponding metering aggregation service.

    When the metering aggregation service has finished processing the data, the service returns a metering response to the plug-in or application, which forwards the response to the media player. This response indicates to the media player which items were successfully reported, and those items are then cleared from the data store.

  3. Collect metering data and issue a response.

    The metering aggregation service decrypts the challenge containing metering data using the metering certificate private key. Then, the metering data can be extracted into an XML string or into an object. Each object contains metering data for one metering ID. First, this data is organized into a collection of items corresponding to content. Each content item contains a collection of items that correspond to actions. Each action item contains a name and value, indicating an action and its count, such as PLAY and 10.

    The object hierarchy looks like this:

    WMRMMetering
        WMRMMeteringData
             WMRMMeteringContentCollection
                  WMRMMeteringContent
                       WMRMMeteringActionCollection
                            WMRMMeteringAction

    After metering data has been collected, the metering aggregation service sends back a response, which instructs the media player to clear and reset the data store for the items that were just reported.

    Create the metering response as follows:

    1. Use the WMRMMetering.MeteringCertificate property to specify your metering certificate.
    2. Use the WMRMMetering.GetMeteringResponse method to generate a response to the client.

Example Code

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Declare variables.
'""""""""""""""""""""""""""""""""""""""""""""""""""""" 
Dim MObj                    ' WMRMMetering object
Dim MDataObj                ' WMRMMeteringData object
Dim MContentCollObj         ' WMRMMeteringContentCollection object
Dim MContentObj             ' WMRMMeteringContent object
Dim MActionCollObj          ' WMRMMeteringActionCollection object
Dim MActionObj              ' WMRMMeteringAction object

Dim MeterChallenge          ' Metering challenge from the client
Dim MASPrivateKey           ' Private key of the metering aggregation service
Dim MeterCert               ' Metering certificate
Dim MeterXMLString          ' Metering data in XML format
Dim MeterID                 ' Metering ID
Dim TransID                 ' Transaction ID
Dim ContentCollLength       ' Number of items in the content collection
Dim ContentKeyID            ' Key ID for a content item
Dim ActionCollLength        ' Number of items in the action collection
Dim ActionName              ' Action name
Dim ActionValue             ' Action count
Dim MeterResponseString     ' Metering response string
Dim x, y                    ' Counters

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Set variables.
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
MeterChallenge = "<Replace with a metering challenge from the client>"
MeterCert = "<Replace with your metering certificate>"
MASPrivateKey = "<Replace with the private key for your service>"

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Extract metering data an a WMRMMeteringData object and as an XML string.
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
Set MObj = Server.CreateObject("WMRMObjs.WMRMMetering")
MObj.ServerPrivateKey = MASPrivateKey
MObj.Challenge = MeterChallenge
Set MDataObj = MObj.GetMeteringData
Set MeterXMLString = MObj.GetMeteringDataAsXml
MeterID = MDataObj.MeteringId
TransID = MDataObj.TransactionId

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Retrieve the collection of content items.
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
Set MContentCollObj = MDataObj.ContentCollection
ContentCollLength = MContentCollObj.length

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Retrieve the key ID and action data for each content item.
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
For x = 0 To (ContentCollLength - 1)
    Set MContentObj = MContentCollObj.item(x)
    ContentKeyID = MContentObj.KeyID

    '"""""""""""""""""""""""""""""""""""""""""""""""""""""
    ' Retrieve the collection of actions for the current content item.
    '"""""""""""""""""""""""""""""""""""""""""""""""""""""
    Set MActionCollObj = MContentObj.Actions
    ActionCollLength = MActionCollObj.length

    '"""""""""""""""""""""""""""""""""""""""""""""""""""""
    ' Retrieve each action and its value.
    '"""""""""""""""""""""""""""""""""""""""""""""""""""""
    For y = 0 To ActionCollLength - 1
        Set MActionObj = MActionCollObj.item(y)
        ActionName = MActionObj.Name
        ActionValue = MActionObj.Value
    Next
Next

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Generate the metering response.
'""""""""""""""""""""""""""""""""""""""""""""""""""""" 
MObj.MeteringCertificate = MeterCert
MeterResponseString = MObj.GetMeteringResponse

See Also

PreviousNext

© 2007 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft