Skip to main content
Email Password   helpLost your password?
DSGraphEditDemo

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:

//add namespace    

using DaggerLib.DSGraphEdit;

DaggerLib.DSGraphedit provides three controls:

DSGraphEditPanel

Constructing a DSGraphEditPanel

DSGraphEditPanel can be created in four different ways:

  1. // construct a DSGraphEditPanel with an empty IFilterGraph
    
    DSGraphEditPanel dsGraphEditPanel = new DSGraphEditPanel();
  2. // construct a DSGraphEditPanel from an existing IFilterGraph
    
    IFilterGraph myFilterGraph = (IFilterGraph)new FilterGraph();
    ...
    // do something with myFilterGraph
    
    ...
    DSGraphEditPanel dsGraphEditPanel = new DSGraphEditPanel(myFilterGraph);
  3. // construct a DSGraphEditPanel from a *.grf file
    
    // Grf files are files that are created by GraphEdit or from a call 
    
    // to DSGraphEditPanel.SaveFilterGraph(string filename). 
    
    // Also, constructing a DSGraphEditPanel from a grf file should 
    
    // always be enclosed in a try/catch block because 
    
    // it may want some filters that are not registered on your system. 
    
    
    DSGraphEditPanel dsGraphEditPanel = null;
    try
    {
        dsGraphEditPanel = new DSGraphEditPanel("c:\\somegraphfile.grf");
    }
    catch (Exception ex)
    {
        // we failed, show the error
    
        MessageBox.Show(ex.Message, "Error loading graph file");
    }
  4. // attempt connection to a remote graph on the ROT via 
    
    // the DSGraphEditPanel.ConnectToRemoteGraph static method
    
    DSGraphEditPanel dsGraphEditPanel = null;
    try
    {
        dsGraphEditPanel = DSGraphEditPanel.ConnectToRemoteGraph();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "Error connecting to remote graph");
    }
    ...
    // do something with your connected graph
    
    ...
    // disconnect from the 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:

Connecting to a Remote Graph

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:

DSGraphEditPanel Items
The Toolbar Buttons
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):

DSGraphEditDemo DMO

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:

DSFiltersPanel

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.

Graph Navigator

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:

// create an arbitrary IFilterGraph

IFilterGraph myFilterGraph = (IFilterGraph)new FilterGraph();
...
// do something with myFilterGraph

...
// create and show the DSGraphEditForm as a modal dialog

DSGraphEditForm dsGraphEditForm = new DSGraphEditForm(myFilterGraph);
dsGraphEditForm.ShowDialog();

// dispose of it

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

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
General64 bit Pin
JohnnyLocust
23:54 26 Sep '09  
Generalcan' compile the Code Pin
aquilaii
7:22 23 Aug '09  
GeneralRe: can' compile the Code Pin
JohnnyLocust
6:57 25 Aug '09  
GeneralError reading .MOV with QuickTime Decoder Pin
emmanuel30
8:12 9 May '09  
GeneralUsing your code Pin
WKaa
22:21 13 Nov '08  
GeneralRe: Using your code Pin
JohnnyLocust
11:30 15 Nov '08  
GeneralAttach to remote filtergraph running on Windows Mobile 6.0 ? Pin
carbi1897
14:04 12 Nov '08  
GeneralFantastic Job! You Need One More Feature to Be Number One... Pin
GUI Developer
3:38 25 Oct '08  
QuestionRe: Fantastic Job! You Need One More Feature to Be Number One... Pin
carbi1897
13:30 12 Nov '08  
AnswerRe: Fantastic Job! You Need One More Feature to Be Number One...OpenSource VLC Source Pin
carbi1897
7:01 14 Nov '08  
GeneralPhilips SPC 900 NC/00 PC Camera [modified] Pin
Howard Anderson
13:49 23 Jun '08  
GeneralRe: Philips SPC 900 NC/00 PC Camera Pin
Howard Anderson
14:21 23 Jun '08  
GeneralHow to run in x86 mode on x64 Vista Pin
Mr. Baz
10:19 19 Mar '08  
GeneralFurther readings [modified] Pin
Klatoo
2:28 12 Jan '08  
Generalwhere to Questions about DaggerLib code? Pin
BryanWilkins
9:38 7 Jan '08  
GeneralRe: where to Questions about DaggerLib code? Pin
JohnnyLocust
22:55 8 Jan '08  
QuestionCapturing Audio from the Windows Media Player at the back end to feed into a volume mixer and feed to speakers and headphones [modified] Pin
GrizzlyDoug
19:53 20 Dec '07  
GeneralRe: Capturing Audio from the Windows Media Player at the back end to feed into a volume mixer and feed to speakers and headphones Pin
JohnnyLocust
10:27 21 Dec '07  
GeneralRe: Capturing Audio from the Windows Media Player at the back end to feed into a volume mixer and feed to speakers and headphones [modified] Pin
GrizzlyDoug
14:24 21 Dec '07  
GeneralRe: Capturing Audio from the Windows Media Player at the back end to feed into a volume mixer and feed to speakers and headphones Pin
JohnnyLocust
7:40 23 Dec '07  
GeneralRe: Capturing Audio from the Windows Media Player at the back end to feed into a volume mixer and feed to speakers and headphones Pin
GrizzlyDoug
13:53 24 Dec '07  
GeneralRe: Capturing Audio from the Windows Media Player at the back end to feed into a volume mixer and feed to speakers and headphones Pin
GrizzlyDoug
14:45 27 Dec '07  
GeneralExcellent! [modified] Pin
Ernest Laurentin
6:38 6 Dec '07  
GeneralCould you please send a copy of DraggerLib source code to me? Pin
winne_ll
2:03 17 Nov '07  
GeneralRe: Could you please send a copy of DraggerLib source code to me? Pin
JohnnyLocust
11:29 19 Dec '07  


Last Updated 20 Dec 2007 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009