13.07.2015 Views

Quicktime File Format (2012-08-14).pdf

Quicktime File Format (2012-08-14).pdf

Quicktime File Format (2012-08-14).pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Some Useful Examples and ScenariosCreating, Copying, and Disposing of Atom ContainersOnce you have retrieved a child atom, you can call QTNextChildAnyType function to retrieve subsequentchildren of a parent atom. QTNextChildAnyType returns an offset to the next atom of any type in a parentatom’s child list. This function is useful for iterating through a parent atom’s children quickly.QuickTime also provides functions for retrieving an atom’s type, ID, and data. You can call QTGetAtomTypeAndIDfunction to retrieve an atom’s type and ID. You can access an atom’s data in one of three ways.●●●To copy an atom’s data to a handle, you can use the QTCopyAtomDataToHandle function.To copy an atom’s data to a pointer, you can use the QTCopyAtomDataToPtr function.To access an atom’s data directly, you should lock the atom container in memory by callingQTLockContainer. Once the container is locked, you can call QTGetAtomDataPtr to retrieve a pointerto an atom’s data. When you have finished accessing the atom’s data, you should call theQTUnlockContainer function to unlock the container in memory.Modifying AtomsQuickTime provides functions that you can call to modify attributes or data associated with an atom in an atomcontainer. To modify an atom’s ID, you call the function QTSetAtomID.You use the QTSetAtomData function to update the data associated with a leaf atom in an atom container.The QTSetAtomData function replaces a leaf atom’s data with new data. The code sample in Listing 6-8 (page332) calls QTFindChildByIndex to determine whether an atom container contains a sprite’s visible property.If so, the sample calls QTSetAtomData to replace the atom’s data with a new visible property.Listing 6-8Modifying an atom’s dataQTAtom propertyAtom;// if the atom isn’t in the container, add itif ((propertyAtom = QTFindChildByIndex (sprite, kParentAtomIsContainer,kSpritePropertyVisible, 1, nil)) == 0)FailOSErr (QTInsertChild (sprite, kParentAtomIsContainer,kSpritePropertyVisible, 1, 0, sizeof(short), visible, nil))// if the atom is in the container, replace its dataelseFailOSErr (QTSetAtomData (sprite, propertyAtom, sizeof(short),visible));<strong>2012</strong>-<strong>08</strong>-<strong>14</strong> | © 2004, <strong>2012</strong> Apple Inc. All Rights Reserved.332

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!