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 Containers// if an atom does exist, update its dataelseFailOSErr (QTSetAtomData (sprite, propertyAtom,sizeof(short), visible));}// ...// handle other sprite properties// ...}You can call the QTFindChildByID function to search for and retrieve a parent atom’s child by its type andID. The sample code function AddSpriteToSample, shown in Listing 6-7 (page 331), adds a sprite, representedby an atom container, to a key sample, represented by another atom container. AddSpriteToSample callsQTFindChildByID to determine whether the atom container theSample contains an atom of typekSpriteAtomType with the ID spriteID. If not, AddSpriteToSample calls QTInsertChild to insert anatom with that type and ID. A value of 0 is passed for the index parameter to indicate that the atom shouldbe inserted at the end of the child list. A value of 0 is passed for the dataSize parameter to indicate that theatom does not have any data. Then, AddSpriteToSample calls QTInsertChildren to insert the atoms inthe container theSprite as children of the new atom. FailIf and FailOSErr are macros that exit thecurrent function when an error occurs.Listing 6-7Finding a child atom by IDOSErr AddSpriteToSample (QTAtomContainer theSample,QTAtomContainer theSprite, short spriteID){OSErr err = noErr;QTAtom newSpriteAtom;FailIf (QTFindChildByID (theSample, kParentAtomIsContainer,kSpriteAtomType, spriteID, nil), paramErr);FailOSErr (QTInsertChild (theSample, kParentAtomIsContainer,kSpriteAtomType, spriteID, 0, 0, nil, &newSpriteAtom));FailOSErr (QTInsertChildren (theSample, newSpriteAtom, theSprite));}<strong>2012</strong>-<strong>08</strong>-<strong>14</strong> | © 2004, <strong>2012</strong> Apple Inc. All Rights Reserved.331

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

Saved successfully!

Ooh no, something went wrong!