A context is an object that inherits and implements the IPropertyMap interface that manipulates the encapsulated member data. When the encapsulated data define a server, a user, or some content, the object is known as a server context, a user context, or a presentation context, respectively. The NetShow server uses contexts to pass client, server, and presentation data to the notification and authorization components. The IPropertyMap interface supports methods for adding, removing, evaluating, and modifying the properties of name/value pairs of data. The NetShow server maintains several different contexts to describe different aspects of each server task. Contexts supported by the server include the following:
Context | Description |
Server | Contains information about the Netshow server. |
User | Contains information about the client. |
Presentation | Contains information about the media stream. |
Command | Reserved for future implementation. |
Following is a list of predefined server context properties that are maintained by the server:
Property Name | Description |
NSS_SERVER_NAME | A string value containing the server’s name. |
NSS_VIRTUAL_SERVER_NAME | A string value containing the server’s alias. |
NSS_SERVER_VERSION_HI | The high-order 32 bits of a 64-bit integer specifying the version of the NetShow server. The most significant 16 bits of this property indicate the version. The least significant 16 bits of this property indicate the minor version. |
NSS_SERVER_VERSION_LO | The low-order 32 bits of a 64-bit integer specifying the version of the NetShow server. The most significant 16 bits of this property indicate the minor minor version. The least significant 16 bits of this property indicate the build number. |
Following is a list of predefined user context properties that are maintained by the server:
Property Name | Description |
NSS_USER_AGENT | A String value containing the information about the user connecting to the server. It can be used to differentiate whether the connected user is a player or another server. This property may not contain valid information if it is stripped by a proxy. |
NSS_USER_IP_ADDRESS | A String value containing the user’s IP address. The IP address may not be meaningful if it is masked by a firewall. The value of this property may change for different connections of the same client. |
NSS_USER_CONTROL_PROTOCOL | A String value containing the protocol type. Valid types include; MMS, RTSP, HTTP, and UNKNOWN. |
NSS_USER_ID | A String value containing the client ID. This ID corresponds with the ClientId property of the NetShow Unicast Manager Admin control, and it can be used to disconnect the client. |
NSS_USER_NAME | A String value containing the user name. This property is only valid after the user has been successfully authenticated. |
NSS_USER_AUTHENTICATOR | A pointer to the IUnknown interface of the authenticator object used to authenticate the user. |
NSS_USER_GUID | A String value containing the client GUID. This GUID is generated when the player is installed on the client computer. |
Following is a list of predefined presentation context properties that are maintained by the server:
Property Name | Description |
NSS_PRESENT_LIVE | A Boolean value specifying whether or not the presentation is live. |
NSS_PRESENT_BROADCAST | A Boolean value specifying whether or not the presentation is being broadcast. |
NSS_PRESENT_SEEKABLE | A Boolean value specifying whether or not the file supports seeking to a specific time or marker. |
NSS_PRESENT_STRIDABLE | A Boolean value specifying whether or not the file supports fast forward and rewind. |
NSS_PRESENT_RELIABLE | A Boolean value specifying whether or not the presentation is reliable. |
NSS_PRESENT_PHYSICAL_NAME | A String value containing the name of the file being streamed. |
NSS_PRESENT_REQUEST_NAME | A String value containing the name the client used to request the presentation. |
NSS_PRESENT_BITRATE | A floating-point value indicating the bit-rate of the stream. |
NSS_PRESENT_DURATION_HI | The high-order 32 bits of a 64-bit integer indicating the duration of the movie in miliseconds. |
NSS_PRESENT_DURATION_LO | The low-order 32 bits of a 64-bit integer indicating the duration of the movie in miliseconds. |
NSS_PRESENT_FRAMES_PER_SEC | An integer indicating the number of frames per second. |
NSS_PRESENT_PLAY_RATE | A floating-point value indicating the play rate of the presentation. A value of 1 indicates normal speed. Values greater than 1 indicate that the presentation is being fast-forwarded, and negative values indicate rewind. |
NSS_PRESENT_START_POS_HI | The high-order 32 bits of a 64-bit integer indicating the starting position of the movie. |
NSS_PRESENT_START_POS_LO | The low-order 32 bits of a 64-bit integer indicating the starting position of the movie. |
NSS_PRESENT_TOTAL_BYTES_SENT_HI | The high-order 32 bits of a 64-bit integer indicating the total number of bytes of the presentation that were sent to the client. |
NSS_PRESENT_TOTAL_BYTES_SENT_LO | The low-order 32 bits of a 64-bit integer indicating the total number of bytes of the presentation that were sent to the client. |
NSS_PRESENT_TOTAL_PLAY_TIME_HI | The high-order 32 bits of a 64-bit integer indicating the total time the presentation was streamed to the client in milliseconds. |
NSS_PRESENT_TOTAL_PLAY_TIME_LO | The low-order 32 bits of a 64-bit integer indicating the total time the presentation was streamed to the client in milliseconds. |
The server sets different context properties for different types of events. The following table lists the property values that are set by the server for initialization or when authorization or notification of an event occurs:
Events | Properties Set By Server |
When initialization occurs | Server Context: NSS_SERVER_NAME NSS_VIRTUAL_SERVER_NAME NSS_SERVER_VERSION_HI NSS_SERVER_VERSION_LO |
NSSE_CONNECT and NSSE_DISCONNECT |
Server Context: NSS_SERVER_NAME NSS_VIRTUAL_SERVER_NAME NSS_SERVER_VERSION_HI NSS_SERVER_VERSION_LO
User Context: |
NSSE_SKIP_AUTHENTICATION | Server Context: NSS_SERVER_NAME NSS_VIRTUAL_SERVER_NAME NSS_SERVER_VERSION_HI NSS_SERVER_VERSION_LO
User Context:
Presentation Context: |
NSSE_OPEN and NSSE_CLOSE |
Server Context: NSS_SERVER_NAME NSS_VIRTUAL_SERVER_NAME NSS_SERVER_VERSION_HI NSS_SERVER_VERSION_LO
User Context:
Presentation Context: |
NSSE_PLAY and NSSE_STOP * items are only set for the NSSE_STOP event. |
Server Context: NSS_SERVER_NAME NSS_VIRTUAL_SERVER_NAME NSS_SERVER_VERSION_HI NSS_SERVER_VERSION_LO
User Context:
Presentation Context:
*NSS_PRESENT_TOTAL_BYTES_SENT_HI |
Note The NSS_USER_AUTHENTICATOR and NSS_USER_NAME properties are NOT set by the server unless authentication is enabled and the user has successfully been authenticated.
The notification and authorization component can add new properties to the server, user, or presentation contexts, and set or retrieve the existing properties at any time during the life of the context. For example, the fee charged for viewing the title can be added to the presentation context when the title is opened. Then the billing cost can easily be retrieved from the context when the server sends notification that the title has been closed.
Each context holds the value of its properties for a predetermined duration or lifetime. The values contained in the context can be set and retrieved until the end of that context’s lifetime. The following table details the lifespans of the contexts:
Context | Lifetime |
Server | Always available. |
User | Available from the time the client connects to the server up to the time the client disconnects. |
Presentation | Available from the time the title is opened up to the time the title is closed. A new presentation context is created for each title that is opened by each client. |
Note: The pointer to the context may be lost immediately after the method returns. To maintain access to the properties during asynchronous calls, call AddRef to increment the interface’s reference counter. Alternately, the data needed by the component could be stored in temporary variables. If AddRef is used, the component should call Release to free the pointer when the context is no longer needed.
The following code demonstrates how you can retrieve the user name from the user context:
HRESULT hres;
VARIANT userName;
hres = pUser->QueryInterface(IID_IPropertyMap,
(void**) &pIUserPropMap);
hres = pIUserPropMap->Read(_T("NSS_USER_NAME"),
&userName);
© 1996-1998 Microsoft Corporation. All rights reserved.