Check before trying to get an object from a dictionary.

This commit is contained in:
Damiano Galassi committed 2021-12-14 13:26:15 +01:00
1 parent 33fbcfcb13
commit 488420c5cc
1 file changed
+6 -2
+6 -2
View File
@@ -821,7 +821,7 @@ MP42_OBJC_DIRECT_MEMBERS
- (UInt32)timescaleForTrack:(AVAssetTrack *)track {
// Prefer the asbd sample rate, naturalTimeScale might not be
// the right one if we are reading for .ts
// the right one if we are reading from .ts
if ([track.mediaType isEqualToString:AVMediaTypeAudio] && track.naturalTimeScale == 90000) {
CMFormatDescriptionRef formatDescription = (__bridge CMFormatDescriptionRef)track.formatDescriptions.firstObject;
@@ -850,6 +850,8 @@ MP42_OBJC_DIRECT_MEMBERS
CFDictionaryRef atoms = CFDictionaryGetValue(extentions, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms);
CFDataRef magicCookie = NULL;
if (atoms)
{
if (code == kCMVideoCodecType_H264 || code == kMP42VideoCodecType_DolbyVisionH264) {
magicCookie = CFDictionaryGetValue(atoms, @"avcC");
}
@@ -863,6 +865,7 @@ MP42_OBJC_DIRECT_MEMBERS
else if (code == kCMVideoCodecType_MPEG4Video) {
magicCookie = CFDictionaryGetValue(atoms, @"esds");
}
}
return (__bridge NSData *)magicCookie;
@@ -1061,11 +1064,12 @@ MP42_OBJC_DIRECT_MEMBERS
CFDictionaryRef extentions = CMFormatDescriptionGetExtensions(formatDescription);
CFDictionaryRef atoms = CFDictionaryGetValue(extentions, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms);
if (atoms) {
CFDataRef magicCookie = CFDictionaryGetValue(atoms, @"vttC");
return (__bridge NSData *)magicCookie;
}
}
}
}
return nil;