ILMRTSPCommandParser Interface

This interface is used for parsing the RTSP command received by the RTSP Server. The interface is created by the LEAD RTSP Sink filter and passed to the ILMRTSPServerMedia::HandleCommand method whenever an RTSP command is received from the RTSP client.

You are expected to parse and interpret the RTSP command using this the helper functions in this interface and build a response into the ILMRTSPResponseBuilder interface.

Data Types

LMRTSPCommandType

Summary

Lists the possible RTSP command types returned by the GetCommandType method.

Syntax

typedef enum 
{ 
   RTSP_UNKNOWN  = -1, 
   RTSP_DESCRIBE = 0, 
   RTSP_SETUP, 
   RTSP_PLAY, 
   RTSP_PAUSE, 
   RTSP_TEARDOWN, 
   RTSP_OPTIONS, 
   RTSP_ANNOUNCE, 
   RTSP_RECORD, 
   RTSP_REDIRECT, 
   RTSP_GET_PARAMETER, 
   RTSP_SET_PARAMETER, 
   HTTP_GET, 
} LMRTSPCommandType; 

Methods

HRESULT GetCommandType(BSTR *pCommandString, LMRTSPCommandType *pCommand)

Description

Parses the RTSP command and will extract only the command component.

Parameters

pCommandString

Pointer to a variable that will receive the command as a string. It can be NULL if the command string is not desired.

pCommand

Pointer to a variable that will receive the command as an enumeration value. It can be NULL if this information is not desired.

Comments

You can get the command as a string or as an enumeration value.

For example, if the RTSP command was like this:

SETUP rtsp://192.168.0.185/subfolder/dvd.mpg/trackID=0 RTSP/1.0

CSeq: 2

Transport: RTP/AVP;unicast;client_port=1024-1025

User-Agent: LEAD RTSP Source

This method would return "SETUP" for pCommandString and RTSP_SETUP for pCommand.

Note that either parameter can be NULL, but at least one of the parameters must be not NULL.

The string returned in pCommandString has been allocated with the Win32 API SysAllocString, so you must free it using SysFreeString.

Returns

Return Description
S_OK Successful.
< 0 An error occurred.
E_OUTOFMEMORY Out of memory.
E_POINTER Both pCommandString and pCommand are NULL.

HRESULT GetCommandFullURL(BSTR *pURL)

Description

Parses the RTSP command and will extract the URL as a full path.

Parameters

pURL

Pointer to a variable that will receive the full URL as a string.

Comments

For example, for the DESCRIBE command shown in the GetCommandType method, this method would set pURL to "rtsp://192.168.0.185/subfolder/dvd.mpg/trackID=0".

The string returned in pURL has been allocated with the Win32 API SysAllocString, so you must free it using SysFreeString.

Returns

Return Description
S_OK Successful.
< 0 An error occurred.
E_OUTOFMEMORY Out of memory.
E_POINTER pURL is NULL.

HRESULT GetCommandRelativeURL(BSTR *pURL)

Description

Parses the RTSP command and will extract the URL as a relative path.

Parameters

pURL

Pointer to a variable that will receive the relative URL as a string.

Comments

This method will discard any trailing "/trackID=" portions of the URL.

For example, for the DESCRIBE command shown in the GetCommandType method, this method would set pURL to "subfolder/dvd.mpg".

The string returned in pURL has been allocated with the Win32 API SysAllocString, so you must free it using SysFreeString.

Returns

Return Description
S_OK Successful.
< 0 An error occurred.
E_OUTOFMEMORY Out of memory.
E_POINTER pURL is NULL.

HRESULT GetCommandParameters(BSTR *pParameters)

Description

Parses the RTSP command and will extract all the command parameters as one big string.

Parameters

pParameters

Pointer to a variable that will receive the command parameters as a string.

Comments

The string returned in pParameters has been allocated with the Win32 API SysAllocString, so you must free it using SysFreeString.

For example, for the following command:

PLAY rtsp://192.168.0.185/dvr/capture.lbl RTSP/1.0

CSeq: 3

Range: npt=39.036-

User-Agent: LEAD RTSP Source

Session: 235950607

This method would set pParameters to:

CSeq: 3

Range: npt=39.036-

User-Agent: LEAD RTSP Source

Session: 235950607

In particular, you are supposed to pay attention to the "Range: npt=39.036-" parameter, which tells you that the RTSP client wants to start streaming 39.036s from the start of the media.

Returns

Return Description
S_OK Successful.
< 0 An error occurred.
E_OUTOFMEMORY Out of memory
E_POINTER pParameters is NULL.

HRESULT GetGetSessionID(BSTR *pSessionID)

Description

Parses the RTSP command and will extract the session ID.

Parameters

pSessionID

Pointer to a variable that will receive the session ID as a string.

Comments

The string returned in pSessionID has been allocated with the Win32 API SysAllocString, so you must free it using SysFreeString.

For example, in the command shown above for GetCommandParameters, this method would set pSessionID to "235950607".

Returns

Return Description
S_OK Successful.
< 0 An error occurred.
E_OUTOFMEMORY Out of memory.
E_POINTER pSessionID is NULL.

HRESULT GetFullCommand(BSTR *pFullCommand)

Description

Retrieves the full RTSP command as one big string.

Parameters

pFullCommand

Pointer to a variable that will receive the full command as a string.

The string returned in pFullCommand has been allocated with the Win32 API SysAllocString, so you must free it using SysFreeString.

For example, in the command shown above for GetCommandParameters, this method would set pFullCommand to:

PLAY rtsp://192.168.0.185/dvr/capture.lbl RTSP/1.0

CSeq: 3

Range: npt=39.036-

User-Agent: LEAD RTSP Source

Session: 235950607

The end of line is marked with <CR><LF> (hex values 0x0D 0x0A).

Returns

Return Description
S_OK Successful.
< 0 An error occurred.
E_OUTOFMEMORY Out of memory
E_POINTER pFullCommand is NULL.

HRESULT GetNetworkInfo(long *pNetworkCardAddress, long *pServerAddress, long *pClientAddress)

Description

Retrieves the server and client addresses in network byte order.

Parameters

pNetworkCardAddress

Optional pointer to a variable that will be updated with the network card address in network byte order. It can be NULL if this information is not needed.

pServerAddress

Optional pointer to a variable that will be updated with the server address in network byte order. It can be NULL if this information is not needed.

pClientAddress

Optional pointer to a variable that will be updated with the client address in network byte order. It can be NULL if this information is not needed.

Comments

For example, if the server is at 192.168.0.185 and a client connects from 192.168.0.219, pServerAddress will be set to 0xb900a8c0 and pClientAddress will be set to 0xdb00a8c0.

You can use this method to find out who is connecting to you. In particular, you can use this to implement your own security and restrict access to clients from some addresses.

Returns

S_OK (the function never fails).

Help Version 23.0.2024.9.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Filters C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.