IWMSTransportProperties::GetStreamProperties

The GetStreamProperties method retrieves properties of a stream.

Note

This method is available only on Windows Server 2003, Enterprise Edition with Service Pack 1; Windows Server 2003, Datacenter Edition with Service Pack 1; and Windows Server 2008.

HRESULT GetStreamProperties(
  DWORD  dwStreamId,
  DWORD  dwAlternateIndex,
  IWMSContext**  ppProps
);

Arguments

dwStreamId

[in] DWORD containing the stream ID of the stream.

dwAlternateIndex

[in] DWORD containing the unique alternate index of the stream.

ppProps

[out] Pointer to a pointer to an IWMSContextIWMSContext Interface containing the properties of the stream.

Return Value

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Remarks

If you are using RTSP to stream content, you can retrieve the UDP port number of a connected client. To retrieve this value, you must create a custom event notification plug-in that accesses the RTSP SETUP request sent by the client during the initial setup process. You can then use GetStreamProperties to retrieve a pointer to an IWMSContext interface that contains the transport settings that were defined in the SETUP request.

Example

The following example shows how to retrieve the UDP port number of a connected client through the use of a user-defined method. Add WMS_EVENT_SELECT_STREAMS to the list of handled events for your plug-in and call this user-defined method within the IWMSEventNotificationPlugin::OnEvent method.

HRESULT CCustomEventPlugin::GetPortNumber(
                                         IWMSCommandContext, *pCommandCtx)
{
    // Declare variables.
    DWORD                             cDescCount = 0;
    DWORD                             dwStreamId = -1;
    DWORD                             dwPortNumber;
    HRESULT                           hr = S_OK;
    IWMSContext                       *pCommandRequest = NULL;
    IWMSStreamSwitchDescriptionList   *pStrmSwitchDesc = NULL;
    IWMSTransportProperties           *pTransProp = NULL;

    // Retrieve a pointer to the command request context.
    hr = pCommandCtx->GetCommandRequest(&pCommandRequest);

    // Retrieve a pointer to an IWMSStreamSwitchDescriptionList interface.
    hr = pCommandRequest->GetAndQueryIUnknownValue(
                                     WMS_COMMAND_CONTEXT_STREAM_SWITCH,
                                     WMS_COMMAND_CONTEXT_STREAM_SWITCH_ID,
                                     IID_IWMSStreamSwitchDescriptionList,
                                     (IUnknown **)&pStrmSwitchDesc,
                                     0);
    if (FAILED (hr)) goto EXIT;

    // Retrieve the number of stream descriptions in the stream 
    // descriptions list.
    hr = pStrmSwitchDesc->GetDescriptionCount(&cDescCount);

    // After the correct stream is found, retrieve the new stream number 
    // for that stream.
    for (DWORD i = 0; i < cDescCount; i++)
    {
        CWMSStreamSwitch objStreamSwitch;
        ZeroMemory(&objStreamSwitch, sizeof(CWMSStreamSwitch));

        hr = pStrmSwitchDesc->GetIndexedDescription(i, &objStreamSwitch);

        if (SUCCEEDED (hr))
        {
            if ((objStreamSwitch.ModifierType == WMS_NO_MODIFIER) || 
               ((objStreamSwitch.ModifierType == WMS_THINNING_MODIFIER) &&
               ((objStreamSwitch.dwModifier == WMS_NO_THINNING) || 
               (objStreamSwitch.dwModifier == 
                                       WMS_INTERMEDIATE_FRAME_THINNING))))
            {
                dwStreamId = objStreamSwitch.dwNewStreamNumber;
                break;
            }
        }
    }

    // Retrieve a pointer to an IWMSTransportProperties interface.
    hr = pContext->GetAndQueryIUnknownValue(
                                         WMS_COMMAND_CONTEXT_TRANSPORT,
                                         WMS_COMMAND_CONTEXT_TRANSPORT_ID,
                                         IID_IWMSTransportProperties,
                                         (IUnknown **)&pTransProp, 
                                         0);
    if (FAILED (hr)) goto EXIT;

    // Use the new stream number to retrieve the UDP port number through 
    // the stream properties.
    if (dwStreamId != -1)
    {
        IWMSContext * pTransportCtx = NULL;
        hr = pTransProp->GetStreamProperties(dwStreamId,
                                             0,
                                             &pTransportCtx);

        if (SUCCEEDED (hr) )
        {
            // Retrieve the UDP port number of the client.
            hr = pTransportCtx->GetLongValue(
                                     WMS_TRANSPORT_CONTEXT_CLIENT_PORT,
                                     WMS_TRANSPORT_CONTEXT_CLIENT_PORT_ID,
                                     (LONG *)&dwPortNumber,
                                     0);
        }
        else
        {
            goto EXIT;
        }
    }

    EXIT:
    // TODO: Release temporary COM objects.

    return( hr );
}

Requirements

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003, Enterprise Edition with Service Pack 1; Windows Server 2003, Datacenter Edition with Service Pack 1; Windows Server 2008..

See Also

Concepts

Command Context

IWMSTransportProperties Interface

Transport Context