ADC Home > Reference Library > Technical Q&As > QuickTime > Video Effects & Transitions >

Filtering the Effects List returned by QTGetEffectsList


Q: I'm getting a list of QuickTime effects via the QTGetEffectsList function. I will then pass this list to the QTCreateStandardParameterDialog function to create a dialog so the user can choose an effect from the list. However, I would like to be able to edit the list beforehand so it only shows the effects I want. Is this possible?

A: With QuickTime 6 you can use the nifty new function QTGetEffectsListExtended to filter the effects which are placed into the effects list. Full documentation for this function can be found in the "What's New in QuickTime 6" document. We strongly urge developers to use this technique as it will guarantee compatability with future versions of QuickTime.

For example, here's how you would use this call to display only multi-source transition effects:

QTAtomContainer effectsList;
OSErr err;


err = QTGetEffectsListExtended(
    &effectsList,
    2,  /* minimum number of sources */
    -1, /* no maximum number of sources */
    0,  /* getOptions - optional */
    kTransitionMajorClass, /* filter multi-source morph effects */
    kTransitionMinorClass, /* filter transitions */
    0,  /* optional filter procedure */
    0); /* optional refcon for the filter procedure */

Listing 1. Filtering the effects list using QTGetEffectsListExtended

For QuickTime 5 and earlier, you'll need to manually walk the list of effects returned by QTGetEffectsList and delete those effects from the list you don't want shown. The list returned by QTGetEffectsList contains two atoms for each effect component. The first atom, of type kEffectNameAtom ('name'), contains the name of the effect. The second atom, of type kEffectTypeAtom ('type'), contains the type of the effect, which is the sub-type of the effect component. Simply walk this list and remove both the kEffectNameAtom and kEffectTypeAtom atom for those effects you don't want shown. Here's a code snippet showing how it's done:

void BuildAndEditEffectsList() {
    short             childCount, index;
    OSErr             err;
    QTAtomContainer   effectsList, effectSample;
    QTParameterDialog effectsDialog;
        /* these are the only effects we'd like to
            show up in the list */
    const OSType supportedEffects[] = {
        kBlurImageFilterType,
        kBrightnessContrastImageFilterType
    };


        /* get the current list of effects */
        /* min == max == -1, no min or max */
    err = QTGetEffectsList( &effectsList, -1, -1, 0 );
    if (err != noErr) goto bailError;

        /* get a count of the number of effects in the list */
    childCount = QTCountChildrenOfType(
        effectsList, kParentAtomIsContainer, kEffectNameAtom );
        /* iterate over each effect in the list, removing those
        which don't match the ones in our pre-chosen list
        from above */
    for( index = childCount; index > 0 ; index -- )
    {
        QTAtom     effectTypeAtom;
        QTAtomID   id;
        long       effectCodeSize;
        Ptr        effectCodePtr;
        OSType     effectCode;
        short      j;
        Boolean    effectIsSupported;

        effectTypeAtom = QTFindChildByIndex( effectsList,
            kParentAtomIsContainer,
            kEffectTypeAtom, index, &id );
        err = QTLockContainer( effectsList );
        if (err != noErr) goto bailError;

        err = QTGetAtomDataPtr( effectsList,
            effectTypeAtom,
            &effectCodeSize,
            &effectCodePtr);
        if (err != noErr) goto bailError;

            /* grab the actual effect code */
        effectCode = *(OSType *)effectCodePtr;

        err = QTUnlockContainer( effectsList );

            /* check to see if the current
            effect is in our list */
        for( j=0, effectIsSupported=false ;
            j<sizeof(supportedEffects)/sizeof(OSType) ; j++ )
        {
            if ( effectCode == supportedEffects[j] )
            {
                effectIsSupported = true;
                break;
            }
        }
            /* delete the effect from the list if we didn't find a match
            in our custom list */
        if ( !effectIsSupported )
        {
            QTAtom effectNameAtom;

            effectNameAtom = QTFindChildByIndex( effectsList,
                kParentAtomIsContainer, kEffectNameAtom, index, &id );
            err = QTRemoveAtom( effectsList, effectTypeAtom );
            err = QTRemoveAtom( effectsList, effectNameAtom );
        }
    }

        /* now use our newly built effects list to
        create a dialog for later use... */
    err = QTNewAtomContainer( &effectSample );
    err = QTCreateStandardParameterDialog( effectsList,
            effectSample, 0, &effectsDialog );

bailError:
    return;
}

Listing 2. Editing the list of effects returned by QTGetEffectsList


[Sep 04 2002]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.