Bug 50209

Summary: MediaPlayer should try all installed media engines
Product: WebKit Reporter: Eric Carlson <eric.carlson>
Component: MediaAssignee: Eric Carlson <eric.carlson>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, dglazkov, eric, webkit-ews, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Proposed patch
none
Updated patch
none
Patch that might compile darin: review+

Description Eric Carlson 2010-11-29 22:35:58 PST
When a file load fails before reaching HAVE_METADATA and there is more than one registered media engine, MediaPlayer.cpp should try loading with the next installed engine.
Comment 1 Eric Carlson 2010-11-30 17:05:58 PST
Created attachment 75233 [details]
Proposed patch
Comment 2 Eric Carlson 2010-12-08 09:03:15 PST
Created attachment 75913 [details]
Updated patch

Updated to behave correctly when retrying when there is no MIME type.
Comment 3 Eric Seidel (no email) 2010-12-08 12:24:43 PST
Attachment 75913 [details] did not build on mac:
Build output: http://queues.webkit.org/results/6754115
Comment 4 Early Warning System Bot 2010-12-08 12:27:55 PST
Attachment 75913 [details] did not build on qt:
Build output: http://queues.webkit.org/results/6719133
Comment 5 WebKit Review Bot 2010-12-08 12:40:29 PST
Attachment 75913 [details] did not build on chromium:
Build output: http://queues.webkit.org/results/6862077
Comment 6 Build Bot 2010-12-08 13:45:27 PST
Attachment 75913 [details] did not build on win:
Build output: http://queues.webkit.org/results/6720123
Comment 7 Eric Seidel (no email) 2010-12-08 18:11:34 PST
Attachment 75913 [details] did not build on chromium:
Build output: http://queues.webkit.org/results/6759127
Comment 8 Eric Carlson 2010-12-09 07:40:01 PST
Created attachment 76064 [details]
Patch that might compile
Comment 9 Joseph Pecoraro 2010-12-09 18:50:32 PST
Comment on attachment 76064 [details]
Patch that might compile

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

> WebCore/platform/graphics/MediaPlayer.cpp:233
>      unsigned count = engines.size();
>      for (unsigned ndx = 0; ndx < count; ndx++) {

(see comment below)

> WebCore/platform/graphics/MediaPlayer.cpp:257
> +    Vector<MediaPlayerFactory*>& engines = installedMediaEngines();
> +    if (engines.isEmpty())
> +        return 0;
> +
> +    MediaPlayerFactory* engine = 0;
> +    unsigned count = engines.size();
> +    for (unsigned ndx = 0; ndx < count; ndx++) {

I recently learned that Vector::size() is size_t, and on 64bit systems may be 64bits,
but unsigned is always 32bits. Although it probably isn't an issue here (count and
ndx), its something to keep in mind for future code.
Comment 10 Darin Adler 2010-12-14 18:30:52 PST
Comment on attachment 76064 [details]
Patch that might compile

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

> WebCore/platform/graphics/MediaPlayer.cpp:253
> +    if (engines.isEmpty())
> +        return 0;

No need for a special case. The normal code path handles an empty vector just fine.

>> WebCore/platform/graphics/MediaPlayer.cpp:257
>> +    for (unsigned ndx = 0; ndx < count; ndx++) {
> 
> I recently learned that Vector::size() is size_t, and on 64bit systems may be 64bits,
> but unsigned is always 32bits. Although it probably isn't an issue here (count and
> ndx), its something to keep in mind for future code.

Yes, better style to use size_t here. Also, we normally prefer “i” over “ndx”. And I would call it size rather than count, just to make it clearer that it just reflects the size function result.

> WebCore/platform/graphics/MediaPlayer.cpp:264
> +        if (current) {
> +            if (current == engines[ndx])
> +                current = 0;
> +            continue;
> +        }
> +        engine = engines[ndx];
> +        break;

The logic here is a little convoluted. You could write this more clearly by just saying “if (!current) return first" and for the non-zero case using the find function that vectors have without writing out a loop.
Comment 11 Eric Carlson 2010-12-15 09:28:39 PST
http://trac.webkit.org/changeset/74118