An update for Reference signal source for DirectShow DLLs:
- the source is doing more accurately RGB subtypes and allows specification whether you want
- additionally the DLL implements Microsoft Media Foundation Media Source for the video stream
A more detailed description follows.
RGB32 and ARGB32 are very close and share the same byte structure, and due to minimal support of alpha channel with video, these are having the difference mostly in counterpart support in other applications, like for example and specifically hardware-assisted H.264 encoders whcih are taking alpha-enabled variant.
IVideoSourceFilter::SetMediaType method takes
vCompression argument which defines the subtype.
RegisterSources sample code shows how the method is used when exposing reference signal as video capture device.
IVideoMediaSource::SetMediaType methods is applicable to Media Foundation counterpart (see below).
Both implementation only offer the given subtype as default, but in the same time both accept the other variant as well if an application or peer connection is trying to re-agree the media type. Same applies to changing resolution etc. The sources are flexible to take different video format if anyone is requesting it.
The other big new thing is Media Foundation API Media Source which generates reference signal as well. There is no option to set it up as a virtual camera because the API does not offer extensibility of the kind, however the source can be used to generate test content via Media Foundation and the code remains pretty simple. I am publishing
MfGenerate code snippet which demonstrates the necessary steps to create an MP4 file with video, with desired properties.
As Media Foundation offers H.265 (HEVC) and fragmented MP4 options, they can also be easily used with the source to generate test footage.
The code does the following steps:
- Creates a media source (commented out lines show alternate steps to create a media source from a file)
- Creates a source reader from media source
- Builds an H.264 media type from raw video media type
- Creates and configures a sink writer, which is instructed to do its magic setting up H.264 encoder (a side note – the code produces 4096×2304 video, however it is only possible once hardware encoder is enabled; software encoder was rejecting the media type)
- Implements a loop of reading frames until they run out feeding them into encoder/writer
High level APIs are simple (similar to DirectShow), which is untrue for the internals (similar to DirectShow; even more so).
Media Foundation source is video only for now.
MF media source is supposed to be seekable (not really tested; not really testable with topoedit), and allows zero duration to produce infinite feed. Duration is not necessarily taken from property, it can also be specified with overwritten presentation descriptor attribute. The video format can also be set up through stream descriptor media type handler.
Update – Connecting MF Media Source to MFCaptureD3D Sample application
To quickly connect MF media source to Windows SDK MFCaptureD3D Sample application, add #import and a few code lines replacing the source around
CPreview::SetDevice as shown on the image below: