[GTK] Should use GStreamer codec installation infrastructure
authorphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Mar 2013 13:08:24 +0000 (13:08 +0000)
committerphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Mar 2013 13:08:24 +0000 (13:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=34085

Reviewed by Martin Robinson.

Initial support for the GStreamer codec installer. The player will
handle missing-plugins messages and use the pbutils codec
installer facilities to install the missing GStreamer
plugins. Once the plugins are installed reset the pipeline state.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::mediaPlayerPrivatePluginInstallerResultFunction): This
method is used to notify the player that the missing plugins were installed.
(WebCore):
(WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer):
(WebCore::MediaPlayerPrivateGStreamer::handleMessage): Ignore
errors while installing plugins and handle the missing-plugin message.
(WebCore::MediaPlayerPrivateGStreamer::handlePluginInstallerResult):
This method is invoked after the installer finished its task.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
(MediaPlayerPrivateGStreamer):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@147279 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h

index 6f2e32a..b221243 100644 (file)
@@ -1,3 +1,27 @@
+2013-03-30  Philippe Normand  <pnormand@igalia.com>
+
+        [GTK] Should use GStreamer codec installation infrastructure
+        https://bugs.webkit.org/show_bug.cgi?id=34085
+
+        Reviewed by Martin Robinson.
+
+        Initial support for the GStreamer codec installer. The player will
+        handle missing-plugins messages and use the pbutils codec
+        installer facilities to install the missing GStreamer
+        plugins. Once the plugins are installed reset the pipeline state.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::mediaPlayerPrivatePluginInstallerResultFunction): This
+        method is used to notify the player that the missing plugins were installed.
+        (WebCore):
+        (WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer):
+        (WebCore::MediaPlayerPrivateGStreamer::handleMessage): Ignore
+        errors while installing plugins and handle the missing-plugin message.
+        (WebCore::MediaPlayerPrivateGStreamer::handlePluginInstallerResult):
+        This method is invoked after the installer finished its task.
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+        (MediaPlayerPrivateGStreamer):
+
 2013-03-30  Praveen R Jadhav  <praveen.j@samsung.com>
 
         g_slist_reverse() may not be required in webKitWebAudioSrcLoop
index d43fc10..8c883f6 100644 (file)
@@ -37,6 +37,7 @@
 #include "TimeRanges.h"
 #include "WebKitWebSourceGStreamer.h"
 #include <gst/gst.h>
+#include <gst/pbutils/missing-plugins.h>
 #include <limits>
 #include <wtf/gobject/GOwnPtr.h>
 #include <wtf/text/CString.h>
@@ -131,6 +132,12 @@ static gboolean mediaPlayerPrivateVideoChangeTimeoutCallback(MediaPlayerPrivateG
     return FALSE;
 }
 
+static void mediaPlayerPrivatePluginInstallerResultFunction(GstInstallPluginsReturn result, gpointer userData)
+{
+    MediaPlayerPrivateGStreamer* player = reinterpret_cast<MediaPlayerPrivateGStreamer*>(userData);
+    player->handlePluginInstallerResult(result);
+}
+
 void MediaPlayerPrivateGStreamer::setAudioStreamProperties(GObject* object)
 {
     if (g_strcmp0(G_OBJECT_TYPE_NAME(object), "GstPulseSink"))
@@ -212,6 +219,7 @@ MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player)
     , m_originalPreloadWasAutoAndWasOverridden(false)
     , m_preservesPitch(false)
     , m_requestedState(GST_STATE_VOID_PENDING)
+    , m_missingPlugins(false)
 {
 }
 
@@ -686,6 +694,8 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
     case GST_MESSAGE_ERROR:
         if (m_resetPipeline)
             break;
+        if (m_missingPlugins)
+            break;
         gst_message_parse_error(message, &err.outPtr(), &debug.outPtr());
         LOG_MEDIA_MESSAGE("Error %d: %s (url=%s)", err->code, err->message, m_url.string().utf8().data());
 
@@ -765,6 +775,13 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
             changePipelineState(requestedState);
         }
         break;
+    case GST_MESSAGE_ELEMENT:
+        if (gst_is_missing_plugin_message(message)) {
+            char* detail = gst_missing_plugin_message_get_installer_detail(message);
+            GstInstallPluginsReturn result = gst_install_plugins_async(&detail, 0, mediaPlayerPrivatePluginInstallerResultFunction, this);
+            m_missingPlugins = result == GST_INSTALL_PLUGINS_STARTED_OK;
+        }
+        break;
     default:
         LOG_MEDIA_MESSAGE("Unhandled GStreamer message type: %s",
                     GST_MESSAGE_TYPE_NAME(message));
@@ -773,6 +790,15 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
     return TRUE;
 }
 
+void MediaPlayerPrivateGStreamer::handlePluginInstallerResult(GstInstallPluginsReturn result)
+{
+    m_missingPlugins = false;
+    if (result == GST_INSTALL_PLUGINS_SUCCESS) {
+        gst_element_set_state(m_playBin.get(), GST_STATE_READY);
+        gst_element_set_state(m_playBin.get(), GST_STATE_PAUSED);
+    }
+}
+
 void MediaPlayerPrivateGStreamer::processBufferingStats(GstMessage* message)
 {
     // This is the immediate buffering that needs to happen so we have
index 6ce666f..5776eb1 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <glib.h>
 #include <gst/gst.h>
+#include <gst/pbutils/install-plugins.h>
 #include <wtf/Forward.h>
 
 typedef struct _GstBuffer GstBuffer;
@@ -43,6 +44,7 @@ public:
     ~MediaPlayerPrivateGStreamer();
     static void registerMediaEngine(MediaEngineRegistrar);
     gboolean handleMessage(GstMessage*);
+    void handlePluginInstallerResult(GstInstallPluginsReturn);
 
     bool hasVideo() const { return m_hasVideo; }
     bool hasAudio() const { return m_hasAudio; }
@@ -162,6 +164,7 @@ private:
     bool m_preservesPitch;
     GstState m_requestedState;
     GRefPtr<GstElement> m_autoAudioSink;
+    bool m_missingPlugins;
 };
 }