Bug 156020 - [WinCairo][MediaFoundation] Video size is not always set.
Summary: [WinCairo][MediaFoundation] Video size is not always set.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-30 03:59 PDT by peavo
Modified: 2016-03-30 11:40 PDT (History)
3 users (show)

See Also:


Attachments
Patch (3.88 KB, patch)
2016-03-30 04:07 PDT, peavo
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description peavo 2016-03-30 03:59:02 PDT
This happens because getting the video display control from the media session might fail the first time. If it fails the first time, we should try again later.
Comment 1 peavo 2016-03-30 04:07:22 PDT
Created attachment 275192 [details]
Patch
Comment 2 Darin Adler 2016-03-30 09:01:18 PDT
Comment on attachment 275192 [details]
Patch

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

> Source/WebCore/ChangeLog:9
> +        Getting the video display control object from the media session might fail the first time.
> +        In case it fails, we should try again when setting the video size.

Is keeping the video display control object an important optimization? Maybe we should just get it every time.

> Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:353
> +    COMPtr<IMFVideoDisplayControl> videoDisplay = getVideoDisplay();

Probably a little nicer to use auto here.

> Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:778
> +    if (FAILED(MFGetServicePtr()(m_mediaSession.get(), MR_VIDEO_RENDER_SERVICE, IID_PPV_ARGS(&m_videoDisplay))))
> +        return nullptr;
> +
> +    return m_videoDisplay;

Checking FAILED explicitly here means we don’t trust that m_videoDisplay will be nullptr if the function calls. We check FAILED and explicitly return nullptr rather than just returning m_videoDisplay, which will be nullptr.

But when this function is called again, whatever is stored in m_videoDisplay *will* be trusted.

So we should omit the FAILED check since it does us no good.

> Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:794
> +    COMPtr<IMFVideoDisplayControl> videoDisplay = getVideoDisplay();
> +    if (videoDisplay) {

Would read nicer with auto and nesting the assignment in the if statement.

    if (auto videoDisplay = this->videoDisplay()) {

> Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h:138
> +    COMPtr<IMFVideoDisplayControl> getVideoDisplay();

In WebKit coding style we do not use “get” in the names of functions like this one unless they produce values through "out arguments". We can either just call this videoDisplay or use some verb other than “get”.
Comment 3 peavo 2016-03-30 11:37:46 PDT
Thanks for reviewing!
Comment 4 peavo 2016-03-30 11:39:25 PDT
Committed r198848: <http://trac.webkit.org/changeset/198848>