/*---------------------------------------------------------------------- | AP4_IsmaDecryptingProcessor:CreateTrackHandler +---------------------------------------------------------------------*/ AP4_Processor::TrackHandler* AP4_IsmaDecryptingProcessor::CreateTrackHandler(AP4_TrakAtom* trak) { // find the stsd atom AP4_StsdAtom* stsd = dynamic_cast<AP4_StsdAtom*>( trak->FindChild("mdia/minf/stbl/stsd")); // avoid tracks with no stsd atom (should not happen) if (stsd == NULL) return NULL; // we only look at the first sample description AP4_SampleDescription* desc = stsd->GetSampleDescription(0); AP4_SampleEntry* entry = stsd->GetSampleEntry(0); if (desc == NULL || entry == NULL) return NULL; if (desc->GetType() == AP4_SampleDescription::TYPE_ISMACRYP) { // create a handler for this track AP4_IsmaCrypSampleDescription* ismacryp_desc = static_cast<AP4_IsmaCrypSampleDescription*>(desc); if (ismacryp_desc->GetSchemeType() == AP4_ISMACRYP_SCHEME_TYPE_IAEC) { const AP4_UI08* key; const AP4_UI08* salt; if (AP4_SUCCEEDED(m_KeyMap.GetKey(trak->GetId(), key, salt))) { return new AP4_IsmaTrackDecrypter(key, salt, ismacryp_desc, entry); } } } return NULL; }
virtual TrackHandler* CreateTrackHandler(AP4_TrakAtom* trak) { // find the stsd atom AP4_StsdAtom* stsd = AP4_DYNAMIC_CAST(AP4_StsdAtom, trak->FindChild("mdia/minf/stbl/stsd")); // avoid tracks with no stsd atom (should not happen) if (stsd == NULL) return NULL; // we only look at the first sample description AP4_SampleDescription* desc = stsd->GetSampleDescription(0); AP4_MpegAudioSampleDescription* audio_desc = AP4_DYNAMIC_CAST(AP4_MpegAudioSampleDescription, desc); if (audio_desc && audio_desc->GetObjectTypeId()==AP4_OTI_MPEG2_AAC_AUDIO_LC) { // patch the stsd AP4_MpegAudioSampleDescription new_audio_desc(AP4_OTI_MPEG4_AUDIO, audio_desc->GetSampleRate(), audio_desc->GetSampleSize(), audio_desc->GetChannelCount(), &audio_desc->GetDecoderInfo(), audio_desc->GetBufferSize(), audio_desc->GetMaxBitrate(), audio_desc->GetAvgBitrate()); stsd->RemoveChild(stsd->GetChild(AP4_ATOM_TYPE_MP4A)); stsd->AddChild(new_audio_desc.ToAtom()); printf("audio sample description patched\n"); } return NULL; }