Filter configuration through IDatasteadRtspSourceConfig
Note
When the filter is used through the TVideoGrabber SDK, this interface is not used directly: TVideoGrabber configures the filter itself, and the non-default parameters are passed at the end of the URL. See Using from TVideoGrabber.
Overview
The IDatasteadRtspSourceConfig interface declarations are located in the package under the following folders:
| Language | Declaration file |
|---|---|
| C# | Include\C#\DatasteadRTSPSourceFilter.cs |
| VB.NET | Include\C#\DatasteadRTSPSourceFilter.vb |
| C++ | Include\C++\DatasteadRTSPSourceFilter.h |
| Delphi | Include\Delphi\DatasteadRTSPSourceFilter.pas |
The IDatasteadRtspSourceConfig interface lets configure the filter at initialization time, as well as apply realtime actions, like pausing the recording, resuming the recording, generating a new file name on the fly, etc...
The initialization settings:
- can be set by invoking SetStr(), SetInt(), SetBool(), SetDouble(),
- can be retrieved by invoking GetStr(), GetInt(), GetBool(), GetDouble().
The actions can be applied by invoking Action().
The supported parameter identifiers are listed in the Parameter identifiers section.
Usage
- add the "Datastead RTSP/RTMP DirectShow Source" filter to the graph,
- query the IDatasteadRtspSourceConfig interface,
- configure the optional parameters, if needed, and then at last invoke
Action(RTSP_Action_OpenURL, "rtsp://...")to load the URL according to the parameters previously set, e.g.:
DatasteadRtspSourceConfig.SetStr (RTSP_Source_AuthUser_str, "root");
DatasteadRtspSourceConfig.SetStr (RTSP_Source_AuthPassword_str, "admin");
DatasteadRtspSourceConfig.SetInt (RTSP_Source_RTSPTransport_int, 4); // 4 = UDP multicast
DatasteadRtspSourceConfig.SetBool(RTSP_Source_AutoReconnect_bool, false);
DatasteadRtspSourceConfig.SetStr (RTSP_Source_RecordingFileName_str, "c:\\folder\\camerarec.mp4");
DatasteadRtspSourceConfig.Action (RTSP_Action_OpenURL, "rtsp://192.168.0.25/axis-media/media.amp?videocodec=h264&audio=1");
Then, once the graph is started, e.g. to pause the recording after a few minutes:
DatasteadRtspSourceConfig.Action (RTSP_Action_PauseRecording, "");
and then later, e.g.:
DatasteadRtspSourceConfig.Action (RTSP_Action_ResumeRecording, "");
Remarks
a) the parameter identifier name reminds the corresponding Get.../Set... function to invoke
The type of the parameter is included at the end of the name as a reminder. The function invoked must match the parameter type, otherwise the function will return E_INVALIDARG. E.g.:
int BufferDuration;
if (DatasteadRtspSourceConfig.GetInt (RTSP_Source_BufferDuration_int, &BufferDuration) == S_OK) {
// got the BufferDuration value
}
DatasteadRtspSourceConfig.SetStr (RTSP_Source_AuthUser_str, "admin");
DatasteadRtspSourceConfig.SetStr (RTSP_Source_AuthPassword_str, "pass");
wchar_t *RtspUrl = L"rtsp://192.168.1.32/axis-media/media.amp?videocodec=h264";
DatasteadRtspSourceConfig.Action (RTSP_Action_OpenURL, RtspUrl);
b) string returned by GetStr()
Although the string pointer returned by GetStr() is valid as long as the filter exists, we recommend to make a copy of the string returned immediately after invoking GetStr(), to prevent any use of this string pointer after the filter has been released.
Actions that can be applied once the graph is running
Generating a new recording file on the fly
To generate a new file name during the recording, invoke, e.g.:
DatasteadRtspSourceConfig.Action(RTSP_Action_RecordToNewFileNow, "c:\folder\newfilename3.mp4");
To pause the recording, pass a "nul" file name with the same extension:
DatasteadRtspSourceConfig.Action(RTSP_Action_RecordToNewFileNow, "nul.mp4");
Pausing the URL
DatasteadRtspSourceConfig.Action(RTSP_Action_PauseURL, "");
Resuming the URL
DatasteadRtspSourceConfig.Action(RTSP_Action_ResumeURL, "");
Filter configuration through IFileSourceFilter
This method is provided for easier testing from GraphEdit or GraphStudio and quick tests, however for the development we recommend to use the IDatasteadRtspSourceConfig interface instead.
To configure the filter through the common IFileSourceFilter interface and pass the optional parameters, if any, at the end of the URL:
- add the "Datastead RTSP/RTMP DirectShow Source" filter to the graph,
- query the IFileSourceFilter interface,
- invoke
FileSourceFilter.Loadto pass the RTSP URL (can be followed by the in-URL optional parameters, if any), e.g.:
FileSourceFilter.Load ("rtsp://root:admin@192.168.0.25/axis-media/media.amp?videocodec=h264&audio=1>rtsp_transport=udp_multicast>recordingfilename=c:\folder\recfile.mp4", NULL);
- render the desired pin(s),
- run the graph.