Bug 209365

Summary: [MSE] Handle the case where AVStreamDataParser packages sync and non-sync samples together in a CMSampleBufferRef.
Product: WebKit Reporter: Jer Noble <jer.noble>
Component: New BugsAssignee: Jer Noble <jer.noble>
Status: RESOLVED FIXED    
Severity: Normal CC: eric.carlson, ews-watchlist, glenn, peng.liu6, philipj, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
eric.carlson: review+
Patch for landing none

Description Jer Noble 2020-03-20 15:29:23 PDT
[MSE] Handle the case where AVStreamDataParser packages sync and non-sync samples together in a CMSampleBufferRef.
Comment 1 Jer Noble 2020-03-20 15:30:01 PDT
<rdar://problem/60625209>
Comment 2 Jer Noble 2020-03-20 15:36:29 PDT
Created attachment 394140 [details]
Patch
Comment 3 Eric Carlson 2020-03-20 15:57:11 PDT
Comment on attachment 394140 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394140&action=review

> Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:342
> +    CFArrayRef attachmentsArray = CMSampleBufferGetSampleAttachmentsArray(m_sample.get(), true);

The documentation says CMSampleBufferGetSampleAttachmentsArray can return NULL, and some of our code does too (e.g. isCMSampleBufferNonDisplaying), so this should probably check.

> Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:344
> +    if (count == 1)

<= 1

> Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:369
> +    CFArrayRef attachmentsArray = CMSampleBufferGetSampleAttachmentsArray(m_sample.get(), true);
> +    auto count = CFArrayGetCount(attachmentsArray);
> +    if (count == 1)

Ditto the comments above.

> Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:377
> +

Nit: the extra blank isn't really needed.

> Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:399
> +        if (CMSampleBufferCopySampleBufferForRange(kCFAllocatorDefault, m_sample.get(), range, &rawSample) != noErr || !rawSample)
> +            return { };

It would be good to log an error and maybe ASSERT
Comment 4 Jer Noble 2020-03-20 16:02:55 PDT
Created attachment 394143 [details]
Patch for landing
Comment 5 EWS 2020-03-23 08:39:00 PDT
Committed r258846: <https://trac.webkit.org/changeset/258846>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 394143 [details].