void pix_videoDarwin :: brightnessMess(float X) { QTAtomContainer atomContainer; QTAtom featureAtom; VDIIDCFeatureSettings settings; ComponentDescription desc; ComponentResult result = paramErr; //check if device is IIDC GetComponentInfo((Component)m_vdig, &desc, NULL, NULL, NULL); if (vdSubtypeIIDC != desc.componentSubType){ m_brightness = (unsigned short)(65536. * X); VDSetBrightness(m_vdig,&m_brightness); VDGetBrightness(m_vdig,&m_brightness); post("brightness is %d",m_brightness); } else { //IIDC stuff //these things are as stubborn as they are stupid - find one that conforms to spec! //vdIIDCFeatureBrightness result = VDIIDCGetFeaturesForSpecifier(m_vdig, vdIIDCFeatureBrightness, &atomContainer); if (noErr != result) { error("VDIIDCGetFeaturesForSpecifier returned %d",result); } featureAtom = QTFindChildByIndex(atomContainer, kParentAtomIsContainer, vdIIDCAtomTypeFeature, 1, NULL); if (0 == featureAtom) error("featureAtom not found"); result = QTCopyAtomDataToPtr(atomContainer, QTFindChildByID(atomContainer, featureAtom, vdIIDCAtomTypeFeatureSettings, vdIIDCAtomIDFeatureSettings, NULL), true, sizeof(settings), &settings, NULL); settings.state.flags = (vdIIDCFeatureFlagOn | vdIIDCFeatureFlagManual | vdIIDCFeatureFlagRawControl); settings.state.value = X; result = QTSetAtomData(atomContainer, QTFindChildByID(atomContainer, featureAtom, vdIIDCAtomTypeFeatureSettings, vdIIDCAtomIDFeatureSettings, NULL), sizeof(settings), &settings); result = VDIIDCSetFeatures(m_vdig, atomContainer); } }
void pix_videoDarwin :: gainMess(float X) { QTAtomContainer atomContainer; QTAtom featureAtom; VDIIDCFeatureSettings settings; ComponentDescription desc; ComponentResult result = paramErr; //check if device is IIDC GetComponentInfo((Component)m_vdig, &desc, NULL, NULL, NULL); if (vdSubtypeIIDC == desc.componentSubType){ //IIDC stuff //vdIIDCFeatureGain result = VDIIDCGetFeaturesForSpecifier(m_vdig, vdIIDCFeatureWhiteBalanceU, &atomContainer); if (noErr != result) { error("VDIIDCGetFeaturesForSpecifier vdIIDCFeatureExposure returned %d",result); } featureAtom = QTFindChildByIndex(atomContainer, kParentAtomIsContainer, vdIIDCAtomTypeFeature, 1, NULL); if (0 == featureAtom) error("featureAtom vdIIDCFeatureExposure not found"); result = QTCopyAtomDataToPtr(atomContainer, QTFindChildByID(atomContainer, featureAtom, vdIIDCAtomTypeFeatureSettings, vdIIDCAtomIDFeatureSettings, NULL), true, sizeof(settings), &settings, NULL); settings.state.flags = (vdIIDCFeatureFlagOn | vdIIDCFeatureFlagManual | vdIIDCFeatureFlagRawControl); settings.state.value = X; result = QTSetAtomData(atomContainer, QTFindChildByID(atomContainer, featureAtom, vdIIDCAtomTypeFeatureSettings, vdIIDCAtomIDFeatureSettings, NULL), sizeof(settings), &settings); result = VDIIDCSetFeatures(m_vdig, atomContainer); } }
OSErr SpriteUtils_AddSpriteToSample (QTAtomContainer theSample, QTAtomContainer theSprite, QTAtomID theSpriteID) { QTAtom mySpriteAtom = 0; OSErr myErr = paramErr; // see if the sample already contains a sprite atom of the specified ID mySpriteAtom = QTFindChildByID(theSample, kParentAtomIsContainer, kSpriteAtomType, theSpriteID, NULL); if (mySpriteAtom != 0) goto bail; // here, the index 0 means to append the sprite to the sample myErr = QTInsertChild(theSample, kParentAtomIsContainer, kSpriteAtomType, theSpriteID, 0, 0, NULL, &mySpriteAtom); if (myErr != noErr) goto bail; myErr = QTInsertChildren(theSample, mySpriteAtom, theSprite); bail: return(myErr); }
OSErr QTWired_MakeSpriteDraggable (QTAtomContainer theContainer, QTAtomID theID) { QTAtom mySpriteAtom = 0; QTAtom myEventAtom = 0; QTAtom myActionAtom = 0; QTAtom myParamAtom = 0; QTAtom myConditionalAtom, myExpressionAtom, myOperatorAtom, myOperandAtom, myOperandTypeAtom, myActionListAtom, myParameterAtom; short myOperandIndex; long myAction; QTAtomID myVariableID; float myVariableValue; float myConstantValue; Boolean myIsAbsolute; 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, 1, 0, NULL, &mySpriteAtom); if (myErr != noErr) goto bail; } ////////// // // add a mouse click event handler // ////////// // find the event atom of type kQTEventMouseClick in the sprite atom myEventAtom = QTFindChildByID(theContainer, mySpriteAtom, kQTEventType, kQTEventMouseClick, NULL); if (myEventAtom == 0) { // if there is none, insert a new event atom of type kQTEventMouseClick into the sprite atom myErr = QTInsertChild(theContainer, mySpriteAtom, kQTEventType, kQTEventMouseClick, 1, 0, NULL, &myEventAtom); if (myErr != noErr) goto bail; } // add an action atom to the mouse click event handler myErr = QTInsertChild(theContainer, myEventAtom, kAction, 0, 0, 0, NULL, &myActionAtom); if (myErr != noErr) goto bail; myAction = EndianU32_NtoB(kActionSpriteTrackSetVariable); myErr = QTInsertChild(theContainer, myActionAtom, kWhichAction, 1, 1, sizeof(myAction), &myAction, NULL); if (myErr != noErr) goto bail; // add parameters to the set variable action: variable ID (QTAtomID) and value (float) myVariableID = EndianU32_NtoB(kMouseStateVariableID); myErr = QTInsertChild(theContainer, myActionAtom, kActionParameter, 0, (short)kFirstParam, sizeof(myVariableID), &myVariableID, NULL); if (myErr != noErr) goto bail; myVariableValue = (float)1; EndianUtils_Float_NtoB(&myVariableValue); myErr = QTInsertChild(theContainer, myActionAtom, kActionParameter, 0, (short)kSecondParam, sizeof(myVariableValue), &myVariableValue, NULL); if (myErr != noErr) goto bail; ////////// // // add a mouse click end event handler // ////////// // find the event atom of type kQTEventMouseClick in the sprite atom myEventAtom = QTFindChildByID(theContainer, mySpriteAtom, kQTEventType, kQTEventMouseClickEnd, NULL); if (myEventAtom == 0) { // if there is none, insert a new event atom of type kQTEventMouseClick into the sprite atom myErr = QTInsertChild(theContainer, mySpriteAtom, kQTEventType, kQTEventMouseClickEnd, 1, 0, NULL, &myEventAtom); if (myErr != noErr) goto bail; } // add an action atom to the mouse click event handler myErr = QTInsertChild(theContainer, myEventAtom, kAction, 0, 0, 0, NULL, &myActionAtom); if (myErr != noErr) goto bail; myAction = EndianU32_NtoB(kActionSpriteTrackSetVariable); myErr = QTInsertChild(theContainer, myActionAtom, kWhichAction, 1, 1, sizeof(myAction), &myAction, NULL); if (myErr != noErr) goto bail; // add parameters to the set variable action: variable ID (QTAtomID) and value (float) myVariableID = EndianU32_NtoB(kMouseStateVariableID); myErr = QTInsertChild(theContainer, myActionAtom, kActionParameter, 0, (short)kFirstParam, sizeof(myVariableID), &myVariableID, NULL); if (myErr != noErr) goto bail; myVariableValue = (float)0; EndianUtils_Float_NtoB(&myVariableValue); myErr = QTInsertChild(theContainer, myActionAtom, kActionParameter, 0, (short)kSecondParam, sizeof(myVariableValue), &myVariableValue, NULL); if (myErr != noErr) goto bail; ////////// // // add an idle event handler // ////////// // find the event atom of type kQTEventIdle in the sprite atom myEventAtom = QTFindChildByID(theContainer, mySpriteAtom, kQTEventType, kQTEventIdle, NULL); if (myEventAtom == 0) { // if there is none, insert a new event atom of type kQTEventIdle into the sprite atom myErr = QTInsertChild(theContainer, mySpriteAtom, kQTEventType, kQTEventIdle, 1, 0, NULL, &myEventAtom); if (myErr != noErr) goto bail; } // add an action atom to the mouse click event handler myErr = QTInsertChild(theContainer, myEventAtom, kAction, 0, 0, 0, NULL, &myActionAtom); if (myErr != noErr) goto bail; myAction = EndianU32_NtoB(kActionCase); myErr = QTInsertChild(theContainer, myActionAtom, kWhichAction, 1, 1, sizeof(myAction), &myAction, NULL); if (myErr != noErr) goto bail; // add a parameter atom to the kActionCase action atom; this will serve as a parent to hold the expression and action atoms myErr = QTInsertChild(theContainer, myActionAtom, kActionParameter, 1, kFirstParam, 0, NULL, &myParamAtom); if (myErr != noErr) goto bail; // the condition atom myErr = QTInsertChild(theContainer, myParamAtom, kConditionalAtomType, 0, 1, 0, NULL, &myConditionalAtom); if (myErr != noErr) goto bail; myErr = QTInsertChild(theContainer, myConditionalAtom, kExpressionContainerAtomType, 1, 1, 0, NULL, &myExpressionAtom); if (myErr != noErr) goto bail; myErr = QTInsertChild(theContainer, myExpressionAtom, kOperatorAtomType, kOperatorEqualTo, 1, 0, NULL, &myOperatorAtom); if (myErr != noErr) goto bail; // add the operands to the operator atom myOperandIndex = 1; myConstantValue = 1; myErr = QTInsertChild(theContainer, myOperatorAtom, kOperandAtomType, 0, myOperandIndex, 0, NULL, &myOperandAtom); if (myErr != noErr) goto bail; myErr = QTInsertChild(theContainer, myOperandAtom, kOperandConstant, 1, 1, 0, NULL, &myOperandTypeAtom); if (myErr != noErr) goto bail; EndianUtils_Float_NtoB(&myConstantValue); myErr = QTSetAtomData(theContainer, myOperandTypeAtom, sizeof(myConstantValue), &myConstantValue); myOperandIndex = 2; myVariableID = kMouseStateVariableID; myErr = QTInsertChild(theContainer, myOperatorAtom, kOperandAtomType, 0, myOperandIndex, 0, NULL, &myOperandAtom); if (myErr != noErr) goto bail; myErr = QTInsertChild(theContainer, myOperandAtom, kOperandSpriteTrackVariable, 1, 1, 0, NULL, &myOperandTypeAtom); if (myErr != noErr) goto bail; myVariableID = EndianU32_NtoB(myVariableID); myErr = QTInsertChild(theContainer, myOperandTypeAtom, kActionParameter, 1, 1, sizeof(myVariableID), &myVariableID, NULL); if (myErr != noErr) goto bail; // add an action list atom myErr = QTInsertChild(theContainer, myConditionalAtom, kActionListAtomType, 1, 1, 0, NULL, &myActionListAtom); if (myErr != noErr) goto bail; // add sprite translate action myErr = QTInsertChild(theContainer, myActionListAtom, kAction, 0, 0, 0, NULL, &myActionAtom); if (myErr != noErr) goto bail; myAction = EndianU32_NtoB(kActionSpriteTranslate); myErr = QTInsertChild(theContainer, myActionAtom, kWhichAction, 1, 1, sizeof(myAction), &myAction, NULL); if (myErr != noErr) goto bail; ////////// // // add parameters to the translate action: Fixed x, Fixed y, Boolean isAbsolute // ////////// // first parameter: get current mouse position x myErr = QTInsertChild(theContainer, myActionAtom, kActionParameter, 0, (short)kFirstParam, 0, NULL, &myParameterAtom); if (myErr != noErr) goto bail; myErr = QTInsertChild(theContainer, myParameterAtom, kExpressionContainerAtomType, 1, 1, 0, NULL, &myExpressionAtom); if (myErr != noErr) goto bail; myErr = QTInsertChild(theContainer, myExpressionAtom, kOperandAtomType, 0, 1, 0, NULL, &myOperandAtom); if (myErr != noErr) goto bail; myErr = QTInsertChild(theContainer, myOperandAtom, kOperandMouseLocalHLoc, 1, 1, 0, NULL, NULL); if (myErr != noErr) goto bail; // second parameter: get current mouse position y myErr = QTInsertChild(theContainer, myActionAtom, kActionParameter, 0, (short)kSecondParam, 0, NULL, &myParameterAtom); if (myErr != noErr) goto bail; myErr = QTInsertChild(theContainer, myParameterAtom, kExpressionContainerAtomType, 1, 1, 0, NULL, &myExpressionAtom); if (myErr != noErr) goto bail; myErr = QTInsertChild(theContainer, myExpressionAtom, kOperandAtomType, 0, 1, 0, NULL, &myOperandAtom); if (myErr != noErr) goto bail; myErr = QTInsertChild(theContainer, myOperandAtom, kOperandMouseLocalVLoc, 1, 1, 0, NULL, NULL); if (myErr != noErr) goto bail; myIsAbsolute = true; myErr = QTInsertChild(theContainer, myActionAtom, kActionParameter, 0, (short)kThirdParam, sizeof(myIsAbsolute), &myIsAbsolute, NULL); bail: return(myErr); }
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; }