IWMSDataContainerVersion::GetExpirationTime

banner art

Previous Next

IWMSDataContainerVersion::GetExpirationTime

The GetExpirationTime method retrieves the content expiration date.

Syntax

  HRESULT GetExpirationTime(
  DATE*  pdateExpirationTime
);

Parameters

pdateExpirationTime

[out] Pointer to a DATE containing the expiration. The DATE type is implemented using an 8-byte floating point number. Days are represented by whole number increments starting with midnight on 30 December 1899 as time zero. Hour values are expressed as the absolute value of the fractional part of a day. This is illustrated in the following table.

Date Value
30 December 1899, midnight 0.00
30 December 1899, noon 0.50
1 January 1900, midnight 2.00
4 January 1900, midnight 5.00
4 January 1900, 6 A.M. 5.25
4 January 1900, noon 5.50
4 January 1900, 9 P.M. 5.875

Return Values

If the method succeeds, the plug-in must return S_OK. To report an error, the plug-in can return any HRESULT other than S_OK. If the plug-in uses the IWMSEventLog interface to log error information directly to the Windows Event Viewer, it is recommended that it return NS_E_PLUGIN_ERROR_REPORTED. 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 interface to send custom error information to the Windows Event Viewer, returning NS_E_PLUGIN_ERROR_REPORTED stops the server from also logging to the event viewer. For more information about retrieving plug-in error information, see Identifying Plug-in Errors.

Remarks

When content is downloaded, an expiration date must be associated with it. The date is specified by the origin sever to indicate the time at which content can no longer be considered current. A cache proxy plug-in must check the date to determine whether the content has expired. If it has, the plug-in must call IWMSCacheProxyServerCallback::OnCompareContentInformation so that the cache server can retrieve content information from the origin server and compare it to information about the cached content. If it has not expired, the plug-in can direct the server to stream the content to a client.

Example Code

// Declare variables.
HRESULT hr = S_OK;
IWMSDataContainerVersion *pContentVersion = NULL;
SYSTEMTIME stNow;
DATE dateNow;
DATE dateExp;
BOOL fExpired = TRUE;

// Retrieve a pointer to an IWMSDataContainerVersion interface from 
// the cache content information context pointed to by pContentInfo.
hr = pContentInfo->GetAndQueryIUnknownValue( 
         WMS_CACHE_CONTENT_INFORMATION_DATA_CONTAINER_VERSION,
         WMS_CACHE_CONTENT_INFORMATION_DATA_CONTAINER_VERSION_ID,
         IID_IWMSDataContainerVersion,
         (IUnknown **) &pContentVersion,
         0 );

// Retrieve the expiration date from the
// IWMSDataContainerVersion interface.
hr = pContentVersion->GetExpirationTime( &dateExp );
if (FAILED(hr)) goto EXIT;


// Retrieve the current date and time on the local computer.
GetSystemTime( &stNow );
SystemTimeToVariantTime( &stNow, &dateNow );

// Determine whether the content in the cache has expired.
if( dateNow < dateExp ) 
{
    fExpired = FALSE;
}

EXIT:
    // TODO: Release temporary objects.

Requirements

Header: datacontainerversion.h.

Library: WMSServerTypeLib.dll.

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

See Also

Previous Next