Share via


Downloading Content

banner art

Previous Next

Downloading Content

This section builds on the information presented in Cache Hit with Expired Content and Cache Miss to identify specific tasks your plug-in must perform when downloading content from another server. You can download either a single file or a playlist of files. The following steps identify one possible way that the server and cache proxy plug-in can interact when a client requests digital media. The actual interaction between a server and a plug-in depends on how you implement the plug-in.

  • Note   When downloading content, your plug-in must persist metadata information for clients who later connect and stream from cache. Metadata is used to describe content. It can include information such as the name of the author, the rating, and the copyright, and it can originate from the file header or from external sources. Saving metadata is discussed in the following.
  1. The plug-in calls DownloadContent on the IWMSCacheProxyServer interface.

  2. The server calls OnDownloadContentProgress on the IWMSCacheProxyServerCallback interface once for each media element that you are downloading. If you are downloading a playlist, this method is called for each item in the list.

  3. When the server calls OnDownloadContentProgress, it passes a pointer to an IWMSContext interface in the pArchiveContext parameter. The WMS_ARCHIVE_CONTENT_DESCRIPTION_LIST_BUFFER value of this context contains a pointer to an INSSBuffer interface that contains serialized metadata for the content. Your plug-in should not modify the metadata.

  4. The plug-in must allocate an IWMSContext object that it can use to identify the individual INSSBuffer objects created by the server to persist metadata for the content being downloaded. For more information about creating contexts, see AllocIWMSContext on the IWMSClassObject interface.

  5. The plug-in must create a playlist file that identifies the location of the cached content and an associated ID string. For example, if you are downloading a playlist that contains two media elements, your file must have a format similar to the following.

    <seq>
    <media src="c:\archive_0" cacheID="id_0" />
    <media src="c:\archive_1" cacheID="id_1" />
    </seq>
    

  6. Each time the server calls OnDownloadContentProgress, the plug-in must add another name-value pair to the context it allocated in step 4. The name must consist of the cacheID attribute (see the playlist in step 5), and the value must equal the INSSBuffer pointer passed by the server in the pArchiveContext parameter when it called OnDownloadContentProgress. For more information about specifying name-value pairs, see the IWMSContext interface.

  7. The server calls OnDownloadContentFinished on the IWMSCacheProxyServerCallback interface when all files have been downloaded.

The following diagram illustrates the downloading process and highlights the steps needed to persist metadata.

Diagram illustrating how to write a plug-in that downloads content from an origin server.

After the content has been downloaded, if the plug-in is able to declare an on-demand cache hit the next time that a client requests the content, the plug-in must pass to the server the locations of the buffers used to store metadata for the content. This is accomplished by the following steps:

  1. The server calls QueryCache on the IWMSCacheProxy interface of the cache plug-in.
  2. The plug-in calls OnQueryCache on the IWMSCacheProxyCallback interface and passes WMS_CACHE_QUERY_HIT_PLAY_ON_DEMAND in the Response parameter. The plug-in must also pass a URL for the playlist (see step 5 of the preceding discussion) in the bstrCacheUrl parameter. Finally, the plug-in must return a pointer to the IWMSContext object it created to hold the content description list (see step 4). It must specify the pointer to this context in the WMS_CACHE_CONTENT_INFORMATION_CONTENT_DESCRIPTION_LISTS value of the IWMSContext object that it passes back to the server through the pContentInfo parameter.

See Also (General)

See Also (Visual Basic .NET)

See Also (C#)

See Also (C++)

Previous Next