Another FreeFrame wrapper

You can dowload the code and the binary of my FreeFrame wrapper here. To use the wrapper in a C# application, you can use the following:

Type comtype = null;
object freeFrame = null;

Guid FFguid = new Guid("F10FF33C-C89F-4765-A960-0EF260EE7670");

comtype = Type.GetTypeFromCLSID( FFguid );
freeFrame = Activator.CreateInstance( comtype );

graphBuilder.AddFilter( (IBaseFilter)freeFrame, "FreeFrame" );
DsError.ThrowExceptionForHR(hr);

PlugIn = freeFrame as IFFPlugMain;
hr = graphBuilder.RenderFile(videoFname, null);
DsError.ThrowExceptionForHR(hr);

where IFFPlugMain is defined as:

[Guid("9567207A-D64A-440d-A078-81EE2E1D4CDE"),

InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

public interface IFFPlugMain

{

void SetPlugin([In, MarshalAs(UnmanagedType.LPStr)] string Filename);
void GetNumParameters(out int numParams );
void GetParameterName(int idx, out IntPtr name );
void GetParameterDefault(int idx, out float value );
void GetParameter(int idx, out float value );
void SetParameter(int idx, float value );

void GetPtr([Out] IntPtr ptr);
void CallPlugMain( uint code, uint arg, uint inst, out uint ret );

}

You can retrieve parameter values with code like:

PlugIn.GetNumParameters(out paramCount);
IntPtr namePtr = Marshal.AllocHGlobal(16);

for(int i = 0; i < paramCount; i++ )
{
PlugIn.GetParameterName(i,out namePtr);
str = Marshal.PtrToStringAnsi(namePtr);
...

and set parameters with code like:

public void UpdateParams()
{
for(int i = 0; i < paramCount; i++ )
{
mediaControl.Pause();
PlugIn.SetParameter(i, (float)paramTrackBars[i].Value/100.0f );
mediaControl.Run();
}
}

I'll post a more complete sample in the near future. You can download the sources of FreeFrame video effects from Pete Warden's web site, for example.

 




Bookmark it...
Digg!Reddit!Del.icio.us!Google!Facebook!Slashdot!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!
 
< Prev   Next >
Joomla Template by Joomlashack
Joomla Templates by JoomlaShack Joomla Templates by Compass Design