Commit df1a34bb authored by kov@webkit.org's avatar kov@webkit.org
Browse files

2010-03-12 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>

        Reviewed by Eric Carlson.

        media/video-preload.html fails
        https://bugs.webkit.org/show_bug.cgi?id=35793

        Only effectively load, and start buffering when playing, or when
        the preload attribute is set.

        Test: media/video-preload.html

        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
        (WebCore::MediaPlayerPrivate::MediaPlayerPrivate):
        (WebCore::MediaPlayerPrivate::load):
        (WebCore::MediaPlayerPrivate::commitLoad):
        (WebCore::MediaPlayerPrivate::prepareToPlay):
        (WebCore::MediaPlayerPrivate::setPreload):
        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55927 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 39cfce0a
2010-03-12 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
Reviewed by Eric Carlson.
media/video-preload.html fails
https://bugs.webkit.org/show_bug.cgi?id=35793
Only effectively load, and start buffering when playing, or when
the preload attribute is set.
Test: media/video-preload.html
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivate::MediaPlayerPrivate):
(WebCore::MediaPlayerPrivate::load):
(WebCore::MediaPlayerPrivate::commitLoad):
(WebCore::MediaPlayerPrivate::prepareToPlay):
(WebCore::MediaPlayerPrivate::setPreload):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
2010-03-12 Dmitry Titov <dimich@chromium.org>
 
Not reviewed, build fix.
......
......@@ -314,6 +314,8 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
, m_fillTimeoutId(0)
, m_maxTimeLoaded(0)
, m_bufferingPercentage(0)
, m_preload(MediaPlayer::Auto)
, m_delayingLoad(false)
{
if (doGstInit())
createGSTPlayBin();
......@@ -368,6 +370,22 @@ MediaPlayerPrivate::~MediaPlayerPrivate()
void MediaPlayerPrivate::load(const String& url)
{
g_object_set(m_playBin, "uri", url.utf8().data(), NULL);
if (m_preload == MediaPlayer::None) {
m_delayingLoad = true;
return;
}
commitLoad();
}
void MediaPlayerPrivate::commitLoad()
{
// GStreamer needs to have the pipeline set to a paused state to
// start providing anything useful.
gst_element_set_state(m_playBin, GST_STATE_PAUSED);
LOG_VERBOSE(Media, "Load %s", url.utf8().data());
if (m_networkState != MediaPlayer::Loading) {
m_networkState = MediaPlayer::Loading;
......@@ -377,12 +395,6 @@ void MediaPlayerPrivate::load(const String& url)
m_readyState = MediaPlayer::HaveNothing;
m_player->readyStateChanged();
}
g_object_set(m_playBin, "uri", url.utf8().data(), NULL);
// GStreamer needs to have the pipeline set to a paused state to
// start providing anything useful.
gst_element_set_state(m_playBin, GST_STATE_PAUSED);
}
bool MediaPlayerPrivate::changePipelineState(GstState newState)
......@@ -404,6 +416,14 @@ bool MediaPlayerPrivate::changePipelineState(GstState newState)
return true;
}
void MediaPlayerPrivate::prepareToPlay()
{
if (m_delayingLoad) {
m_delayingLoad = false;
commitLoad();
}
}
void MediaPlayerPrivate::play()
{
if (changePipelineState(GST_STATE_PLAYING))
......@@ -1365,12 +1385,19 @@ void MediaPlayerPrivate::setPreload(MediaPlayer::Preload preload)
{
ASSERT(m_playBin);
m_preload = preload;
GstPlayFlags flags;
g_object_get(m_playBin, "flags", &flags, NULL);
if (preload == MediaPlayer::None)
g_object_set(m_playBin, "flags", flags & ~GST_PLAY_FLAG_DOWNLOAD, NULL);
else
g_object_set(m_playBin, "flags", flags | GST_PLAY_FLAG_DOWNLOAD, NULL);
if (m_delayingLoad && m_preload != MediaPlayer::None) {
m_delayingLoad = false;
commitLoad();
}
}
void MediaPlayerPrivate::createGSTPlayBin()
......
......@@ -63,9 +63,11 @@ class MediaPlayerPrivate : public MediaPlayerPrivateInterface {
bool hasAudio() const;
void load(const String &url);
void commitLoad();
void cancelLoad();
bool loadNextLocation();
void prepareToPlay();
void play();
void pause();
......@@ -167,6 +169,8 @@ class MediaPlayerPrivate : public MediaPlayerPrivateInterface {
guint m_fillTimeoutId;
float m_maxTimeLoaded;
int m_bufferingPercentage;
MediaPlayer::Preload m_preload;
bool m_delayingLoad;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment