I am new to DirectShow. I have a DirectShow source filter that takes a file name as input. It outputs video and audio. I have built a graph and can run it and all works fine. For my testing, I have hard coded the name of the input file using the IFileSourceFilter at the time I build the graph. I have also added test code that will later change the source filter on my graph to a different file at runtime and this works fine. Now that my testing is complete, I want to move this code into production. For production - the source file is not known until runtime. So I want to remove the initial setting of a hard coded file name when I create the graph, and just change it as needed at runtime. I tried changing my code to not set the source file when I build the graph (both by omitting the code, and by passing a null string for the file name). Neither worked. When I try to connect the pins - I receive an error connecting the audio output pin to the default DirectShow audio device (error 0x80004005 ). Seems that a missing or invalid file name will not even allow me to connect the pins to build the graph. I was hoping to just build the graph once when my app initializes, leave it around, and then change the source file as needed during the operation of my program. As I see it, my choices are: A) Have a dummy file that can be loaded at initialization. Then just change it as needed. Don't like this. B) Add the filters needed to the graph when I startup, and then connect all the pins later when I need to load a file. Keeping a flag to tell me if the pins are already connected so there is no need to do this again. Don't like this much either. So what is the the "normal" order of operations for this type of thing in DirectShow? Can somebody offer me an "option C"? -TIA -Figmo
From: "Figmo" > A) Have a dummy file that can be loaded at > initialization. Then just change it as needed. Don't > like this. > > B) Add the filters needed to the graph when I startup, > and then connect all the pins later when I need to load a > file. Keeping a flag to tell me if the pins are already > connected so there is no need to do this again. Don't > like this much either. http://msdn.microsoft.com/en-us/library/ms785719(VS.85).aspx <<<It is not designed to load multiple files, and any calls to this method after the first call will fail.>>> > So what is the the "normal" order of operations for this > type of thing in DirectShow? Can somebody offer me an > "option C"? Build the graph when you know the file name: 1. you can not change the file and 2. the file is required to know the media types and thus what filters are needed. -- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
On Wed, 2 Jul 2008 14:40:12 -0700 (PDT), Figmo wrote: > I was hoping to just build the graph once when my app initializes, > leave it around, and then change the source file as needed during the > operation of my program. As Alessandro wrote, this is not something that IFileSourceFilter is meant to do. The usual approach to this is to use two graphs. See Geraint's free GMFBridge which comes with source code. The samples includes a playlist of multiple files. -- Please read this before replying: 1. Dshow & posting help: http://tmhare.mvps.org/help.htm 2. Trim & respond inline (please don't top post or snip everything) 3. Benefit others: follow up if you are helped or you found a solution