OSErr QTWired_AddWraparoundMatrixOnIdle (QTAtomContainer theContainer) { MatrixRecord myMinMatrix, myMaxMatrix, myDeltaMatrix; long myFlags = kActionFlagActionIsDelta | kActionFlagParameterWrapsAround; QTAtom myActionAtom; OSErr myErr = noErr; myMinMatrix.matrix[0][0] = myMinMatrix.matrix[0][1] = myMinMatrix.matrix[0][2] = EndianS32_NtoB(0xffffffff); myMinMatrix.matrix[1][0] = myMinMatrix.matrix[1][1] = myMinMatrix.matrix[1][2] = EndianS32_NtoB(0xffffffff); myMinMatrix.matrix[2][0] = myMinMatrix.matrix[2][1] = myMinMatrix.matrix[2][2] = EndianS32_NtoB(0xffffffff); myMaxMatrix.matrix[0][0] = myMaxMatrix.matrix[0][1] = myMaxMatrix.matrix[0][2] = EndianS32_NtoB(0x7fffffff); myMaxMatrix.matrix[1][0] = myMaxMatrix.matrix[1][1] = myMaxMatrix.matrix[1][2] = EndianS32_NtoB(0x7fffffff); myMaxMatrix.matrix[2][0] = myMaxMatrix.matrix[2][1] = myMaxMatrix.matrix[2][2] = EndianS32_NtoB(0x7fffffff); myMinMatrix.matrix[2][1] = EndianS32_NtoB(Long2Fix((1 * kSpriteTrackHeight / 4) - (kPenguinHeight / 2))); myMaxMatrix.matrix[2][1] = EndianS32_NtoB(Long2Fix((3 * kSpriteTrackHeight / 4) - (kPenguinHeight / 2))); SetIdentityMatrix(&myDeltaMatrix); myDeltaMatrix.matrix[2][1] = Long2Fix(1); // change location myErr = WiredUtils_AddSpriteSetMatrixAction(theContainer, kParentAtomIsContainer, kQTEventIdle, 0, NULL, 0, 0, NULL, &myDeltaMatrix, &myActionAtom); if (myErr != noErr) goto bail; myErr = WiredUtils_AddActionParameterOptions(theContainer, myActionAtom, 1, myFlags, sizeof(myMinMatrix), &myMinMatrix, sizeof(myMaxMatrix), &myMaxMatrix); bail: return(myErr); }
int process_first_packet__flac(StreamInfo *si, ogg_page *op, ogg_packet *opckt) { unsigned long serialnoatom[3] = { EndianU32_NtoB(sizeof(serialnoatom)), EndianU32_NtoB(kCookieTypeOggSerialNo), EndianS32_NtoB(ogg_page_serialno(op)) }; unsigned long atomhead[2] = { EndianU32_NtoB(opckt->bytes + sizeof(atomhead) - 13), EndianU32_NtoB(kCookieTypeFLACStreaminfo) }; UInt32 sib = EndianU32_BtoN(* (UInt32 *) (((char *)opckt->packet) + 27)); si->si_flac.metablocks = (SInt32) EndianU16_BtoN(* (UInt16 *) (((char *)opckt->packet) + 7)); sib >>= 4; si->si_flac.bps = (sib & 0x1f) + 1; sib >>= 5; si->numChannels = (sib & 0x07) + 1; si->rate = (sib >> 3) & 0xfffff; //si->lastMediaInserted = 0; si->mediaLength = 0; dbg_printf("! -- - flac_first_packet: ch: %d, rate: %ld, bps: %ld\n", si->numChannels, si->rate, si->si_flac.bps); PtrAndHand(serialnoatom, si->soundDescExtension, sizeof(serialnoatom)); //check errors? PtrAndHand(atomhead, si->soundDescExtension, sizeof(atomhead)); //check errors? PtrAndHand((((char *)opckt->packet) + 13), si->soundDescExtension, opckt->bytes - 13); //check errors? si->si_flac.state = kFStateReadingComments; return 0; };
int process_first_packet__speex(StreamInfo *si, ogg_page *op, ogg_packet *opckt) { unsigned long serialnoatom[3] = { EndianU32_NtoB(sizeof(serialnoatom)), EndianU32_NtoB(kCookieTypeOggSerialNo), EndianS32_NtoB(ogg_page_serialno(op)) }; unsigned long atomhead[2] = { EndianU32_NtoB(opckt->bytes + sizeof(atomhead)), EndianU32_NtoB(kCookieTypeSpeexHeader) }; SpeexHeader *inheader = (SpeexHeader *) opckt->packet; si->si_speex.header.bitrate = EndianS32_LtoN(inheader->bitrate); si->si_speex.header.extra_headers = EndianS32_LtoN(inheader->extra_headers); si->si_speex.header.frame_size = EndianS32_LtoN(inheader->frame_size); si->si_speex.header.frames_per_packet = EndianS32_LtoN(inheader->frames_per_packet); si->si_speex.header.header_size = EndianS32_LtoN(inheader->header_size); si->si_speex.header.mode = EndianS32_LtoN(inheader->mode); si->si_speex.header.mode_bitstream_version = EndianS32_LtoN(inheader->mode_bitstream_version); si->si_speex.header.nb_channels = EndianS32_LtoN(inheader->nb_channels); si->si_speex.header.rate = EndianS32_LtoN(inheader->rate); si->si_speex.header.reserved1 = EndianS32_LtoN(inheader->reserved1); si->si_speex.header.reserved2 = EndianS32_LtoN(inheader->reserved2); si->si_speex.header.speex_version_id = EndianS32_LtoN(inheader->speex_version_id); si->si_speex.header.vbr = EndianS32_LtoN(inheader->vbr); //si->si_speex.header. = EndianS32_LtoN(inheader->); dbg_printf("! -- - speex_first_packet: ch: %d, rate: %ld\n", si->si_speex.header.nb_channels, si->si_speex.header.rate); si->numChannels = si->si_speex.header.nb_channels; si->rate = si->si_speex.header.rate; //si->lastMediaInserted = 0; si->mediaLength = 0; PtrAndHand(serialnoatom, si->soundDescExtension, sizeof(serialnoatom)); //check errors? PtrAndHand(atomhead, si->soundDescExtension, sizeof(atomhead)); //check errors? PtrAndHand(opckt->packet, si->soundDescExtension, opckt->bytes); //check errors? si->si_speex.state = kSStateReadingComments; return 0; };
OSErr QTWired_AddCursorChangeOnMouseOver (QTAtomContainer theContainer, QTAtomID theID) { QTAtom mySpriteAtom = 0; QTAtom myBehaviorAtom = 0; QTSpriteButtonBehaviorStruct myBehaviorRec; OSErr myErr = noErr; // find the sprite atom with the specified ID in the specified container mySpriteAtom = QTFindChildByID(theContainer, kParentAtomIsContainer, kSpriteAtomType, theID, NULL); if (mySpriteAtom == 0) { // if there is none, insert a new sprite atom into the specified container myErr = QTInsertChild(theContainer, kParentAtomIsContainer, kSpriteAtomType, theID, 0, 0, NULL, &mySpriteAtom); if (myErr != noErr) goto bail; } // insert a new sprite behaviors atom into the sprite atom myErr = QTInsertChild(theContainer, mySpriteAtom, kSpriteBehaviorsAtomType, 1, 1, 0, NULL, &myBehaviorAtom); if (myErr != noErr) goto bail; ////////// // // insert three atoms into the sprite behaviors atom; these three atoms specify what to do on each // of the four defined state transitions for the (1) sprite image, (2) cursor, and (3) status string // ////////// // set the sprite image behavior; -1 means: no change associated with this state transition myBehaviorRec.notOverNotPressedStateID = EndianS32_NtoB(-1); myBehaviorRec.overNotPressedStateID = EndianS32_NtoB(-1); myBehaviorRec.overPressedStateID = EndianS32_NtoB(-1); myBehaviorRec.notOverPressedStateID = EndianS32_NtoB(-1); myErr = QTInsertChild(theContainer, myBehaviorAtom, kSpriteImageBehaviorAtomType, 1, 1, sizeof(QTSpriteButtonBehaviorStruct), &myBehaviorRec, NULL); if (myErr != noErr) goto bail; // set the sprite cursor behavior; -1 means: no change associated with this state transition myBehaviorRec.notOverNotPressedStateID = EndianS32_NtoB(-1); myBehaviorRec.overNotPressedStateID = EndianS32_NtoB(kQTCursorOpenHand); myBehaviorRec.overPressedStateID = EndianS32_NtoB(-1); myBehaviorRec.notOverPressedStateID = EndianS32_NtoB(-1); myErr = QTInsertChild(theContainer, myBehaviorAtom, kSpriteCursorBehaviorAtomType, 1, 1, sizeof(QTSpriteButtonBehaviorStruct), &myBehaviorRec, NULL); if (myErr != noErr) goto bail; // set the status string behavior; -1 means: no change associated with this state transition myBehaviorRec.notOverNotPressedStateID = EndianS32_NtoB(-1); myBehaviorRec.overNotPressedStateID = EndianS32_NtoB(-1); myBehaviorRec.overPressedStateID = EndianS32_NtoB(-1); myBehaviorRec.notOverPressedStateID = EndianS32_NtoB(-1); myErr = QTInsertChild(theContainer, myBehaviorAtom, kSpriteStatusStringsBehaviorAtomType, 1, 1, sizeof(QTSpriteButtonBehaviorStruct), &myBehaviorRec, NULL); if (myErr != noErr) goto bail; bail: return(myErr); }
int convertToMP4PathThrough(CFStringRef inFile, CFStringRef outFile) { OSStatus error; MovieExportComponent movieExporter = NULL; Handle inDataRef=0, outDataRef=0; OSType inDataRefType, outDataRefType; short inResID = 0; Movie theMovie=0; int ret = -1; error = OpenADefaultComponent(MovieExportType, kQTFileTypeMP4, &movieExporter); if(error) { fprintf(stderr,"OpenADefaultComponent error: cannot find the QuickTime conponent\n"); goto last; } error = QTNewDataReferenceFromFullPathCFString(inFile, kQTNativeDefaultPathStyle, 0, &inDataRef, &inDataRefType); if(error) { fprintf(stderr,"QTNewDataReferenceFromFullPathCFString error: input file path is invalid\n"); goto last; } error = QTNewDataReferenceFromFullPathCFString(outFile, kQTNativeDefaultPathStyle, 0, &outDataRef, &outDataRefType); if(error) { fprintf(stderr,"QTNewDataReferenceFromFullPathCFString error: output file path is invalid\n"); goto last; } error = NewMovieFromDataRef(&theMovie, newMovieActive, &inResID, inDataRef, inDataRefType); if(error) { fprintf(stderr,"NewMovieFromDataRef error: cannot open the input file\n"); goto last; } Track theTrack = getSoundTrack(theMovie); Media theMedia = GetTrackMedia(theTrack); DeleteTrackSegment(theTrack, 0, GetTrackDuration(theTrack)); SetMovieTimeScale(theMovie, GetMediaTimeScale(theMedia)); InsertMediaIntoTrack(theTrack, 0, 0, GetMediaDuration(theMedia), fixed1); Boolean useHighResolutionAudio = true; QTSetComponentProperty( movieExporter, kQTPropertyClass_MovieExporter, kQTMovieExporterPropertyID_EnableHighResolutionAudioFeatures, sizeof(Boolean), &useHighResolutionAudio ); UInt32 ftyp = 'mp42'; QTSetComponentProperty( movieExporter, kQTPropertyClass_MovieExporter, 'ftyp', 4, &ftyp ); QTAtomContainer ac; MovieExportGetSettingsAsAtomContainer(movieExporter, &ac); QTAtom ensoAtom = QTFindChildByID(ac, kParentAtomIsContainer, kQTSettingsMovieExportEnableSound, 1, NULL); if(ensoAtom) { long size, *data; QTGetAtomDataPtr(ac,ensoAtom,&size,(Ptr *)&data); data[0] = EndianS32_NtoB('past'); QTSetAtomData(ac, ensoAtom, size, data); MovieExportSetSettingsFromAtomContainer(movieExporter, ac); } DisposeHandle(ac); /*Boolean cancelled; error = MovieExportDoUserDialog(movieExporter, theMovie, NULL, 0, GetMovieDuration(theMovie), &cancelled); if(cancelled) goto last; if(error) { printf("MovieExportDoUserDialog error\n"); goto last; }*/ error = ConvertMovieToDataRef(theMovie, 0, outDataRef, outDataRefType, kQTFileTypeMP4, FOUR_CHAR_CODE('TVOD'), createMovieFileDeleteCurFile|createMovieFileDontCreateResFile, movieExporter); if(error) { fprintf(stderr,"ConvertMovieToDataRef error: cannot translate .mov into .m4a (%d)\n",error); goto last; } ret = 0; last: if(movieExporter) CloseComponent(movieExporter); if(theMovie) DisposeMovie(theMovie); if(inDataRef) DisposeHandle(inDataRef); if(outDataRef) DisposeHandle(outDataRef); return ret; }
OSErr QTTarg_AddIconMovieSamplesToMedia (Media theMedia) { QTAtomContainer mySample = NULL; QTAtomContainer mySpriteData = NULL; QTAtom myActionAtom = 0; QTAtom myTargetAtom = 0; RGBColor myKeyColor; Point myLocation; short isVisible, myIndex; Fixed myDegrees; FixedPoint myPoint; OSErr myErr = noErr; ////////// // // create a key frame sample containing the sprite images // ////////// // create a new, empty key frame sample myErr = QTNewAtomContainer(&mySample); if (myErr != noErr) goto bail; myKeyColor.red = myKeyColor.green = myKeyColor.blue = 0xffff; // white myPoint.x = Long2Fix(kIconDimension / 2); myPoint.y = Long2Fix(kIconDimension / 2); // add images to the key frame sample SpriteUtils_AddPICTImageToKeyFrameSample(mySample, kOldQTIconID, &myKeyColor, kOldQTIconSpriteAtomID, &myPoint, NULL); SpriteUtils_AddPICTImageToKeyFrameSample(mySample, kNewQTIconID, &myKeyColor, kNewQTIconSpriteAtomID, &myPoint, NULL); ////////// // // add the initial sprite properties and actions to the key frame sample // ////////// // the old QT icon sprite myErr = QTNewAtomContainer(&mySpriteData); if (myErr != noErr) goto bail; myLocation.h = kIconDimension + (kIconDimension / 2); myLocation.v = ((kIconSpriteTrackHeight - kIconDimension) / 2) + (kIconDimension / 2); isVisible = true; myIndex = kOldQTIconImageIndex; SpriteUtils_SetSpriteData(mySpriteData, &myLocation, &isVisible, NULL, &myIndex, NULL, NULL, NULL); WiredUtils_AddQTEventAndActionAtoms(mySpriteData, kParentAtomIsContainer, kQTEventMouseClickEndTriggerButton, kActionSpriteRotate, &myActionAtom); myDegrees = EndianS32_NtoB(FixRatio(90, 1)); WiredUtils_AddActionParameterAtom(mySpriteData, myActionAtom, kFirstParam, sizeof(myDegrees), &myDegrees, NULL); WiredUtils_AddSpriteIDActionTargetAtom(mySpriteData, myActionAtom, 2, NULL); SpriteUtils_AddSpriteToSample(mySample, mySpriteData, kOldQTIconSpriteAtomID); QTDisposeAtomContainer(mySpriteData); // the new QT icon sprite myErr = QTNewAtomContainer(&mySpriteData); if (myErr != noErr) goto bail; myLocation.h = kIconSpriteTrackWidth - (kIconDimension + (kIconDimension / 2)); myLocation.v = ((kIconSpriteTrackHeight - kIconDimension) / 2) + (kIconDimension / 2); isVisible = true; myIndex = kNewQTIconImageIndex; SpriteUtils_SetSpriteData(mySpriteData, &myLocation, &isVisible, NULL, &myIndex, NULL, NULL, NULL); WiredUtils_AddQTEventAndActionAtoms(mySpriteData, kParentAtomIsContainer, kQTEventMouseClickEndTriggerButton, kActionSpriteRotate, &myActionAtom); myDegrees = EndianS32_NtoB(FixRatio(90, 1)); WiredUtils_AddActionParameterAtom(mySpriteData, myActionAtom, kFirstParam, sizeof(myDegrees), &myDegrees, NULL); WiredUtils_AddSpriteIDActionTargetAtom(mySpriteData, myActionAtom, 1, NULL); SpriteUtils_AddSpriteToSample(mySample, mySpriteData, kNewQTIconSpriteAtomID); SpriteUtils_AddSpriteSampleToMedia(theMedia, mySample, kSpriteMediaFrameDurationIcon, true, NULL); bail: if (mySample != NULL) QTDisposeAtomContainer(mySample); if (mySpriteData != NULL) QTDisposeAtomContainer(mySpriteData); return(myErr); }
OSErr SpriteUtils_AddCompressedImageToKeyFrameSample (QTAtomContainer theKeySample, ImageDescriptionHandle theImageDesc, long theDataSize, Ptr theCompressedDataPtr, QTAtomID theImageID, FixedPoint *theRegistrationPoint, StringPtr theImageName) { Handle myImageData = NULL; QTAtom myDefaultsAtom, myImagesContainerAtom, myImageAtom; ImageDescriptionHandle myImageDesc = NULL; OSErr myErr = noErr; #if TARGET_RT_LITTLE_ENDIAN myImageDesc = (ImageDescriptionHandle)NewHandle(GetHandleSize((Handle)theImageDesc)); BlockMoveData(*theImageDesc, *myImageDesc, GetHandleSize((Handle)theImageDesc)); EndianUtils_ImageDescription_NtoB(myImageDesc); #else myImageDesc = theImageDesc; // already is big endian #endif // append compressed picture data to myImageDesc to obtain sprite image data myImageData = NewHandle(0); myErr = MemError(); if (myErr != noErr) goto bail; myErr = HandAndHand((Handle)myImageDesc, myImageData); if (myErr != noErr) goto bail; myErr = PtrAndHand(theCompressedDataPtr, myImageData, theDataSize); if (myErr != noErr) goto bail; myDefaultsAtom = QTFindChildByIndex(theKeySample, 0, kSpriteSharedDataAtomType, 1, NULL); if (myDefaultsAtom == 0) { myErr = QTInsertChild(theKeySample, kParentAtomIsContainer, kSpriteSharedDataAtomType, 1, 0, 0, NULL, &myDefaultsAtom); if (myErr != noErr) goto bail; } myImagesContainerAtom = QTFindChildByIndex(theKeySample, myDefaultsAtom, kSpriteImagesContainerAtomType, 1, NULL); if (myImagesContainerAtom == 0) { myErr = QTInsertChild(theKeySample, myDefaultsAtom, kSpriteImagesContainerAtomType, 1, 0, 0, NULL, &myImagesContainerAtom); if (myErr != noErr) goto bail; } myErr = QTInsertChild(theKeySample, myImagesContainerAtom, kSpriteImageAtomType, theImageID, 0, 0, NULL, &myImageAtom); if (myErr != noErr) goto bail; HLock(myImageData); myErr = QTInsertChild(theKeySample, myImageAtom, kSpriteImageDataAtomType, 1, 0, GetHandleSize(myImageData), *myImageData, NULL); if (myErr != noErr) goto bail; HUnlock(myImageData); if (theRegistrationPoint != NULL) { FixedPoint myRegistrationPoint; myRegistrationPoint.x = EndianS32_NtoB(theRegistrationPoint->x); myRegistrationPoint.y = EndianS32_NtoB(theRegistrationPoint->y); myErr = QTInsertChild(theKeySample, myImageAtom, kSpriteImageRegistrationAtomType, 1, 0, sizeof(myRegistrationPoint), &myRegistrationPoint, NULL); if (myErr != noErr) goto bail; } else { FixedPoint myRegistrationPoint = { 0, 0 }; // flipping {0,0} doesn't change anything so we don't flip myErr = QTInsertChild(theKeySample, myImageAtom, kSpriteImageRegistrationAtomType, 1, 0, sizeof(myRegistrationPoint), &myRegistrationPoint, NULL); if (myErr != noErr) goto bail; } if (theImageName != NULL) { myErr = QTInsertChild(theKeySample, myImageAtom, kSpriteImageNameAtomType, 1, 0, theImageName[0], &theImageName[1], NULL); if (myErr != noErr) goto bail; } bail: #if TARGET_RT_LITTLE_ENDIAN if (myImageDesc != NULL) DisposeHandle((Handle)myImageDesc); #else // myImageDesc is still theImageDesc, so don't dispose of it #endif if (myImageData != NULL) DisposeHandle(myImageData); return(myErr); }