Bug 125905 - [MSE][Mac] Add AVSampleBufferAudioRenderer support.
Summary: [MSE][Mac] Add AVSampleBufferAudioRenderer support.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jer Noble
URL:
Keywords:
Depends on: 125899
Blocks:
  Show dependency treegraph
 
Reported: 2013-12-17 18:42 PST by Jer Noble
Modified: 2013-12-18 17:11 PST (History)
3 users (show)

See Also:


Attachments
Patch (20.97 KB, patch)
2013-12-17 18:46 PST, Jer Noble
no flags Details | Formatted Diff | Diff
Patch (21.41 KB, patch)
2013-12-18 07:32 PST, Jer Noble
eric.carlson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jer Noble 2013-12-17 18:42:49 PST
[MSE][Mac] Add AVSampleBufferAudioRenderer support.
Comment 1 Jer Noble 2013-12-17 18:46:21 PST
Created attachment 219489 [details]
Patch

Initial version. The ChangeLog is a little sparse, and I intend to flesh it out.
Comment 2 Jer Noble 2013-12-18 07:32:38 PST
Created attachment 219534 [details]
Patch
Comment 3 Eric Carlson 2013-12-18 09:53:32 PST
Comment on attachment 219534 [details]
Patch

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

> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:326
> +        [renderer flush];
> +        [renderer stopRequestingMediaData];

Shouldn't these be called in the opposite order to avoid a potential race?

> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:380
> +    return info->sourceBuffer->processCodedFrame(info->trackID, sampleBuffer, info->mediaType) ? noErr : paramErr;

paramErr :-O

> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:447
> +    for (auto it = m_audioRenderers.begin(), end = m_audioRenderers.end(); it != end; ++it) {
> +        AVSampleBufferAudioRenderer* renderer = it->second.get();
> +        if (m_mediaSource)
> +            m_mediaSource->player()->removeAudioRenderer(renderer);
> +        [renderer flush];
> +        [renderer stopRequestingMediaData];
> +    }
> +
> +    m_audioRenderers.clear();

This looks like the same code you have in the destructor. Can it be in a shared method?

> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:510
> +        if (m_mediaSource)
> +            m_mediaSource->player()->addDisplayLayer(m_displayLayer.get());

player()->addDisplayLayer() is a noop if it the layer has already been added?

> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:558
> +    int trackID = trackIDString.toInt();

Might be worth adding an ASSERT(trackID < m_audioRenderers.size())

> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:604
> +    int trackID = trackIDString.toInt();

Ditto.

> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:624
> +    int trackID = trackIDString.toInt();

Ditto.
Comment 4 Jer Noble 2013-12-18 16:04:03 PST
(In reply to comment #3)
> (From update of attachment 219534 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=219534&action=review
> 
> > Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:326
> > +        [renderer flush];
> > +        [renderer stopRequestingMediaData];
> 
> Shouldn't these be called in the opposite order to avoid a potential race?

Since the renderers are requesting media data on the main dispatch queue, there's no opportunity for a race.  But I'll swap them anyways.

> > Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:380
> > +    return info->sourceBuffer->processCodedFrame(info->trackID, sampleBuffer, info->mediaType) ? noErr : paramErr;
> 
> paramErr :-O

I no rite?!  Luckily, this gets removed in a future patch.

> > Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:447
> > +    for (auto it = m_audioRenderers.begin(), end = m_audioRenderers.end(); it != end; ++it) {
> > +        AVSampleBufferAudioRenderer* renderer = it->second.get();
> > +        if (m_mediaSource)
> > +            m_mediaSource->player()->removeAudioRenderer(renderer);
> > +        [renderer flush];
> > +        [renderer stopRequestingMediaData];
> > +    }
> > +
> > +    m_audioRenderers.clear();
> 
> This looks like the same code you have in the destructor. Can it be in a shared method?

I think so.

> > Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:510
> > +        if (m_mediaSource)
> > +            m_mediaSource->player()->addDisplayLayer(m_displayLayer.get());
> 
> player()->addDisplayLayer() is a noop if it the layer has already been added?

No, it swaps out the existing layer for the new one.  The existing one might have been created by ensurePlatformLayer().

> > Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:558
> > +    int trackID = trackIDString.toInt();
> 
> Might be worth adding an ASSERT(trackID < m_audioRenderers.size())

The "if (m_audioRenderers.count(trackID))" check should handle that.  Besides, what if a video has 2 video tracks, then 1 audio track?

> > Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:604
> > +    int trackID = trackIDString.toInt();
> 
> Ditto.
> 
> > Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:624
> > +    int trackID = trackIDString.toInt();
> 
> Ditto.

Both these have ASSERT_NOT_REACHED checks.
Comment 5 Jer Noble 2013-12-18 17:11:45 PST
Committed r160810: <http://trac.webkit.org/changeset/160810>