ILMRTSPResponseBuilder Interface

This interface is used for building the RTSP command response which will be sent by the RTSP Server to the RTSP client. 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 the ILMRTSPCommandParser interface and build a response into this interface.

Interface Properties:

Type

Name

Description

long

ResponseCode

This property indicates the response code. The default is 551 (indicating an error).

So you must change this property to 200 to indicate success. For a full list of the possible RTSP responses, see "RFC 2326 - Real Time Streaming Protocol (RTSP)".

BSTR

ResponseString

A string to be sent along with the ResponseCode to the client. This property is updated automatically whenever you update the ResponseCode property.

But you can also update it yourself with a more meaningful string after you change ResponseCode.

BSTR

ContentType

A string indicating the content type. The default value is empty string ".

This value will be put in the response with the "Content-Type: " prefix and tells the RTSP client the form of the content.

You should set this in commands that expect content, like DESCRIBE. The most common content type is "application/sdp", which is what most RTSP clients will expect for the DESCRIBE command.

Interface Methods:

HRESULT AddHeaderField(BSTR fieldName, BSTR fieldValue)

Parameters

fieldName

String indicating the field name.

fieldValue

String indicating the field value.

Description

This method will add a header field. The header fields have the format

<header-field>: <header-value>

For example, the following call can be used to add the sessionID field:

hr = pBuilder->AddHeaderField(L"Session", L"MySessionString;timeout=70"); 

After this, the RTSP response will contain the following information in the header:

Session: MySessionString;timeout=80

Returns

S_OK if successful, < 0 if an error occurred.

Common Error Codes

E_OUTOFMEMORY

Out of memory

E_POINTER

At least one of the parameters is NULL

HRESULT AddContent(BSTR content)

Parameters

content

String indicating one or more lines of content.

Description

This method will add one or more lines of content. And end-of-line is added to any existing content to separate previous content from this content being added.

The content being added should match the type indicated by the ContentType property.

For example, the following code will set the content type, add a few lines of content and call ILMRTSPServerSession::HandleCommand to finalize the response for a DESCRIBE command:

// In this example, CRTSPServerFolderMedia is implementing the ILMRTSPServerMedia 
// The class has a sink interface used to get the DESCRIBE information declared as follows: 
//      ILMRTSPServerSession *m_pDescribeSession; 
HRESULT CRTSPServerFolderMedia::HandleDescribeCommand(ILMRTSPServer *pServer, ILMRTSPCommandParser *pParser, ILMRTSPResponseBuilder *pBuilder, DWORD_PTR socket) 
{ 
   /* UpdateDescribeSessionFilename is another class member that updates the graph containing m_pDescribeSession filter instance with the source file indicated in pParser */ 
   HRESULT hr = UpdateDescribeSessionFilename(pParser); 
   if(FAILED(hr)) 
   { 
      // if UpdateDescribeSessionFilename failed, then the file does not exist or is not supported 
      // so just set the ResponseCode to an appropriate error code and return 
      pBuilder->put_ResponseCode(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ? 404 : 415); 
      return hr; 
   } 
   // I can handle the file, so set the ContentType to application/sdp and 
   // add the content values the filter does not know about 
   hr = pBuilder->put_ContentType(L"application/sdp"); 
   if(SUCCEEDED(hr)) 
      hr = AddContent(pBuilder, L"v=0"); 
   if(SUCCEEDED(hr)) 
      hr = AddContent(pBuilder, L"o=- 0 0 IN IP4 127.0.0.1"); 
   if(SUCCEEDED(hr)) 
      hr = AddContent(pBuilder, L"s=Test session"); 
   // in this case, I am playing the whole file from start (position 0sec) 
   if(SUCCEEDED(hr)) 
      hr = AddContent(pBuilder, L"a=range:npt=0-"); 
   // let ILMRTSPServerSession::HandleCommand fill the other content values describing the media streams 
   if(SUCCEEDED(hr)) 
      hr = m_pDescribeSession->HandleCommand(pServer, pParser, pBuilder, socket); 
   if(SUCCEEDED(hr)) 
      hr = pBuilder->put_ResponseCode(200); // SUCCESS! 
   else 
      pBuilder->RemoveAllContent(); 
   return hr; 
} 

Returns

S_OK if successful, < 0 if an error occurred.

Common Error Codes

E_OUTOFMEMORY

Out of memory

HRESULT RemoveAllContent()

Description

This method removes all content previously added with AddContent.

Returns

S_OK (the function never fails).

 

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

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