Compartir a través de


IWMSCacheProxyServerCallback.OnGetContentInformation (Visual Basic .NET)

The OnGetContentInformation method is called by the server to respond when a cache plug-in calls IWMSCacheProxyServer.GetContentInformation.

IWMSCacheProxyServerCallback.OnGetContentInformation(  lHr As Int32,
  pContentInfo As IWMSContext,
  varContext As Object
)

Arguments

Int32 indicating whether the call to IWMSCacheProxyServer.GetContentInformation succeeded.

IWMSContextIWMSContext Object (Visual Basic .NET) containing a Cache Content Information Context. The context includes a variable named WMS_CACHE_CONTENT_INFORMATION_CONTENT_TYPE, which can be zero to indicate on-demand content, or one of the values in the following table, or a bitwise OR of both values.

Value

Description

WMS_CACHE_CONTENT_TYPE_BROADCAST

The content is a broadcast.

WMS_CACHE_CONTENT_TYPE_PLAYLIST

The content is a playlist.

Object containing a value defined by the plug-in when it called IWMSCacheProxyServer.GetContentInformation. For example, your plug-in can use this parameter to persist state information. The server does not alter this value and passes it back when calling OnGetContentInformation.

Return Value

This method does not return a value. To report an error, the plug-in can throw a COMException object to the server. If the plug-in uses the IWMSEventLogIWMSEventLog Object (C#) to log error information, it is recommended that it throw NS_E_PLUGIN_ERROR_REPORTED (0xC00D157D). Typically, the server attempts to make plug-in error information available to the server object model, the Windows Event Viewer, and the troubleshooting list in the details pane of the Windows Media Services MMC. However, if the plug-in uses the IWMSEventLog object to send custom error information to the Windows Event Viewer, throwing NS_E_PLUGIN_ERROR_REPORTED stops the server from also logging to the event viewer. For more information about plug-in error information, see Identifying Plug-in Errors.

Remarks

Cache proxy plug-ins generally call GetContentInformation when performing any of the following operations:

  • Rolling over to a different protocol

  • Establishing a cache-miss policy

  • Processing a prestuff request

In each case, the plug-in must get more information about the content before it can proceed. For example, to establish a cache-miss policy, the plug-in must determine whether the content is a broadcast, a playlist, or on demand. Also, before prestuffing content, it must determine whether the content can be cached.

Example

Imports Microsoft.WindowsMediaServices.Interop
Imports System.Runtime.InteropServices

Public Sub OnGetContentInformation(ByVal lHr As Integer, _
                                   ByVal ContentInformation As IWMSContext, _
                                   ByVal varContext As Object) _
  Implements IWMSCacheProxyServerCallback.OnGetContentInformation

    Dim nFlag As Integer
    Dim bAddCacheItem As Boolean
    Dim nRetHr As Integer
    Dim ci As ContentInfo
    Dim bDownloadInProgress As Boolean
    Dim MissResponse As WMS_CACHE_QUERY_MISS_RESPONSE

    Try
        ' Set default values.
        nFlag = 0
        bAddCacheItem = False
        nRetHr = 0

        ' Retrieve the user-defined ContentInfo object from the
        ' varContext parameter. The ContentInfo object describes
        ' an item of cached content.
        ci = varContext

        ' If this function is called from AddCacheItem(), lExpiration
        ' will not be zero, and you can call DownloadContent().
        If ci.lExpiration <> 0 Then
            bAddCacheItem = True
            lHr = 0
        End If

        ' Download the content if the server indicates that your
        ' plug-in's call to GetContentInformation() succeeded.
        If lHr = 0 Then
            ' Call a user-defined function, GetContentInfoFromContext(),
            ' to retrieve cache content information from the pContentInfo
            ' parameter. The context contains a reference to an
            ' IWMSDataContainerVersion object that the plug-in can use
            ' to retrieve content information. 
            GetContentInfoFromContext(ContentInformation, ci)

            ' Determine whether the content can be downloaded
            nFlag = ci.CacheFlags And WMS_DATA_CONTAINER_VERSION_CACHE_FLAGS.WMS_DATA_CONTAINER_VERSION_ALLOW_PROXY_CACHING

            If (nFlag <> 0) Or (bAddCacheItem = True) Then
                ' Identify a Cache URL.
                If ((Not bAddCacheItem) Or (bAddCacheItem And ci.CacheUrl = "")) Then
                    ci.CacheUrl = "C:\WMSCache\Test"
                End If

                ' Call a user-defined function, IsDownloadInProgress(), to
                ' determine whether there is a download in progress.
                bDownloadInProgress = IsDownloadInProgress(ci)
                If bDownloadInProgress = False Then
                    ' If there is no current download, call a user-defined
                    ' function, AddForDownload(), to add cache content
                    ' information to the DataSet object.
                    AddForDownload(ci)

                    ' Download the content by calling 
                    ' IWMSCacheProxyServer.DownloadContent().
                    CacheProxyServer.DownloadContent(ci.OriginUrl, _
                                                     ci.CacheUrl, _
                                                     0, 0, 0, 0, _
                                                     Me, _
                                                     Nothing, _
                                                     ci)
                Else
                    ' Debugging is already in progress.
                End If

                ' If the content is a broadcast, do not download it, but
                ' store the content information in the DataSet with an
                ' empty cache URL.
                If (ci.ContentType And 1) <> 0 Then
                    UpdateTable(ci)
                End If

            End If

        Else
            ' The server returned E_ACCESSDENIED in response to the
            ' plug-in's call to GetContentInformation().
            If lHr = -2147024891 Then
                nRetHr = 0
            End If

        End If

        ' Determine whether stream splitting is allowed.
        nFlag = ci.CacheFlags And WMS_DATA_CONTAINER_VERSION_CACHE_FLAGS.WMS_DATA_CONTAINER_VERSION_ALLOW_STREAM_SPLITTING

        ' If the stream can be split, broadcast the content.
        ' Otherwise, play the content on demand.
        If nFlag <> 0 Then
            MissResponse = WMS_CACHE_QUERY_MISS_RESPONSE.WMS_CACHE_QUERY_MISS_PLAY_BROADCAST
        End If

        ' Call IWMSCacheProxyCallback.OnQueryCacheMissPolicy.
        ci.CacheProxyCallback.OnQueryCacheMissPolicy(nRetHr, MissReponse, ci.OriginUrl, Nothing, ContentInformation, ci.varContext) Then

    Catch
        Throw New COMException()
    End Try

End Sub

Requirements

Reference: Add a reference to Microsoft.WindowsMediaServices.

Namespace: Microsoft.WindowsMediaServices.Interop.

Assembly: Microsoft.WindowsMediaServices.dll.

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; Windows Server 2008.

See Also

Concepts

IWMSCacheProxyServerCallback Object (Visual Basic .NET)