Check before trying to get an object from a dictionary.
This commit is contained in:
1 file changed
+6
-2
@@ -821,7 +821,7 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
|
|
||||||
- (UInt32)timescaleForTrack:(AVAssetTrack *)track {
|
- (UInt32)timescaleForTrack:(AVAssetTrack *)track {
|
||||||
// Prefer the asbd sample rate, naturalTimeScale might not be
|
// 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) {
|
if ([track.mediaType isEqualToString:AVMediaTypeAudio] && track.naturalTimeScale == 90000) {
|
||||||
CMFormatDescriptionRef formatDescription = (__bridge CMFormatDescriptionRef)track.formatDescriptions.firstObject;
|
CMFormatDescriptionRef formatDescription = (__bridge CMFormatDescriptionRef)track.formatDescriptions.firstObject;
|
||||||
|
|
||||||
@@ -850,6 +850,8 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
CFDictionaryRef atoms = CFDictionaryGetValue(extentions, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms);
|
CFDictionaryRef atoms = CFDictionaryGetValue(extentions, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms);
|
||||||
CFDataRef magicCookie = NULL;
|
CFDataRef magicCookie = NULL;
|
||||||
|
|
||||||
|
if (atoms)
|
||||||
|
{
|
||||||
if (code == kCMVideoCodecType_H264 || code == kMP42VideoCodecType_DolbyVisionH264) {
|
if (code == kCMVideoCodecType_H264 || code == kMP42VideoCodecType_DolbyVisionH264) {
|
||||||
magicCookie = CFDictionaryGetValue(atoms, @"avcC");
|
magicCookie = CFDictionaryGetValue(atoms, @"avcC");
|
||||||
}
|
}
|
||||||
@@ -863,6 +865,7 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
else if (code == kCMVideoCodecType_MPEG4Video) {
|
else if (code == kCMVideoCodecType_MPEG4Video) {
|
||||||
magicCookie = CFDictionaryGetValue(atoms, @"esds");
|
magicCookie = CFDictionaryGetValue(atoms, @"esds");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (__bridge NSData *)magicCookie;
|
return (__bridge NSData *)magicCookie;
|
||||||
|
|
||||||
@@ -1061,11 +1064,12 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
|
|
||||||
CFDictionaryRef extentions = CMFormatDescriptionGetExtensions(formatDescription);
|
CFDictionaryRef extentions = CMFormatDescriptionGetExtensions(formatDescription);
|
||||||
CFDictionaryRef atoms = CFDictionaryGetValue(extentions, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms);
|
CFDictionaryRef atoms = CFDictionaryGetValue(extentions, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms);
|
||||||
|
if (atoms) {
|
||||||
CFDataRef magicCookie = CFDictionaryGetValue(atoms, @"vttC");
|
CFDataRef magicCookie = CFDictionaryGetValue(atoms, @"vttC");
|
||||||
|
|
||||||
return (__bridge NSData *)magicCookie;
|
return (__bridge NSData *)magicCookie;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil;
|
return nil;
|
||||||
|
|||||||
Reference in new issue
Block a user