DirectShow configuration


Overview

Building and starting the DirectShow graph synchronously (the function blocks until the connection completes):


- create the filter graph instace,

- create the instance with CoCreateInstance,

- add the filter to the graph
- query the filter instance for the IDatasteadRTSPSourceConfig interface
- invoke Hresult hr = DatasteadRTSPSourceConfig.SetAction (RTSP_Action_OpenURL, "rtsp://...") to open the URL
- if hr == S_OK, render the video and/or audio pins and run the graph

If a recording file name has been specified the file writing starts along with the video/audio rendering.


Building and starting the DirectShow graph asynchronously without blocking the main thread:


sample code in the C# demo project included


A) create an initialization function that starts the connection and exits immediately

- create the filter graph instace,

- create the instance with CoCreateInstance,

- add the filter to the graph
- query the ImediaEventEx and invoke mediaEventEx.SetNotifyWindow (AppHandle) to receive the graph events
- query the filter instance for the IDatasteadRTSPSourceConfig interface
- invoke Hresult hr = DatasteadRTSPSourceConfig.SetAction (RTSP_Action_OpenURLAsync, "rtsp://...") to open the URL
- the function exits immediately and returns S_OK if the URL syntax is correct
(so at this point the app remains responsive while the filter is connecting in the background)


B)

when the connection completes, the graph event callback occurs with a EC_RTSPNOTIFY (param1, param2):

param1 returns EC_RTSP_PARAM1_OPENURLASYNC_CONNECTION_RESULT as param1
Param2 returns 0 if the connection failed, and 1 if the connection succeeded

From this event:
- if the connection failed, release the graph
- if the connection succeeded, render the video and/or audio pins and run the graph


Note: if a recording file name has been specified the filter starts writing to the file as soon as the connection succeeds.


Filter CLSID


Filter CLSID: {55D1139D-5E0D-4123-9AED-575D7B039569}


C#


public static readonly Guid DatasteadRtspRtmpSource = new Guid ("55D1139D-5E0D-4123-9AED-575D7B039569");



C++:


// {55D1139D-5E0D-4123-9AED-575D7B039569}

static const GUID CLSID_DatasteadRtspRtmpSource =

{ 0x55D1139D, 0x5E0D, 0x4123, { 0x9A, 0xED, 0x57, 0x5D, 0x7B, 0x03, 0x95, 0x69 } };


Delphi:


const

CLSID_DatasteadRtspRtmpSource: TGUID = '{55D1139D-5E0D-4123-9AED-575D7B039569}';



43