|
Introduction
DSGraphEdit is a library to easily add functionality similar to Microsoft's venerable GraphEdit to your .NET applications. Most of the functionality has been recreated with a few new bells and whistles to aid in the debugging of DirectShow software.
Background
GraphEdit is a utility that comes with the DirectShow SDK (later moved to the Windows SDK) that is a visual tool for creating and testing filter graphs for media playback. One of the more powerful functions of GraphEdit is its ability to hook into a filter graph running in an external application via the ROT (Running Object Table). However, doing so tends to be frustrating as it frequently crashes and only provides limited functionality while connected to a remote graph. Another drawback of GraphEdit is that it is closed source and can't be freely redistributed with your own software. DSGraphEdit uses DirectShowLib, Media Foundation .NET (for the Enhanced Video Renderer) and DaggerLib. DaggerLib is a library that aids in the visual construction and execution of DAGs (Direct Acyclic Graphs) for flow-based programming. It will be covered in more detail in future articles.
Using the Code
To use DSGraphEdit in your own application, add a reference to the DaggerLib.DSGraphEdit.dll file found in the lib directory and add the namespace to the form:
using DaggerLib.DSGraphEdit;
DaggerLib.DSGraphedit provides three controls:
DSGraphEditPanel: the workspace for viewing and manipulating a Filter Graph.ed.
DSFiltersPanel: a panel that maintains a tree of DirectShow filters registered on your system.
DSGraphEditForm: an all-in-one dialog of DSGraphEditPanel and DSFiltersPanel to make testing easier.
DSGraphEditPanel
Constructing a DSGraphEditPanel
DSGraphEditPanel can be created in four different ways:
-
DSGraphEditPanel dsGraphEditPanel = new DSGraphEditPanel();
-
IFilterGraph myFilterGraph = (IFilterGraph)new FilterGraph();
...
...
DSGraphEditPanel dsGraphEditPanel = new DSGraphEditPanel(myFilterGraph);
-
DSGraphEditPanel dsGraphEditPanel = null;
try
{
dsGraphEditPanel = new DSGraphEditPanel("c:\\somegraphfile.grf");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error loading graph file");
}
-
DSGraphEditPanel dsGraphEditPanel = null;
try
{
dsGraphEditPanel = DSGraphEditPanel.ConnectToRemoteGraph();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error connecting to remote graph");
}
...
...
dsGraphEditPanel.Dispose();
dsGraphEditPanel = null;
The DSGraphEditPanel.ConnectToRemoteGraph() static method will prompt the user with a dialog box containing a list of IFilterGraphs that are currently registered on ROT:
To disconnect from a Remote Graph, simply dispose of the DSGraphEditPanel with the Dispose() method. Also, similar to constructing from a *.grf file, the ConnectToRemoteGraph static method should always be enclosed in a try/catch block.
Working with DSGraphEditPanel
DSGraphEditPanel is comprised of three areas:
The Toolbar Buttons
Runs the Filter Graph. The corresponding method is DSGraphEditPanel.Play().
Pauses the Filter Graph. The corresponding method is DSGraphEditPanel.Pause().
Stops the Filter Graph. The corresponding method is DSGraphEditPanel.Run().
Skips forward one frame. The corresponding method is DSGraphEditPanel.StepOneFrame().
Synchronizes the contents of the displayed graph with the Filter Graph. Use this if you think the contents of the canvas do not accurately reflect the current state of the Filter Graph. The corresponding method is DSGraphEditPanel.SyncGraphs().
Auto-arranges the filters in the displayed graph. The corresponding method is DSGraphEditPanel.ArrangeNodes().
Disconnects all pins in the Filter Graph.
Saves the Filter Graph to a *.grf file. These are compatible with Microsoft's GraphEdit. The corresponding method is DSGraphEditPanel.SaveFilterGraph(string filename).
Renders a media file into the Filter Graph. The corresponding method is DSGraphEditPanel.RenderMediaFile(string filename).
Renders a URL (Uniform Resource Locator) into the Filter Graph. The corresponding method is DSGraphEditPanel.RenderURL(string URL).
Provides several styles for displaying connections between filters. The corresponding property is DSGraphEditPanel.NoodleStyle (yes, they're called Noodles):
Bezier: a simple bezier curve.
Lines: a five-segment line.
CircuitBoardCoarse: all right angles (uses AStar path finding).
CircuitBoardFine: same as CircuitBoardCoarse, but allows non-right angles.
Ramen: same as CircuitBoardFine, but uses splines instead of line segments
Provides several operational and visual styles for the Filter Graph:
- Drop Shadow: Filters and Noodles cast a drop shadow on the canvas. The corresponding property is
DSGraphEditPanel.DropShadow.
- Pin Placement: sets the pins on the Filters to be inside, outside or indented. The corresponding property is
DSGraphEditPanel.PinPlacement.
- Show Pin Names: draws the names for the pins onto the canvas. The corresponding property is
DSGraphEditPanel.ShowPinNames.
- Show/Hide Time Slider: sets the Time Slider (in)visible. The corresponding property is
DSGraphEditPanel.ShowTimeSlider.
- Modal Properties: sets if Filters show their properties in a modal dialog or directly on the canvas. The corresponding property is
DSGraphEditPanel.ModalProperties.
- Connect Intelligent: sets if the Filter Graph adds intermediate filters when it connects two pins. The corresponding property is
DSGraphEditPanel.ConnectIntelligent.
- Use Clock: enables or disables the reference clock of the Filter Graph. The corresponding property is
DSGraphEditPanel.UseReferenceClock.
The Time Slider
If filterGraph has IMediaSeeking available, you can set the current playback of the graph with the Time Slider. Unlike Microsoft's GraphEdit, the Time Slider displays the current time (in hrs:mins:secs:frame format) and allows you to set the start and end positions of the media.
The Canvas
The Canvas is where the Filters are displayed as Nodes with interconnecting Noodles. Connecting pins is as easy as drag and drop, or point and click. In addition, depending on the type of Filter that is represented, the Node can have several different attributes.
If DSGraphEditPanel is set to ModalProprties = false, clicking the button will show/hide the properties for the filter inside the node. This way, you can have multiple filter properties open at once on the canvas. Otherwise, the filter properties will be shown in a modal dialog box. When viewing filter properties, clicking the Scan Interfaces button will scan the filter for all known DirectShow and Media Foundation interfaces, in addition to any interfaces in the Registry, and display them in a dialog box for your snooping pleasure.
If DSGraphEditPanel was created with the DSGraphEditPanel() or DSGraphEditPanel(string graphFileName) constructors and the filter is a Video Renderer, the video will be displayed inside the node. To detach the video into its own window, click the Detach Video Window button . Closing the detached video window will return to the video inside the Node. Also, if a Video Renderer is attached to any DVD Navigator Filter, the video window will post mouse events to the Navigator allowing interaction with DVD menus.
Unlike Microsoft's GraphEdit, DSGraphEditPanels allows you view and modify properties of DMOs (DirectX Media Objects):
DSFiltersPanel
DSFiltersPanel provides a searchable TreeView of all the DirectShow filters registered on the system. After DSFiltersPanel is constructed, set its AssociatedGraphPanel property to the current DSGraphEditPanel. Once a DSFilterPanel is created and associated with a DSGraphEditPanel, you can drag/drop filters onto a DSGraphEditPanel, double click them to add to the associated DSGraphEditPanel or click the Insert Filter button . DSFilterPanel also provides a property panel with all the FilterData information found in the registry:
Graph Navigator
The Graph Navigator provides a small overview of the current DSGraphEditPanel with a puck that shows the part of the canvas that is visible in the viewport. You can drag the puck to quickly scroll the graph to new locations.
DSGraphEditForm
DSGraphEditForm allows you to take a quick peek at a Filter Graph without having to hassle with setting up a DSGraphEditPanel/DSFiltersPanel pair or using connect to a remote graph:
IFilterGraph myFilterGraph = (IFilterGraph)new FilterGraph();
...
...
DSGraphEditForm dsGraphEditForm = new DSGraphEditForm(myFilterGraph);
dsGraphEditForm.ShowDialog();
dsGraphEditForm.Dispose();
dsGraphEditForm = null;
No muss, no fuss.
Known Issues
In order for DSGraphEditPanel.ConnectToRemoteGraph() to work on Windows Vista, you actually need to have the version of GraphEdit from the Windows SDK for Windows Vista and register the proppage.dll that comes with it. If you have the older version of GraphEdit from the previous version of the Windows SDK, it still won't work. It has to be the one from the Windows SDK for Vista. The reason for this is that Microsoft (in their infinite wisdom) removed almost all the proxy/stub pairs from Quartz.dll in Vista and moved them all into the proppage.dll file. Without the proxy/stub pairs registered, Windows can't marshal proxies from one thread apartment to another. (Shame on you, Microsoft.)
History
- 10/30/07: Initial release of
DSGraphEdit
- 12/14/07: Version 1.1
- The DSGraphEdit demo now uses the Weifenluo DockPanel Suite for MDI-style multiple graph editing.
- Major optimizations to
DaggerLib.UI.Windows rendering speed.
- Full source to
DaggerLib.Core and DaggerLib.UI.Windows now included in Solution.
- Added
GraphNavigator control for easier editing/browsing of large graphs.
- Pin names are drawn inside nodes when not viewing non-modal properties.
- Arrange Nodes now accounts for pin names that are drawn on the Canvas.
InitVideoWindow in VideoInternalWindow would fail when loading a Graph that had an unconnected video renderer.
VideoInternalWindow now supports loading graphs that contain an EVR filter.
SyncGraph now removes/re-routes connections.
VideoInternalWindow posts mouse location and mouse clicks to attached DVD Navigators for interaction with DVD menus.
- Filter Nodes hosting a
VideoInternalWindow connected to DVD Navigators now have a DVD Chapters button.
VideoInternalWindow now supports windowed full screen.
- Added
CanvasImage property to DSGraphEditPanel for retrieving a snapshot of the Canvas.
- Now scans ALL interfaces Pins and Filters support (not just the
DirectShow interfaces).
- Fixed some property pages not being visible in non-modal mode.
| You must Sign In to use this message board. |
|
| | Msgs 1 to 25 of 43 (Total in Forum: 43) (Refresh) | FirstPrevNext |
|
 |
|
|
 |
|
|
Most certainly. I've not placed any restrictions on using any of the code in DaggerLib or DsGraphEdit in commercial applications.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi, Do you know of any way to attach your version of Graph Edit to a graph running on Windows Mobile 6.0 without DCOM support? The usual mechanism for creating and registering an ItemMoniker in the ROT fails. Thanks 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi,
First, you did a beautiful, amazing job. Congratualtions.
Second, why did you write this great piece of software? Are you planning to sell it? You ould easily sell it for $29.95 and sell 10,000 copies in a year. I know, I sell a lot of software.
Third, the one feature that is missing is the only feature that GraphEditPlus sells which is their code generation--you can select C++ or C# and the code is written to load the graph and play it in a console application and the code generated to do this is displyed in a popup window so you can copy and paste it, and compile it. This is the feature that would make your program beat GraphEditPlus.
Fourth, every good application needs a demo that blows people out of the water. I have that demo for you. Did you know that you can easily compile VLC as a DirectShow filter and a free sample of the source code to do this is avaailable on the Internet--FREE? If you add this VLC as a DirectShow SOURCE filter to a sample graph it will play virtually any file format and RTSP streams from ip cameras and it has the best free multiplexer. That would give you a demo filter that literally does everything including RIPPING copy protected DVDs.
Anyway, congratulations again on a really beautiful piece of work.
If you ever need an investor for a project, call me and let's talk.
Bill SerGio, The Infomercial King
www.SlickSkins.net GUI Guy
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi, This sounds too good to be true. Where can the sample source code be found to compile VLC as a DirectShow source filter ? Thanks 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
An opensource VLC DirectShow Source Filter for multiplexing captured audio/video for file writing or RTP streaming is available for download at http://www.sensoray.com/support/videoLan.htm
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi, I have been working with a "Philips SPC 900 NC/00 PC Camera" in several different software systems trying to understand how to handle display of the "Properties" window. I was hoping your software would be able to handle it so I could see what I was doing wrong but alas, your software "hangs" when I try to bring up the "Properties" window. You have to kill the program using the Task Manager or, if your are debugging, simply stop debugging. The statement that is hanging is this: "pp.Activate(tp.Handle, ref rect, false);", line 130 of PropertyPagePanel.cs. This behavior is also exhibited by GraphStudio which is in C++. Essentially the same problem.
In my software (HandyAvi), I have been using "OleCreatePropertyFrame" to bring up the window. That works and displays the "General" and "Video" tabs correctly but when the user hits the "Audio" tab, it crashes the whole application! Very annoying! (At least it doesn't "hang" so it is a little easier for the user )
These problems do not occur with other cameras so I assume Philips did something peculiar.
Also, the problem does not occur in GraphEdit or in GraphEditPlus (which I just bought) or in the Philips application that came with the camera so there must be some way to handle this?
What do we have to do to get the "SPC 900" "Properties" panel to display and behave properly?
Thanks,
Howard
Howard C. Anderson HTTP://www.astroshow.com
modified on Monday, June 23, 2008 6:58 PM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Oh-oh.
I just tried my application on XP and it works. I compiled on Vista and the problem occurs in Vista. When I run the executable (without recompiling) it runs fine on XP without crashing when I hit the "Audio" tab.
So what was that you were saying about proxies in Vista? I have latest stuff installed on Vista. What else do I have to do I wonder?
I need the application to work on XP AND Vista... I don't want to have to tell the users to install other "proxy" stuff or whatever. It needs to be self-contained so that it installs and works.
Thanks,
Howard
Howard C. Anderson HTTP://www.astroshow.com
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I'm using Vista x64 and DSGraphEdit launches in 64-bit mode, but the filters I need to use are 32-bit only. Is there a way I can launch DSGraphEdit in 32-bit mode?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi,
I'm new to the whole subject and would like to read a bit more about it as I have to admit that I don't have a clou
I got currently a problem on my PC that I can not view videos, but hear the sound, and if I start your program everything works magically (only if I load also a film to render).
I'm surer there is an easy? explanation to it, but don't have the necessary knowledge yet to find the problem.
So - do you have any recommendation on books or articles I could read to learn more about the subject?
Look really forward for any recommendation,
Best regards
Chris
modified on Sunday, January 27, 2008 5:41:52 PM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
How/where can I post questions concerning the DaggerLib code?
Is there an easy way to make the daggerlib graphs top down? Instead of left right?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
BryanWilkins wrote: How/where can I post questions concerning the DaggerLib code?
You can email me at JohnnyLocust@gmail.com
BryanWilkins wrote: Is there an easy way to make the daggerlib graphs top down? Instead of left right?
I'll work on that this week. In DaggerUINode.cs, UpdatePaths, UpdateTargetRegions, UpdateRegion, and CreateBackImage have to be extended to allow for vertical alignment, plus DaggerNoodle.cs has to be changed. If you let me know what you're trying to achieve, I may be able to help you. I made DaggerLib to be able to create flow based visual languages as seamless as possible.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I like your project. It has some good ideas. I have a volume mixer that I have put together programmatically using C++ and MFC, which captures music from an mp3 file and feeds it to the audio mixer filter as an input. It also has three microphones as inputs, and a set of speakers as well as two pairs of headsets as outputs. So it has 4 inputs and three outputs. That was my first shot at building a filtergraph to capture audio. I want to take it one step further and capture audio from the Windows Media Player in place of the mp3 file to feed as an input to the audio mixer. Does anyone know how to capture the audio from the back end of the WMP just before it goes out to the sound renderer? I tried using a moniker for rendered output and that didn't work. I also tried using a moniker for the sound card to feed into the audiomixer, and I didn't get very far. Is there a better strategy that I should be using, or are there filters out there that capture the wmp audio from audio CDs as well as video DVDs, that might help me in solving this problem. I'm trying to keep it generic as far as the audio, so I want to capture the audio further down the line where it has been converted to a standard format, such as a wave or some other standard format, just before it goes to the sound renderer. Any help in the form of code samples would be greatly appreciated.
Thanks in advance!
GrizMan
modified on Friday, December 21, 2007 10:10:13 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
With the Sample Grabber Filter, do you have an opportunity to select from several sources? If so, can it be audio output from a DVD or CD that is playing in the WMP? Basically, does it take it from the back end just before it goes to the renderer?
As you can see I'm a newbie to this filter stuff. I did a little more research and found that the sample grabber is a transform filter, so it looks like it needs an input and an output. I read that if you add the filter to your graph and give a source, it will add in the filters it needs to capture the feed from the source. My question: When you setup the sample grabber in the code and you give the Major type as MediaType_Audio, is that good enough, and then it will look at all audio in the system and grab the system level audio before it gets rendered, as well as add any filters it needs? I guess my basic question is how do you make the system audio an input to the Sample Grabber filter?
After a little more research and a test that I built up in code I have a variation on my last question above. I was wondering if there is a filter that could be the first filter in a graph that would capture the system audio before it goes to the audio renderer and then I could use it to feed into the sample grabber or my volume mixer that I described above? It would probably have to be a source filter (I think that's the type) that would use the system audio as the source, as opposed to a transform or sink filter.
Thanks in advance
GrizMan
modified on Saturday, December 22, 2007 2:14:43 PM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Audio capture source filters for sound cards usually expose a Wave Out or Wave Mix pin (the name varies by sound card vendor) that can be used to capture the audio that is currently being played on a device. You can't modify it before it is sent to the device though. If you're looking to capture audio from WMP, I'd really recommend looking at the WMP plugin sdk. It explains how to create and register a DMO for it. There are also examples of how to create a DMO in the DirectShowLib samples. They're actually much easier to create than a regular DirectShow filter.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
So what your suggesting is that I can create a DMO (DirectX Media Object) programmatically that is associated with the WMP and I can feed that directly into some type of DMO filter, which can have it's connection rendered to the volume mixer as the first input, and which would be the start of my filtergraph with the system sound. Then I can render the connections for the mic's as additional input capture devices to the volume mixer, as well as render the connections to the output devices, which are the speaker system, and two earphone headsets. If this all sounds correct, do you remember the name of a code sample or project that creates the DMO and has a DMO filter that accesses the DMO for the WMP so I can Google it and check out the code as well as any descriptions I may need that describe the process?
Also, for the audio capture source filter, if we wanted to capture the sound, it sounds like we would have to go to the vendor of the sound card to get a filter to capture the sound in a wave format, which could then be fed into the volume mixer? Do you think this is a filter I could just download from the vendor of the sound card?
As you can tell from my questions, and previous statements, I am a novice and I just want to make sure I am doing this properly. That's why I'm asking the question about the example.
Again, thanks in advance for your assistance.
GrizMan
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I'm replying to myself just to let anyone out there that is in this situation that there is an input device filter for Stereo Mix or Wave Out Mix, which captures the sound as it goes to the speakers and you can use that filter to start the graph.
I ran into one thing though. I set the stereo mix filter in my graph and then it needs some kind of enable of the Main Input Mix or the Pin Line Input Mix and I am not able to enable either of them.
Any help would be great and as always, thanks in advance.
GrizMan
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
I have just started to study c#. I want to know how to draw lines, especially in line connection. So could you please send me a copy of DraggerLib? My Email address: lwinne@gmail.com Thanks very much.
BR Winne
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
The updated version of DSGraphEdit now has the full source for DaggerLib in it. Sorry it took so long.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
Thanks a lot! Now we can receive your original codes. It's excellent.
www.codeproject.com is a good web for our programer.
I like life and I think it is living.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I'll need a little more info from ya to figure out why. Which filters are not appearing? Do they appear in the AddFilters dialog in GraphEdit? If they do appear in GraphEdit, what category are they under?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I re-regestered the filters and they did show up. One filter video source (a camera) and another creates some effects in video sequences. Before re-regestering, the filters did show up in GraphEdit.
Anyway, I was able to work around the issue.
DSGraphEdit is AWESOME!!!!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Great Program -- I love it. One problem, some of my filters don't appear in the list even though they are registered and in the windows/system32 directory. Any suggestions?
|
| Sign In·View Thread·PermaLink | | | | | | |