Determine the bandwidth usage of each client on the Streaming Media Server
Summary
In some cases, it is useful to know the bandwidth used by a single client connected to the server. Sometimes, due to some features (such as Quick Start and quick cache), the bandwidth used may be larger
Capacity transfer rate. This article describes how to add context values so that developers can use these values to retrieve this information programmatically.
To determine the most accurate bandwidth statistics for each client in Windows Media Services 9 series, you must define the following two context values. You must add these values
To the project header file or wmscontextnames. h.
// Type: Long
// Description: bandwidth allocated.
Define_name_and_hint (wms_present_allocated_bandwidth, "wms_present_allocated_bandwidth", 30)
// Type: Long
// Description: bandwidth allocated by network sink.
Define_name_and_hint (wms_present_bandwidth_allocated_by_networksink, "wms_present_bandwidth_allocated_by_networksink", 48)
After adding the demo context value, you can use the demo context of the client to quickly determine the total bandwidth usage by retrieving the two values and then adding them together to get the total value. The following code example shows the operation steps:
// Declare variables.
Long lsinkallocatedbandwidth = 0;
Long ldatapathallocatedbandwidth = 0;
Long ltotalbandwidth = 0;
HR = ppresentationcontext-> getlongvalue (
Wms_present_bandwidth_allocated_by_networksink,
Wms_present_bandwidth_allocated_by_networksink_id,
& Lsinkallocatedbandwidth,
0 );
If (failed (HR ))
{
HR = s_ OK;
Lsinkallocatedbandwidth = 0;
}
HR = ppresentationcontext-> getlongvalue (
Wms_present_allocated_bandwidth,
Wms_present_allocated_bandwidth_id,
& Ldatapathallocatedbandwidth,
0 );
If (failed (HR ))
{
HR = s_ OK;
Ldatapathallocatedbandwidth = 0;
}
Ltotalbandwidth = lsinkallocatedbandwidth + ldatapathallocatedbandwidth;