// Stream-in ctor CompositionOffsetAtom::CompositionOffsetAtom(MP4_FF_FILE *fp, uint32 mediaType, uint32 size, uint32 type, OSCL_wString& filename, uint32 parsingMode): FullAtom(fp, size, type), OsclTimerObject(OsclActiveObject::EPriorityNominal, "CompositionOffsetAtom") { _psampleCountVec = NULL; _psampleOffsetVec = NULL; MT_SampleCount = NULL; MT_EntryCount = NULL; iMarkerTableCreation = false; MT_Table_Size = 0; _currGetSampleCount = 0; _currGetIndex = -1; _currGetTimeOffset = 0; _currPeekSampleCount = 0; _currPeekIndex = -1; _currPeekTimeOffset = 0; MT_Counter = 1; addSampleCount = 0; prevSampleCount = 0; entrycountTraversed = 0; refSample = MT_SAMPLECOUNT_INCREMENT; MT_j = 1; _mediaType = mediaType; _parsed_entry_cnt = 0; _fileptr = NULL; _parsing_mode = 0; _parsing_mode = parsingMode; _stbl_buff_size = CTTS_MIN_SAMPLE_TABLE_SIZE; _next_buff_number = 0; _curr_buff_number = 0; _curr_entry_point = 0; _stbl_fptr_vec = NULL; iLogger = PVLogger::GetLoggerObject("mp4ffparser"); iStateVarLogger = PVLogger::GetLoggerObject("mp4ffparser_mediasamplestats"); iParsedDataLogger = PVLogger::GetLoggerObject("mp4ffparser_parseddata"); iMarkerTableCreation = false; /* Add this AO to the scheduler */ if (OsclExecScheduler::Current() != NULL) { if (!IsAdded()) { AddToScheduler(); } } if (_success) { if (!AtomUtils::read32(fp, _entryCount)) { _success = false; } PVMF_MP4FFPARSER_LOGPARSEDINFO((0, "CompositionOffsetAtom::CompositionOffsetAtom- _entryCount =%d", _entryCount)); uint32 dataSize = _size - (DEFAULT_FULL_ATOM_SIZE + 4); uint32 entrySize = (4 + 4); if ((_entryCount*entrySize) > dataSize) { _success = false; } if (_success) { if (_entryCount > 0) { if (parsingMode == 1) { // cache size is 4K so that optimization // should work if entry_count is greater than 4K if (_entryCount > _stbl_buff_size) { uint32 fptrBuffSize = (_entryCount / _stbl_buff_size) + 1; PV_MP4_FF_ARRAY_NEW(NULL, uint32, (fptrBuffSize), _stbl_fptr_vec); if (_stbl_fptr_vec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleCountVec); if (_psampleCountVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleOffsetVec); if (_psampleOffsetVec == NULL) { PV_MP4_ARRAY_DELETE(NULL, _psampleOffsetVec); _psampleOffsetVec = NULL; _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } for (uint32 idx = 0; idx < _stbl_buff_size; idx++) //initialization { _psampleCountVec[idx] = 0; _psampleOffsetVec[idx] = 0; } OsclAny* ptr = (MP4_FF_FILE *)(oscl_malloc(sizeof(MP4_FF_FILE))); if (ptr == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } _fileptr = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE()); _fileptr->_fileServSession = fp->_fileServSession; _fileptr->_pvfile.SetCPM(fp->_pvfile.GetCPM()); _fileptr->_pvfile.SetFileHandle(fp->_pvfile.iFileHandle); if (AtomUtils::OpenMP4File(filename, Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, _fileptr) != 0) { _success = false; _mp4ErrorCode = FILE_OPEN_FAILED; } _fileptr->_fileSize = fp->_fileSize; int32 _head_offset = AtomUtils::getCurrentFilePosition(fp); AtomUtils::seekFromCurrPos(fp, dataSize); AtomUtils::seekFromStart(_fileptr, _head_offset); return; } else { _parsing_mode = 0; _stbl_buff_size = _entryCount; } } else { _stbl_buff_size = _entryCount; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psampleCountVec); if (_psampleCountVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psampleOffsetVec); if (_psampleOffsetVec == NULL) { PV_MP4_ARRAY_DELETE(NULL, _psampleOffsetVec); _psampleOffsetVec = NULL; _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } for (uint32 idx = 0; idx < _entryCount; idx++) //initialization { _psampleCountVec[idx] = 0; _psampleOffsetVec[idx] = 0; } uint32 number = 0; uint32 offset = 0; for (_parsed_entry_cnt = 0; _parsed_entry_cnt < _entryCount; _parsed_entry_cnt++) { if (!AtomUtils::read32(fp, number)) { _success = false; break; } if (!AtomUtils::read32(fp, offset)) { _success = false; break; } _psampleCountVec[_parsed_entry_cnt] = (number); _psampleOffsetVec[_parsed_entry_cnt] = (offset); } } } if (!_success) { _mp4ErrorCode = READ_TIME_TO_SAMPLE_ATOM_FAILED; } } else { if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED) _mp4ErrorCode = READ_TIME_TO_SAMPLE_ATOM_FAILED; } }
// Stream-in ctor // Create and return a new SampleToChunkAtom by reading in from an ifstream SampleToChunkAtom::SampleToChunkAtom(MP4_FF_FILE *fp, uint32 size, uint32 type, OSCL_wString& filename, uint32 parsingMode) : FullAtom(fp, size, type) { _pfirstChunkVec = NULL; _psamplesPerChunkVec = NULL; _psampleDescriptionIndexVec = NULL; _Index = 0; _numChunksInRun = 0; _majorGetIndex = 0; _currGetChunk = -1; _numGetChunksInRun = 0; _currGetSampleCount = 0; _firstGetSampleInCurrChunk = 0; _numGetSamplesPerChunk = 0; _currGetSDI = 0; _majorPeekIndex = 0; _currPeekChunk = -1; _numPeekChunksInRun = 0; _currPeekSampleCount = 0; _firstPeekSampleInCurrChunk = 0; _numPeekSamplesPerChunk = 0; _currPeekSDI = 0; _parsed_entry_cnt = 0; _fileptr = NULL; _stbl_buff_size = MAX_CACHED_TABLE_ENTRIES_FILE; _next_buff_number = 0; _curr_buff_number = 0; _curr_entry_point = 0; _stbl_fptr_vec = NULL; _parsing_mode = parsingMode; iLogger = PVLogger::GetLoggerObject("mp4ffparser"); iStateVarLogger = PVLogger::GetLoggerObject("mp4ffparser_mediasamplestats"); iParsedDataLogger = PVLogger::GetLoggerObject("mp4ffparser_parseddata"); if (_success) { _currentChunkNumber = 0; _maxNumSamplesPerChunk = DEFAULT_MAX_NUM_SAMPLES_PER_CHUNK; _maxChunkDataSize = DEFAULT_MAX_CHUNK_DATA_SIZE; if (!AtomUtils::read32(fp, _entryCount)) { _success = false; } PVMF_MP4FFPARSER_LOGPARSEDINFO((0, "SampleToChunkAtom::SampleToChunkAtom- _entryCount =%d", _entryCount)); TOsclFileOffset dataSize = _size - (DEFAULT_FULL_ATOM_SIZE + 4); uint32 entrySize = (4 + 4 + 4); if ((TOsclFileOffset)(_entryCount*entrySize) > dataSize) { _success = false; } if (_success) { if (_entryCount > 0) { if (_parsing_mode) { if ((_entryCount > _stbl_buff_size)) // cahce size is 4K so that optimization should work if entry_count is greater than 4K { uint32 fptrBuffSize = (_entryCount / _stbl_buff_size) + 1; PV_MP4_FF_ARRAY_NEW(NULL, TOsclFileOffset, (fptrBuffSize), _stbl_fptr_vec); if (_stbl_fptr_vec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _pfirstChunkVec); if (_pfirstChunkVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psamplesPerChunkVec); if (_psamplesPerChunkVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleDescriptionIndexVec); if (_psampleDescriptionIndexVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } { OsclAny* ptr = (MP4_FF_FILE *)(oscl_malloc(sizeof(MP4_FF_FILE))); if (ptr == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } _fileptr = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE()); _fileptr->_fileServSession = fp->_fileServSession; _fileptr->_pvfile.SetCPM(fp->_pvfile.GetCPM()); _fileptr->_pvfile.SetFileHandle(fp->_pvfile.iFileHandle); if (AtomUtils::OpenMP4File(filename, Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, _fileptr) != 0) { _success = false; _mp4ErrorCode = FILE_OPEN_FAILED; } _fileptr->_fileSize = fp->_fileSize; } TOsclFileOffset _head_offset = AtomUtils::getCurrentFilePosition(fp); AtomUtils::seekFromCurrPos(fp, dataSize); AtomUtils::seekFromStart(_fileptr, _head_offset); ParseEntryUnit(0); uint32 firstsamplenum = 0; resetStateVariables(firstsamplenum); return; } else { _parsing_mode = 0; _stbl_buff_size = _entryCount; } } else { _parsing_mode = 0; _stbl_buff_size = _entryCount; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _pfirstChunkVec); PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psamplesPerChunkVec); PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psampleDescriptionIndexVec); uint32 firstChunk; uint32 samplesPerChunk; uint32 sampleDescrIndex; uint32 offSet = 0; uint32 prevFirstChunk = 0; uint32 j = 0; for (uint32 i = 0; i < _entryCount; i++) { if (!AtomUtils::read32(fp, firstChunk)) { _success = false; break; } if (i == 0) offSet = firstChunk; if (!AtomUtils::read32(fp, samplesPerChunk)) { _success = false; break; } if (!AtomUtils::read32(fp, sampleDescrIndex)) { _success = false; break; } if (firstChunk > prevFirstChunk) { _pfirstChunkVec[j] = (firstChunk - offSet); _psamplesPerChunkVec[j] = (samplesPerChunk); _psampleDescriptionIndexVec[j] = (sampleDescrIndex); prevFirstChunk = firstChunk; j++; } } _entryCount = j; uint32 firstsamplenum = 0; resetStateVariables(firstsamplenum); } else { _pfirstChunkVec = NULL; _psamplesPerChunkVec = NULL; _psampleDescriptionIndexVec = NULL; } } if (!_success) { _mp4ErrorCode = READ_SAMPLE_TO_CHUNK_ATOM_FAILED; PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>SampleToChunkAtom::SampleToChunkAtom- Read SampleToChunk Atom failed %d", _mp4ErrorCode)); } } else { if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED) { _mp4ErrorCode = READ_SAMPLE_TO_CHUNK_ATOM_FAILED; PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>SampleToChunkAtom::SampleToChunkAtom- Read SampleToChunk Atom failed %d", _mp4ErrorCode)); } } }
// Constructor TrackFragmentAtom::TrackFragmentAtom(MP4_FF_FILE *fp, uint32 &size, uint32 type, uint32 movieFragmentCurrentOffset, uint32 movieFragmentBaseOffset, uint32 moofSize, TrackDurationContainer *trackDurationContainer, Oscl_Vector<TrackExtendsAtom*, OsclMemAllocator> *trackExtendAtomVec, bool &parseTrafCompletely, bool &trafParsingCompleted, uint32 &countOfTrunsParsed) : Atom(fp, size, type) { OSCL_UNUSED_ARG(movieFragmentCurrentOffset); _pTrackFragmentHeaderAtom = NULL; _pTrackFragmentRunAtom = NULL; _pinput = NULL; _commonFilePtr = NULL; _fileSize = 0; _currentTrackFragmentRunSampleNumber = 0; _currentPlaybackSampleTimestamp = 0; _movieFragmentOffset = 0; _prevSampleOffset = 0; _trackEndDuration = 0; _startTrackFragmentTSOffset = 0; _pFragmentptrOffsetVec = NULL; _peekPlaybackSampleNumber = 0; _default_duration = 0; _use_default_duratoin = false; _pTrackDurationContainer = trackDurationContainer; tf_flags = 0; trun_offset = 0; trunParsingCompleted = true; iLogger = PVLogger::GetLoggerObject("mp4ffparser_traf"); iStateVarLogger = PVLogger::GetLoggerObject("mp4ffparser_mediasamplestats_traf"); iParsedDataLogger = PVLogger::GetLoggerObject("mp4ffparser_parseddata_traf"); OsclAny*ptr = oscl_malloc(sizeof(MP4_FF_FILE)); if (ptr == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } _pinput = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE(*fp)); _pinput->_fileServSession = fp->_fileServSession; _pinput->_pvfile.SetCPM(fp->_pvfile.GetCPM()); _pinput->_fileSize = fp->_fileSize; _pinput->_pvfile.Copy(fp->_pvfile); uint32 trun_start = 0; uint32 count = size - DEFAULT_ATOM_SIZE; uint32 _movieFragmentBaseOffset = movieFragmentBaseOffset - DEFAULT_ATOM_SIZE; bool bdo_present = false; uint32 base_data_offset = _movieFragmentBaseOffset; trackId = 0; trun_offset = moofSize + DEFAULT_ATOM_SIZE; if (_success) { PV_MP4_FF_NEW(fp->auditCB, trackFragmentRunAtomVecType, (), _pTrackFragmentRunAtomVec); while (count > 0) { uint32 atomType = UNKNOWN_ATOM; uint32 atomSize = 0; AtomUtils::getNextAtomType(fp, atomSize, atomType); if (atomType == TRACK_FRAGMENT_HEADER_ATOM) { if (_pTrackFragmentHeaderAtom == NULL) { PV_MP4_FF_NEW(fp->auditCB, TrackFragmentHeaderAtom, (fp, atomSize, atomType), _pTrackFragmentHeaderAtom); if (!_pTrackFragmentHeaderAtom->MP4Success()) { _success = false; _mp4ErrorCode = READ_MOVIE_EXTENDS_HEADER_FAILED; return; } count -= _pTrackFragmentHeaderAtom->getSize(); trackId = _pTrackFragmentHeaderAtom->getTrackId(); tf_flags = _pTrackFragmentHeaderAtom->getFlags(); PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "@@@@@@@@@@@@@@@****** Track ID= %d ********@@@@@@@@@@@@@@@@", trackId)); PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "#### tf_flag =0x%x######", tf_flags)); if (tf_flags & 0x000001) { uint64 bdo = _pTrackFragmentHeaderAtom->getBaseDataOffset(); base_data_offset = Oscl_Int64_Utils::get_uint64_lower32(bdo); bdo_present = true; } else base_data_offset = _movieFragmentBaseOffset; trun_start = base_data_offset; if (trackDurationContainer != NULL) { for (int32 i = 0; i < trackDurationContainer->getNumTrackInfoVec(); i++) { TrackDurationInfo* trackInfo = trackDurationContainer->getTrackdurationInfoAt(i); if (trackInfo->trackId == trackId) { _trackEndDuration = trackInfo->trackDuration; _startTrackFragmentTSOffset = _trackEndDuration; } } } } else { //duplicate atom count -= atomSize; atomSize -= DEFAULT_ATOM_SIZE; AtomUtils::seekFromCurrPos(fp, atomSize); } } else if (atomType == TRACK_FRAGMENT_RUN_ATOM) { uint32 trunsParsed = countOfTrunsParsed; if (countOfTrunsParsed > COUNT_OF_TRUNS_PARSED_THRESHOLD) { countOfTrunsParsed = COUNT_OF_TRUNS_PARSED_THRESHOLD; } // here we want parser to parse complete TRUN atom. PV_MP4_FF_NEW(fp->auditCB, TrackFragmentRunAtom, (fp, atomSize, atomType, base_data_offset, trun_start, trun_offset, _trackEndDuration, bdo_present, trunParsingCompleted, countOfTrunsParsed), _pTrackFragmentRunAtom); countOfTrunsParsed = trunsParsed + 1; if (!_pTrackFragmentRunAtom->MP4Success()) { _success = false; _mp4ErrorCode = READ_TRACK_EXTENDS_ATOM_FAILED; return; } bdo_present = false; count -= _pTrackFragmentRunAtom->getSize(); size = count; uint32 trunFlags = _pTrackFragmentRunAtom->getFlags(); if (!(trunFlags & 0x000100)) { _use_default_duratoin = true; if (tf_flags & 0x000008) { _default_duration = _pTrackFragmentHeaderAtom->getDefaultSampleDuration(); _pTrackFragmentRunAtom->setDefaultDuration(_default_duration); } else { for (uint32 idx = 0; idx < trackExtendAtomVec->size(); idx++) { TrackExtendsAtom* pTrackExtendAtom = (*trackExtendAtomVec)[idx]; uint32 id = pTrackExtendAtom->getTrackId(); if (id == trackId) { uint32 trexDefaultDuration = pTrackExtendAtom->getDefaultSampleDuration(); _default_duration = trexDefaultDuration; _pTrackFragmentRunAtom->setDefaultDuration(trexDefaultDuration); } } } } if (!(trunFlags & 0x000200)) { if (tf_flags & 0x000010) _pTrackFragmentRunAtom->setDefaultSampleSize(_pTrackFragmentHeaderAtom->getDefaultSampleSize(), trun_offset); else { for (uint32 idx = 0; idx < trackExtendAtomVec->size(); idx++) { TrackExtendsAtom* pTrackExtendAtom = (*trackExtendAtomVec)[idx]; uint32 id = pTrackExtendAtom->getTrackId(); if (id == trackId) { uint32 trexDefaultSampleSize = pTrackExtendAtom->getDefaultSampleSize(); _pTrackFragmentRunAtom->setDefaultSampleSize(trexDefaultSampleSize, trun_offset); } } } } _pTrackFragmentRunAtomVec->push_back(_pTrackFragmentRunAtom); _trackEndDuration = _pTrackFragmentRunAtom->GetSampleTimeStamp(); PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "****** tr_flag =0x%x ********", trunFlags)); if (!parseTrafCompletely) { trafParsingCompleted = false; uint64 duration = _trackEndDuration; trackDurationContainer->updateTrackDurationForTrackId(trackId, duration); break; } } else { count -= atomSize; atomSize -= DEFAULT_ATOM_SIZE; AtomUtils::seekFromCurrPos(fp, atomSize); } uint64 track_duration = _trackEndDuration; trackDurationContainer->updateTrackDurationForTrackId(trackId, track_duration); trafParsingCompleted = true; } } else {
// Ctor to create a new ChunkOffsetAtom by reading in from an ifstream ChunkOffsetAtom::ChunkOffsetAtom(MP4_FF_FILE *fp, uint32 size, uint32 type, OSCL_wString& filename, uint32 parsingMode) : FullAtom(fp, size, type) { _pchunkOffsets = NULL; _stbl_buff_size = MAX_CACHED_TABLE_ENTRIES_FILE; _next_buff_number = 0; _curr_buff_number = 0; _curr_entry_point = 0; _stbl_fptr_vec = NULL; _parsed_entry_cnt = 0; _parsingMode = parsingMode; _fileptr = NULL; if (_success) { _currentDataOffset = 0; if (!AtomUtils::read32(fp, _entryCount)) { _success = false; } uint32 dataSize = _size - (DEFAULT_FULL_ATOM_SIZE + 4); uint32 entrySize = 4; if ((_entryCount*entrySize) > dataSize) { _success = false; } if (_success) { if (_entryCount > 0) { if (_parsingMode == 1) { // cache size is 4K so that optimization should work if entry_count is greater than 4K if ((_entryCount > _stbl_buff_size)) { uint32 fptrBuffSize = (_entryCount / _stbl_buff_size) + 1; PV_MP4_FF_ARRAY_NEW(NULL, uint32, (fptrBuffSize), _stbl_fptr_vec); if (_stbl_fptr_vec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _pchunkOffsets); if (_pchunkOffsets == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } { OsclAny* ptr = (MP4_FF_FILE *)(oscl_malloc(sizeof(MP4_FF_FILE))); if (ptr == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } _fileptr = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE()); _fileptr->_fileServSession = fp->_fileServSession; _fileptr->_pvfile.SetCPM(fp->_pvfile.GetCPM()); if (AtomUtils::OpenMP4File(filename, Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, _fileptr) != 0) { _success = false; _mp4ErrorCode = FILE_OPEN_FAILED; } _fileptr->_fileSize = fp->_fileSize; } int32 _head_offset = AtomUtils::getCurrentFilePosition(fp); AtomUtils::seekFromCurrPos(fp, dataSize); AtomUtils::seekFromStart(_fileptr, _head_offset); return; } else { _parsingMode = 0; _stbl_buff_size = _entryCount; } } else { _stbl_buff_size = _entryCount; } _parsingMode = 0; PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _pchunkOffsets); uint32 offset = 0; for (uint32 i = 0; i < _entryCount; i++) { if (!AtomUtils::read32(fp, offset)) { _success = false; break; } _pchunkOffsets[i] = offset; } _parsed_entry_cnt = _entryCount; } else { _pchunkOffsets = NULL; } } if (!_success) { _mp4ErrorCode = READ_CHUNK_OFFSET_ATOM_FAILED; } } else { if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED) _mp4ErrorCode = READ_CHUNK_OFFSET_ATOM_FAILED; } }
// Stream-in ctor TimeToSampleAtom::TimeToSampleAtom(MP4_FF_FILE *fp, uint32 mediaType, uint32 size, uint32 type, OSCL_wString& filename, uint32 parsingMode) : FullAtom(fp, size, type) { _psampleCountVec = NULL; _psampleDeltaVec = NULL; _currGetSampleCount = 0; _currGetIndex = -1; _currGetTimeDelta = 0; _currPeekSampleCount = 0; _currPeekIndex = -1; _currPeekTimeDelta = 0; _mediaType = mediaType; _parsed_entry_cnt = 0; _fileptr = NULL; _parsing_mode = 0; _parsing_mode = parsingMode; _stbl_buff_size = MAX_CACHED_TABLE_ENTRIES_FILE; _next_buff_number = 0; _curr_buff_number = 0; _curr_entry_point = 0; _stbl_fptr_vec = NULL; iLogger = PVLogger::GetLoggerObject("mp4ffparser"); iStateVarLogger = PVLogger::GetLoggerObject("mp4ffparser_mediasamplestats"); iParsedDataLogger = PVLogger::GetLoggerObject("mp4ffparser_parseddata"); if (_success) { if (!AtomUtils::read32(fp, _entryCount)) { _success = false; } PVMF_MP4FFPARSER_LOGPARSEDINFO((0, "TimeToSampleAtom::TimeToSampleAtom- _entryCount =%d", _entryCount)); uint32 dataSize = _size - (DEFAULT_FULL_ATOM_SIZE + 4); uint32 entrySize = (4 + 4); if ((_entryCount*entrySize) > dataSize) { _success = false; } if (_success) { if (_entryCount > 0) { if (parsingMode == 1) { // cache size is 4K so that optimization should work if entry_count is greater than 4K if ((_entryCount > _stbl_buff_size)) { uint32 fptrBuffSize = (_entryCount / _stbl_buff_size) + 1; PV_MP4_FF_ARRAY_NEW(NULL, uint32, (fptrBuffSize), _stbl_fptr_vec); if (_stbl_fptr_vec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleCountVec); if (_psampleCountVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleDeltaVec); if (_psampleDeltaVec == NULL) { PV_MP4_ARRAY_DELETE(NULL, _psampleDeltaVec); _psampleDeltaVec = NULL; _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } for (uint32 idx = 0; idx < _stbl_buff_size; idx++) //initialization { _psampleCountVec[idx] = 0; _psampleDeltaVec[idx] = 0; } OsclAny* ptr = (MP4_FF_FILE *)(oscl_malloc(sizeof(MP4_FF_FILE))); if (ptr == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } _fileptr = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE()); _fileptr->_fileServSession = fp->_fileServSession; _fileptr->_pvfile.SetCPM(fp->_pvfile.GetCPM()); _fileptr->_pvfile.SetFileHandle(fp->_pvfile.iFileHandle); if (AtomUtils::OpenMP4File(filename, Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, _fileptr) != 0) { _success = false; _mp4ErrorCode = FILE_OPEN_FAILED; } _fileptr->_fileSize = fp->_fileSize; int32 _head_offset = AtomUtils::getCurrentFilePosition(fp); AtomUtils::seekFromCurrPos(fp, dataSize); AtomUtils::seekFromStart(_fileptr, _head_offset); return; } else { _parsing_mode = 0; _stbl_buff_size = _entryCount; } } else { _stbl_buff_size = _entryCount; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psampleCountVec); if (_psampleCountVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psampleDeltaVec); if (_psampleDeltaVec == NULL) { PV_MP4_ARRAY_DELETE(NULL, _psampleDeltaVec); _psampleDeltaVec = NULL; _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } for (uint32 idx = 0; idx < _entryCount; idx++) //initialization { _psampleCountVec[idx] = 0; _psampleDeltaVec[idx] = 0; } uint32 number = 0; uint32 delta = 0; for (_parsed_entry_cnt = 0; _parsed_entry_cnt < _entryCount; _parsed_entry_cnt++) { if (!AtomUtils::read32(fp, number)) { _success = false; break; } if (!AtomUtils::read32(fp, delta)) { _success = false; break; } _psampleCountVec[_parsed_entry_cnt] = (number); _psampleDeltaVec[_parsed_entry_cnt] = (delta); } } } if (!_success) { _mp4ErrorCode = READ_TIME_TO_SAMPLE_ATOM_FAILED; } } else { if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED) _mp4ErrorCode = READ_TIME_TO_SAMPLE_ATOM_FAILED; } }