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

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, 
} LMRTSPCommandType; 

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

Interface Methods:

HRESULT GetCommandType(BSTR *pCommandString, LMRTSPCommandType *pCommand)

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.

Description

This method will parse the RTSP command and will extract only the command component. You can get the command as a string or as a 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

S_OK if successful, < 0 if an error occurred.

Common Error Codes

E_OUTOFMEMORY

Out of memory

E_POINTER

Both pCommandString and pCommand are NULL

HRESULT GetCommandFullURL(BSTR *pURL)

Parameters

pURL

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

Description

This method will parse the RTSP command and will extract the URL as a full path.

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

S_OK if successful, < 0 if an error occurred.

Common Error Codes

E_OUTOFMEMORY

Out of memory

E_POINTER

pURL is  NULL

HRESULT GetCommandRelativeURL(BSTR *pURL)

Parameters

pURL

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

Description

This method will parse the RTSP command and will extract the URL as a relative path. It will also 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

S_OK if successful, < 0 if an error occurred.

Common Error Codes

E_OUTOFMEMORY

Out of memory

E_POINTER

pURL is  NULL

HRESULT GetCommandParameters(BSTR *pParameters)

Parameters

pParameters

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

Description

This method will parse the RTSP command and will extract all the command parameters as one big string.

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

S_OK if successful, < 0 if an error occurred.

Common Error Codes

E_OUTOFMEMORY

Out of memory

E_POINTER

pParameters is  NULL

HRESULT GetGetSessionID(BSTR *pSessionID)

Parameters

pSessionID

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

Description

This method will parse the RTSP command and will extract the session ID.

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

S_OK if successful, < 0 if an error occurred.

Common Error Codes

E_OUTOFMEMORY

Out of memory

E_POINTER

pSessionID is  NULL

HRESULT GetFullCommand(BSTR *pFullCommand)

Parameters

pFullCommand

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

Description

This method retrieve the full RTSP command as one big 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

S_OK if successful, < 0 if an error occurred.

Common Error Codes

E_OUTOFMEMORY

Out of memory

E_POINTER

pFullCommand is  NULL

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

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.

Description

This method retrieves the server and client addresses in network byte order.

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 20.0.2020.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Filters C API Help