Skip to content

DirectShow configuration

Building and starting the DirectShow graph synchronously

(the function blocks until the connection completes)

  • create the filter graph instance,
  • create the filter instance with CoCreateInstance,
  • add the filter to the graph,
  • query the filter instance for the IDatasteadRTSPSourceConfig interface,
  • invoke HRESULT hr = DatasteadRTSPSourceConfig.Action (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 instance,
  • create the filter 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.Action (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,
  • 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 CLSIDs

Datastead RTSP/RTMP/HTTP/ONVIF Source

Depending on the URL source, this filter exposes:

  • the video and audio pins if the source has video and audio,
  • only the video pin if the source has only video,
  • only the audio pin if the source has only audio.

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

C#:

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

C++:

// {55D1139D-5E0D-4123-9AED-575D7B039569}
static const GUID Datastead_RTSP_RTMP_HTTP_ONVIF =
{ 0x55D1139D, 0x5E0D, 0x4123, { 0x9A, 0xED, 0x57, 0x5D, 0x7B, 0x03, 0x95, 0x69 } };

Delphi:

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

Datastead RTSP/RTMP/HTTP/ONVIF Source (video only)

This filter works exactly as the main filter, but exposes only the video pin and may connect faster by ignoring the audio streams if any.

Filter CLSID: {37C4205F-F04F-453E-851E-1730FB55792C}

C#:

public static readonly Guid Datastead_RTSP_RTMP_HTTP_ONVIF_VideoOnly = new Guid ("37C4205F-F04F-453E-851E-1730FB55792C");

C++:

// {37C4205F-F04F-453E-851E-1730FB55792C}
static const GUID Datastead_RTSP_RTMP_HTTP_ONVIF_VideoOnly =
{ 0x37c4205f, 0xf04f, 0x453e, { 0x85, 0x1e, 0x17, 0x30, 0xfb, 0x55, 0x79, 0x2c } };

Delphi:

const
  Datastead_RTSP_RTMP_HTTP_ONVIF_VideoOnly: TGUID = '{37C4205F-F04F-453E-851E-1730FB55792C}';