// ------------------------------------- // Initialization functions // Bool16 QTAtom_mdhd::Initialize() { // Temporary vars UInt32 tempInt32; // // Parse this atom's fields. ReadInt32(mdhdPos_VersionFlags, &tempInt32); fVersion = (UInt8)((tempInt32 >> 24) & 0x000000ff); fFlags = tempInt32 & 0x00ffffff; if (0 == fVersion) { // Verify that this atom is the correct length. if( fTOCEntry.AtomDataLength != 24 ) { DEEP_DEBUG_PRINT(("QTAtom_mdhd::Initialize failed. Expected AtomDataLength == 24 version: %d AtomDataLength: %" _64BITARG_ "u\n",fVersion, fTOCEntry.AtomDataLength)); return false; } ReadInt32To64(mdhdPos_CreationTime, &fCreationTime); ReadInt32To64(mdhdPos_ModificationTime, &fModificationTime); ReadInt32(mdhdPos_TimeScale, &fTimeScale); ReadInt32To64(mdhdPos_Duration, &fDuration); ReadInt16(mdhdPos_Language, &fLanguage); ReadInt16(mdhdPos_Quality, &fQuality); } else if (1 == fVersion) { // Verify that this atom is the correct length. if( fTOCEntry.AtomDataLength != 36 ) { DEEP_DEBUG_PRINT(("QTAtom_mdhd::Initialize failed. Expected AtomDataLength == 36 version: %d AtomDataLength: %" _64BITARG_ "u\n",fVersion, fTOCEntry.AtomDataLength)); return false; } ReadInt64(mdhdPosV1_CreationTime, &fCreationTime); ReadInt64(mdhdPosV1_ModificationTime, &fModificationTime); ReadInt32(mdhdPosV1_TimeScale, &fTimeScale); ReadInt64(mdhdPosV1_Duration, &fDuration); ReadInt16(mdhdPosV1_Language, &fLanguage); ReadInt16(mdhdPosV1_Quality, &fQuality); } else { DEEP_DEBUG_PRINT(("QTAtom_mdhd::Initialize failed. Version unsupported: %d\n",fVersion)); return false; } // // Compute the reciprocal of the timescale. fTimeScaleRecip = 1 / (Float64)fTimeScale; // // This atom has been successfully read in. return true; }
UInt32 QTRTPFile::GetSeekTimestamp(UInt32 trackID) { // General vars RTPTrackListEntry *trackEntry = NULL; UInt32 mediaTime; UInt32 rtpTimestamp; UInt32* timeStampP; DEEP_DEBUG_PRINT(("Calculating RTP timestamp for track #%"_U32BITARG_" at time %.2f.\n", trackID, fRequestedSeekTime)); // // Find this track. if( !FindTrackEntry(trackID, &trackEntry) ) return 0; if (trackEntry->CurPacket) // we have the packet { timeStampP = (UInt32 *)((char *)trackEntry->CurPacket + 4); rtpTimestamp = ntohl(*timeStampP); } else { // // Calculate the timestamp at this seek time. mediaTime = (UInt32)(fRequestedSeekTime * trackEntry->HintTrack->GetTimeScale()); if( trackEntry->HintTrack->GetRTPTimescale() == trackEntry->HintTrack->GetTimeScale() ) rtpTimestamp = mediaTime; else rtpTimestamp = (UInt32)(mediaTime * (trackEntry->HintTrack->GetRTPTimescale() * trackEntry->HintTrack->GetTimeScaleRecip()) ); // // Add the appropriate offsets. rtpTimestamp += trackEntry->BaseTimestampRandomOffset + trackEntry->FileTimestampRandomOffset; } // // Return the RTP timestamp. DEEP_DEBUG_PRINT(("..timestamp=%"_U32BITARG_"\n", rtpTimestamp)); return rtpTimestamp; }
// ------------------------------------- // Initialization functions // Bool16 QTAtom_elst::Initialize() { // Temporary vars UInt32 tempInt32; // // Parse this atom's fields. ReadInt32(elstPos_VersionFlags, &tempInt32); fVersion = (UInt8)((tempInt32 >> 24) & 0x000000ff); fFlags = tempInt32 & 0x00ffffff; if (fVersion > 1) { DEEP_DEBUG_PRINT(("QTAtom_elst::Initialize failed. Version unsupported: %d\n", fVersion)); return false; } ReadInt32(elstPos_NumEdits, &fNumEdits); // // Read in all of the edits. if (fNumEdits > 0) { DEEP_DEBUG_PRINT(("QTAtom_elst::Initialize ..%" _U32BITARG_ " edits found.\n", fNumEdits)); // // Allocate our ref table. fEdits = NEW EditListEntry[fNumEdits]; if (fEdits == NULL) return false; // // Read them all in.. for (UInt32 CurEdit = 0; CurEdit < fNumEdits; CurEdit++) { if (0 == fVersion) { // // Get all of the data in this edit list entry. ReadInt32To64(elstPos_EditList + (CurEdit * 12) + elstEntryPos_Duration, &fEdits[CurEdit].EditDuration); ReadInt32To64Signed(elstPos_EditList + (CurEdit * 12) + elstEntryPos_MediaTime, &fEdits[CurEdit].StartingMediaTime); ReadInt32(elstPos_EditList + (CurEdit * 12) + elstEntryPos_MediaRate, &fEdits[CurEdit].EditMediaRate); } else if (1 == fVersion) { // Get all of the data in this edit list entry. ReadInt64(elstPos_EditList + (CurEdit * 20) + elstEntryPosV1_Duration, &fEdits[CurEdit].EditDuration); ReadInt64(elstPos_EditList + (CurEdit * 20) + elstEntryPosV1_MediaTime, (UInt64*)&fEdits[CurEdit].StartingMediaTime); ReadInt32(elstPos_EditList + (CurEdit * 20) + elstEntryPosV1_MediaRate, &fEdits[CurEdit].EditMediaRate); } DEEP_DEBUG_PRINT(("QTAtom_elst::Initialize ..Edit #%" _U32BITARG_ ": Duration=%" _64BITARG_ "u; MediaTime=%" _64BITARG_ "d\n", CurEdit, fEdits[CurEdit].EditDuration, fEdits[CurEdit].StartingMediaTime)); // // Adjust our starting media time. if (fEdits[CurEdit].StartingMediaTime == -1) fFirstEditMovieTime = fEdits[CurEdit].EditDuration; } } // // This atom has been successfully read in. return true; }
// ------------------------------------- // Initialization functions // Bool16 QTAtom_tkhd::Initialize(void) { // Temporary vars UInt32 tempInt32; // // Parse this atom's fields. ReadInt32(tkhdPos_VersionFlags, &tempInt32); fVersion = (UInt8)((tempInt32 >> 24) & 0x000000ff); fFlags = tempInt32 & 0x00ffffff; if (0 == fVersion) { // Verify that this atom is the correct length. if( fTOCEntry.AtomDataLength != 84 ) { DEEP_DEBUG_PRINT(("QTAtom_tkhd::Initialize failed. Expected AtomDataLength == 84 version: %d AtomDataLength: %"_64BITARG_"u\n",fVersion, fTOCEntry.AtomDataLength)); return false; } ReadInt32To64(tkhdPos_CreationTime, &fCreationTime); ReadInt32To64(tkhdPos_ModificationTime, &fModificationTime); ReadInt32(tkhdPos_TrackID, &fTrackID); ReadInt32To64(tkhdPos_Duration, &fDuration); ReadInt16(tkhdPos_AlternateGroup, &fAlternateGroup); ReadInt16(tkhdPos_Volume, &fVolume); ReadInt32(tkhdPos_a, &fa); ReadInt32(tkhdPos_b, &fb); ReadInt32(tkhdPos_u, &fu); ReadInt32(tkhdPos_c, &fc); ReadInt32(tkhdPos_d, &fd); ReadInt32(tkhdPos_v, &fv); ReadInt32(tkhdPos_x, &fx); ReadInt32(tkhdPos_y, &fy); ReadInt32(tkhdPos_w, &fw); ReadInt32(tkhdPos_TrackWidth, &fTrackWidth); ReadInt32(tkhdPos_TrackHeight, &fTrackHeight); } else if (1 == fVersion) { // Verify that this atom is the correct length. if (fTOCEntry.AtomDataLength != 96) { DEEP_DEBUG_PRINT(("QTAtom_tkhd::Initialize failed. Expected AtomDataLength == 96 version: %d AtomDataLength: %"_64BITARG_"u\n",fVersion, fTOCEntry.AtomDataLength)); return false; } ReadInt64(tkhdPosV1_CreationTime, &fCreationTime); ReadInt64(tkhdPosV1_ModificationTime, &fModificationTime); ReadInt32(tkhdPosV1_TrackID, &fTrackID); ReadInt64(tkhdPosV1_Duration, &fDuration); ReadInt16(tkhdPosV1_AlternateGroup, &fAlternateGroup); ReadInt16(tkhdPosV1_Volume, &fVolume); ReadInt32(tkhdPosV1_a, &fa); ReadInt32(tkhdPosV1_b, &fb); ReadInt32(tkhdPosV1_u, &fu); ReadInt32(tkhdPosV1_c, &fc); ReadInt32(tkhdPosV1_d, &fd); ReadInt32(tkhdPosV1_v, &fv); ReadInt32(tkhdPosV1_x, &fx); ReadInt32(tkhdPosV1_y, &fy); ReadInt32(tkhdPosV1_w, &fw); ReadInt32(tkhdPosV1_TrackWidth, &fTrackWidth); ReadInt32(tkhdPosV1_TrackHeight, &fTrackHeight); } else { DEEP_DEBUG_PRINT(("QTAtom_tkhd::Initialize failed. Version unsupported: %d",fVersion)); return false; } // // This atom has been successfully read in. return true; }
// ------------------------------------- // Initialization functions // Bool16 QTAtom_mvhd::Initialize() { // Temporary vars UInt32 tempInt32; // // Parse this atom's fields. ReadInt32(mvhdPos_VersionFlags, &tempInt32); fVersion = (UInt8)((tempInt32 >> 24) & 0x000000ff); fFlags = tempInt32 & 0x00ffffff; if (0 == fVersion) { // Verify that this atom is the correct length. if (fTOCEntry.AtomDataLength != 100) { DEEP_DEBUG_PRINT(("QTAtom_mvhd::Initialize failed. Expected AtomDataLength == 100 version: %d AtomDataLength: %" _64BITARG_ "u\n", fVersion, fTOCEntry.AtomDataLength)); return false; } ReadInt32To64(mvhdPos_CreationTime, &fCreationTime); ReadInt32To64(mvhdPos_ModificationTime, &fModificationTime); ReadInt32(mvhdPos_TimeScale, &fTimeScale); ReadInt32To64(mvhdPos_Duration, &fDuration); ReadInt32(mvhdPos_PreferredRate, &fPreferredRate); ReadInt16(mvhdPos_PreferredVolume, &fPreferredVolume); ReadInt32(mvhdPos_a, &fa); ReadInt32(mvhdPos_b, &fb); ReadInt32(mvhdPos_u, &fu); ReadInt32(mvhdPos_c, &fc); ReadInt32(mvhdPos_d, &fd); ReadInt32(mvhdPos_v, &fv); ReadInt32(mvhdPos_x, &fx); ReadInt32(mvhdPos_y, &fy); ReadInt32(mvhdPos_w, &fw); ReadInt32(mvhdPos_PreviewTime, &fPreviewTime); ReadInt32(mvhdPos_PreviewDuration, &fPreviewDuration); ReadInt32(mvhdPos_PosterTime, &fPosterTime); ReadInt32(mvhdPos_SelectionTime, &fSelectionTime); ReadInt32(mvhdPos_SelectionDuration, &fSelectionDuration); ReadInt32(mvhdPos_CurrentTime, &fCurrentTime); ReadInt32(mvhdPos_NextTrackID, &fNextTrackID); } else if (1 == fVersion) { // Verify that this atom is the correct length. if (fTOCEntry.AtomDataLength != 112) { DEEP_DEBUG_PRINT(("QTAtom_mvhd::Initialize failed. Expected AtomDataLength = 112 version: %d AtomDataLength: %" _64BITARG_ "u\n", fVersion, fTOCEntry.AtomDataLength)); return false; } ReadInt64(mvhdPosV1_CreationTime, &fCreationTime); ReadInt64(mvhdPosV1_ModificationTime, &fModificationTime); ReadInt32(mvhdPosV1_TimeScale, &fTimeScale); ReadInt64(mvhdPosV1_Duration, &fDuration); ReadInt32(mvhdPosV1_PreferredRate, &fPreferredRate); ReadInt16(mvhdPosV1_PreferredVolume, &fPreferredVolume); ReadInt32(mvhdPosV1_a, &fa); ReadInt32(mvhdPosV1_b, &fb); ReadInt32(mvhdPosV1_u, &fu); ReadInt32(mvhdPosV1_c, &fc); ReadInt32(mvhdPosV1_d, &fd); ReadInt32(mvhdPosV1_v, &fv); ReadInt32(mvhdPosV1_x, &fx); ReadInt32(mvhdPosV1_y, &fy); ReadInt32(mvhdPosV1_w, &fw); ReadInt32(mvhdPosV1_PreviewTime, &fPreviewTime); ReadInt32(mvhdPosV1_PreviewDuration, &fPreviewDuration); ReadInt32(mvhdPosV1_PosterTime, &fPosterTime); ReadInt32(mvhdPosV1_SelectionTime, &fSelectionTime); ReadInt32(mvhdPosV1_SelectionDuration, &fSelectionDuration); ReadInt32(mvhdPosV1_CurrentTime, &fCurrentTime); ReadInt32(mvhdPosV1_NextTrackID, &fNextTrackID); } else { DEEP_DEBUG_PRINT(("QTAtom_mvhd::Initialize failed. Version unsupported: %d\n", fVersion)); return false; } // // This atom has been successfully read in. return true; }