確定流媒體伺服器中每用戶端頻寬使用量
概要
某些時候,瞭解串連到伺服器的單個用戶端使用的頻寬很有用。有時由於一些功能(例如,快速啟動和快速緩衝),使用的頻寬可能大於內
容的傳輸率。本文說明了如何添加上下文值,使開發人員利用這些值以編程方式檢索此資訊。
要確定 Windows Media Services 9 Series 最準確的每用戶端頻寬統計資訊,您必需定義下面的兩個示範上下文值。您必須將這些值添加
到項目中的標題檔案中或 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)
添加示範上下文值後,您可以利用用戶端的示範上下文,通過檢索這兩個值然後加在一起得出總值來快速確定總的頻寬使用量。下面的程式碼範例顯示了操作步驟:
// 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;