-
We have published all of the Media Foundation samples from the Windows 7 SDK on MSDN Code Gallery. You can find them here:
http://code.msdn.microsoft.com/mediafoundation
You will still need to download the Windows SDK in order to build the samples.
-
The Media Foundation SDK documentation has been updated for the Windows 7 Release Candidate (RC)
http://msdn.microsoft.com/en-us/library/ms694197(VS.85).aspx
Highlights:
Please remember that everything new in the SDK is still pre-release and subject to change.
- Mike
This posting is provided "AS IS" with no warranties, and confers no rights.
-
Based on a couple of threads in the Media Foundation Development forum, there is some confusion about the status of new Media Foundation features.
All of the new features for Media Foundation mentioned here require Windows 7 to run. You can install the Windows 7 SDK on a Windows Vista or XP machine and use it to build the new samples, etc, but any application that uses the new features will run only on Windows 7.
- Mike
-
One of the new features in Media Foundation is the Source Reader.
Media Foundation, like DirectShow before it, has focused on the end-to-end pipeline. The application passes in a URL and streaming happens on another thread. The application gives commands (play, pause) and gets events (end of stream).
While this approach is convenient for playback, it makes it relatively hard for the application to get access to the bits as they travel from the source to the renderer.
The Source Reader uses a different model. The application passes in a URL and then requests samples by calling IMFSourceReader::ReadSample in a loop. You can use the Source Reader to get compressed or uncompressed data from the source. For uncompressed data, the Source Reader hosts any decoders that are needed.
I see two very broad categories of application for the Source Reader:
- Applications that implement their own playback pipeline -- say, by using Direct3D to draw the video frames directly.
- Applications that need to perform non-real-time processing on media data, such as encoding, signal processing, video thumbnails, etc. For this type of application, all you want are the uncompressed samples; you don't need the API to manage streaming threads or a presentation clock.
Format SDK programmers will find the Source Reader looks similar to the FSDK reader object. (The Source Reader can operate in either synchronous or asynchronous mode).
For DirectShow programmers, the Source Reader fills approximately the same niche as the Sample Grabber filter, except it is (IMO) easier to use.
More information here:
Please remember that everything new in the SDK is beta. There have been minor changes to the Source Reader API for the upcoming RC.
- Mike
-
It's been brought to my attention that the MSDN table of contents (TOC) is having some problems, at least in the "Audio and Video" node of the MSDN Library.
1. The TOC for the Media Foundation documentation is out of sync. Anything that is new for Windows 7 is not in the TOC. So if you navigate through the topics in Media Foundation, you wil find lots of "orphaned" pages.
Update: This issue has been fixed.
2. The latest version of the DirectShow documentation has a new URL, and the old link points to an older version of the documentation. The latest DirectShow documentation is here: http://msdn.microsoft.com/en-us/library/dd375454(VS.85).aspx
Update: No ETA for fixing this issue.
I do not have an ETA for when these issues will be fixed. Apologies for the inconvenience. My only advice is to install the Windows SDK and use that documentation.
- Mike
-
MFPlay is a new high-level playback API for Media Foundation.
Previously, to play a file in Media Foundation, the application had to:
- Use the source resolver to create a media source.
- Enumerate the streams and find the media types (audio or video).
- Construct a partial topology, connecting the streams to the right renderers.
- Set the topology on the media session.
With MFPlay, the equivalent steps are just one line of code:
const WCHAR *sURL = L"C:\\Users\\Public\\Videos\\example.wmv";
hr = MFPCreateMediaPlayer(
sURL,
TRUE, // Start playback automatically?
0, // Flags.
NULL, // Callback pointer.
hwnd,
&g_pPlayer
);
MFPlay also uses a much simpler event mechanism than the media session. The media session requires asynchronous calls to BeginGetEvent/EndGetEvent, and the event callback is invoked from a separate workqueue thread. MFPlay uses a single callback method that passes an event structure:
STDMETHODIMP MediaPlayerCallback::OnMediaPlayerEvent(
MFP_EVENT_HEADER *pEventHeader
)
{
switch (pEventHeader->eEventType)
{
case MFP_EVENT_TYPE_PLAY:
OnPlay(MFP_GET_PLAY_EVENT(pEventHeader));
break;
// Other event types (not shown).
}
}
By default, the event callback is invoked on your application's WndProc thread, so you can treat MFPlay events much like window messages.
You can read more about MFPlay here:
There is also an MFPlay sample in the Windows 7 BETA SDK, located under Samples\Multimedia\MediaFoundation\SimplePlay.
Please remember that everything new in the SDK is beta and subject to change.
- Mike
-
The Windows SDK for Windows 7 is available for download!
http://www.microsoft.com/downloads/details.aspx?FamilyID=a91dc12a-fc94-4027-b67e-46bab7c5226c&DisplayLang=en
Updated documentation for Media Foundation is also live on MSDN:
http://msdn.microsoft.com/en-us/library/ms694197(VS.85).aspx
You can read about what's new for Media Foundation here:
http://msdn.microsoft.com/en-us/library/bb970511(VS.85).aspx
Please remember that everything new in the SDK is beta and subject to change. Over the next few weeks, I will be posting more about the new features.
- Mike