gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-2288-g2b3bded
Date: Thu, 21 Jul 2016 21:45:44 +0000 (UTC)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  2b3bdede0305c4fc3ad21a0a4197330606c9b880 (commit)
      from  df95d2dd4c121ece9663f26f91e3945dd9469de3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=2b3bdede0305c4fc3ad21a0a4197330606c9b880


commit 2b3bdede0305c4fc3ad21a0a4197330606c9b880
Author: daghovland <address@hidden>
Date:   Wed Jun 1 17:36:31 2016 +0200

    Changes to the gst plugin installation:
    
    - Switched to the async call, so a crash in the
      installation does not crash the flash movie
    - Added dialogs after the plugin installation
      for different outcomes
    - Passed the movie_root object down from as_objects
      to make dialogs avaiable in gst_plugin installation
    - Allow the user to block repeated plugin installation attempts
    
    Changed in Gstreamer plugin installation:
       Movie is set to pause while installing
    
    Used HostInterface via the MediaHandler as suggested by Strk
    
    Added fixes from Bastiaan Jacques and Richard Wilbur

diff --git a/gui/Player.cpp b/gui/Player.cpp
index 617b0fa..5e2078b 100644
--- a/gui/Player.cpp
+++ b/gui/Player.cpp
@@ -518,6 +518,11 @@ Player::run(int argc, char* argv[], const std::string& 
infile,
     // Register Player to receive FsCommand events from the core.
     root.registerFSCommandCallback(_callbacksHandler.get());
 
+    // Register Player to receive commands from  the media (gstreamer plugin 
installation etc.)
+#ifdef USE_MEDIA
+    _mediaHandler->setCallbackHandler(_callbacksHandler);
+#endif
+
     // log_debug("Player Host FD #%d, Player Control FD #%d", _hostfd, 
_controlfd);
     
     // Set host requests fd (if any)
diff --git a/gui/gui.cpp b/gui/gui.cpp
index b248926..15043da 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -26,6 +26,7 @@
 
 #include <vector>
 #include <algorithm> 
+#include <iostream>
 
 #include "MovieClip.h"
 #include "Renderer.h"
diff --git a/libmedia/Makefile.am b/libmedia/Makefile.am
index 985e034..ba7e940 100644
--- a/libmedia/Makefile.am
+++ b/libmedia/Makefile.am
@@ -126,6 +126,10 @@ endif
 
 libgnashmedia_la_CPPFLAGS = \
        -I$(top_srcdir)/libbase \
+       -I$(top_srcdir)/libcore \
+       -I$(top_srcdir)/libcore/swf     \
+       -I$(top_srcdir)/libcore/parser  \
+       -I$(top_srcdir)/libcore/vm      \
        $(PTHREAD_CFLAGS) \
        $(BOOST_CFLAGS) \
        $(NULL)
diff --git a/libmedia/MediaHandler.cpp b/libmedia/MediaHandler.cpp
index 9b08248..8225e3a 100644
--- a/libmedia/MediaHandler.cpp
+++ b/libmedia/MediaHandler.cpp
@@ -118,8 +118,16 @@ MediaHandler::createFlashAudioDecoder(const AudioInfo& 
info)
             throw MediaException(err.str());
         }
     }
+
+}
+
+// Called from Player.cpp
+void
+MediaHandler::setCallbackHandler(std::shared_ptr<HostInterface> eventHandler){
+    _eventHandler = eventHandler;
 }
 
+
 } // namespace media 
 } // namespace gnash
 
diff --git a/libmedia/MediaHandler.h b/libmedia/MediaHandler.h
index cf0465b..881237c 100644
--- a/libmedia/MediaHandler.h
+++ b/libmedia/MediaHandler.h
@@ -29,6 +29,7 @@
 #include <string>
 
 #include "GnashFactory.h"
+#include "HostInterface.h"
 
 // Forward declarations
 namespace gnash {
@@ -140,6 +141,11 @@ public:
     /// and this should be used to allocate a large enough input buffer.
     virtual size_t getInputPaddingSize() const { return 0; }
 
+
+    // Sets the event handler.
+    // Used by GstUtil.cpp to trigger gui events after plugin installation
+    void setCallbackHandler(std::shared_ptr<HostInterface> handler);
+
 protected:
 
     /// Base constructor
@@ -167,6 +173,10 @@ protected:
     /// If this cannot read the necessary 3 bytes, it throws an IOException.
     bool isFLV(IOChannel& stream);
 
+    // Set by Player.cpp during init
+    // Used by GstUtil.cpp for gui events during plugin installation
+    std::shared_ptr<HostInterface> _eventHandler;
+
 };
 
 
diff --git a/libmedia/gst/AudioDecoderGst.cpp b/libmedia/gst/AudioDecoderGst.cpp
index ea275c9..6fb8d2b 100644
--- a/libmedia/gst/AudioDecoderGst.cpp
+++ b/libmedia/gst/AudioDecoderGst.cpp
@@ -29,7 +29,9 @@ namespace media {
 namespace gst {
 
 
-AudioDecoderGst::AudioDecoderGst(SoundInfo& info)
+AudioDecoderGst::AudioDecoderGst(SoundInfo& info, 
std::shared_ptr<HostInterface> eventHandler)
+    :
+    _eventHandler(eventHandler)
 {
     // init GStreamer. TODO: what about doing this in MediaHandlerGst ctor?
     gst_init (nullptr, nullptr);
@@ -45,7 +47,9 @@ AudioDecoderGst::AudioDecoderGst(SoundInfo& info)
     // FIXME: should we handle other types?
 }
 
-AudioDecoderGst::AudioDecoderGst(const AudioInfo& info)
+AudioDecoderGst::AudioDecoderGst(const AudioInfo& info, 
std::shared_ptr<HostInterface> eventHandler)
+    :
+    _eventHandler(eventHandler)
 {
     // init GStreamer. TODO: what about doing this in MediaHandlerGst ctor?
     gst_init (nullptr, nullptr);
@@ -168,7 +172,7 @@ void AudioDecoderGst::setup(GstCaps* srccaps)
         throw MediaException(_("AudioDecoderGst: internal error (caps creation 
failed)"));      
     }
 
-    bool success = GstUtil::check_missing_plugins(srccaps);
+    bool success = GstUtil::check_missing_plugins(srccaps, 
_eventHandler.get());
     if (!success) {
         GstStructure* sct = gst_caps_get_structure(srccaps, 0);
         std::string type(gst_structure_get_name(sct));
diff --git a/libmedia/gst/AudioDecoderGst.h b/libmedia/gst/AudioDecoderGst.h
index 4ff299c..4f88b88 100644
--- a/libmedia/gst/AudioDecoderGst.h
+++ b/libmedia/gst/AudioDecoderGst.h
@@ -22,6 +22,7 @@
 
 #include "log.h"
 #include "AudioDecoder.h"
+#include "HostInterface.h"
 
 #include <gst/gst.h>
 #include "GnashImage.h"
@@ -44,8 +45,8 @@ namespace gst {
 class DSOEXPORT AudioDecoderGst : public AudioDecoder {
        
 public:
-    AudioDecoderGst(const AudioInfo& info);
-    AudioDecoderGst(SoundInfo& info);
+    AudioDecoderGst(const AudioInfo& info, std::shared_ptr<HostInterface> 
handler);
+    AudioDecoderGst(SoundInfo& info, std::shared_ptr<HostInterface> handler);
 
     ~AudioDecoderGst();
 
@@ -55,6 +56,8 @@ public:
 
 private:
 
+    std::shared_ptr<HostInterface> _eventHandler;
+
     std::uint8_t* pullBuffers(std::uint32_t&  outputSize);
 
     void setup(GstCaps* caps);
diff --git a/libmedia/gst/GstUtil.cpp b/libmedia/gst/GstUtil.cpp
index 580bc11..f62b7a2 100644
--- a/libmedia/gst/GstUtil.cpp
+++ b/libmedia/gst/GstUtil.cpp
@@ -24,9 +24,11 @@
 #endif
 
 #include <sstream>
+#include <vector>
 
 #include "GstUtil.h"
 #include "log.h"
+#include "GnashException.h"
 
 #include "swfdec_codec_gst.h"
 
@@ -97,9 +99,11 @@ GstElement* GstUtil::get_audiosink_element()
     return element;
 }
 
-// static
+/**
+     This function is not thread-safe.
+**/
 bool
-GstUtil::check_missing_plugins(GstCaps* caps)
+GstUtil::check_missing_plugins(GstCaps* caps, HostInterface* eventHandler)
 {
     GstElementFactory * factory = swfdec_gst_get_element_factory(caps);
 
@@ -109,6 +113,15 @@ GstUtil::check_missing_plugins(GstCaps* caps)
     }
 
 #ifdef HAVE_GST_PBUTILS_INSTALL_PLUGINS_H
+
+    if(!eventHandler){
+       throw new GnashException("GstUtil::check_missing_plugins was not given 
a HostInterface");
+    }
+
+    if (GstUtil::no_plugin_install){
+        return false;
+    }
+
     gst_pb_utils_init();
 
 
@@ -126,26 +139,112 @@ GstUtil::check_missing_plugins(GstCaps* caps)
 
     char* details[] =  { detail, nullptr };
 
-    GstInstallPluginsReturn ret = gst_install_plugins_sync(details, nullptr);
-    g_free(details[0]);
+    std::vector<void*> * callback_data = new std::vector<void*>;
+    callback_data->push_back(detail);
+    callback_data->push_back(eventHandler);
 
-    // FIXME: what about partial success?
-    if (ret == GST_INSTALL_PLUGINS_SUCCESS) {
-        if (! gst_update_registry()) {
-            log_error(_("gst_update_registry failed. You'll need to "
-                        "restart Gnash to use the new plugins."));
-        }
+    GstInstallPluginsReturn ret = gst_install_plugins_async(details, nullptr, 
GstUtil::plugin_installer_return, callback_data);
 
-        return true;
+    if (ret == GST_INSTALL_PLUGINS_STARTED_OK) {
+       
eventHandler->call(HostMessage(HostMessage::EXTERNALINTERFACE_STOPPLAY));
+       return true;
+    } else {
+       log_error(_("gst_install_plugins_async failed. Please report."));
+       g_free(detail);
+       return false;
     }
+
 #else
     log_error(_("Missing plugin, but automatic plugin installation not "
                 "available."));
+    return false;
 #endif  // end of HAVE_GST_PBUTILS_INSTALL_PLUGINS_H
 
-    return false;
 }
 
+#ifdef HAVE_GST_PBUTILS_INSTALL_PLUGINS_H
+
+// static
+bool GstUtil::no_plugin_install = false;
+
+// Helper function for plugin_installer_return below.
+// Called when all or some plugins were successfully installed
+// static
+void
+GstUtil::plugin_success_dialog(const char* success_msg,
+                              const char* fail_msg,
+                              HostInterface* eventHandler)
+{
+    if (! gst_update_registry()) {
+        log_error(_("gst_update_registry failed. You'll need to "
+                   "restart Gnash to use the new plugins."));
+       eventHandler->call(HostMessage(HostMessage::NOTIFY_ERROR,
+                                     std::string(fail_msg)));
+       GstUtil::no_plugin_install = true;
+    } else {
+      bool restart = 
boost::any_cast<bool>(eventHandler->call(HostMessage(HostMessage::QUERY,
+                                                                        
std::string(success_msg))));
+       if(restart){
+           
eventHandler->call(HostMessage(HostMessage::EXTERNALINTERFACE_REWIND));
+       }
+    }
+}
+
+// Helper function for plugin_installer_return below.
+// Called when there is an error during plugin installation
+// static
+void
+GstUtil::plugin_fail_dialog(const char* fail_msg,
+                           HostInterface* eventHandler)
+{
+    GstUtil::no_plugin_install = 
boost::any_cast<bool>(eventHandler->call(HostMessage(HostMessage::QUERY,
+                                                                               
      std::string(fail_msg)
+                                                                               
      + std::string(_(" Do you wish to block any further attempts at plugin 
installation?")))));
+}
+
+
+
+// Callback function for use by the plugin installer
+void
+GstUtil::plugin_installer_return(GstInstallPluginsReturn result,
+                                gpointer user_data)
+{
+    std::vector<void*> * v((std::vector<void*> *) (user_data));
+    HostInterface* eventHandler = (HostInterface*) (v->at(1));
+    char* detail = (char*) v->at(0);
+
+    g_free(detail);
+
+    if(!eventHandler){
+      throw new GnashException("plugin_installer_return was not given a 
HostInterface");
+    }
+    switch(result) {
+    case GST_INSTALL_PLUGINS_SUCCESS:
+       plugin_success_dialog(_("Plugin installation succeeded. Do you wish to 
restart the movie from the beginning?"),_("Plugin installation succeeded, but 
could not be registered by Gnash. You will need to restart Gnash to see all 
content in this file."), eventHandler);
+       break;
+    case GST_INSTALL_PLUGINS_NOT_FOUND:
+        plugin_fail_dialog(_("A plugin needed for playing this file was not 
found. You may still play the file, but some content may not be shown."), 
eventHandler);
+       break;
+    case GST_INSTALL_PLUGINS_ERROR:
+        plugin_fail_dialog(_("There was an error during installation of a 
plugin needed for playing this file. You may still play the file, but some 
content may not be shown."), eventHandler);
+       break;
+    case GST_INSTALL_PLUGINS_PARTIAL_SUCCESS:
+        plugin_fail_dialog(_("Only some of the plugins needed to see this 
movie could be installed. To see all content here you will need to install 
these."), eventHandler);
+       plugin_success_dialog(_("Do you wish to restart the movie from the 
beginning?"),_("Some plugins were installed, but could not be registered by 
Gnash. You will need to restart gnash to see more content in this file. To see 
all content in this file you also need to install the remaining plugins"), 
eventHandler);
+       break;
+    case GST_INSTALL_PLUGINS_USER_ABORT:
+        plugin_fail_dialog("", eventHandler);
+       break;
+    default:
+       throw new GnashException("Gst plugin installer returned unrecognized 
error code.");
+    }
+    eventHandler->call(HostMessage(HostMessage::EXTERNALINTERFACE_PLAY));
+    g_free(v);
+    return;
+}
+
+#endif  // end of HAVE_GST_PBUTILS_INSTALL_PLUGINS_H
+
 } // gnash.media.gst namespace
 } // gnash.media namespace 
 } // namespace gnash
diff --git a/libmedia/gst/GstUtil.h b/libmedia/gst/GstUtil.h
index 1537ad4..69d7f71 100644
--- a/libmedia/gst/GstUtil.h
+++ b/libmedia/gst/GstUtil.h
@@ -22,6 +22,10 @@
 
 #include <gst/gst.h>
 #include "dsodefs.h" // DSOEXPORT
+#include "HostInterface.h"
+
+// Needed for declaration of the thread functions to install plugins
+#include <gst/pbutils/install-plugins.h>
 
 // GST_TIME_AS_MSECONDS not defined as of gst 0.10.9
 // is defined as of gst 0.10.19
@@ -73,12 +77,28 @@ public:
     /// @return if there is a decoder available to decode the passed type,
     ///         or if we succeeded in installing one, returns true. Otherwise,
     ///         returns false.
-    static bool check_missing_plugins(GstCaps* caps);
+    static bool check_missing_plugins(GstCaps* caps, HostInterface* 
eventHandler);
         
 private:
 
+
   GstUtil();
   ~GstUtil();
+
+#ifdef HAVE_GST_PBUTILS_INSTALL_PLUGINS_H
+    // Initially false, set to true if the user does not want to retry plugin 
installation
+    static bool no_plugin_install;
+
+    // Callback function for the gst plugin installer
+    static void plugin_installer_return(GstInstallPluginsReturn, gpointer);
+    // Helper for the callback. Displays dialog in case of installation success
+    static void plugin_success_dialog(const char* success_msg,
+                                     const char* fail_msg,
+                                     HostInterface* eventHandler);
+    // Helper for the callback. Displays dialog in case of installation failure
+    static void plugin_fail_dialog(const char* fail_msg,
+                                  HostInterface* eventHandler);
+#endif  // end of HAVE_GST_PBUTILS_INSTALL_PLUGINS_H
 };
 
 } // gnash.media.gst namespace
diff --git a/libmedia/gst/MediaHandlerGst.cpp b/libmedia/gst/MediaHandlerGst.cpp
index 21613eb..ef0ac87 100644
--- a/libmedia/gst/MediaHandlerGst.cpp
+++ b/libmedia/gst/MediaHandlerGst.cpp
@@ -92,7 +92,7 @@ MediaHandlerGst::createVideoDecoder(const VideoInfo& info)
             return std::unique_ptr<VideoDecoder>();
         }
         return std::unique_ptr<VideoDecoder>(
-            new VideoDecoderGst(extrainfo->caps));
+            new VideoDecoderGst(extrainfo->caps, _eventHandler));
     }
     videoCodecType format = static_cast<videoCodecType>(info.codec);
     int width = info.width;
@@ -107,7 +107,7 @@ MediaHandlerGst::createVideoDecoder(const VideoInfo& info)
         datasize = extrainfo->size;
     }
 
-    std::unique_ptr<VideoDecoder> ret( new VideoDecoderGst(format, width, 
height, extradata, datasize) );
+    std::unique_ptr<VideoDecoder> ret( new VideoDecoderGst(format, width, 
height, extradata, datasize, _eventHandler) );
     return ret;
 }
 
@@ -124,7 +124,7 @@ MediaHandlerGst::createAudioDecoder(const AudioInfo& info)
 #endif
     {
         try {
-            ret.reset(new AudioDecoderGst(info));
+            ret.reset(new AudioDecoderGst(info, _eventHandler));
         }
         catch (const MediaException& ex) {
 
diff --git a/libmedia/gst/MediaHandlerGst.h b/libmedia/gst/MediaHandlerGst.h
index 85e2fd0..4d8c2f5 100644
--- a/libmedia/gst/MediaHandlerGst.h
+++ b/libmedia/gst/MediaHandlerGst.h
@@ -63,6 +63,7 @@ public:
     virtual AudioInput* getAudioInput(size_t index);
 
     virtual void cameraNames(std::vector<std::string>& names) const;
+
 };
 
 
diff --git a/libmedia/gst/VideoDecoderGst.cpp b/libmedia/gst/VideoDecoderGst.cpp
index 27d6a59..1be5bf1 100644
--- a/libmedia/gst/VideoDecoderGst.cpp
+++ b/libmedia/gst/VideoDecoderGst.cpp
@@ -27,10 +27,11 @@ namespace gst {
 
 // TODO: implement proper seeking.
 
-VideoDecoderGst::VideoDecoderGst(GstCaps* caps)
+VideoDecoderGst::VideoDecoderGst(GstCaps* caps, std::shared_ptr<HostInterface> 
eventHandler)
     :
     _width(0),
-    _height(0)
+    _height(0),
+    _eventHandler(eventHandler)
 {
     // init GStreamer. TODO: what about doing this in MediaHandlerGst ctor?
     gst_init (nullptr, nullptr);
@@ -53,10 +54,12 @@ VideoDecoderGst::height() const
 // TODO: either use width and height or remove them!
 VideoDecoderGst::VideoDecoderGst(videoCodecType codec_type,
         int /*width*/, int /*height*/,
-        const std::uint8_t* extradata, size_t extradatasize)
+                                const std::uint8_t* extradata, size_t 
extradatasize,
+                                std::shared_ptr<HostInterface> eventHandler)
     :
     _width(0),
-    _height(0)
+    _height(0),
+    _eventHandler(eventHandler)
 {
     // init GStreamer. TODO: what about doing this in MediaHandlerGst ctor?
     gst_init (nullptr, nullptr);
@@ -123,7 +126,7 @@ VideoDecoderGst::setup(GstCaps* srccaps)
                     "(caps creation failed)"));      
     }
 
-    bool success = GstUtil::check_missing_plugins(srccaps);
+    bool success = GstUtil::check_missing_plugins(srccaps, 
_eventHandler.get());
     if (!success) {
         GstStructure* sct = gst_caps_get_structure(srccaps, 0);
         std::string type(gst_structure_get_name(sct));
diff --git a/libmedia/gst/VideoDecoderGst.h b/libmedia/gst/VideoDecoderGst.h
index 193a309..f16377f 100644
--- a/libmedia/gst/VideoDecoderGst.h
+++ b/libmedia/gst/VideoDecoderGst.h
@@ -25,6 +25,7 @@
 #include "VideoDecoder.h"
 #include "dsodefs.h"
 #include "MediaParser.h" // for videoCodecType enum
+#include "HostInterface.h"
 
 #include <gst/gst.h>
 
@@ -74,8 +75,9 @@ class DSOEXPORT VideoDecoderGst : public VideoDecoder
 {
 public:
     VideoDecoderGst(videoCodecType codec_type, int width, int height,
-                    const std::uint8_t* extradata, size_t extradatasize);
-    VideoDecoderGst(GstCaps* caps);
+                    const std::uint8_t* extradata, size_t extradatasize,
+                   std::shared_ptr<HostInterface> eventhandler);
+    VideoDecoderGst(GstCaps* caps, std::shared_ptr<HostInterface> 
eventhandler);
     ~VideoDecoderGst();
 
     void push(const EncodedVideoFrame& buffer);
@@ -99,6 +101,8 @@ private:
     int _width;
     int _height;
 
+    std::shared_ptr<HostInterface> _eventHandler;
+
     void setup(GstCaps* caps);
 
     VideoDecoderGst();
diff --git a/libsound/Makefile.am b/libsound/Makefile.am
index 1d0e092..f351eff 100644
--- a/libsound/Makefile.am
+++ b/libsound/Makefile.am
@@ -68,6 +68,7 @@ noinst_HEADERS = \
 libgnashsound_la_CPPFLAGS = \
        -I$(top_srcdir)/libbase \
        -I$(top_srcdir)/libmedia \
+       -I$(top_srcdir)/libcore \
        $(PTHREAD_CFLAGS) \
        $(BOOST_CFLAGS) \
        $(SDL_CFLAGS) \

-----------------------------------------------------------------------

Summary of changes:
 gui/Player.cpp                   |    5 ++
 gui/gui.cpp                      |    1 +
 libmedia/Makefile.am             |    4 ++
 libmedia/MediaHandler.cpp        |    8 +++
 libmedia/MediaHandler.h          |   10 ++++
 libmedia/gst/AudioDecoderGst.cpp |   10 +++-
 libmedia/gst/AudioDecoderGst.h   |    7 ++-
 libmedia/gst/GstUtil.cpp         |  123 ++++++++++++++++++++++++++++++++++----
 libmedia/gst/GstUtil.h           |   22 ++++++-
 libmedia/gst/MediaHandlerGst.cpp |    6 +-
 libmedia/gst/MediaHandlerGst.h   |    1 +
 libmedia/gst/VideoDecoderGst.cpp |   13 ++--
 libmedia/gst/VideoDecoderGst.h   |    8 ++-
 libsound/Makefile.am             |    1 +
 14 files changed, 191 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]