|
|
@@ -24,15 +24,20 @@
|
|
|
#import "NSNotificationCenter+VAPThreadSafe.h"
|
|
|
#include <sys/sysctl.h>
|
|
|
#import <AVFoundation/AVFoundation.h>
|
|
|
+#import <TargetConditionals.h>
|
|
|
|
|
|
@implementation UIDevice (HWD)
|
|
|
|
|
|
- (BOOL)hwd_isSimulator {
|
|
|
+ #if TARGET_OS_SIMULATOR
|
|
|
+ return YES;
|
|
|
+ #endif
|
|
|
+
|
|
|
static dispatch_once_t token;
|
|
|
static BOOL isSimulator = NO;
|
|
|
dispatch_once(&token, ^{
|
|
|
NSString *model = [self machineName];
|
|
|
- if ([model isEqualToString:@"x86_64"] || [model isEqualToString:@"i386"]) {
|
|
|
+ if ([model isEqualToString:@"x86_64"] || [model isEqualToString:@"i386"] || [model isEqualToString:@"arm64"]) {
|
|
|
isSimulator = YES;
|
|
|
}
|
|
|
});
|
|
|
@@ -207,11 +212,23 @@ NSString *const QGMP4HWDErrorDomain = @"QGMP4HWDErrorDomain";
|
|
|
CMBlockBufferRef blockBuffer = NULL;
|
|
|
|
|
|
_status = CMBlockBufferCreateWithMemoryBlock(kCFAllocatorDefault,
|
|
|
- (void *)packetData.bytes,
|
|
|
+ NULL,
|
|
|
packetData.length,
|
|
|
- kCFAllocatorNull, NULL, 0,
|
|
|
+ kCFAllocatorDefault, NULL, 0,
|
|
|
packetData.length, 0,
|
|
|
- &blockBuffer);
|
|
|
+ &blockBuffer);
|
|
|
+ if (_status != kCMBlockBufferNoErr || blockBuffer == NULL) {
|
|
|
+ VAP_Error(kQGVAPModuleCommon, @"create block buffer fail! frame:%@ status:%@", @(frameIndex), @(_status));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ _status = CMBlockBufferReplaceDataBytes(packetData.bytes, blockBuffer, 0, packetData.length);
|
|
|
+ if (_status != kCMBlockBufferNoErr) {
|
|
|
+ VAP_Error(kQGVAPModuleCommon, @"copy packet data to block buffer fail! frame:%@ status:%@", @(frameIndex), @(_status));
|
|
|
+ CFRelease(blockBuffer);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// 6. create a CMSampleBuffer.
|
|
|
CMSampleBufferRef sampleBuffer = NULL;
|
|
|
const size_t sampleSizeArray[] = {packetData.length};
|
|
|
@@ -225,6 +242,11 @@ NSString *const QGMP4HWDErrorDomain = @"QGMP4HWDErrorDomain";
|
|
|
CFRelease(blockBuffer);
|
|
|
}
|
|
|
|
|
|
+ if (_status != noErr || sampleBuffer == NULL) {
|
|
|
+ VAP_Error(kQGVAPModuleCommon, @"create sample buffer fail! frame:%@ status:%@", @(frameIndex), @(_status));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// 7. use VTDecompressionSessionDecodeFrame
|
|
|
if (@available(iOS 9.0, *)) {
|
|
|
__typeof(self) __weak weakSelf = self;
|
|
|
@@ -258,6 +280,10 @@ NSString *const QGMP4HWDErrorDomain = @"QGMP4HWDErrorDomain";
|
|
|
[self findKeyFrameAndDecodeToCurrent:frameIndex];
|
|
|
} else {
|
|
|
_invalidRetryCount = 0;
|
|
|
+ if (status != noErr) {
|
|
|
+ VAP_Error(kQGVAPModuleCommon, @"decode frame fail! frame:%@ error:%@", @(frameIndex), @(status));
|
|
|
+ CFRelease(sampleBuffer);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
} else {
|