Title: [114493] trunk
Revision
114493
Author
[email protected]
Date
2012-04-18 01:40:40 -0700 (Wed, 18 Apr 2012)

Log Message

Source/WebCore: [BlackBerry] Tab awareness for HTML5 concurrent audio
https://bugs.webkit.org/show_bug.cgi?id=82930
Support for concurrent HTML5 audio improvements being made in
the platform library, which need to be aware of tabs and tab
visibility. PR96004.

Patch by Max Feil <[email protected]> on 2012-04-18
Reviewed by George Staikos.

Test: media/audio-concurrent-supported.html

* platform/blackberry/PageClientBlackBerry.h:
* platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
(WebCore::MediaPlayerPrivate::MediaPlayerPrivate):
(WebCore::MediaPlayerPrivate::showErrorDialog):
(WebCore::MediaPlayerPrivate::isTabVisible):
(WebCore):
* platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:
(MediaPlayerPrivate):

Source/WebKit/blackberry: [BlackBerry] Tab awareness for HTML5 concurrent audio
https://bugs.webkit.org/show_bug.cgi?id=82930
Support for concurrent HTML5 audio improvements being made in
the platform library, which need to be aware of tabs and tab
visibility. PR96004.

Patch by Max Feil <[email protected]> on 2012-04-18
Reviewed by George Staikos.

* Api/WebPageClient.h:
* Api/WebPage_p.h:
(BlackBerry::WebKit::WebPagePrivate::isVisible):

LayoutTests: [BlackBerry] Tab awareness for HTML5 concurrent audio
https://bugs.webkit.org/show_bug.cgi?id=82930
Layout test for concurrent HTML5 audio. This is a simple test
to confirm that multiple audio elements can play at the same time.

Patch by Max Feil <[email protected]> on 2012-04-18
Reviewed by George Staikos.

* media/audio-concurrent-supported-expected.txt: Added.
* media/audio-concurrent-supported.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (114492 => 114493)


--- trunk/LayoutTests/ChangeLog	2012-04-18 08:17:11 UTC (rev 114492)
+++ trunk/LayoutTests/ChangeLog	2012-04-18 08:40:40 UTC (rev 114493)
@@ -1,3 +1,15 @@
+2012-04-18  Max Feil  <[email protected]>
+
+        [BlackBerry] Tab awareness for HTML5 concurrent audio
+        https://bugs.webkit.org/show_bug.cgi?id=82930
+        Layout test for concurrent HTML5 audio. This is a simple test
+        to confirm that multiple audio elements can play at the same time.
+
+        Reviewed by George Staikos.
+
+        * media/audio-concurrent-supported-expected.txt: Added.
+        * media/audio-concurrent-supported.html: Added.
+
 2012-04-18  Zoltan Arvai  <[email protected]>
 
         [Qt] Unreviewed gardening, skipping test that uses disabled feature SHADOW_DOM

Added: trunk/LayoutTests/media/audio-concurrent-supported-expected.txt (0 => 114493)


--- trunk/LayoutTests/media/audio-concurrent-supported-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/audio-concurrent-supported-expected.txt	2012-04-18 08:40:40 UTC (rev 114493)
@@ -0,0 +1,16 @@
+Test that multiple audio elements can play concurrently.
+
+Starting a total of 2 concurrent audio elements.
+EVENT(0, canplaythrough)
+EXPECTED (0, testElement.currentTime == '0') OK
+EVENT(0, playing)
+EXPECTED (0, testElement.currentTime > '0') OK
+EVENT(1, canplaythrough)
+EXPECTED (1, testElement.currentTime == '0') OK
+EVENT(1, playing)
+EXPECTED (1, testElement.currentTime > '0') OK
+Making sure all 2 audio elements are in playing state:
+EXPECTED (0, testElement.paused == 'false') OK
+EXPECTED (1, testElement.paused == 'false') OK
+END OF TEST
+

Added: trunk/LayoutTests/media/audio-concurrent-supported.html (0 => 114493)


--- trunk/LayoutTests/media/audio-concurrent-supported.html	                        (rev 0)
+++ trunk/LayoutTests/media/audio-concurrent-supported.html	2012-04-18 08:40:40 UTC (rev 114493)
@@ -0,0 +1,79 @@
+<html>
+    <title>Test of concurrent HTML5 audio</title>
+    <body>
+
+    <p>Test that multiple audio elements can play concurrently.</p>
+
+    <script src=""
+    <script src=""
+    <script>
+        var maxPlayers = 2; // Number of concurrent audio elements to test. For larger values a longer media file is needed.
+        var timeupdateEventCount = 0;
+        var audioElementCount = 0;
+
+        function errorListener(event)
+        {
+             logResult(false, "Element " + audioElementCount + " caught 'error' event, audio.error.code = " + this.error.code);
+             endTest();
+        }
+
+        function canplaythroughListener(event)
+        {
+             consoleWrite("EVENT(" + audioElementCount + ", canplaythrough)");
+             testElement = this;
+             testExpected(audioElementCount + ", testElement.currentTime", 0);
+             this.play();
+        }
+
+        function playingListener(event)
+        {
+             consoleWrite("EVENT(" + audioElementCount + ", playing)");
+        }
+
+        function timeupdateListener(event)
+        {
+            ++timeupdateEventCount;
+
+            // wait 2 timeupdate events so we are sure the media engine is
+            // playing the media.
+            if (timeupdateEventCount >= 2) {
+                // make sure time is advancing
+                testElement = this;
+                testExpected(audioElementCount + ", testElement.currentTime", 0, '>');
+                this.removeEventListener('timeupdate', timeupdateListener);
+                if (++audioElementCount >= maxPlayers) {
+                    // All audio elements have been started playing. Make sure
+                    // all of them are still playing.
+                    consoleWrite("Making sure all " + maxPlayers + " audio elements are in playing state:");
+                    for (var i = 0; i < maxPlayers; i++) {
+                        testElement = document.getElementsByTagName('audio')[i];
+                        testExpected(i + ", testElement.paused", false);
+                    }
+                    endTest();
+                } else {
+                    // Start the next audio element
+                    testAudioElement(audioElementCount);
+                }
+            }
+        }
+
+        function testAudioElement(count)
+        {
+            var audioElement = document.getElementsByTagName('audio')[count];
+            audioElement.addEventListener('error', errorListener);
+            audioElement.addEventListener('canplaythrough', canplaythroughListener);
+            timeupdateEventCount = 0;
+            audioElement.addEventListener('timeupdate', timeupdateListener);
+            audioElement.addEventListener('playing', playingListener);
+            audioElement.src = "" "content/silence");
+        }
+
+        consoleWrite("Starting a total of " + maxPlayers + " concurrent audio elements.");
+        for (var i = 0; i < maxPlayers; i++)
+            document.write("<audio controls></audio>");
+
+        testAudioElement(0);
+    </script>
+
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (114492 => 114493)


--- trunk/Source/WebCore/ChangeLog	2012-04-18 08:17:11 UTC (rev 114492)
+++ trunk/Source/WebCore/ChangeLog	2012-04-18 08:40:40 UTC (rev 114493)
@@ -1,3 +1,24 @@
+2012-04-18  Max Feil  <[email protected]>
+
+        [BlackBerry] Tab awareness for HTML5 concurrent audio
+        https://bugs.webkit.org/show_bug.cgi?id=82930
+        Support for concurrent HTML5 audio improvements being made in
+        the platform library, which need to be aware of tabs and tab
+        visibility. PR96004.
+
+        Reviewed by George Staikos.
+
+        Test: media/audio-concurrent-supported.html
+
+        * platform/blackberry/PageClientBlackBerry.h:
+        * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
+        (WebCore::MediaPlayerPrivate::MediaPlayerPrivate):
+        (WebCore::MediaPlayerPrivate::showErrorDialog):
+        (WebCore::MediaPlayerPrivate::isTabVisible):
+        (WebCore):
+        * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:
+        (MediaPlayerPrivate):
+
 2012-04-18  Noel Gordon  <[email protected]>
 
         [CG] ImageBuffer: check getPremultipliedImageData() error return

Modified: trunk/Source/WebCore/platform/blackberry/PageClientBlackBerry.h (114492 => 114493)


--- trunk/Source/WebCore/platform/blackberry/PageClientBlackBerry.h	2012-04-18 08:17:11 UTC (rev 114492)
+++ trunk/Source/WebCore/platform/blackberry/PageClientBlackBerry.h	2012-04-18 08:40:40 UTC (rev 114493)
@@ -69,6 +69,7 @@
     virtual WebCore::IntSize viewportSize() const = 0;
     virtual int showAlertDialog(BlackBerry::WebKit::WebPageClient::AlertType) = 0;
     virtual bool isActive() const = 0;
+    virtual bool isVisible() const = 0;
     virtual bool authenticationChallenge(const WebCore::KURL&, const WebCore::ProtectionSpace&, WebCore::Credential&) = 0;
     virtual SaveCredentialType notifyShouldSaveCredential(bool) = 0;
 };

Modified: trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp (114492 => 114493)


--- trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp	2012-04-18 08:17:11 UTC (rev 114492)
+++ trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp	2012-04-18 08:40:40 UTC (rev 114493)
@@ -97,11 +97,6 @@
 
 MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
     : m_webCorePlayer(player)
-#if USE(ACCELERATED_COMPOSITING)
-    , m_platformPlayer(new MMRPlayer(this, true))
-#else
-    , m_platformPlayer(new MMRPlayer(this, false))
-#endif
     , m_networkState(MediaPlayer::Empty)
     , m_readyState(MediaPlayer::HaveNothing)
     , m_fullscreenWebPageClient(0)
@@ -115,6 +110,14 @@
     , m_waitMetadataTimer(this, &MediaPlayerPrivate::waitMetadataTimerFired)
     , m_waitMetadataPopDialogCounter(0)
 {
+    void* tabId = 0;
+    if (frameView() && frameView()->hostWindow())
+        tabId = frameView()->hostWindow()->platformPageClient();
+#if USE(ACCELERATED_COMPOSITING)
+    m_platformPlayer = new MMRPlayer(this, tabId, true);
+#else
+    m_platformPlayer = new MMRPlayer(this, tabId, false);
+#endif
 }
 
 MediaPlayerPrivate::~MediaPlayerPrivate()
@@ -690,10 +693,8 @@
     }
 
     int rc = 0;
-    HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());
-    Document* topdoc = element->document()->topDocument();
-    if (topdoc->view() && topdoc->view()->hostWindow())
-        rc = topdoc->view()->hostWindow()->platformPageClient()->showAlertDialog(atype);
+    if (frameView() && frameView()->hostWindow())
+        rc = frameView()->hostWindow()->platformPageClient()->showAlertDialog(atype);
     return rc;
 }
 
@@ -721,6 +722,13 @@
     return m_fullscreenWebPageClient;
 }
 
+bool MediaPlayerPrivate::isTabVisible() const
+{
+    if (frameView() && frameView()->hostWindow())
+        return frameView()->hostWindow()->platformPageClient()->isVisible();
+    return true;
+}
+
 #if USE(ACCELERATED_COMPOSITING)
 static const double BufferingAnimationDelay = 1.0 / 24;
 static char* s_bufferingImageData = 0;

Modified: trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h (114492 => 114493)


--- trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h	2012-04-18 08:17:11 UTC (rev 114492)
+++ trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h	2012-04-18 08:40:40 UTC (rev 114493)
@@ -132,6 +132,7 @@
 #endif
 
     virtual bool isFullscreen() const;
+    virtual bool isTabVisible() const;
     virtual int showErrorDialog(BlackBerry::Platform::MMRPlayer::Error);
     virtual BlackBerry::Platform::Graphics::Window* platformWindow();
 

Modified: trunk/Source/WebKit/blackberry/Api/WebPageClient.h (114492 => 114493)


--- trunk/Source/WebKit/blackberry/Api/WebPageClient.h	2012-04-18 08:17:11 UTC (rev 114492)
+++ trunk/Source/WebKit/blackberry/Api/WebPageClient.h	2012-04-18 08:40:40 UTC (rev 114493)
@@ -222,6 +222,7 @@
     virtual bool lockOrientation(bool landscape) = 0;
     virtual void unlockOrientation() = 0;
     virtual bool isActive() const = 0;
+    virtual bool isVisible() const = 0;
     virtual void requestWebGLPermission(const WebString&) = 0;
 
     virtual void setToolTip(WebString) = 0;

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (114492 => 114493)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-04-18 08:17:11 UTC (rev 114492)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-04-18 08:40:40 UTC (rev 114493)
@@ -178,6 +178,7 @@
     virtual double currentZoomFactor() const;
     virtual int showAlertDialog(WebPageClient::AlertType atype);
     virtual bool isActive() const;
+    virtual bool isVisible() const { return m_visible; }
     virtual bool authenticationChallenge(const WebCore::KURL&, const WebCore::ProtectionSpace&, WebCore::Credential&);
     virtual SaveCredentialType notifyShouldSaveCredential(bool);
 

Modified: trunk/Source/WebKit/blackberry/ChangeLog (114492 => 114493)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-04-18 08:17:11 UTC (rev 114492)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-04-18 08:40:40 UTC (rev 114493)
@@ -1,3 +1,17 @@
+2012-04-18  Max Feil  <[email protected]>
+
+        [BlackBerry] Tab awareness for HTML5 concurrent audio
+        https://bugs.webkit.org/show_bug.cgi?id=82930
+        Support for concurrent HTML5 audio improvements being made in
+        the platform library, which need to be aware of tabs and tab
+        visibility. PR96004.
+
+        Reviewed by George Staikos.
+
+        * Api/WebPageClient.h:
+        * Api/WebPage_p.h:
+        (BlackBerry::WebKit::WebPagePrivate::isVisible):
+
 2012-04-17  Jacky Jiang  <[email protected]>
 
         [BlackBerry] Viewport metatag doesn't disable double-tap zoom
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to