// Destructor
PVA_FF_MediaInformationAtom::~PVA_FF_MediaInformationAtom()
{
    uint32 mediaType = (uint32)iMediaType;
    PV_MP4_FF_DELETE(NULL, PVA_FF_SampleTableAtom, _psampleTableAtom);

    PV_MP4_FF_DELETE(NULL, PVA_FF_DataInformationAtom, _pdataInformationAtom);

    if (mediaType == MEDIA_TYPE_AUDIO)
    {
        PVA_FF_SoundMediaHeaderAtom *ptr = (PVA_FF_SoundMediaHeaderAtom *)_pmediaInformationHeader;
        PV_MP4_FF_DELETE(NULL, PVA_FF_SoundMediaHeaderAtom, ptr);
    }
    else if (mediaType == MEDIA_TYPE_VISUAL)
    {
        PVA_FF_VideoMediaHeaderAtom *ptr = (PVA_FF_VideoMediaHeaderAtom *)_pmediaInformationHeader;
        PV_MP4_FF_DELETE(NULL, PVA_FF_VideoMediaHeaderAtom, ptr);
    }
    else
    {
        PVA_FF_Mpeg4MediaHeaderAtom *ptr = (PVA_FF_Mpeg4MediaHeaderAtom *)_pmediaInformationHeader;
        PV_MP4_FF_DELETE(NULL, PVA_FF_Mpeg4MediaHeaderAtom, ptr);
    }



}
Exemplo n.º 2
0
ProtectionSchemeInformationBox::~ProtectionSchemeInformationBox()
{
    if (_pSchemeInformationBox != NULL)
    {
        PV_MP4_FF_DELETE(NULL, SchemeInformationBox, _pSchemeInformationBox);
    }
    if (_pOriginalFormatBox != NULL)
    {
        PV_MP4_FF_DELETE(NULL, OriginalFormatBox, _pOriginalFormatBox);
    }
}
Exemplo n.º 3
0
MetaDataAtom::~MetaDataAtom()
{
    if (_pHdlrAtom != NULL)
    {
        PV_MP4_FF_DELETE(NULL, HandlerAtom, _pHdlrAtom);
    }
    if (_pITunesILSTAtom != NULL)
    {
        PV_MP4_FF_DELETE(NULL, ITunesILSTAtom, _pITunesILSTAtom);
    }
}
// Destructor
PVA_FF_TextSampleEntry::~PVA_FF_TextSampleEntry()
{
    if (_pBackgroundRGBA)
    {
        OSCL_FREE(_pBackgroundRGBA);
        _pBackgroundRGBA = NULL;
    }
    PV_MP4_FF_DELETE(NULL, PVA_FF_BoxRecord, _pBoxRecord);
    PV_MP4_FF_DELETE(NULL, PVA_FF_StyleRecord, _pStyleRecord);
    PV_MP4_FF_DELETE(NULL, PVA_FF_FontTableAtom, _pFontTableAtom);
}
Exemplo n.º 5
0
//destructor
PVA_FF_MovieExtendsAtom::~PVA_FF_MovieExtendsAtom()
{
    PV_MP4_FF_DELETE(NULL, PVA_FF_MovieExtendsHeaderAtom, _pMehdAtom);

    // Delete trex atoms
    for (uint32 ii = 0; ii < _pTrexAtomVec->size(); ii++)
    {
        PV_MP4_FF_DELETE(NULL, PVA_FF_TrackExtendAtom, (*_pTrexAtomVec)[ii]);
    }
    PV_MP4_FF_TEMPLATED_DELETE(NULL, PVA_FF_TrackExtendsAtomVecType, Oscl_Vector, _pTrexAtomVec);

}
// Destructor
H263SampleEntry::~H263SampleEntry()
{
    if (_pH263SpecificAtom != NULL)
    {
        PV_MP4_FF_DELETE(NULL, H263SpecficAtom, _pH263SpecificAtom);
    }

    if (_pH263decSpecificInfo != NULL)
    {
        PV_MP4_FF_DELETE(NULL, H263DecoderSpecificInfo, _pH263decSpecificInfo);
    }
}
Exemplo n.º 7
0
//destructor
PVA_FF_MovieFragmentAtom::~PVA_FF_MovieFragmentAtom()
{
    // delete header atom
    PV_MP4_FF_DELETE(NULL, PVA_FF_MovieFragmentHeaderAtom, _pMfhdAtom);

    // Delete track fragment atom list
    for (uint32 ii = 0; ii < _pTrafList->size(); ii++)
    {
        PV_MP4_FF_DELETE(NULL, PVA_FF_TrackFragmentAtom, (*_pTrafList)[ii]);
    }
    PV_MP4_FF_TEMPLATED_DELETE(NULL, PVA_FF_TrackFragmentAtomVecType, Oscl_Vector, _pTrafList);

}
MovieExtendsAtom::~MovieExtendsAtom()
{
    if (_pMovieExtendsHeaderAtom != NULL)
    {
        PV_MP4_FF_DELETE(NULL, MovieExtendsHeaderAtom, _pMovieExtendsHeaderAtom);
        _pMovieExtendsHeaderAtom = NULL;
    }
    for (uint32 i = 0; i < _pTrackExtendsAtomVec->size(); i++)
    {
        PV_MP4_FF_DELETE(NULL, TrackExtendsAtom, (*_pTrackExtendsAtomVec)[i]);
    }
    PV_MP4_FF_TEMPLATED_DELETE(NULL, trackExtendsAtomVecType, Oscl_Vector, _pTrackExtendsAtomVec);

}
//destructor
PVA_FF_MovieFragmentRandomAccessAtom::~PVA_FF_MovieFragmentRandomAccessAtom()
{
    // delete movie fragment random access offset atom
    PV_MP4_FF_DELETE(NULL, PVA_FF_MfroAtom, _pMfroAtom);

    // Delete track fragment  random access atom list
    for (uint32 ii = 0; ii < _pTfraList->size(); ii++)
    {
        PV_MP4_FF_DELETE(NULL, PVA_FF_TfraAtom, (*_pTfraList)[ii]);
    }
    PV_MP4_FF_TEMPLATED_DELETE(NULL, PVA_FF_TrackFragmentRandomAccessAtomVecType,
                               Oscl_Vector, _pTfraList);

}
Exemplo n.º 10
0
SchemeInformationBox::~SchemeInformationBox()
{
    if (_pOMADRMKMSBox != NULL)
    {
        PV_MP4_FF_DELETE(NULL, OMADRMKMSBox, _pOMADRMKMSBox);
    }
}
Exemplo n.º 11
0
PVA_FF_EditAtom::~PVA_FF_EditAtom()
{
    if (_peditList != NULL)
    {
        PV_MP4_FF_DELETE(NULL, PVA_FF_EditListAtom, _peditList);
    }
}
Exemplo n.º 12
0
// Destructor
TrackReferenceAtom::~TrackReferenceAtom()
{
    if (_ptrackReferenceTypeAtom != NULL)
    {
        PV_MP4_FF_DELETE(NULL, TrackReferenceTypeAtom, _ptrackReferenceTypeAtom);
    }
}
// Destructor
MpegSampleEntry::~MpegSampleEntry()
{
    if (_pes != NULL)
    {
        // Cleanup ESDAtom
        PV_MP4_FF_DELETE(NULL, ESDAtom, _pes);
    }
}
// Destructor
MediaAtom::~MediaAtom()
{
    if (_pmediaHeader != NULL)
    {
        PV_MP4_FF_DELETE(NULL, MediaHeaderAtom, _pmediaHeader);
    }

    if (_phandler != NULL)
    {
        PV_MP4_FF_DELETE(NULL, HandlerAtom, _phandler);
    }

    if (_pmediaInformation != NULL)
    {
        PV_MP4_FF_DELETE(NULL, MediaInformationAtom, _pmediaInformation);
    }
}
Exemplo n.º 15
0
// Destructor
ESDAtom::~ESDAtom()
{
    if (_pdescriptor != NULL)
    {
        // Cleanup the ESDescriptor
        PV_MP4_FF_DELETE(NULL, ESDescriptor, _pdescriptor);
    }
}
// Destructor
ObjectDescriptorAtom::~ObjectDescriptorAtom()
{
    // Cleanup InitialObjectDescriptor
    if (_pOD != NULL)
    {
        PV_MP4_FF_DELETE(NULL, InitialObjectDescriptor, _pOD);
    }
}
// Destructor
TrackAtom::~TrackAtom()
{
    if (_ptrackHeader != NULL)
        PV_MP4_FF_DELETE(NULL, TrackHeaderAtom, _ptrackHeader);

    if (_pmediaAtom != NULL)
        PV_MP4_FF_DELETE(NULL, MediaAtom, _pmediaAtom);

    if (_puserdataatom != NULL)
        PV_MP4_FF_DELETE(NULL, UserDataAtom, _puserdataatom);

    if (_ptrackReference != NULL)
        PV_MP4_FF_DELETE(NULL, TrackReferenceAtom, _ptrackReference);

    if (_pEditAtom != NULL)
        PV_MP4_FF_DELETE(NULL, EditAtom, _pEditAtom);
}
// Stream-in ctor
DataReferenceAtom::DataReferenceAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
        : FullAtom(fp, size, type)
{

    _pdataEntryVec = NULL;

    if (_success)
    {

        _pparent = NULL;

        PV_MP4_FF_NEW(fp->auditCB, dataEntryUrlAtomVecType, (), _pdataEntryVec);

        if (!AtomUtils::read32(fp, _entryCount))
        {
            _success = false;
            _mp4ErrorCode = READ_DATA_REFERENCE_ATOM_FAILED;
        }
        else
        {
            // THERE MUST BE ATLEAST ONE ENTRY
            int32 temp = (int32)(_entryCount);

            if (temp <= 0)
            {
                _success = false;
                _mp4ErrorCode = READ_DATA_REFERENCE_ATOM_FAILED;
            }
        }

        if (_success)
        {
            DataEntryUrlAtom *deua = NULL;
            for (uint32 i = 0; i < _entryCount; i++)
            {
                PV_MP4_FF_NEW(fp->auditCB, DataEntryUrlAtom, (fp), deua);
                if (!deua->MP4Success())
                {
                    _success = false;
                    _mp4ErrorCode = deua->GetMP4Error();
                    if (deua != NULL)
                    {
                        PV_MP4_FF_DELETE(NULL, DataEntryUrlAtom, deua);
                        deua = NULL;
                    }
                    break;
                }
                else
                {
                    (*_pdataEntryVec).push_back(deua);
                    deua->setParent(this);
                }
            }
        }
    }
    else
    {
        if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
// Destructor
AVCConfigurationBox::~AVCConfigurationBox()
{
    if (_sequenceParameterSetVec != NULL)
    {
        for (uint32 i = 0; i < _sequenceParameterSetVec->size(); i++)
        {
            PV_MP4_FF_DELETE(NULL, ParameterSet, (*_sequenceParameterSetVec)[i]);
        }
        PV_MP4_FF_TEMPLATED_DELETE(NULL, parameterSetVecType, Oscl_Vector, _sequenceParameterSetVec);
    }
    if (_pictureParameterSetVec != NULL)
    {
        for (uint32 i = 0; i < _pictureParameterSetVec->size(); i++)
        {
            PV_MP4_FF_DELETE(NULL, ParameterSet, (*_pictureParameterSetVec)[i]);
        }
        PV_MP4_FF_TEMPLATED_DELETE(NULL, parameterSetVecType, Oscl_Vector, _pictureParameterSetVec);
    }
}
// Destructor
AVCSampleEntry::~AVCSampleEntry()
{
    if (_pAVCConfigurationBox != NULL)
    {
        PV_MP4_FF_DELETE(NULL, AVCConfigurationBox, _pAVCConfigurationBox);
    }
    if (_pMPEG4BitRateBox != NULL)
    {
        PV_MP4_FF_DELETE(NULL, MPEG4BitRateBox, _pMPEG4BitRateBox);
    }
    if (_pPASPBox != NULL)
    {
        PV_MP4_FF_DELETE(NULL, PASPBox, _pPASPBox);
    }
    if (_decoderSpecificInfo != NULL)
    {
        PV_MP4_FF_DELETE(NULL, DecoderSpecificInfo, _decoderSpecificInfo);
    }
}
// Destructor
PVA_FF_DecoderConfigDescriptor::~PVA_FF_DecoderConfigDescriptor()
{
    if (_pdecSpecificInfoVec != NULL)
    {
        for (uint32 i = 0; i < _pdecSpecificInfoVec->size(); i++)
        {
            PV_MP4_FF_DELETE(NULL, PVA_FF_DecoderSpecificInfo, (*_pdecSpecificInfoVec)[i]);
        }
        PV_MP4_FF_TEMPLATED_DELETE(NULL, PVA_FF_DecoderSpecificInfoVecType, Oscl_Vector, _pdecSpecificInfoVec);
    }
}
Exemplo n.º 22
0
// Destructor
PVA_FF_TrackAtom::~PVA_FF_TrackAtom()
{
    PV_MP4_FF_DELETE(NULL, PVA_FF_TrackHeaderAtom, _ptrackHeader);

    PV_MP4_FF_DELETE(NULL, PVA_FF_MediaAtom, _pmediaAtom);

    if (_ptrackReference != NULL)
    {
        PV_MP4_FF_DELETE(NULL, PVA_FF_TrackReferenceAtom, _ptrackReference);
    }

    if (_eList != NULL)
    {
        PV_MP4_FF_DELETE(NULL, PVA_FF_EditAtom, _eList);
    }

    if (_pUserDataAtom != NULL)
    {
        PV_MP4_FF_DELETE(NULL, PVA_FF_UserDataAtom, _pUserDataAtom);
    }
}
// Destructor
TrackFragmentRandomAccessAtom::~TrackFragmentRandomAccessAtom()
{
    if (_pTFRAEntriesVec != NULL)
    {
        // CLEAN UP VECTOR!!
        for (uint32 i = 0; i < _pTFRAEntriesVec->size(); i++)
        {
            PV_MP4_FF_DELETE(NULL, TFRAEntries, (*_pTFRAEntriesVec)[i]);
        }
        PV_MP4_FF_TEMPLATED_DELETE(NULL, TFRAEntriesVecType, Oscl_Vector, _pTFRAEntriesVec);
    }

}
// Destructor
PVA_FF_ObjectDescriptor::~PVA_FF_ObjectDescriptor()
{
    // Cleanup vector of ES_ID_Refs
    if (_pES_ID_Ref_Vec != NULL)
    {
        for (uint32 i = 0; i < _pES_ID_Ref_Vec->size(); i++)
        {
            PVA_FF_ES_ID_Ref* ref = (*_pES_ID_Ref_Vec)[i];
            PV_MP4_FF_DELETE(NULL, PVA_FF_ES_ID_Ref, ref);
        }
        PV_MP4_FF_TEMPLATED_DELETE(NULL, PVA_FF_ES_ID_RefVecType, Oscl_Vector, _pES_ID_Ref_Vec);
    }
}
PVA_FF_AssetInfoKeyWordsAtom::~PVA_FF_AssetInfoKeyWordsAtom()
{
    if (_pKeyWordVect != NULL)
    {
        for (uint32 idx = 0; idx < _pKeyWordVect->size();idx++)
        {
            if ((*_pKeyWordVect)[idx] != NULL)
            {
                PV_MP4_FF_DELETE(NULL, PVA_FF_AssetInfoKeyWordStruct, (*_pKeyWordVect)[idx]);
                (*_pKeyWordVect)[idx] = NULL;
            }
        }
        PV_MP4_FF_TEMPLATED_DELETE(NULL, PVA_FF_AssetInfoKeyWordStructVecType, Oscl_Vector, _pKeyWordVect);
        _pKeyWordVect = NULL;
    }

}
// Destructor
PVA_FF_H263SampleEntry::~PVA_FF_H263SampleEntry()
{
    PV_MP4_FF_DELETE(NULL, PVA_FF_H263SpecficAtom, pH263SpecificAtom);
}
// Stream-in ctor
SampleDescriptionAtom::SampleDescriptionAtom(MP4_FF_FILE *fp,
        uint32 mediaType,
        uint32 size,
        uint32 type)
        : FullAtom(fp, size, type),
        _pMediaType(mediaType)
{
    _psampleEntryVec      = NULL;
    _pAMRSampleEntryAtom  = NULL;
    _pH263SampleEntryAtom = NULL;
    _pAVCSampleEntryVec   = NULL;
    _o3GPPAMR = false;
    _o3GPPH263 = false;
    _o3GPPWBAMR = false;
    _oAVC = false;
    _o3GPPEVRC = false;
    _o3GPPQCELP = false;

    _p3GPP2SpeechSampleEntry = NULL;

    uint32 count = size - DEFAULT_ATOM_SIZE;
    count -= 4; //for 4-byte handle_type

    _pProtectionSchemeInformationBox = NULL;

    if (_success)
    {
        if (!AtomUtils::read32(fp, _entryCount))
        {
            _success = false;
        }
        count -= 4;
        int32 tmp = (int32)_entryCount;

        if (tmp <= 0)
        {
            _success = false;
            _mp4ErrorCode = READ_SAMPLE_DESCRIPTION_ATOM_FAILED;
            return;
        }

        if ((mediaType != MEDIA_TYPE_HINT) &&
                (mediaType != MEDIA_TYPE_TEXT))
        {
            if (tmp > MAX_ALLOWED_MEDIA_SAMPLE_ENTRIES)
            {
                _success = false;
                _mp4ErrorCode = READ_SAMPLE_DESCRIPTION_ATOM_FAILED;
                return;
            }
        }

        if (_success)
        {
            PV_MP4_FF_NEW(fp->auditCB, sampleEntryVecType, (), _psampleEntryVec);
            PV_MP4_FF_NEW(fp->auditCB, AVCSampleEntryVecType, (), _pAVCSampleEntryVec);


            for (uint32 i = 0; i < _entryCount; i++)
            {
                SampleEntry *entry = NULL;

                uint32 atomType = UNKNOWN_ATOM;
                uint32 atomSize = 0;

                AtomUtils::getNextAtomType(fp, atomSize, atomType);
                count -= atomSize;

                switch (mediaType)
                {
                    case MEDIA_TYPE_AUDIO:
                    {
                        if (atomType == ENCRYPTED_AUDIO_SAMPLE_ENTRY)
                        {
                            PV_MP4_FF_NEW(fp->auditCB, EcnaBox, (fp, atomSize, atomType), entry);
                            if (!entry->MP4Success())
                            {
                                _success = false;
                                _mp4ErrorCode = entry->GetMP4Error();
                                EcnaBox *ptr = (EcnaBox *)entry;
                                PV_MP4_FF_DELETE(NULL, EcnaBox, ptr);
                                return;
                            }
                            _pProtectionSchemeInformationBox =
                                ((EcnaBox*)entry)->_pProtectionSchemeInformationBox;
                        }
                        else if (atomType == AMR_SAMPLE_ENTRY_ATOM)
                        {
                            if (_o3GPPAMR == false)
                            {
                                PV_MP4_FF_NEW(fp->auditCB, AMRSampleEntry, (fp, atomSize, atomType), _pAMRSampleEntryAtom);

                                if (!_pAMRSampleEntryAtom->MP4Success())
                                {
                                    _success = false;
                                    _mp4ErrorCode = _pAMRSampleEntryAtom->GetMP4Error();
                                    PV_MP4_FF_DELETE(NULL, AMRSampleEntry, _pAMRSampleEntryAtom);
                                    _pAMRSampleEntryAtom = NULL;
                                    return;
                                }
                                else
                                {
                                    _pAMRSampleEntryAtom->setParent(this);
                                }
                                _o3GPPAMR = true;
                            }
                            else
                            {
                                // Multiple AMR Sample Entries are illegal
                                _success = false;
                                _mp4ErrorCode = READ_SAMPLE_DESCRIPTION_ATOM_FAILED;
                                return;
                            }
                        }
                        else if (atomType == AMRWB_SAMPLE_ENTRY_ATOM)
                        {
                            if (_o3GPPWBAMR == false)
                            {
                                PV_MP4_FF_NEW(fp->auditCB, AMRSampleEntry, (fp, atomSize, atomType), _pAMRSampleEntryAtom);

                                if (!_pAMRSampleEntryAtom->MP4Success())
                                {
                                    _success = false;
                                    _mp4ErrorCode = _pAMRSampleEntryAtom->GetMP4Error();
                                    PV_MP4_FF_DELETE(NULL, AMRSampleEntry, _pAMRSampleEntryAtom);
                                    _pAMRSampleEntryAtom = NULL;
                                    return;
                                }
                                else
                                {
                                    _pAMRSampleEntryAtom->setParent(this);
                                }
                                _o3GPPWBAMR = true;
                            }
                            else
                            {
                                // Multiple AMR Sample Entries are illegal
                                _success = false;
                                _mp4ErrorCode = READ_SAMPLE_DESCRIPTION_ATOM_FAILED;
                                return;
                            }
                        }
                        else if (atomType == AUDIO_SAMPLE_ENTRY)
                        {
                            PV_MP4_FF_NEW(fp->auditCB, AudioSampleEntry, (fp, atomSize, atomType), entry);
                            if (!entry->MP4Success())
                            {
                                _success = false;
                                _mp4ErrorCode = entry->GetMP4Error();
                                AudioSampleEntry *ptr = (AudioSampleEntry *)entry;
                                PV_MP4_FF_DELETE(NULL, AudioSampleEntry, ptr);
                                return;
                            }
                        }
                        else if ((atomType == EVRC_SAMPLE_ENTRY)   ||
                                 (atomType == EVRCB_SAMPLE_ENTRY)  ||
                                 (atomType == EVRCWB_SAMPLE_ENTRY) ||
                                 (atomType == QCELP_SAMPLE_ENTRY)  ||
                                 (atomType == SMV_SAMPLE_ENTRY)    ||
                                 (atomType == VMR_SAMPLE_ENTRY))
                        {
                            if (atomType == QCELP_SAMPLE_ENTRY)
                                _o3GPPQCELP = true;
                            else if ((atomType == EVRC_SAMPLE_ENTRY) ||
                                    (atomType == EVRCB_SAMPLE_ENTRY))
                                _o3GPPEVRC = true;

                            if (_p3GPP2SpeechSampleEntry == NULL)
                            {
                                PV_MP4_FF_NEW(fp->auditCB, SpeechSampleEntry3GPP2, (fp, atomSize, atomType), _p3GPP2SpeechSampleEntry);
                                if (!_p3GPP2SpeechSampleEntry->MP4Success())
                                {
                                    _success = false;
                                    _mp4ErrorCode = _p3GPP2SpeechSampleEntry->GetMP4Error();
                                    PV_MP4_FF_DELETE(NULL, SpeechSampleEntry3GPP2, _p3GPP2SpeechSampleEntry);
                                    _p3GPP2SpeechSampleEntry = NULL;
                                    return;
                                }
                                else
                                {
                                    _p3GPP2SpeechSampleEntry->setParent(this);
                                }
                            }
                            else
                            {
                                // Multiple Sample Entries are illegal
                                _success = false;
                                _mp4ErrorCode = READ_SAMPLE_DESCRIPTION_ATOM_FAILED;
                                return;
                            }
                        }
                        else
                        {
                            atomSize -= DEFAULT_ATOM_SIZE;
                            AtomUtils::seekFromCurrPos(fp, atomSize);
                        }
                        _handlerType = MEDIA_TYPE_AUDIO;
                        break;
                    }

                    case MEDIA_TYPE_TEXT:
                    {
// TIMED_TEXT_SUPPORT start
                        if (atomType == ENCRYPTED_TEXT_SAMPLE_ENTRY)
                        {
                            PV_MP4_FF_NEW(fp->auditCB, EnctBox, (fp, atomSize, atomType), entry);
                            if (!entry->MP4Success())
                            {
                                _success = false;
                                _mp4ErrorCode = entry->GetMP4Error();
                                EnctBox *ptr = (EnctBox *)entry;
                                PV_MP4_FF_DELETE(NULL, EnctBox, ptr);
                                return;
                            }
                            _pProtectionSchemeInformationBox =
                                ((EnctBox*)entry)->_pProtectionSchemeInformationBox;

                        }
                        else if (atomType == TEXT_SAMPLE_ENTRY)
                        {
                            PV_MP4_FF_NEW(fp->auditCB, TextSampleEntry, (fp, atomSize, atomType), entry);
                            if (!entry->MP4Success())
                            {
                                _success = false;
                                _mp4ErrorCode = entry->GetMP4Error();
                                TextSampleEntry *ptr = (TextSampleEntry *)entry;
                                PV_MP4_FF_DELETE(NULL, TextSampleEntry, ptr);
                                return;
                            }

                        }
                        else
// TIMED_TEXT_SUPPORT end
                        {
                            atomSize -= DEFAULT_ATOM_SIZE;
                            AtomUtils::seekFromCurrPos(fp, atomSize);
                        }
                        _handlerType = MEDIA_TYPE_TEXT;
                    }
                    break;

                    case MEDIA_TYPE_VISUAL:
                    {
                        if (atomType == ENCRYPTED_VIDEO_SAMPLE_ENTRY)
                        {
                            PV_MP4_FF_NEW(fp->auditCB, EcnvBox, (fp, atomSize, atomType), entry);
                            if (!entry->MP4Success())
                            {
                                _success = false;
                                _mp4ErrorCode = entry->GetMP4Error();
                                EcnvBox *ptr = (EcnvBox *)entry;
                                PV_MP4_FF_DELETE(NULL, EcnvBox, ptr);
                                return;
                            }
                            _pProtectionSchemeInformationBox =
                                ((EcnvBox*)entry)->_pProtectionSchemeInformationBox;

                        }
                        else if (atomType == H263_SAMPLE_ENTRY_ATOM)
                        {
                            if (_o3GPPH263 == false)
                            {
                                PV_MP4_FF_NEW(fp->auditCB, H263SampleEntry, (fp, atomSize, atomType), _pH263SampleEntryAtom);

                                if (!_pH263SampleEntryAtom->MP4Success())
                                {
                                    _success = false;
                                    _mp4ErrorCode = _pH263SampleEntryAtom->GetMP4Error();
                                    return;
                                }
                                else
                                {
                                    _pH263SampleEntryAtom->setParent(this);
                                }
                                _o3GPPH263 = true;
                            }
                            else
                            {
                                // Multiple H263 Sample Entries are illegal
                                _success = false;
                                _mp4ErrorCode = READ_SAMPLE_DESCRIPTION_ATOM_FAILED;
                                return;
                            }
                        }
                        else if (atomType == VIDEO_SAMPLE_ENTRY)
                        {
                            PV_MP4_FF_NEW(fp->auditCB, VisualSampleEntry, (fp, atomSize, atomType), entry);
                            if (!entry->MP4Success())
                            {
                                _success = false;
                                _mp4ErrorCode = entry->GetMP4Error();
                                VisualSampleEntry *ptr = (VisualSampleEntry *)entry;
                                PV_MP4_FF_DELETE(NULL, VisualSampleEntry, ptr);
                                return;
                            }
                        }
                        else if (atomType == AVC_SAMPLE_ENTRY)
                        {
                            if (_oAVC == false)
                            {
                                AVCSampleEntry* pAVCSampleEntry = NULL;
                                PV_MP4_FF_NEW(fp->auditCB, AVCSampleEntry, (fp, atomSize, atomType), pAVCSampleEntry);
                                if (!pAVCSampleEntry->MP4Success())
                                {
                                    _success = false;
                                    _mp4ErrorCode = pAVCSampleEntry->GetMP4Error();
                                    PV_MP4_FF_DELETE(NULL, AVCSampleEntry, pAVCSampleEntry);
                                    return;
                                }
                                else
                                {
                                    pAVCSampleEntry->setParent(this);
                                }
                                _oAVC = true;

                                if (pAVCSampleEntry != NULL)
                                {
                                    (*_pAVCSampleEntryVec).push_back(pAVCSampleEntry);
                                }
                            }
                            else
                            {
                                // Multiple AVC Sample Entries are illegal
                                _success = false;
                                _mp4ErrorCode = READ_SAMPLE_DESCRIPTION_ATOM_FAILED;
                                return;
                            }
                        }
                        else
                        {
                            atomSize -= DEFAULT_ATOM_SIZE;
                            AtomUtils::seekFromCurrPos(fp, atomSize);
                        }
                        _handlerType = MEDIA_TYPE_VISUAL;
                        break;
                    }

                    default:
                    {
                        atomSize -= DEFAULT_ATOM_SIZE;
                        AtomUtils::seekFromCurrPos(fp, atomSize);
                    }
                }

                if (entry != NULL)
                {
                    if (!entry->MP4Success())
                    {
                        _success = false;
                        _mp4ErrorCode = entry->GetMP4Error();
                        break; // Break out of the for loop
                    }
                    else
                    {
                        entry->setParent(this);
                        (*_psampleEntryVec).push_back(entry);
                    }
                }
            } // end for loop
            if (count > 0)
            {
                //skip the rest of bytes
                AtomUtils::seekFromCurrPos(fp, count);
            }

        } // end if success

    }
    else
    {
        if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
Exemplo n.º 28
0
MetaDataAtom::MetaDataAtom(MP4_FF_FILE *fp, uint32 size, uint32 type): Atom(fp, size, type)
{
    _success = true;

    // User ilst Data
    _pITunesILSTAtom = NULL;
    _pHdlrAtom = NULL;
    int32 _count = _size - getDefaultSize();

    uint32 data_32_hdlr = 0;
    iLogger = PVLogger::GetLoggerObject("mp4ffparser");

    // Skip first 4 bytes.
    if (!AtomUtils::read32(fp, data_32_hdlr))
    {
        _success = false;
        _mp4ErrorCode = READ_META_DATA_FAILED;
        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>MetaDataAtom::MetaDataAtom READ_META_DATA_FAILED   if(!AtomUtils::read32(fp,data_32_hdlr)))"));
        return;
    }
    _count -= 4;

    while (_count > 0)
    {
        uint32 atomType = UNKNOWN_ATOM;
        uint32 atomSize = 0;

        uint32 currPtr = AtomUtils::getCurrentFilePosition(fp);
        AtomUtils::getNextAtomType(fp, atomSize, atomType);

        // Validate atomSize
        if (atomSize < DEFAULT_ATOM_SIZE)
        {
            _success = false;
            _mp4ErrorCode = ZERO_OR_NEGATIVE_ATOM_SIZE;
            break;
        }

        if ((atomType == FREE_SPACE_ATOM) || (atomType == UNKNOWN_ATOM))
        {
            //skip the atom
            if (_count < atomSize)
            {
                AtomUtils::seekFromStart(fp, currPtr);
                AtomUtils::seekFromCurrPos(fp, _count);
                _count = 0;
                return;
            }

            _count -= atomSize;
            atomSize -= DEFAULT_ATOM_SIZE;
            AtomUtils::seekFromCurrPos(fp, atomSize);
        }
        else if (atomType == HANDLER_ATOM)
        {
            PV_MP4_FF_NEW(fp->auditCB, HandlerAtom, (fp, atomSize, atomType), _pHdlrAtom);

            if (!_pHdlrAtom->MP4Success())
            {
                AtomUtils::seekFromStart(fp, currPtr);
                AtomUtils::seekFromCurrPos(fp, atomSize);
                PV_MP4_FF_DELETE(NULL, HandlerAtom, _pHdlrAtom);
                _pHdlrAtom = NULL;
                _count -= atomSize;
            }

            if (_pHdlrAtom != NULL)
            {
                if (_pHdlrAtom->getHandlerType() != ITUNES_MDIRAPPL_HDLR_PART1)
                {
                    // Skip the parsing...
                    fp->_pvfile.Seek(atomSize, Oscl_File::SEEKCUR);
                    return;
                }
                _count -= _pHdlrAtom->getSize();
            }
        }
        // Read the ilst Atom
        else if (atomType == ITUNES_ILST_ATOM)
        {
            PV_MP4_FF_NEW(fp->auditCB, ITunesILSTAtom, (fp, atomSize, atomType), _pITunesILSTAtom);

            if (!_pITunesILSTAtom->MP4Success())
            {
                AtomUtils::seekFromStart(fp, currPtr);
                AtomUtils::seekFromCurrPos(fp, atomSize);
                PV_MP4_FF_DELETE(NULL, ITunesILSTAtom, _pITunesILSTAtom);
                _pITunesILSTAtom = NULL;
                _count -= atomSize;
            }
            else
                _count -= _pITunesILSTAtom->getSize();
        }
        else
        {
            //Unexpected atomType. Flag an error.
            _success = false;
            _mp4ErrorCode = READ_META_DATA_FAILED;
            break;
        }
    }
}
// Constructor
MovieExtendsAtom::MovieExtendsAtom(MP4_FF_FILE *fp,
                                   uint32 size,
                                   uint32 type)
        : Atom(fp, size, type)
{
    _pMovieExtendsHeaderAtom        = NULL;

    PV_MP4_FF_NEW(fp->auditCB, trackExtendsAtomVecType, (), _pTrackExtendsAtomVec);

    uint32 count = size - DEFAULT_ATOM_SIZE;

    if (_success)
    {
        while (count > 0)
        {
            uint32 atomType = UNKNOWN_ATOM;
            uint32 atomSize = 0;

            AtomUtils::getNextAtomType(fp, atomSize, atomType);

            if (atomType == MOVIE_EXTENDS_HEADER_ATOM)
            {
                if (_pMovieExtendsHeaderAtom == NULL)
                {
                    PV_MP4_FF_NEW(fp->auditCB, MovieExtendsHeaderAtom, (fp, atomSize, atomType), _pMovieExtendsHeaderAtom);
                    if (!_pMovieExtendsHeaderAtom->MP4Success())
                    {
                        _success = false;
                        _mp4ErrorCode = READ_MOVIE_EXTENDS_HEADER_FAILED;
                        return;
                    }
                    count -= _pMovieExtendsHeaderAtom->getSize();
                }
                else
                {
                    //duplicate atom
                    count -= atomSize;
                    atomSize -= DEFAULT_ATOM_SIZE;
                    AtomUtils::seekFromCurrPos(fp, atomSize);
                }
            }
            else if (atomType == TRACK_EXTENDS_ATOM)
            {
                TrackExtendsAtom *pTrackExtendsAtom = NULL;
                PV_MP4_FF_NEW(fp->auditCB, TrackExtendsAtom, (fp, atomSize, atomType), pTrackExtendsAtom);
                if (!pTrackExtendsAtom->MP4Success())
                {
                    _success = false;
                    PV_MP4_FF_DELETE(NULL, TrackExtendsAtom, pTrackExtendsAtom);
                    _mp4ErrorCode = READ_TRACK_EXTENDS_ATOM_FAILED;
                    return;
                }
                count -= pTrackExtendsAtom->getSize();
                _pTrackExtendsAtomVec->push_back(pTrackExtendsAtom);
            }

        }
    }
    else
    {
        _mp4ErrorCode = READ_MOVIE_EXTENDS_ATOM_FAILED;
    }
}
AVCConfigurationBox::AVCConfigurationBox(MP4_FF_FILE *fp, uint32 size, uint32 type)
        : Atom(fp, size, type)
{
    _mp4ErrorCode = READ_AVC_CONFIG_BOX_FAILED;

    _sequenceParameterSetVec = NULL;
    _pictureParameterSetVec  = NULL;
    _totalSeqParameterSetLength = 0;
    _totalPicutureParameterSetLength = 0;

    if (_success)
    {
        _success = false;
        _pparent = NULL;

        PV_MP4_FF_NEW(fp->auditCB, parameterSetVecType, (), _sequenceParameterSetVec);
        PV_MP4_FF_NEW(fp->auditCB, parameterSetVecType, (), _pictureParameterSetVec);

        if (!AtomUtils::read8(fp, _configurationVersion))
        {
            return;
        }
        if (!AtomUtils::read8(fp, _avcProfileIndication))
        {
            return;
        }
        if (!AtomUtils::read8(fp, _profileCompatibility))
        {
            return;
        }

        if (!AtomUtils::read8(fp, _avcLevelIndication))
        {
            return;
        }

        _constraint_set0_flag = (uint8)((_profileCompatibility & ~0x7F) >> 7);
        _constraint_set1_flag = (uint8)((_profileCompatibility & ~0xBF) >> 6);
        _constraint_set2_flag = (uint8)((_profileCompatibility & ~0xDF) >> 5);
        _reserved_zero_5bits = 0;

        if (!AtomUtils::read8(fp, _lengthSizeMinusOne))
        {
            return;
        }
        _lengthSizeMinusOne &= LENGTH_SIZE_MINUS_ONE_MASK;

        if (!AtomUtils::read8(fp, _numSequenceParameterSets))
        {
            return;
        }
        _numSequenceParameterSets &= NUM_SEQUENCE_PARAM_SETS_MASK;

        uint8 i;
        uint16 parameterSetLen;

        for (i = 0; i < _numSequenceParameterSets; i++)
        {
            if (!AtomUtils::read16(fp, parameterSetLen))
            {
                return;
            }

            _totalSeqParameterSetLength += parameterSetLen;

            ParameterSet *paramSet = NULL;
            PV_MP4_FF_NEW(fp->auditCB, ParameterSet, (parameterSetLen, fp), paramSet);

            if (!(paramSet->getSuccess()))
            {
                PV_MP4_FF_DELETE(NULL, ParameterSet, paramSet);
                return;
            }

            (*_sequenceParameterSetVec).push_back(paramSet);

        }

        if (!AtomUtils::read8(fp, _numPictureParameterSets))
        {
            return;
        }

        for (i = 0; i < _numPictureParameterSets; i++)
        {
            if (!AtomUtils::read16(fp, parameterSetLen))
            {
                return;
            }

            _totalPicutureParameterSetLength += parameterSetLen;

            ParameterSet *paramSet = NULL;
            PV_MP4_FF_NEW(fp->auditCB, ParameterSet, (parameterSetLen, fp), paramSet);

            if (!(paramSet->getSuccess()))
            {
                PV_MP4_FF_DELETE(NULL, ParameterSet, paramSet);
                return;
            }

            (*_pictureParameterSetVec).push_back(paramSet);

        }
        _success = true;
        _mp4ErrorCode = EVERYTHING_FINE;

    }
}