-
-
Save hisui/c93ab3d943fe38268bc3 to your computer and use it in GitHub Desktop.
Checking if a given frame is a key frame.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static BOOL isKeyFrame(CMSampleBufferRef sample) | |
{ | |
auto a = CMSampleBufferGetSampleAttachmentsArray(sample, 0); | |
if (CFArrayGetCount(a) > 0) { | |
CFBooleanRef value; | |
auto b = CFDictionaryGetValueIfPresent | |
((CFDictionaryRef) CFArrayGetValueAtIndex(a, 0) | |
, kCMSampleAttachmentKey_NotSync | |
, reinterpret_cast<const void **>(&value)) | |
; | |
return !b || !CFBooleanGetValue(value); | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ObjC:
static BOOL isKeyFrame(CMSampleBufferRef sample)
{
CFArrayRef a = CMSampleBufferGetSampleAttachmentsArray(sample, 0);
if (a && CFArrayGetCount(a) > 0) {
CFBooleanRef value;
Boolean b = CFDictionaryGetValueIfPresent((CFDictionaryRef) CFArrayGetValueAtIndex(a, 0), kCMSampleAttachmentKey_NotSync, (const void **)(&value));
}