Bug 137935 - MediaPlayerPrivateAVFoundation::hasAudio() returns false even when there is an audible AVMediaSelectionOption selected
Summary: MediaPlayerPrivateAVFoundation::hasAudio() returns false even when there is a...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ada Chan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-21 15:10 PDT by Ada Chan
Modified: 2014-10-22 16:22 PDT (History)
7 users (show)

See Also:


Attachments
Patch (7.94 KB, patch)
2014-10-21 21:43 PDT, Ada Chan
eric.carlson: review+
Details | Formatted Diff | Diff
Revised patch (6.54 KB, patch)
2014-10-22 13:53 PDT, Ada Chan
no flags Details | Formatted Diff | Diff
Revised patch: this time with the tests (8.29 KB, patch)
2014-10-22 14:03 PDT, Ada Chan
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 Ada Chan 2014-10-21 15:10:38 PDT
This caused HTMLMediaElement::hasAudio() to return false for some streaming media with audio.  I ran into this when watching a video on money.cnn.com.
Comment 1 Ada Chan 2014-10-21 21:43:07 PDT
Created attachment 240250 [details]
Patch
Comment 2 Eric Carlson 2014-10-22 09:55:58 PDT
Comment on attachment 240250 [details]
Patch

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

> LayoutTests/http/tests/media/hls/hls-audio-tracks-has-audio.html:10
> +            if (window.testRunner) {
> +                testRunner.dumpAsText();
> +                testRunner.waitUntilDone();
> +            }

Nit: video-test.js does this automatically so this is unnecessary.

> LayoutTests/http/tests/media/hls/hls-audio-tracks-has-audio.html:12
> +            function start() {

Nit: the opening brace for a function is on a new line.

> LayoutTests/http/tests/media/hls/hls-audio-tracks-has-audio.html:13
> +                video = document.getElementById('video');

Nit: test.js automatically initializes a "video" global variable so this is unnecessary.

> LayoutTests/http/tests/media/hls/hls-audio-tracks-has-audio.html:18
> +            function canplaythrough() {

Ditto about the function's opening brace.

> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:1716
> +            hasAudio = true;

I think this should this be "|=" because it it technically possible for a file to have audio tracks that are not in a selection group.

> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:1719
> +            hasVideo = true;

Ditto for video tracks.

> Source/WebCore/testing/Internals.cpp:2094
> +bool Internals::mediaElementHasAudio(Node* node)
> +{
> +    if (!is<HTMLMediaElement>(*node))
> +        return false;
> +
> +    HTMLMediaElement* element = downcast<HTMLMediaElement>(node);
> +    return element->hasAudio();
> +}

I would prefer it if this was more method, maybe something something like  "mediaElementHasCharacteristic(Node* node, String characteristic)"
Comment 3 Ada Chan 2014-10-22 13:53:05 PDT
(In reply to comment #2)
> Comment on attachment 240250 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=240250&action=review
> 
> > LayoutTests/http/tests/media/hls/hls-audio-tracks-has-audio.html:10
> > +            if (window.testRunner) {
> > +                testRunner.dumpAsText();
> > +                testRunner.waitUntilDone();
> > +            }
> 
> Nit: video-test.js does this automatically so this is unnecessary.

Removed.

> 
> > LayoutTests/http/tests/media/hls/hls-audio-tracks-has-audio.html:12
> > +            function start() {
> 
> Nit: the opening brace for a function is on a new line.

Fixed.

> 
> > LayoutTests/http/tests/media/hls/hls-audio-tracks-has-audio.html:13
> > +                video = document.getElementById('video');
> 
> Nit: test.js automatically initializes a "video" global variable so this is
> unnecessary.

video-test.js does initialize "video" but before the document is loaded so it may not have found it.  I'm going to call findMediaElement() here instead.

> 
> > LayoutTests/http/tests/media/hls/hls-audio-tracks-has-audio.html:18
> > +            function canplaythrough() {
> 
> Ditto about the function's opening brace.

Fixed.

> 
> > Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:1716
> > +            hasAudio = true;
> 
> I think this should this be "|=" because it it technically possible for a
> file to have audio tracks that are not in a selection group.
> 
> > Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:1719
> > +            hasVideo = true;
> 
> Ditto for video tracks.

Done.

> 
> > Source/WebCore/testing/Internals.cpp:2094
> > +bool Internals::mediaElementHasAudio(Node* node)
> > +{
> > +    if (!is<HTMLMediaElement>(*node))
> > +        return false;
> > +
> > +    HTMLMediaElement* element = downcast<HTMLMediaElement>(node);
> > +    return element->hasAudio();
> > +}
> 
> I would prefer it if this was more method, maybe something something like 
> "mediaElementHasCharacteristic(Node* node, String characteristic)"

Done.

I'll send out a revised patch.  Thanks for your feedback!
Comment 4 Ada Chan 2014-10-22 13:53:32 PDT
Created attachment 240294 [details]
Revised patch
Comment 5 Ada Chan 2014-10-22 14:03:10 PDT
Created attachment 240295 [details]
Revised patch: this time with the tests
Comment 6 Ada Chan 2014-10-22 16:22:04 PDT
Committed:
http://trac.webkit.org/changeset/175072