Skip to content

Callbacks

Besides the graph events, the filter can call the application back directly. Each callback is registered through a dedicated interface obtained with QueryInterface on the filter (see Interfaces exposed by the filter).

Warning

A callback runs in one of the filter's own threads, not in the application's main thread. Keep the callback body short, do not run a message loop in it, and do not stop or release the graph from inside it.

Asynchronous connection callback

Interface IDatasteadRTSPSourceCallbackConfig. It provides an alternative to the EC_RTSPNOTIFY graph event for RTSP_Action_OpenURLAsync:

typedef void (__stdcall *OpenURLAsyncCompletionCB) (void *Sender, intptr_t CustomParam, HRESULT Result);

HRESULT SetAsyncOpenURLCallback (OpenURLAsyncCompletionCB CallbackFunctionPtr, void *Sender, intptr_t CustomParam);

Result returns S_OK when the connection succeeded, or an error code when it failed.

Sample callbacks

Interface IDatasteadRTSPSampleCallback. The three callbacks are independent; only the ones actually needed have to be registered.

typedef void (__stdcall *DatasteadRTSP_RawSampleCallback) (void *Sender, int StreamNumber, char *CodecName,
        int64_t SampleTime_Absolute, int64_t SampleTime_Relative,
        BYTE *Buffer, int BufferSize, char *InfoString);

typedef void (__stdcall *DatasteadRTSP_VideoSampleCallback) (void *Sender,
        int64_t SampleTime_Absolute, int64_t SampleTime_Relative,
        BYTE *Buffer, int BufferSize,
        int VideoWidth, int VideoHeight, int BitCount, int Stride);

typedef void (__stdcall *DatasteadRTSP_AudioSampleCallback) (void *Sender,
        int64_t SampleTime_Absolute, int64_t SampleTime_Relative,
        BYTE *Buffer, int BufferSize,
        int SamplesPerSec, int Channels, int BitsPerSample);

HRESULT SetRawSampleCallback      (DatasteadRTSP_RawSampleCallback   SampleCallback, void *Sender);
HRESULT SetVideoRGBSampleCallback (DatasteadRTSP_VideoSampleCallback SampleCallback, void *Sender);
HRESULT SetAudioPCMSampleCallback (DatasteadRTSP_AudioSampleCallback SampleCallback, void *Sender);
  • SetRawSampleCallback: delivers the compressed samples as they are received, before decoding. StreamNumber and CodecName identify the stream.
  • SetVideoRGBSampleCallback: delivers the decoded video frames as RGB bitmaps. Stride is the number of bytes per line, which may be larger than VideoWidth * BitCount / 8.
  • SetAudioPCMSampleCallback: delivers the decoded audio as uncompressed PCM.

Interface IDatasteadRTSPSampleCallback2 adds an overlay callback, which uses the same signature as the video sample callback but lets the application modify the frame buffer before it is delivered to the output pin:

HRESULT SetVideoRGBOverlayCallback (DatasteadRTSP_VideoSampleCallback SampleCallback, void *Sender);

File writer callback

Interface IDatasteadRTSPSampleCallback3. The callback receives every file operation performed by the recorder, which lets the application write the recording somewhere else, or re-stream it. See File writer callback in the recording chapter.

enum TFileWriteCallbackOperation { fw_Open, fw_Close, fw_Seek, fw_Write, fw_Read };

typedef int (__stdcall *DatasteadRTSP_FileWriteCallback) (void *Sender,
        TFileWriteCallbackOperation FileWriteCallbackOperation,
        BYTE *pBuffer, int BufferSize, int64_t SeekPosition, int whence);

HRESULT SetFileWriteCallback (DatasteadRTSP_FileWriteCallback FileWriteCallback, void *Sender);

NTP timestamp callback

Interface IDatasteadRTSP_NTPTimeStampCallback. It reports the RTCP sender reports used to convert the RTP timestamps into absolute NTP time. See also NTP time of IP cameras.

typedef void (__stdcall *DatasteadRTSP_NTPTimeStampCallback) (void *Sender,
        int64_t last_rtcp_ntp_time, uint32_t last_rtcp_timestamp,
        int64_t delta_rtcp_ntp_time, uint32_t delta_rtcp_timestamp);

HRESULT SetNTPTimeStampCallback (DatasteadRTSP_NTPTimeStampCallback NTPTimeStampCallback, void *Sender);

ONVIF probing callback

Interface IDatasteadONVIFProbingCompleteCallback. The filter probes the ONVIF services of the camera in the background; this callback reports the outcome.

typedef void (__stdcall *TBackgroundProbingCompleteCallback) (void *opaque, bool success);

HRESULT SetONVIFProbingCallback (TBackgroundProbingCompleteCallback InterfaceCallback, void *Sender);

ONVIF discovery callback

Interface IDatasteadONVIFDiscovery, described in Camera information and discovery:

enum TONVIFDiscoveryStatus { dcs_CameraFound, dcs_MulticastCompleted, dcs_IPRangeCompleted };

typedef void (__stdcall *TDiscoveryCallback) (void *opaque,
        TONVIFDiscoveryStatus DiscoveryCallbackStatus, int CameraCount);

HRESULT SetDiscoveryNotificationCallback (TDiscoveryCallback DiscoveryCallback, void *DiscoveryCallback_cbcontext);