DirectShow: Difference between revisions
removed a "lol" |
|||
Line 39: | Line 39: | ||
=== Video Renderer vs. VMR7 vs. VMR9 === |
=== Video Renderer vs. VMR7 vs. VMR9 === |
||
{{divbox|navy|Technical details follow|The following section contains technical references and assumes the reader has knowledge of the APIs being discussed. Readers not interested in those details may skip this part |
{{divbox|navy|Technical details follow|The following section contains technical references and assumes the reader has knowledge of the APIs being discussed. Readers not interested in those details may skip this part.}} |
||
Case in point to the complexity argument – originally the way to play video was to use the ''Video Renderer'' filter. This drew the images using [[DirectDraw]], but could also fall back to [[Graphics Device Interface]] (GDI) drawing in some circumstances. One problem with it was limited access to the window: Video for Windows had been plagued with [[deadlock]]s caused by applications' incorrect handling of the video window, so in early DirectShow releases, the handle to the playback window was hidden from applications. This of course made it very difficult for sophisticated applications to handle Windows messages, such as WM_SETCURSOR.<ref name="ivwhandlenote">This is not entirely true, as some clever people found that the EnumChildWindows API could be called on the owner window of the IVideoWindow and then steal its WndProc messages directly.</ref> There was also no reliable way to draw caption text or graphics on top of the video. |
Case in point to the complexity argument – originally the way to play video was to use the ''Video Renderer'' filter. This drew the images using [[DirectDraw]], but could also fall back to [[Graphics Device Interface]] (GDI) drawing in some circumstances. One problem with it was limited access to the window: Video for Windows had been plagued with [[deadlock]]s caused by applications' incorrect handling of the video window, so in early DirectShow releases, the handle to the playback window was hidden from applications. This of course made it very difficult for sophisticated applications to handle Windows messages, such as WM_SETCURSOR.<ref name="ivwhandlenote">This is not entirely true, as some clever people found that the EnumChildWindows API could be called on the owner window of the IVideoWindow and then steal its WndProc messages directly.</ref> There was also no reliable way to draw caption text or graphics on top of the video. |
||
Revision as of 16:04, 1 October 2006
DirectShow (sometimes abbreviated as DS or DShow), codename Quartz, is a multimedia framework and API produced by Microsoft for software developers to perform various operations with media files. It is a replacement for Microsoft's earlier Video for Windows technology. Based on the Microsoft Windows Component Object Model framework, DirectShow provides a common interface for media across many of Microsoft's Programming Languages, and is an extensible, filter-based framework that can render or record media files on demand at the behest of the user or developer. The DirectShow development tools and documentation are distributed as part of the Microsoft Platform SDK.
Applications such as Windows Media Player use DirectShow or a variation thereof to display content from a file or URL. DirectShow's most notable competition is RealNetworks' Helix Framework and Apple Computer's QuickTime framework. Microsoft plans to eventually replace DirectShow with Media Foundation.
History
ActiveMovie, codename Quartz, the predecessor of DirectShow, was started in the Windows 3.0 days by Geraint Davies for Microsoft as an answer to QuickTime, the most popular media platform at the time. ActiveMovie was first available as an add-on to Windows 95 and that required Internet Explorer 3.0. Its main purpose at the time was to serve as a plugin for Internet Explorer to play media files inside of its window(s), such as what QuickTime offered for Netscape and Internet Explorer at the time, and to serve as a replacement for Video for Windows, particularly for MPEG files whose frame-reordering was difficult to deal with in Video for Windows.
In 1998, around the time of DirectX 5's release, ActiveMovie was renamed to DirectShow (reflecting Microsoft's efforts at the time to consolidate technologies that worked "directly" with hardware under a common naming scheme) and was included as part of the "DirectMedia SDK". In version 7 of DirectX, DirectShow became part of the mainline distribution of the DirectX SDK and given its own place alongside other DirectX APIs such as DirectInput. Even then, DirectShow was mostly used as a way to receive data from video input devices, such as a camcorder, and the ability of it to render data from a file was mostly used by Windows Media Player.
As of April 2005, DirectShow was removed from DirectX and moved to the Microsoft Platform SDK instead. The DirectX SDK is, however, still required to build DirectShow samples.[1]. DirectShow is not included in 2006 PSDK/DirectXSDK anymore; you will have to install the April 2005 PSDK.
Design Model
The way DirectShow works usually is that a developer creates a filter graph, adds some filters – possibly custom – to the graph, and then renders a file, URL or camera. During the rendering process, the filter graph searches the Windows Registry for registered filters and builds its graph of filters based on the location provided. After this, it connects the filters together, and, at the developer's request, plays/pauses etc. the created graph.
Each filter represents a stage in the processing of the data, e.g. reading from a file or camera, decoding, transforming or rendering. The filter has a number of pins that represent connection points on the filter that can be connected to other filters. Pins can be either output or input. Depending on the filter, data is either "pulled" from an output pin or "pushed" to an input pin in order to transfer data between filters.
Most filters are built using a set of C++ classes provided in the DirectShow SDK, called the DirectShow Base Classes. These handle much of the creation, registration and connection logic for the filter. For the filter graph to use filters automatically, they need to be registered in a separate DirectShow registry entry as well as being registered with COM. This registration can be managed by the DirectShow Base Classes. However, if the application adds the filters manually, they do not need to be registered at all. Unfortunately, it is difficult to modify a graph that is already running. It is usually easier to stop the graph and create a new graph from scratch.
Features
There are several levels of abstraction available in rendering sources in DirectShow, and doing any of these is fairly simple to do as long as a custom filter is not needed. At the most basic level, the procedure is for the developer to build a filter graph from scratch by manually adding and connecting each desired filter in the graph. The procedure for the next level of complexity is for the developer to create his or her own filter graph, for example from a source filter that contains information about a file or website address (URL) and possibly some custom filter that the user would desire, and then to let DirectShow complete the filter graph for the user and connect the filters together. Finally, the developer could just let DirectShow create a filter graph for him or her automatically from a source such as a file or URL.
By default, DirectShow supports several common media file formats, such as MPEG2 (no Encoding Support), MP3,[2] and Windows Media Video as well as several more mundane formats, such as plain static images.[3] Since the technology is licensed in Windows, no payout to Fraunhofer is required for, say, an MP3 license. Extensions allow DirectShow to be extended to support any format available; for example, there have been filters made for Ogg Vorbis files[4] and AC3, and a number of others.
Unlike the main C API of QuickTime where it is necessary to call MoviesTask in a loop to load a media file, DirectShow handles all of this in a transparent way. It creates several background threads that smoothly play the requested file or URL without much work required from the programmer. Also in contrast to QuickTime, nothing special is required for loading a URL instead of a local file on disk - DirectShow's filter graph abstracts these details from the programmer. Recent developments in QuickTime (including an ActiveX Control) have lessened this, however.
Criticism
Commanding DirectShow to play a file is a relatively simple task. However, while programming more advanced customizations, such as commanding DirectShow to display certain windows messages from the video window or creating custom filters, many developers complain of difficulties. It is often regarded as one of Microsoft's most complex development libraries/APIs.
Developers rarely create DirectShow filters "from scratch", rather, they employ a set of MFC-like (although not requiring MFC) classes called the "DirectShow Base Classes." The Base Classes can often simplify development, allowing the programmer to bypass certain tasks. However, the process may remain relatively complex; the code found in the Base Classes is nearly half the size of the entire MFC library. As a result, even with the Base Classes, the number of COM objects that DirectShow contains overwhelms many developers. In some cases, DirectShow's API deviates from traditional COM rules, particularly in regards to the parameters used for methods. To overcome their difficulties with DirectShow's unique COM rules, developers often turn to a higher level API that uses DirectShow, notably, Windows Media Player SDK. This API provides the developer with an ActiveX Control that has fewer COM interfaces to deal with.
DirectShow has also been criticized for its support of Digital Rights Management. However, this criticism appears misplaced, as DirectShow, "in and of itself," has minimal support for DRM in its API. In fact, it is Windows Media Player SDK that more significantly reflects Microsoft's adherence to DRM.
DirectShow has also been scrutinized for compatibility problems with third-party media players (media displaying software not belonging to Microsoft). After a settlement with the European Union, Microsoft started shipping a version of Windows that excluded Windows Media Player. While all of DirectShow's default formats[3] appeared to be supported, Microsoft suggested that the stripped-down versions of the operating system may not have supported all of those formats.[5]
Video Renderer vs. VMR7 vs. VMR9
Case in point to the complexity argument – originally the way to play video was to use the Video Renderer filter. This drew the images using DirectDraw, but could also fall back to Graphics Device Interface (GDI) drawing in some circumstances. One problem with it was limited access to the window: Video for Windows had been plagued with deadlocks caused by applications' incorrect handling of the video window, so in early DirectShow releases, the handle to the playback window was hidden from applications. This of course made it very difficult for sophisticated applications to handle Windows messages, such as WM_SETCURSOR.[6] There was also no reliable way to draw caption text or graphics on top of the video.
Windows XP introduced a new filter called VMR-7[7] (Abbreviation for Video Mixing Renderer 7, sometimes just referred to as plain VMR). The 7 was because VMR-7 only used DirectDraw version 7 to render the video and did not have the option to use GDI drawing. The main new feature of VMR-7 was the ability to mix multiple streams and graphics, so allowing applications to draw text and graphics over the video. VMR7 also featured a "windowless mode"[8] which fixed the problems with access to the window handle; however it required a bit of extra initialization code. For non-technical reasons, it was released only on Windows XP.[9]
DirectX 9 included yet another renderer, dubbed VMR-9.[10] This version depends on DirectX9-style graphics (also known as Direct3D). Unlike the VMR-7, it also would work on any system that supported DirectX9, provided that the graphics adapter could support the required Direct3D modes. However, this caused even further splintering on an already extremely involved API.
References
- "MSDN DirectShow documentation". Retrieved August 17.
{{cite web}}
: Check date values in:|accessdate=
(help); Unknown parameter|accessyear=
ignored (|access-date=
suggested) (help) - Pesce, Mark D. (2003). Programming Microsoft® DirectShow® for Digital Video and Television. Microsoft Press. ISBN 0-7356-1821-6. (Sample Chapter)
- Various posts from the "Microsoft.public.win32.programmer.directx.video" newsgroup
Notes
- ^ "DirectX FAQ". Retrieved September 11.
{{cite web}}
: Check date values in:|accessdate=
(help); Unknown parameter|accessyear=
ignored (|access-date=
suggested) (help) - ^ While DirectShow can play VBR MP3s, it cannot seek accurately or perform many other functions correctly in them due to incorrect parsing of the file (possibly due to incorrect parsing of the XING header). The Windows Media Player 10 SDK and later versions of windows media player do this correctly, however.
- ^ a b "formats supported by default in DirectShow". Retrieved September 11.
{{cite web}}
: Check date values in:|accessdate=
(help); Unknown parameter|accessyear=
ignored (|access-date=
suggested) (help) - ^ "illiminable Directshow Filters for Ogg Vorbis, Speex, Theora and FLAC". Retrieved March 11.
{{cite web}}
: Check date values in:|accessdate=
(help); Unknown parameter|accessyear=
ignored (|access-date=
suggested) (help) - ^ "EU ruling will break websites, says Microsoft". Retrieved March 20.
{{cite web}}
: Check date values in:|accessdate=
(help); Unknown parameter|accessyear=
ignored (|access-date=
suggested) (help) - ^ This is not entirely true, as some clever people found that the EnumChildWindows API could be called on the owner window of the IVideoWindow and then steal its WndProc messages directly.
- ^ "Video Mixing Renderer 7 (VMR-7)". Retrieved September 11.
{{cite web}}
: Check date values in:|accessdate=
(help); Unknown parameter|accessyear=
ignored (|access-date=
suggested) (help) - ^ "windowless mode". Retrieved September 11.
{{cite web}}
: Check date values in:|accessdate=
(help); Unknown parameter|accessyear=
ignored (|access-date=
suggested) (help) - ^ Some people have noted that it "unofficially" works on Windows 2000 also: owing to a build error, some of the DirectX runtime packages for Windows 2000 accidentally included VMR-7.
- ^ "Video Mixing Renderer 9 (VMR-9)". Retrieved September 11.
{{cite web}}
: Check date values in:|accessdate=
(help); Unknown parameter|accessyear=
ignored (|access-date=
suggested) (help)
External links
- MSDN - 'Official DirectShow documentation from MSDN'
- MSDN - 'DirectShow Downloads from MSDN'
- Home page of Geraint Davies - 'Creator of DirectShow and a DirectShow MVP – Contains several FAQs and examples.'
- The March Hare - 'Prolific DirectShow MVP – Contains several FAQs'
- Chris P's code - 'Another DirectShow MVP – Some samples focused on audio.'
- AV Programming Forum - 'Articles and Forum for DirectShow and Format SDK.'
- RadLight - 'Theora DirectShow filter enables Microsoft Windows Media Player to play Theora videos.'
- Illiminable - 'Open source Directshow filter for Ogg Vorbis, Speex, Theora and FLAC for Windows Media Player. The source code, available from the xiph.org Subversion repository, contains implementations of more than 15 different DirectShow filters.'
- MediaLooks DirectShow SDK - 'An alternative DirectShow SDK, a replacement for DirectShow Base Classes.'
- Standard Mpeg DirectShow SDK - 'DirectShow SDK for encoding to Mpeg.'
- DirectShow in Russian - 'DirectShow Tutorial (Russian)'