开发者

How do you Reuse a DirectShow filter graph with different file

开发者 https://www.devze.com 2023-02-28 17:16 出处:网络
I have an application the creates directshow graphs using filterGraph.RenderEx(); since 1it can take a long time to get the graph up and running, I would like to create a few graphs at the start of th

I have an application the creates directshow graphs using filterGraph.RenderEx(); since 1it can take a long time to get the graph up and running, I would like to create a few graphs at the start of the app and then reuse them by changing the source file. ie

  1. play file1.wmv
  2. wait for file to finish
  3. change the graph to point to file2.wmv
  4. play file2

How do you change the source file so you do not have to recreate the entire graph for the next file?

Edit:::

I am not trying to play files back to back, but overlapping. The graphs are actually rendering to texture2d objects as part of a d3d application.

Here is what I am doing. I am adding a sourceFilter using:

IBaseFilter sourceFilter;
int hr = filterGraph.AddSourceFilter(file, file, out sourceFilter);
/* We will want to enum all the pins on the source filter */

IEnumPins pinEnum;
hr = sourceFilter.EnumPins(out pinEnum);
DsError.ThrowExceptionForHR(hr);

IntPtr fetched = IntPtr.Zero;
IPin[] pins = { null };

/* Counter for how many pins successfully rendered */
int pinsRendered = 0;

/* Loop over each pin of the source filter */
while (pinEnum.Next(pins.Length, pins, fetched) == 0)
{
     if (filterGraph.RenderEx(pins[0], AMRenderExFlags.None, IntPtr.Zero) >= 0)
         pinsRendered++;

     Marshal.ReleaseComObject(pins[开发者_开发问答0]);
}
Marshal.ReleaseComObject(pinEnum);

When the file is done playing, at some point in the future,I would like to set the source filter to another file(of the same type), so i don't have to completely rebuild the graph which can be very slow to create. Is there something i can cast the sourceFilter object to that allows me to set it to another file?


The GMFBridge can be used for this. There are ports to .NET AFAIK. Have a look at the GMFPlay application mentioned at http://directshownet.sourceforge.net/about.html.

Using intelligent connect can slow down the graph building process. Using direct connections should speed up the process as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消