Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
.gif)
| Previous | Next |
IWMSTransportProperties.GetStreamProperties (Visual Basic .NET)
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.
Syntax
IWMSTransportProperties .GetStreamProperties( dwStreamId As UInt32, dwAlternateIndex As UInt32, ByRef ppProps As IWMSContext );
Parameters
dwStreamId
UInt32 containing the stream ID of the stream.
dwAlternateIndex
UInt32 containing the unique alternate index of the stream.
ppProps
Reference to an IWMSContext object containing the properties of the stream.
Return Values
This method does not return a value.
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 an IWMSContext object that contains the transport settings that were defined in the SETUP request.
Example Code
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.
Function GetPortNumber(ByVal pCommandCtx As IWMSCommandContext) As Integer
' Declare variables.
Dim TransportProperties_Guid As Guid = _
GetType(IWMSTransportProperties).GUID
Dim StreamSwitchDescriptionList_Guid As Guid = _
GetType(IWMSStreamSwitchDescriptionList).GUID
Dim oUnknownXPort As Object
Dim oUnknownSS As Object
Dim iPortNumber As Integer = 0
Dim dwStreamId As Int64 = -1
Dim cmdCtx As IWMSContext
Dim transCtx As IWMSContext
Dim oTransProps As IWMSTransportProperties
Dim oSwitchList As IWMSStreamSwitchDescriptionList
Dim dwCount As System.UInt32
Try
' Retrieve the command request context.
pCommandCtx.GetCommandRequest(cmdCtx)
' Retrieve an object and explicitly cast it as an
' IWMSStreamSwitchDescriptionList object.
cmdCtx.GetAndQueryIUnknownValue( _
WMSDefines.WMS_COMMAND_CONTEXT_STREAM_SWITCH, _
WMSDefines.WMS_COMMAND_CONTEXT_STREAM_SWITCH_ID, _
StreamSwitchDescriptionList_Guid, oUnknownSS, 0)
oSwitchList = CType(oUnknownSS, IWMSStreamSwitchDescriptionList)
' Retrieve the number of stream descriptions in the stream
' descriptions list.
oSwitchList.GetDescriptionCount(dwCount)
' After the correct stream is found, retrieve the new stream
' number for that stream.
Dim z As Integer
For z = 0 To System.Convert.ToInt32(dwCount) - 1
Dim objStreamSwitch As CWMSStreamSwitch
oSwitchList.GetIndexedDescription( _
System.Convert.ToUInt32(z), objStreamSwitch)
If objStreamSwitch.ModifierType = _
WMS_STREAM_MODIFIERS.WMS_NO_MODIFIER Or _
(objStreamSwitch.ModifierType = _
WMS_STREAM_MODIFIERS.WMS_THINNING_MODIFIER And _
(System.Convert.ToInt32(objStreamSwitch.dwModifier) = 0 _
Or System.Convert.ToInt32(objStreamSwitch.dwModifier) = _
1)) Then
dwStreamId = _
System.Convert.ToInt64(objStreamSwitch.dwNewStreamNumber)
Exit For
End If
Next z
' Retrieve an object and explicitly cast it as an
' IWMSTransportProperties object.
cmdCtx.GetAndQueryIUnknownValue( _
WMSDefines.WMS_COMMAND_CONTEXT_TRANSPORT, _
WMSDefines.WMS_COMMAND_CONTEXT_TRANSPORT_ID, _
TransportProperties_Guid, oUnknownXPort, 0)
oTransProps = CType(oUnknownXPort, IWMSTransportProperties)
' Use the new stream number to retrieve the UDP port number
' through the stream properties.
If dwStreamId <> -1 Then
oTransProps.GetStreamProperties( _
System.Convert.ToUInt32(dwStreamId), _
System.Convert.ToUInt32(0), transCtx)
' Retrieve the UDP port number of the client.
transCtx.GetLongValue( _
WMSDefines.WMS_TRANSPORT_CONTEXT_CLIENT_PORT, _
WMSDefines.WMS_TRANSPORT_CONTEXT_CLIENT_PORT_ID, _
iPortNumber, 0)
End If
Catch ex As Exception
If Not ex.Message.ToLower().StartsWith("invalid index") Then
' TODO: Handle exception.
End If
End Try
' Return the port number.
Return iPortNumber
End Function
Requirements
Reference: Add a reference to Microsoft.WindowsMediaServices.
Namespace: Microsoft.WindowsMediaServices.Interop.
Assembly: Microsoft.WindowsMediaServices.dll.
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
| Previous | Next |