[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r12302: Allow selection of media han
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r12302: Allow selection of media handlers at runtime. If none is selected, the |
Date: |
Wed, 14 Jul 2010 20:28:49 +0200 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 12302 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2010-07-14 20:28:49 +0200
message:
Allow selection of media handlers at runtime. If none is selected, the
first ordered handler will be chosen as a default. If there is only one media
handler, behaviour is as before.
Selection is command line only with the option -M. Rcfile selection is not
yet implemented.
Testing does not yet support selection, but rather chooses the default.
Change renderer selection from --Renderer to --renderer for consistency.
Show media handler information in gtk. Fix some typos.
All sound_handlers need a MediaHandler on construction. This isn't an
ideal situation (though better than using a singleton media handler), but
sound_handler needs redesigning to fix it.
XVideo is probably broken.
removed:
libmedia/ffmpeg/MediaHandlerFfmpeg.h
libmedia/gst/MediaHandlerGst.h
libmedia/haiku/MediaHandlerHaiku.h
added:
libbase/GnashFactory.h
modified:
configure.ac
gui/Player.cpp
gui/Player.h
gui/gnash.cpp
gui/gtk.cpp
gui/gtk_glue_agg_xv.cpp
gui/pythonmod/gnash-view.cpp
libbase/Makefile.am
libcore/RunResources.h
libcore/Video.cpp
libcore/Video.h
libcore/asobj/Camera_as.cpp
libcore/asobj/Microphone_as.cpp
libcore/asobj/NetStream_as.cpp
libcore/asobj/Sound_as.cpp
libcore/swf/tag_loaders.cpp
libmedia/Makefile.am
libmedia/MediaHandler.cpp
libmedia/MediaHandler.h
libmedia/ffmpeg/MediaHandlerFfmpeg.cpp
libmedia/gst/MediaHandlerGst.cpp
libmedia/haiku/MediaHandlerHaiku.cpp
libsound/EmbedSound.cpp
libsound/EmbedSound.h
libsound/NullSoundHandler.h
libsound/sdl/sound_handler_sdl.cpp
libsound/sdl/sound_handler_sdl.h
libsound/sound_handler.cpp
libsound/sound_handler.h
testsuite/MovieTester.cpp
testsuite/MovieTester.h
utilities/processor.cpp
=== modified file 'configure.ac'
--- a/configure.ac 2010-07-09 23:45:26 +0000
+++ b/configure.ac 2010-07-14 12:56:34 +0000
@@ -902,29 +902,42 @@
media_handler_specified=false
AC_ARG_ENABLE(media,
- AC_HELP_STRING([--enable-media=handler], [Enable media handling support using
the specified handler: gst, ffmpeg or none (no sound) [[gst]] ]),
- [case "${enableval}" in
- GST|gst)
- media_handler=gst
- media_handler_specified=true
- ;;
- ffmpeg|FFMPEG)
- media_handler=ffmpeg
- media_handler_specified=true
- ;;
- no|NO|none)
- media_handler=none
- media_handler_specified=true
- ;;
- *) AC_MSG_ERROR([bad value ${enableval} for --enable-media option]) ;;
- esac],
- [media_handler=gst; media_handler_specified=true]
+ AC_HELP_STRING([--enable-media=handler],
+ [Enable media handling support using the specified handler: gst, ffmpeg or
none (no sound) [[gst]] ]),
+
+ if test -n ${enableval}; then
+ enableval=`echo ${enableval} | tr '\054' ' ' `
+ fi
+ while test -n "${enableval}"; do
+ val=`echo ${enableval} | cut -d ' ' -f 1`
+ [case "${val}" in
+ GST|gst)
+ build_media_gst=yes
+ media_handler_specified=true
+ ;;
+ FFMPEG|ffmpeg)
+ build_media_ffmpeg=yes
+ media_handler_specified=true
+ ;;
+ no|NO|none)
+ media_handler_specified=true
+ ;;
+ *)
+ AC_MSG_ERROR([bad value ${enableval} for --enable-media option])
+ ;;
+
+ esac]
+ enableval=`echo ${enableval} | cut -d ' ' -f 2-6`
+ if test "x$val" = "x$enableval"; then
+ break;
+ fi
+ done
)
+
dnl If we're on Haiku, there is only one supported media handler.
if test x"${build_haiku}" = xyes; then
- media_handler=ffmpeg
- media_handler_specified=true
+ build_media_haiku=true
fi
AC_ARG_ENABLE(lirc, AC_HELP_STRING([--enable-lirc], [Disable support for
Lirc]),
@@ -2043,7 +2056,7 @@
AM_CONDITIONAL([QT_WIN32], [test "$platform" = "Win32"])
dnl Need GLIB for both GTK and GST
-if test x"${build_gtk}" = xyes -o x"${media_handler}" = xgst; then
+if test x"${build_gtk}" = xyes -o x"${build_media_gst}" = xyes; then
GNASH_PATH_GLIB
fi
@@ -2184,7 +2197,7 @@
fi
missing_codecs=""
-if test "$media_handler" = "gst"; then
+if test x"$build_media_gst" = "xyes"; then
AC_PATH_PROG(GST_INSPECT, gst-inspect, ,[${pathlist}])
if test "x$GST_INSPECT" != "x" -a x"${darwin}" = xno ; then
AC_PATH_PROG(GST_INSPECT, gst-inspect-0.10, ,[${pathlist}])
@@ -2221,18 +2234,19 @@
if test x"${media_handler_specified}" = xfalse; then
if test x"$GSTREAMER_LIBS" = x; then
AC_MSG_WARN([No appropriate gstreamer library found, will try using
ffmpeg.])
- media_handler=ffmpeg
+ build_media_gst=no
+ build_media_ffmpeg=yes
fi
fi
fi
-if test x"$media_handler" = x"ffmpeg"; then
+if test x"$build_media_ffmpeg" = x"yes"; then
GNASH_PATH_FFMPEG
if test x"${media_handler_specified}" = xfalse; then
# If the library is not found, or its version is not ok, we'll try gst
if test x"${ac_cv_path_ffmpeg_lib}" = x -o x"${ffmpeg_version_check}" !=
xok; then
AC_MSG_WARN([No appropriate ffmpeg library found, disabling media
handling.])
- media_handler=none
+ build_media_ffmpeg=no
fi
fi
fi
@@ -2269,11 +2283,11 @@
AM_CONDITIONAL(USE_SOUND_SDL, test x$build_sound_sdl = xyes)
AM_CONDITIONAL(USE_SOUND_AHI, test x$build_sound_ahi = xyes)
AM_CONDITIONAL(USE_SOUND_MKIT, test x$build_sound_mkit = xyes)
-AM_CONDITIONAL(USE_FFMPEG_ENGINE, test x"$media_handler" = xffmpeg)
-AM_CONDITIONAL(USE_GST_ENGINE, test x"$media_handler" = xgst)
+AM_CONDITIONAL(USE_FFMPEG_ENGINE, test x"${build_media_ffmpeg}" = x"yes")
+AM_CONDITIONAL(USE_GST_ENGINE, test x"${build_media_gst}" = x"yes")
AM_CONDITIONAL(HAVE_OPENGL, test x"${OPENGL_LIBS}" != x)
dnl for now the Haiku media handler is experimental
-AM_CONDITIONAL(USE_HAIKU_ENGINE, test x"$media_handler" = xno)
+AM_CONDITIONAL(USE_HAIKU_ENGINE, test x"$build_media_haiku" = xyes)
if test x$build_sound_mkit = xyes; then
if test x"${haiku}" != xyes; then
@@ -2295,14 +2309,6 @@
fi
fi
-case "${media_handler}" in
- ffmpeg) AC_DEFINE([USE_FFMPEG], [1], [Use FFMPEG for media decoding]) ;;
- gst) AC_DEFINE([USE_GST], [1], [Use gstreamer for media decoding]) ;;
- *)
-esac
-dnl I'm kinda lazy, get rid of this later... //Markus
-AM_CONDITIONAL(HAVE_GST, test x$media_handler = xgst)
-
if test x$build_fltk = xyes; then
GNASH_PKG_FIND(fltk2, [fltk/FL_API.h], [Fast Light Toolkit], fl_window_flush)
fi
@@ -2369,7 +2375,7 @@
dnl Until the hwaccel patches in ffmpeg wind up in the ffmpeg-plugin,
dnl restrict using HW Accel to using ffmpeg directly.
-if test x"${media_handler}" = x"gst" -a x"${build_vaapi}" = x"yes" -a
x"${have_ffmpeg_vaapi}" = x"yes"; then
+if test x"${build_media_ffmpeg}" = x"no" -a x"${build_vaapi}" = x"yes" -a
x"${have_ffmpeg_vaapi}" = x"yes"; then
AC_MSG_ERROR(["Hardware acceleration currently not supported unless using
ffmpeg."])
fi
@@ -3162,7 +3168,7 @@
fi
-if test "$media_handler" = "gst"; then
+if test x"$build_media_gst" = x"yes"; then
if test x"$missing_codecs" != x; then
echo " Your Gstreamer installation is missing these codecs:
$missing_codecs"
echo " Please install the gstreamer-ffmpeg for Gstreamer"
@@ -3194,7 +3200,7 @@
fi
fi
- if test x"$media_handler" = x"ffmpeg"; then
+ if test x"${build_media_ffmpeg}" = x"yes"; then
if test x"$FFMPEG_LIBS" != x; then
echo " MP3 and video support enabled through ffmpeg"
if test x"${ffmpeg_version_check}" != xok; then
=== modified file 'gui/Player.cpp'
--- a/gui/Player.cpp 2010-07-11 06:43:23 +0000
+++ b/gui/Player.cpp 2010-07-14 13:51:15 +0000
@@ -49,14 +49,6 @@
#include "SystemClock.h"
#include "ExternalInterface.h"
-#ifdef USE_FFMPEG
-# include "MediaHandlerFfmpeg.h"
-#elif defined(USE_GST)
-# include "MediaHandlerGst.h"
-#elif defined(USE_HAIKU_ENGINE)
-# include "MediaHandlerHaiku.h"
-#endif
-
#include "GnashSystemIOHeaders.h" // for write()
#include "log.h"
#include <iostream>
@@ -189,13 +181,14 @@
if (_doSound) {
try {
#ifdef SOUND_SDL
- _soundHandler.reset(sound::create_sound_handler_sdl(_audioDump));
-#elif defined(SOUND_GST)
- _soundHandler.reset(media::create_sound_handler_gst());
+ _soundHandler.reset(sound::create_sound_handler_sdl(
+ _mediaHandler.get(), _audioDump));
#elif defined(SOUND_AHI)
- _soundHandler.reset(sound::create_sound_handler_aos4(_audioDump));
+ _soundHandler.reset(sound::create_sound_handler_aos4(
+ _mediaHandler.get(), _audioDump));
#elif defined(SOUND_MKIT)
- _soundHandler.reset(sound::create_sound_handler_mkit(_audioDump));
+ _soundHandler.reset(sound::create_sound_handler_mkit(
+ _mediaHandler.get(), _audioDump));
#else
log_error(_("Sound requested but no sound support compiled in"));
return;
@@ -214,24 +207,6 @@
}
void
-Player::init_media()
-{
-#ifdef USE_FFMPEG
- _mediaHandler.reset( new gnash::media::ffmpeg::MediaHandlerFfmpeg() );
-#elif defined(USE_GST)
- _mediaHandler.reset( new gnash::media::gst::MediaHandlerGst() );
-#elif defined(USE_HAIKU_ENGINE)
- _mediaHandler.reset( new gnash::media::haiku::MediaHandlerHaiku() );
-#else
- log_error(_("No media support compiled in"));
- return;
-#endif
-
- gnash::media::MediaHandler::set(_mediaHandler);
-}
-
-
-void
Player::init_gui()
{
if (_doRender) {
@@ -309,7 +284,7 @@
}
/// \brief Run, used to open a new flash file. Using previous initialization
-int
+void
Player::run(int argc, char* argv[], const std::string& infile,
const std::string& url)
{
@@ -317,8 +292,6 @@
// a cache of setting some parameter before calling us...
// (example: setDoSound(), setWindowId() etc.. )
init_logfile();
- init_media();
- init_sound();
// gnash.cpp should check that a filename is supplied.
assert (!infile.empty());
@@ -344,10 +317,8 @@
Params::const_iterator it = _params.find("base");
const URL baseURL = (it == _params.end()) ? _baseurl :
URL(it->second, _baseurl);
-
/// The RunResources should be populated before parsing.
_runResources.reset(new RunResources(baseURL.str()));
- _runResources->setSoundHandler(_soundHandler);
boost::shared_ptr<SWF::TagLoadersTable> loaders(new
SWF::TagLoadersTable());
addDefaultLoaders(*loaders);
@@ -362,6 +333,20 @@
_runResources->setHWAccelBackend(_hwaccel);
// Set the Renderer resource, opengl, agg, or cairo
_runResources->setRenderBackend(_renderer);
+
+ _mediaHandler.reset(media::MediaFactory::instance().get(_media));
+
+ if (!_mediaHandler.get()) {
+ boost::format fmt =
+ boost::format(_("Non-existent media handler %1% specified"))
+ % _media;
+ throw GnashException(fmt.str());
+ }
+
+ _runResources->setMediaHandler(_mediaHandler);
+
+ init_sound();
+ _runResources->setSoundHandler(_soundHandler);
init_gui();
@@ -369,8 +354,7 @@
// note that this will also initialize the renderer
// which is *required* during movie loading
if (!_gui->init(argc, &argv)) {
- std::cerr << "Could not initialize gui." << std::endl;
- return EXIT_FAILURE;
+ throw GnashException("Could not initialize GUI");
}
// Parse querystring (before FlashVars, see
@@ -399,7 +383,7 @@
// Load the actual movie.
_movieDef = load_movie();
if (!_movieDef) {
- return EXIT_FAILURE;
+ throw GnashException("Could not load movie!");
}
// Get info about the width & height of the movie.
@@ -438,7 +422,7 @@
// Register Player to receive FsCommand events from the core.
root.registerFSCommandCallback(_callbacksHandler.get());
- gnash::log_debug("Player Host FD #%d, Player Control FD #%d",
+ log_debug("Player Host FD #%d, Player Control FD #%d",
_hostfd, _controlfd);
// Set host requests fd (if any)
@@ -580,7 +564,6 @@
// Clean up as much as possible, so valgrind will help find actual leaks.
gnash::clear();
- return EXIT_SUCCESS;
}
void
=== modified file 'gui/Player.h'
--- a/gui/Player.h 2010-07-11 06:43:23 +0000
+++ b/gui/Player.h 2010-07-14 13:51:15 +0000
@@ -74,7 +74,7 @@
/// movie path/url.
///
///
- int run(int argc, char* argv[],
+ void run(int argc, char* argv[],
const std::string& infile, const std::string& url = "");
float setScale(float s);
@@ -146,6 +146,10 @@
return _hostfd;
}
+ void setMedia(const std::string& media) {
+ _media = media;
+ }
+
void setControlFD(int fd) {
_controlfd = fd;
}
@@ -261,8 +265,6 @@
void init_sound();
- void init_media();
-
void init_logfile();
void init_gui();
@@ -314,7 +316,7 @@
/// needing a RunResources.
boost::shared_ptr<sound::sound_handler> _soundHandler;
- std::auto_ptr<media::MediaHandler> _mediaHandler;
+ boost::shared_ptr<media::MediaHandler> _mediaHandler;
/// Handlers (for sound etc) for a libcore run.
//
@@ -368,6 +370,11 @@
/// If empty, a default is used.
std::string _screenshotFile;
+ /// The identifier for the media handler.
+ //
+ /// If empty, a default is used.
+ std::string _media;
+
};
} // end of gnash namespace
=== modified file 'gui/gnash.cpp'
--- a/gui/gnash.cpp 2010-06-15 16:45:19 +0000
+++ b/gui/gnash.cpp 2010-07-14 16:00:04 +0000
@@ -39,7 +39,9 @@
#include "debugger.h"
#include "arg_parser.h"
#include "GnashNumeric.h" // for clamp
+#include "GnashException.h"
#include "bzrversion.h"
+#include "MediaHandler.h"
#ifdef HAVE_FFMPEG_AVCODEC_H
extern "C" {
@@ -86,8 +88,11 @@
static void
usage()
{
+ std::ostringstream handlers;
+ gnash::media::MediaFactory::instance().listKeys(
+ std::ostream_iterator<std::string>(handlers, " "));
-cout << _("Usage: gnash [options] movie_file.swf\n")
+ cout << _("Usage: gnash [options] movie_file.swf\n")
<< "\n"
<< _("Plays a SWF (Shockwave Flash) movie\n")
<< _("Options:\n")
@@ -105,7 +110,7 @@
<< _(" -vp Be (very) verbose about parsing\n")
#endif
<< _(" -A <file> Audio dump file (wave format)\n")
- << _(" --hwaccel <none|vaapi||xv> Hardware Video Accelerator to use\n")
+ << _(" --hwaccel <none|vaapi|xv> Hardware Video Accelerator to use\n")
<< _(" none|vaapi|xv|omap (default: none)\n")
<< _(" -x, --xid <ID> X11 Window ID for display\n")
<< _(" -w, --writelog Produce the disk based debug log\n")
@@ -116,13 +121,15 @@
<< _(" -1, --once Exit when/if movie reaches the last "
"frame\n")
<< _(" -g, --debugger Turn on the SWF debugger\n")
- << _(" -r, --render-mode <0|1|2|3|agg|cairo|opengl>\n")
+ << _(" -r, --render-mode <0|1|2|3>\n")
<< _(" 0 disable rendering and sound\n")
<< _(" 1 enable rendering, disable sound\n")
<< _(" 2 enable sound, disable rendering\n")
<< _(" 3 enable rendering and sound
(default)\n")
+ << _(" -M, --media < ") << handlers.str() << ">\n"
+ << _(" The media handler to use\n")
// Only list the renderers that were configured in for this build
- << _(" -R, --Renderer <")
+ << _(" -R, --renderer <")
#ifdef RENDERER_OPENGL
<< _(" opengl")
#endif
@@ -190,18 +197,6 @@
<< _(" Configured with: ") << CONFIG_CONFIG << endl
<< _(" CXXFLAGS: ") << CXXFLAGS << endl
<< " Version: " << BRANCH_NICK << ":" << BRANCH_REVNO << endl;
-
-#ifdef USE_FFMPEG
- cout << _("Built against ffmpeg version: ") << LIBAVCODEC_IDENT << endl;
-#endif
-#ifdef USE_GST
- cout << _("Built against gstreamer version: ") << GST_VERSION_MAJOR << "."
- << GST_VERSION_MINOR << "." << GST_VERSION_MICRO << endl;
- guint major, minor, micro, nano;
- gst_version(&major, &minor, µ, &nano);
- cout << _("Linked against gstreamer version: ") << major << "."
- << minor << "." << micro << endl;
-#endif
}
static void
@@ -221,7 +216,8 @@
{ 'c', 0, Arg_parser::no },
{ 'd', "delay", Arg_parser::yes },
{ 'x', "xid", Arg_parser::yes },
- { 'R', "Renderer", Arg_parser::yes },
+ { 'R', "renderer", Arg_parser::yes },
+ { 'M', "media", Arg_parser::yes },
{ 'r', "render-mode", Arg_parser::yes },
{ 't', "timeout", Arg_parser::yes },
{ '1', "once", Arg_parser::no },
@@ -408,6 +404,9 @@
cout << rcfile.getFlashVersionString() << endl;
exit(EXIT_SUCCESS);
break;
+ case 'M':
+ player.setMedia(parser.argument(i));
+ break;
#if defined(RENDERER_AGG) || defined(RENDERER_OPENGL) ||
defined(RENDERER_CAIRO)
case 'R':
switch (parser.argument<char>(i)) {
@@ -583,5 +582,13 @@
return EXIT_FAILURE;
}
- return player.run(argc, argv, infiles.front(), url);
+ // We only expect GnashExceptions here. No others should be thrown!
+ try {
+ player.run(argc, argv, infiles.front(), url);
+ }
+ catch (const gnash::GnashException& ex) {
+ std::cerr << "Error: " << ex.what() << "\n";
+ return EXIT_FAILURE;
+ }
+ return EXIT_SUCCESS;
}
=== modified file 'gui/gtk.cpp'
--- a/gui/gtk.cpp 2010-07-10 09:22:49 +0000
+++ b/gui/gtk.cpp 2010-07-14 13:26:31 +0000
@@ -1881,25 +1881,16 @@
std::string comments = _("Gnash is the GNU SWF Player based on GameSWF.");
+ media::MediaHandler* m = _runResources.mediaHandler();
+
comments.append(_("\nRenderer: "));
comments.append(RENDERER_CONFIG);
- comments.append(_("\nHardwar Acceleration:: "));
+ comments.append(_("\nHardware Acceleration: "));
comments.append(HWACCEL_CONFIG);
comments.append(_("\nGUI: "));
comments.append("GTK2"); // gtk of course!
comments.append(_("\nMedia: "));
- comments.append(MEDIA_CONFIG" ");
-#ifdef HAVE_GST_GST_H
- comments.append(_("\nBuilt against gstreamer version: "));
- std::ostringstream ss;
- ss << GST_VERSION_MAJOR << "." << GST_VERSION_MINOR << "." <<
- GST_VERSION_MICRO;
- comments.append(ss.str());
-#endif
-#ifdef HAVE_FFMPEG_AVCODEC_H
- comments.append(_("\nBuilt against ffmpeg version: "));
- comments.append(LIBAVCODEC_IDENT);
-#endif
+ comments.append(m ? m->description() : "no media handler");
gtk_about_dialog_set_url_hook(NULL, NULL, NULL);
GdkPixbuf *logo_pixbuf = createPixbuf("GnashG.png");
=== modified file 'gui/gtk_glue_agg_xv.cpp'
--- a/gui/gtk_glue_agg_xv.cpp 2010-05-08 21:33:27 +0000
+++ b/gui/gtk_glue_agg_xv.cpp 2010-07-14 10:47:13 +0000
@@ -58,7 +58,7 @@
_window_height(0),
_movie_width(0),
_movie_height(0),
- _mediaHandler(media::MediaHandler::get()),
+ //_mediaHandler(media::MediaHandler::get()),
_shm_info(0)
{
memset(&_xv_format, 0, sizeof(XvImageFormatValues));
=== modified file 'gui/pythonmod/gnash-view.cpp'
--- a/gui/pythonmod/gnash-view.cpp 2010-07-12 09:57:55 +0000
+++ b/gui/pythonmod/gnash-view.cpp 2010-07-14 18:28:49 +0000
@@ -42,12 +42,6 @@
#include "NamingPolicy.h"
#include "StreamProvider.h"
-#ifdef USE_FFMPEG
-# include "MediaHandlerFfmpeg.h"
-#elif defined(USE_GST)
-# include "MediaHandlerGst.h"
-#endif
-
enum
{
PROP_0,
@@ -61,7 +55,7 @@
const gchar *uri;
guint advance_timer;
- std::auto_ptr<gnash::media::MediaHandler> media_handler;
+ boost::shared_ptr<gnash::media::MediaHandler> media_handler;
boost::shared_ptr<gnash::sound::sound_handler> sound_handler;
/// Handlers (for sound etc) for a libcore run.
@@ -217,28 +211,19 @@
gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
dbglogfile.setVerbosity(3);
- // Init media
-#ifdef USE_FFMPEG
- view->media_handler.reset( new gnash::media::ffmpeg::MediaHandlerFfmpeg()
);
- gnash::media::MediaHandler::set(view->media_handler);
-#elif defined(USE_GST)
- view->media_handler.reset( new gnash::media::gst::MediaHandlerGst() );
- gnash::media::MediaHandler::set(view->media_handler);
-#else
- gnash::log_error(_("No media support compiled in"));
-#endif
+ // Use the default media handler.
+ // TODO: allow setting this.
+ view->media_handler.reset(gnash::media::MediaFactory::instance().get(""));
// Init sound
#ifdef SOUND_SDL
try {
- view->sound_handler.reset(gnash::sound::create_sound_handler_sdl(""));
+ view->sound_handler.reset(gnash::sound::create_sound_handler_sdl(
+ view->media_handler.get(), ""));
} catch (gnash::SoundException& ex) {
gnash::log_error(_("Could not create sound handler: %s."
" Will continue w/out sound."), ex.what());
}
-#elif defined(SOUND_GST)
- view->sound_handler.reset(media::create_sound_handler_gst());
-#else
gnash::log_error(_("Sound requested but no sound support compiled in"));
#endif
=== added file 'libbase/GnashFactory.h'
--- a/libbase/GnashFactory.h 1970-01-01 00:00:00 +0000
+++ b/libbase/GnashFactory.h 2010-07-14 16:00:04 +0000
@@ -0,0 +1,124 @@
+// GnashFactory.h A generic class template
+//
+// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+// Foundation, Inc
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifndef GNASH_FACTORY_H
+#define GNASH_FACTORY_H
+
+#ifdef HAVE_CONFIG_H
+# include "gnashconfig.h"
+#endif
+
+#include <map>
+#include <string>
+#include <algorithm>
+#include <iterator>
+#include <boost/utility/enable_if.hpp>
+
+#include "dsodefs.h"
+#include "GnashAlgorithm.h"
+
+namespace gnash {
+
+
+/// A generic factory class for registering and retrieving objects by key.
+//
+/// Note: there is only one GnashFactory for any combination of template
+/// arguments. It's not advisable to have more than one factory for any
+/// type.
+//
+/// Note that this relies on static initialization, so do not call get()
+/// before or after main().
+template<typename T, typename Key = std::string>
+class DSOEXPORT GnashFactory
+{
+public:
+
+ typedef T value_type;
+ typedef Key key_type;
+
+ template<typename Derived>
+ struct RegisterHandler
+ {
+ static T* createHandler() {
+ return new Derived();
+ }
+
+ RegisterHandler(const Key& name) {
+ GnashFactory::instance().registerHandler(name, createHandler);
+ }
+ };
+
+ typedef T*(*CreateHandler)();
+ typedef std::map<std::string, CreateHandler> Handlers;
+
+ /// Get the MediaFactory singleton.
+ static GnashFactory& instance() {
+ static GnashFactory m;
+ return m;
+ }
+
+ /// Dump the registered keys to the iterator.
+ //
+ /// Only usable with output iterators.
+ template<typename Iterator>
+ void listKeys(Iterator i, typename boost::enable_if<boost::is_same<
+ typename std::iterator_traits<Iterator>::iterator_category,
+ std::output_iterator_tag> >::type* dummy = 0) {
+ static_cast<void>(dummy);
+ std::transform(_handlers.begin(), _handlers.end(), i,
+ FirstElement<typename Handlers::value_type>());
+
+ }
+
+ /// Return a MediaHandler identified by a name.
+ //
+ /// @param name The name of the handler to return. An empty string
+ /// will return the first available handler. If the
+ /// string is not empty and no match is found, a null
+ /// pointer will be returned.
+ T* get(const Key& name) {
+ if (name.empty()) {
+ return _handlers.empty() ? 0 : _handlers.begin()->second();
+ }
+
+ typename Handlers::const_iterator it = _handlers.find(name);
+ if (it == _handlers.end()) return 0;
+ return it->second();
+ }
+
+ /// Register a MediaHandler with a particular name.
+ //
+ /// @param name The name to register the MediaHandler under. Duplicated
+ /// names will replace previous handlers!
+ /// @param r A pointer to a function that will return the
+ /// MediaHandler when called.
+ void registerHandler(const Key& name, CreateHandler r) {
+ _handlers[name] = r;
+ }
+
+private:
+
+ Handlers _handlers;
+
+};
+
+} // namespace gnash
+
+#endif
=== modified file 'libbase/Makefile.am'
--- a/libbase/Makefile.am 2010-07-06 10:21:25 +0000
+++ b/libbase/Makefile.am 2010-07-14 16:00:04 +0000
@@ -181,6 +181,7 @@
arg_parser.h \
getclocktime.hpp \
GnashAlgorithm.h \
+ GnashFactory.h \
$(NULL)
if USE_PNG
=== modified file 'libcore/RunResources.h'
--- a/libcore/RunResources.h 2010-03-31 08:24:41 +0000
+++ b/libcore/RunResources.h 2010-07-14 10:47:13 +0000
@@ -32,6 +32,9 @@
namespace sound {
class sound_handler;
}
+ namespace media {
+ class MediaHandler;
+ }
}
namespace gnash {
@@ -45,7 +48,6 @@
/// This must be kept alive for the entire duration of a run (presently
/// until the last SWFMovieDefinition has been destroyed).
/// @todo Check the lifetime and update documentation if it changes.
-/// @todo Add MediaHandler.
class RunResources
{
public:
@@ -67,8 +69,7 @@
/// Set the StreamProvider.
//
/// This can probably be changed during a run without ill effects.
- void setStreamProvider(boost::shared_ptr<StreamProvider> sp)
- {
+ void setStreamProvider(boost::shared_ptr<StreamProvider> sp) {
_streamProvider = sp;
}
@@ -102,6 +103,14 @@
return _soundHandler.get();
}
+ void setMediaHandler(boost::shared_ptr<media::MediaHandler> s) {
+ _mediaHandler = s;
+ }
+
+ media::MediaHandler* mediaHandler() const {
+ return _mediaHandler.get();
+ }
+
void setRenderer(boost::shared_ptr<Renderer> r) {
_renderer = r;
}
@@ -146,6 +155,8 @@
boost::shared_ptr<StreamProvider> _streamProvider;
boost::shared_ptr<sound::sound_handler> _soundHandler;
+
+ boost::shared_ptr<media::MediaHandler> _mediaHandler;
boost::shared_ptr<Renderer> _renderer;
=== modified file 'libcore/Video.cpp'
--- a/libcore/Video.cpp 2010-07-10 13:01:35 +0000
+++ b/libcore/Video.cpp 2010-07-14 10:47:13 +0000
@@ -34,6 +34,7 @@
#include "namedStrings.h"
#include "Global_as.h"
#include "Renderer.h"
+#include "RunResources.h"
// Define this to get debug logging during embedded video decoding
//#define DEBUG_EMBEDDED_VIDEO_DECODING
@@ -66,42 +67,32 @@
{
assert(object);
assert(def);
- initializeDecoder();
-}
-
-Video::~Video()
-{
-}
-
-void
-Video::initializeDecoder()
-{
-
- media::MediaHandler* mh = media::MediaHandler::get();
- if ( ! mh )
- {
+
+ media::MediaHandler* mh = getRunResources(*object).mediaHandler();
+ if (!mh) {
LOG_ONCE( log_error(_("No Media handler registered, "
"won't be able to decode embedded video")) );
return;
}
media::VideoInfo* info = m_def->getVideoInfo();
- if ( ! info )
- {
+ if (!info) {
log_error(_("No Video info in video definition"));
return;
}
- try
- {
+ try {
_decoder = mh->createVideoDecoder(*info);
}
- catch (MediaException &e)
- {
+ catch (MediaException &e) {
log_error("Could not create Video Decoder: %s", e.what());
}
}
+Video::~Video()
+{
+}
+
int
Video::width() const
{
=== modified file 'libcore/Video.h'
--- a/libcore/Video.h 2010-07-10 13:01:35 +0000
+++ b/libcore/Video.h 2010-07-14 10:47:13 +0000
@@ -108,12 +108,6 @@
private:
- /// Initialize decoder for embedded video
- //
- /// Call only if given a non-null video definition.
- ///
- void initializeDecoder();
-
/// Get video frame to be displayed
GnashImage* getVideoFrame();
=== modified file 'libcore/asobj/Camera_as.cpp'
--- a/libcore/asobj/Camera_as.cpp 2010-07-09 06:42:56 +0000
+++ b/libcore/asobj/Camera_as.cpp 2010-07-14 10:47:13 +0000
@@ -28,6 +28,7 @@
#include "NativeFunction.h"
#include "MediaHandler.h"
#include "VideoInput.h"
+#include "RunResources.h"
#include "Object.h"
#include "namedStrings.h"
@@ -254,8 +255,9 @@
// meant, not a new object each time. It will be necessary to query
// the MediaHandler for this, and possibly to store the as_objects
// somewhere.
- //
- media::MediaHandler* handler = media::MediaHandler::get();
+ const RunResources& r = getRunResources(getGlobal(fn));
+ media::MediaHandler* handler = r.mediaHandler();
+
if (!handler) {
log_error(_("No MediaHandler exists! Cannot create a Camera object"));
return as_value();
@@ -529,7 +531,10 @@
}
std::vector<std::string> names;
- media::MediaHandler::get()->cameraNames(names);
+ media::MediaHandler* m = getRunResources(getGlobal(fn)).mediaHandler();
+ if (!m) return as_value();
+
+ m->cameraNames(names);
const size_t size = names.size();
=== modified file 'libcore/asobj/Microphone_as.cpp'
--- a/libcore/asobj/Microphone_as.cpp 2010-07-09 06:42:56 +0000
+++ b/libcore/asobj/Microphone_as.cpp 2010-07-14 10:47:13 +0000
@@ -31,8 +31,9 @@
#include "AudioInput.h"
#include "MediaHandler.h"
#include "Relay.h"
-
+#include "RunResources.h"
#include "namedStrings.h"
+
#include <algorithm>
namespace gnash {
@@ -253,8 +254,9 @@
// meant, not a new object each time. It will be necessary to query
// the MediaHandler for this, and possibly to store the as_objects
// somewhere.
- //
- media::MediaHandler* handler = media::MediaHandler::get();
+ const RunResources& r = getRunResources(getGlobal(fn));
+ media::MediaHandler* handler = r.mediaHandler();
+
if (!handler) {
log_error(_("No MediaHandler exists! Cannot create a Microphone "
"object"));
=== modified file 'libcore/asobj/NetStream_as.cpp'
--- a/libcore/asobj/NetStream_as.cpp 2010-07-09 06:58:02 +0000
+++ b/libcore/asobj/NetStream_as.cpp 2010-07-14 10:47:13 +0000
@@ -104,7 +104,7 @@
_playHead(_playbackClock.get()),
_soundHandler(getRunResources(*owner).soundHandler()),
- _mediaHandler(media::MediaHandler::get()),
+ _mediaHandler(getRunResources(*owner).mediaHandler()),
_audioStreamer(_soundHandler),
_statusCode(invalidStatus)
{
=== modified file 'libcore/asobj/Sound_as.cpp'
--- a/libcore/asobj/Sound_as.cpp 2010-07-10 06:46:47 +0000
+++ b/libcore/asobj/Sound_as.cpp 2010-07-14 10:47:13 +0000
@@ -253,7 +253,7 @@
externalSound(false),
isStreaming(false),
_soundHandler(getRunResources(*owner).soundHandler()),
- _mediaHandler(media::MediaHandler::get()),
+ _mediaHandler(getRunResources(*owner).mediaHandler()),
_startTime(0),
_leftOverData(),
_leftOverPtr(0),
=== modified file 'libcore/swf/tag_loaders.cpp'
--- a/libcore/swf/tag_loaders.cpp 2010-06-12 06:45:03 +0000
+++ b/libcore/swf/tag_loaders.cpp 2010-07-14 10:47:13 +0000
@@ -870,10 +870,11 @@
// then the amount allocated at *data (it may grow)
const unsigned dataLength = in.get_tag_end_position() - in.tell();
- // Allocate MediaHandler::getInputPadding() bytes more for the
SimpleBuffer
+ // Allocate MediaHandler::getInputPaddingSize() bytes more for the
+ // SimpleBuffer
size_t allocSize = dataLength;
- media::MediaHandler* mh = media::MediaHandler::get(); // TODO: don't
use this static !
- if ( mh ) allocSize += mh->getInputPaddingSize();
+ media::MediaHandler* mh = r.mediaHandler();
+ if (mh) allocSize += mh->getInputPaddingSize();
std::auto_ptr<SimpleBuffer> data( new SimpleBuffer(allocSize) );
=== modified file 'libmedia/Makefile.am'
--- a/libmedia/Makefile.am 2010-04-04 22:55:35 +0000
+++ b/libmedia/Makefile.am 2010-07-14 12:19:53 +0000
@@ -21,6 +21,8 @@
# this is where Gnash plugins get installed
pluginsdir = $(prefix)/lib/gnash/plugins
+AM_CXXFLAGS = $(CXXFLAGS) -DREGISTER_MEDIA_HANDLERS
+
#if INSTALL_LTDL
#LIBLTDLHEAD = $(top_srcdir)/libltdl/ltdl.h
#endif
@@ -99,7 +101,6 @@
$(NULL)
noinst_HEADERS += \
- gst/MediaHandlerGst.h \
gst/AudioDecoderGst.h \
gst/VideoDecoderGst.h \
gst/MediaParserGst.h \
@@ -141,7 +142,6 @@
$(NULL)
noinst_HEADERS += \
- ffmpeg/MediaHandlerFfmpeg.h \
ffmpeg/MediaParserFfmpeg.h \
ffmpeg/AudioDecoderFfmpeg.h \
ffmpeg/VideoDecoderFfmpeg.h \
@@ -183,7 +183,6 @@
$(NULL)
noinst_HEADERS += \
- haiku/MediaHandlerHaiku.h \
haiku/MediaParserHaiku.h \
haiku/AudioDecoderHaiku.h \
haiku/VideoDecoderHaiku.h \
@@ -232,7 +231,7 @@
endif
if ENABLE_PCH
-AM_CXXFLAGS = $(PCH_FLAGS)
+AM_CXXFLAGS += $(PCH_FLAGS)
endif
# Rebuild with GCC 4.x Mudflap support
=== modified file 'libmedia/MediaHandler.cpp'
--- a/libmedia/MediaHandler.cpp 2010-02-10 17:02:22 +0000
+++ b/libmedia/MediaHandler.cpp 2010-07-14 13:12:36 +0000
@@ -35,8 +35,6 @@
namespace gnash {
namespace media {
-std::auto_ptr<MediaHandler> MediaHandler::_handler;
-
bool
MediaHandler::isFLV(IOChannel& stream) throw (IOException)
{
=== modified file 'libmedia/MediaHandler.h'
--- a/libmedia/MediaHandler.h 2010-03-11 01:47:08 +0000
+++ b/libmedia/MediaHandler.h 2010-07-14 13:26:31 +0000
@@ -23,9 +23,12 @@
#include "MediaParser.h" // for videoCodecType and audioCodecType enums
#include "dsodefs.h" // DSOEXPORT
#include "VideoConverter.h"
+#include "GnashFactory.h"
#include <vector>
#include <memory>
+#include <map>
+#include <string>
// Forward declarations
namespace gnash {
@@ -37,6 +40,7 @@
class VideoInfo;
class VideoInput;
class AudioInput;
+ class MediaHandler;
}
}
@@ -50,14 +54,11 @@
/// The subsystem's entry point is a MediaHandler instance, which acts
/// as a factory for parsers, decoders and encoders.
///
-/// Theoretically, it should be possible for actual MediaHandler
-/// implementations to be loaded at runtime, altought this is not yet
-/// implemented at time of writing (2008/10/27).
-///
/// @todo fix http://wiki.gnashdev.org/wiki/index.php/Libmedia, is obsoleted
-///
namespace media {
+typedef GnashFactory<MediaHandler> MediaFactory;
+
/// The MediaHandler class acts as a factory to provide parser and decoders
class DSOEXPORT MediaHandler
{
@@ -65,17 +66,8 @@
virtual ~MediaHandler() {}
- /// Return currently registered MediaHandler, possibly null.
- static MediaHandler* get()
- {
- return _handler.get();
- }
-
- /// Register a MediaHandler to use
- static void set(std::auto_ptr<MediaHandler> mh)
- {
- _handler = mh;
- }
+ /// Return a description of this media handler.
+ virtual std::string description() const = 0;
/// Return an appropriate MediaParser for given input
//
@@ -164,11 +156,10 @@
/// If this cannot read the necessary 3 bytes, it throws an IOException.
bool isFLV(IOChannel& stream) throw (IOException);
+protected:
+
MediaHandler() {}
-private:
-
- static std::auto_ptr<MediaHandler> _handler;
};
=== modified file 'libmedia/ffmpeg/MediaHandlerFfmpeg.cpp'
--- a/libmedia/ffmpeg/MediaHandlerFfmpeg.cpp 2010-01-01 17:48:26 +0000
+++ b/libmedia/ffmpeg/MediaHandlerFfmpeg.cpp 2010-07-14 13:26:31 +0000
@@ -18,7 +18,8 @@
//
-#include "MediaHandlerFfmpeg.h"
+#include "MediaHandler.h"
+#include "MediaParser.h"
#include "MediaParserFfmpeg.h"
#include "VideoDecoderFfmpeg.h"
#include "AudioDecoderFfmpeg.h"
@@ -29,12 +30,43 @@
#include "AudioInputFfmpeg.h"
#include "IOChannel.h" // for visibility of destructor
-#include "MediaParser.h" // for visibility of destructor
namespace gnash {
namespace media {
namespace ffmpeg {
+/// FFMPEG based MediaHandler
+class DSOEXPORT MediaHandlerFfmpeg : public MediaHandler
+{
+public:
+
+ virtual std::string description() const {
+ return "FFmpeg Media Handler";
+ }
+
+ virtual std::auto_ptr<MediaParser>
+ createMediaParser(std::auto_ptr<IOChannel> stream);
+
+ virtual std::auto_ptr<VideoDecoder>
+ createVideoDecoder(const VideoInfo& info);
+
+ virtual std::auto_ptr<VideoConverter>
+ createVideoConverter(ImgBuf::Type4CC srcFormat,
+ ImgBuf::Type4CC dstFormat);
+
+ virtual std::auto_ptr<AudioDecoder>
+ createAudioDecoder(const AudioInfo& info);
+
+ virtual size_t getInputPaddingSize() const;
+
+ virtual VideoInput* getVideoInput(size_t index);
+
+ virtual AudioInput* getAudioInput(size_t index);
+
+ virtual void cameraNames(std::vector<std::string>& names) const;
+
+};
+
std::auto_ptr<MediaParser>
MediaHandlerFfmpeg::createMediaParser(std::auto_ptr<IOChannel> stream)
{
@@ -142,6 +174,13 @@
return FF_INPUT_BUFFER_PADDING_SIZE;
}
+#ifdef REGISTER_MEDIA_HANDLERS
+namespace {
+ MediaFactory::RegisterHandler<MediaHandlerFfmpeg> reg("ffmpeg");
+}
+#endif
+
} // gnash.media.ffmpeg namespace
} // gnash.media namespace
} // gnash namespace
+
=== removed file 'libmedia/ffmpeg/MediaHandlerFfmpeg.h'
--- a/libmedia/ffmpeg/MediaHandlerFfmpeg.h 2010-03-11 01:47:08 +0000
+++ b/libmedia/ffmpeg/MediaHandlerFfmpeg.h 1970-01-01 00:00:00 +0000
@@ -1,75 +0,0 @@
-// MediaHandlerFfmpeg.h: FFMPEG media handler, for Gnash
-//
-// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-#ifndef GNASH_MEDIAHANDLERFFMPEG_H
-#define GNASH_MEDIAHANDLERFFMPEG_H
-
-#include "MediaHandler.h" // for inheritance
-
-#include <vector>
-#include <memory>
-
-namespace gnash {
-namespace media {
-
-/// FFMPEG-based media handler module
-//
-/// The module implements the MediaHandler factory as required
-/// by Gnash core for a loadable media handler module.
-///
-/// It uses libavformat and libavcodec:
-/// http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/index.html
-///
-/// Starting point is MediaHandlerFfmpeg.
-///
-namespace ffmpeg {
-
-/// FFMPEG based MediaHandler
-class DSOEXPORT MediaHandlerFfmpeg : public MediaHandler
-{
-public:
-
- virtual std::auto_ptr<MediaParser>
- createMediaParser(std::auto_ptr<IOChannel> stream);
-
- virtual std::auto_ptr<VideoDecoder>
- createVideoDecoder(const VideoInfo& info);
-
- virtual std::auto_ptr<VideoConverter>
- createVideoConverter(ImgBuf::Type4CC srcFormat,
- ImgBuf::Type4CC dstFormat);
-
- virtual std::auto_ptr<AudioDecoder>
- createAudioDecoder(const AudioInfo& info);
-
- virtual size_t getInputPaddingSize() const;
-
- virtual VideoInput* getVideoInput(size_t index);
-
- virtual AudioInput* getAudioInput(size_t index);
-
- virtual void cameraNames(std::vector<std::string>& names) const;
-
-};
-
-
-} // gnash.media.ffmpeg namespace
-} // gnash.media namespace
-} // namespace gnash
-
-#endif
=== modified file 'libmedia/gst/MediaHandlerGst.cpp'
--- a/libmedia/gst/MediaHandlerGst.cpp 2010-01-01 17:48:26 +0000
+++ b/libmedia/gst/MediaHandlerGst.cpp 2010-07-14 13:26:31 +0000
@@ -1,4 +1,3 @@
-// MediaHandlerGst.cpp: GST media handler, for Gnash
//
// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
//
@@ -17,8 +16,10 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-
-#include "MediaHandlerGst.h"
+#include "MediaHandler.h"
+
+#include <sstream>
+
#include "VideoDecoderGst.h"
#include "AudioDecoderGst.h"
#include "MediaParserGst.h"
@@ -26,13 +27,13 @@
#include "VideoInputGst.h"
#include "AudioInputGst.h"
#include "FLVParser.h"
+#include "MediaParser.h"
#ifdef DECODING_SPEEX
#include "AudioDecoderSpeex.h"
#endif
#include "IOChannel.h" // for visibility of destructor
-#include "MediaParser.h" // for visibility of destructor
#include "MediaParserGst.h"
@@ -41,6 +42,49 @@
namespace media {
namespace gst {
+/// GST based MediaHandler
+//
+/// The module implements the MediaHandler factory as required
+/// by Gnash core for a loadable media handler module.
+///
+/// It uses gstreamer: http://gstreamer.freedesktop.org/
+///
+/// Starting point is MediaHandlerGst.
+///
+class DSOEXPORT MediaHandlerGst : public MediaHandler
+{
+public:
+
+ virtual std::string description() const {
+ guint major, minor, micro, nano;
+ gst_version(&major, &minor, µ, &nano);
+ std::ostringstream s;
+ s << _("Gstreamer Media Handler, gst version: ") << major << "."
+ << minor << "." << micro;
+ return s.str();
+ }
+
+ virtual std::auto_ptr<MediaParser>
+ createMediaParser(std::auto_ptr<IOChannel> stream);
+
+ virtual std::auto_ptr<VideoDecoder>
+ createVideoDecoder(const VideoInfo& info);
+
+ virtual std::auto_ptr<AudioDecoder>
+ createAudioDecoder(const AudioInfo& info);
+
+ virtual std::auto_ptr<VideoConverter>
+ createVideoConverter(ImgBuf::Type4CC srcFormat,
+ ImgBuf::Type4CC dstFormat);
+
+ virtual VideoInput* getVideoInput(size_t index);
+
+ virtual AudioInput* getAudioInput(size_t index);
+
+ virtual void cameraNames(std::vector<std::string>& names) const;
+};
+
+
std::auto_ptr<MediaParser>
MediaHandlerGst::createMediaParser(std::auto_ptr<IOChannel> stream)
{
@@ -177,6 +221,12 @@
VideoInputGst::getNames(names);
}
+#ifdef REGISTER_MEDIA_HANDLERS
+namespace {
+ MediaFactory::RegisterHandler<MediaHandlerGst> reg("gst");
+}
+#endif
+
} // gnash.media.gst namespace
} // gnash.media namespace
} // gnash namespace
=== removed file 'libmedia/gst/MediaHandlerGst.h'
--- a/libmedia/gst/MediaHandlerGst.h 2010-03-11 01:47:08 +0000
+++ b/libmedia/gst/MediaHandlerGst.h 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
-// MediaHandlerGst.h: GST media handler, for Gnash
-//
-// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-#ifndef GNASH_MEDIAHANDLERGST_H
-#define GNASH_MEDIAHANDLERGST_H
-
-#include "dsodefs.h" // DSOEXPORT
-#include "MediaHandler.h" // for inheritance
-
-#include <vector>
-#include <memory>
-
-namespace gnash {
-namespace media {
-
-/// Gstreamer-based media handler module
-namespace gst {
-
-/// GST based MediaHandler
-//
-/// The module implements the MediaHandler factory as required
-/// by Gnash core for a loadable media handler module.
-///
-/// It uses gstreamer: http://gstreamer.freedesktop.org/
-///
-/// Starting point is MediaHandlerGst.
-///
-class DSOEXPORT MediaHandlerGst : public MediaHandler
-{
-public:
-
- virtual std::auto_ptr<MediaParser>
- createMediaParser(std::auto_ptr<IOChannel> stream);
-
- virtual std::auto_ptr<VideoDecoder>
- createVideoDecoder(const VideoInfo& info);
-
- virtual std::auto_ptr<AudioDecoder>
- createAudioDecoder(const AudioInfo& info);
-
- virtual std::auto_ptr<VideoConverter>
- createVideoConverter(ImgBuf::Type4CC srcFormat,
- ImgBuf::Type4CC dstFormat);
-
- virtual VideoInput* getVideoInput(size_t index);
-
- virtual AudioInput* getAudioInput(size_t index);
-
- virtual void cameraNames(std::vector<std::string>& names) const;
-};
-
-
-} // gnash.media.gst namespace
-} // gnash.media namespace
-} // namespace gnash
-
-#endif
=== modified file 'libmedia/haiku/MediaHandlerHaiku.cpp'
--- a/libmedia/haiku/MediaHandlerHaiku.cpp 2010-02-17 02:21:56 +0000
+++ b/libmedia/haiku/MediaHandlerHaiku.cpp 2010-07-14 13:26:31 +0000
@@ -17,8 +17,9 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
+#include "MediaParser.h"
+
#include "log.h"
-#include "MediaHandlerHaiku.h"
#include "MediaParserHaiku.h"
#include "VideoDecoderHaiku.h"
#include "AudioDecoderHaiku.h"
@@ -31,12 +32,43 @@
#include "adipe.h"
#include "IOChannel.h" // for visibility of destructor
-#include "MediaParser.h" // for visibility of destructor
namespace gnash {
namespace media {
namespace haiku {
+/// Haiku based MediaHandler
+class DSOEXPORT MediaHandlerHaiku : public MediaHandler
+{
+public:
+
+ virtual std::string description() const {
+ return "Haiku Media Handler";
+ }
+
+ virtual std::auto_ptr<MediaParser>
+ createMediaParser(std::auto_ptr<IOChannel> stream);
+
+ virtual std::auto_ptr<VideoDecoder>
+ createVideoDecoder(const VideoInfo& info);
+
+ virtual std::auto_ptr<VideoConverter>
+ createVideoConverter(ImgBuf::Type4CC srcFormat,
+ ImgBuf::Type4CC dstFormat);
+
+ virtual std::auto_ptr<AudioDecoder>
+ createAudioDecoder(const AudioInfo& info);
+
+// virtual size_t getInputPaddingSize() const;
+
+ virtual VideoInput* getVideoInput(size_t index);
+
+ virtual AudioInput* getAudioInput(size_t index);
+
+ virtual void cameraNames(std::vector<std::string>& names) const;
+
+};
+
std::auto_ptr<MediaParser>
MediaHandlerHaiku::createMediaParser(std::auto_ptr<IOChannel> stream)
{
@@ -145,6 +177,12 @@
//// return FF_INPUT_BUFFER_PADDING_SIZE;
//}
+#ifdef REGISTER_MEDIA_HANDLERS
+namespace {
+ RegisterMediaHandler<MediaHandlerHaiku> reg("haiku");
+}
+#endif
+
} // gnash.media.haiku namespace
} // gnash.media namespace
} // gnash namespace
=== removed file 'libmedia/haiku/MediaHandlerHaiku.h'
--- a/libmedia/haiku/MediaHandlerHaiku.h 2010-03-11 01:47:08 +0000
+++ b/libmedia/haiku/MediaHandlerHaiku.h 1970-01-01 00:00:00 +0000
@@ -1,74 +0,0 @@
-// MediaHandlerHaiku.h: Haiku media kit media handler, for Gnash
-//
-// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-#ifndef GNASH_MEDIAHANDLERHAIKU_H
-#define GNASH_MEDIAHANDLERHAIKU_H
-
-#include "MediaHandler.h" // for inheritance
-
-#include <vector>
-#include <memory>
-
-namespace gnash {
-namespace media {
-
-/// Haiku media kit based media handler module
-//
-/// The module implements the MediaHandler factory as required
-/// by Gnash core for a loadable media handler module.
-///
-/// It uses the Haiku media kit
-///
-/// Starting point is MediaHandlerHaiku.
-///
-namespace haiku {
-
-/// Haiku based MediaHandler
-class DSOEXPORT MediaHandlerHaiku : public MediaHandler
-{
-public:
-
- virtual std::auto_ptr<MediaParser>
- createMediaParser(std::auto_ptr<IOChannel> stream);
-
- virtual std::auto_ptr<VideoDecoder>
- createVideoDecoder(const VideoInfo& info);
-
- virtual std::auto_ptr<VideoConverter>
- createVideoConverter(ImgBuf::Type4CC srcFormat,
- ImgBuf::Type4CC dstFormat);
-
- virtual std::auto_ptr<AudioDecoder>
- createAudioDecoder(const AudioInfo& info);
-
-// virtual size_t getInputPaddingSize() const;
-
- virtual VideoInput* getVideoInput(size_t index);
-
- virtual AudioInput* getAudioInput(size_t index);
-
- virtual void cameraNames(std::vector<std::string>& names) const;
-
-};
-
-
-} // gnash.media.haiku namespace
-} // gnash.media namespace
-} // namespace gnash
-
-#endif
=== modified file 'libsound/EmbedSound.cpp'
--- a/libsound/EmbedSound.cpp 2010-01-25 18:52:20 +0000
+++ b/libsound/EmbedSound.cpp 2010-07-14 10:47:13 +0000
@@ -47,10 +47,7 @@
// Remember size of this block, indexing by offset
m_frames_size[_buf->size()] = size;
- // Make sure we're always appropriately padded...
- media::MediaHandler* mh = media::MediaHandler::get(); // TODO: don't use
this static !
- const size_t paddingBytes = mh ? mh->getInputPaddingSize() : 0;
- _buf->reserve(_buf->size()+size+paddingBytes);
+ _buf->reserve(_buf->size() + size + _paddingBytes);
_buf->append(data, size);
// since ownership was transferred...
@@ -58,18 +55,16 @@
}
EmbedSound::EmbedSound(std::auto_ptr<SimpleBuffer> data,
- std::auto_ptr<media::SoundInfo> info, int nVolume)
+ std::auto_ptr<media::SoundInfo> info, int nVolume, size_t paddingBytes)
:
_buf(data),
soundinfo(info),
- volume(nVolume)
+ volume(nVolume),
+ _paddingBytes(paddingBytes)
{
if ( _buf.get() )
{
- // Make sure we're appropriately padded (this is an event sound)
- media::MediaHandler* mh = media::MediaHandler::get(); // TODO: don't
use this static !
- const size_t paddingBytes = mh ? mh->getInputPaddingSize() : 0;
- if ( _buf->capacity() - _buf->size() < paddingBytes ) {
+ if (_buf->capacity() - _buf->size() < paddingBytes) {
log_error("EmbedSound creator didn't appropriately pad sound data.
"
"We'll do now, but will cost memory copies.");
_buf->reserve(_buf->size()+paddingBytes);
=== modified file 'libsound/EmbedSound.h'
--- a/libsound/EmbedSound.h 2010-03-11 01:47:08 +0000
+++ b/libsound/EmbedSound.h 2010-07-14 10:47:13 +0000
@@ -65,7 +65,9 @@
///
/// @param nVolume initial volume (0..100). Optional, defaults to 100.
///
- EmbedSound(std::auto_ptr<SimpleBuffer> data,
std::auto_ptr<media::SoundInfo> info, int nVolume=100);
+ EmbedSound(std::auto_ptr<SimpleBuffer> data,
+ std::auto_ptr<media::SoundInfo> info, int nVolume,
+ size_t paddingBytes);
~EmbedSound();
@@ -245,6 +247,8 @@
/// @todo make private and mark EmbedSoundInst as friend ?
///
void eraseActiveSound(EmbedSoundInst* inst);
+
+ const size_t _paddingBytes;
};
} // gnash.sound namespace
=== modified file 'libsound/NullSoundHandler.h'
--- a/libsound/NullSoundHandler.h 2010-03-11 01:47:08 +0000
+++ b/libsound/NullSoundHandler.h 2010-07-14 13:43:06 +0000
@@ -25,6 +25,11 @@
#include "dsodefs.h" // for DSOEXPORT
namespace gnash {
+
+namespace media {
+ class MediaHandler;
+}
+
namespace sound {
/// Null sound_handler, for testing
@@ -34,6 +39,8 @@
class DSOEXPORT NullSoundHandler : public sound_handler
{
public:
+ NullSoundHandler(media::MediaHandler* m) : sound_handler(m) {}
+
};
} // gnash.sound namespace
=== modified file 'libsound/sdl/sound_handler_sdl.cpp'
--- a/libsound/sdl/sound_handler_sdl.cpp 2010-01-25 18:52:20 +0000
+++ b/libsound/sdl/sound_handler_sdl.cpp 2010-07-14 10:47:13 +0000
@@ -123,8 +123,10 @@
}
-SDL_sound_handler::SDL_sound_handler(const std::string& wavefile)
+SDL_sound_handler::SDL_sound_handler(media::MediaHandler* m,
+ const std::string& wavefile)
:
+ sound_handler(m),
_audioOpened(false)
{
@@ -144,8 +146,9 @@
}
-SDL_sound_handler::SDL_sound_handler()
+SDL_sound_handler::SDL_sound_handler(media::MediaHandler* m)
:
+ sound_handler(m),
_audioOpened(false)
{
initAudio();
@@ -259,17 +262,15 @@
}
sound_handler*
-create_sound_handler_sdl()
-// Factory.
+create_sound_handler_sdl(media::MediaHandler* m)
{
- return new SDL_sound_handler;
+ return new SDL_sound_handler(m);
}
sound_handler*
-create_sound_handler_sdl(const std::string& wave_file)
-// Factory.
+create_sound_handler_sdl(media::MediaHandler* m, const std::string& wave_file)
{
- return new SDL_sound_handler(wave_file);
+ return new SDL_sound_handler(m, wave_file);
}
// write a wave header, using the current audioSpec settings
=== modified file 'libsound/sdl/sound_handler_sdl.h'
--- a/libsound/sdl/sound_handler_sdl.h 2010-03-11 01:47:08 +0000
+++ b/libsound/sdl/sound_handler_sdl.h 2010-07-14 10:47:13 +0000
@@ -99,9 +99,9 @@
public:
- SDL_sound_handler();
+ SDL_sound_handler(media::MediaHandler* m);
- SDL_sound_handler(const std::string& wave_file);
+ SDL_sound_handler(media::MediaHandler* m, const std::string& wave_file);
~SDL_sound_handler();
=== modified file 'libsound/sound_handler.cpp'
--- a/libsound/sound_handler.cpp 2010-01-25 18:52:20 +0000
+++ b/libsound/sound_handler.cpp 2010-07-14 13:43:06 +0000
@@ -309,7 +309,9 @@
{
assert(sinfo.get());
- std::auto_ptr<EmbedSound> sounddata ( new EmbedSound(data, sinfo) );
+ std::auto_ptr<EmbedSound> sounddata(
+ new EmbedSound(data, sinfo, 100,
+ _mediaHandler ? _mediaHandler->getInputPaddingSize() : 0));
int sound_id = _sounds.size();
@@ -364,12 +366,10 @@
void
-sound_handler::playSound(int sound_handle, int loopCount,
- unsigned int inPoint,
- unsigned int outPoint,
- StreamBlockId blockId,
- const SoundEnvelopes* envelopes,
- bool allowMultiples)
+sound_handler::playSound(int sound_handle,
+ int loopCount, unsigned int inPoint, unsigned int outPoint,
+ StreamBlockId blockId, const SoundEnvelopes* envelopes,
+ bool allowMultiples)
{
assert (sound_handle >= 0 && static_cast<unsigned int>(sound_handle) <
_sounds.size());
=== modified file 'libsound/sound_handler.h'
--- a/libsound/sound_handler.h 2010-03-11 01:47:08 +0000
+++ b/libsound/sound_handler.h 2010-07-14 10:47:13 +0000
@@ -412,19 +412,17 @@
protected:
- sound_handler()
+ sound_handler(media::MediaHandler* m)
:
_soundsStarted(0),
_soundsStopped(0),
_paused(false),
_muted(false),
- _mediaHandler(media::MediaHandler::get()),
_volume(100),
_sounds(),
- _inputStreams()
+ _inputStreams(),
+ _mediaHandler(m)
{
- // for now, we rely on this being always available
- assert(_mediaHandler);
}
/// Plug an InputStream to the mixer
@@ -482,9 +480,6 @@
/// True if sound is muted
bool _muted;
- /// The registered MediaHandler at construction time
- media::MediaHandler* _mediaHandler;
-
/// Final output volume
int _volume;
@@ -507,6 +502,8 @@
///
InputStreams _inputStreams;
+ media::MediaHandler* _mediaHandler;
+
/// Unplug any completed input stream
void unplugCompletedInputStreams();
@@ -575,23 +572,26 @@
#ifdef SOUND_SDL
/// @throw a SoundException if fails to initialize audio card.
-DSOEXPORT sound_handler* create_sound_handler_sdl();
+DSOEXPORT sound_handler* create_sound_handler_sdl(media::MediaHandler* m);
/// @throw a SoundException if fails to initialize audio card.
-DSOEXPORT sound_handler* create_sound_handler_sdl(const std::string&
wave_file);
+DSOEXPORT sound_handler* create_sound_handler_sdl(media::MediaHandler* m,
+ const std::string& wave_file);
#elif defined(SOUND_AHI)
/// @throw a SoundException if fails to initialize audio card.
-DSOEXPORT sound_handler* create_sound_handler_aos4();
+DSOEXPORT sound_handler* create_sound_handler_aos4(media::MediaHandler* m);
/// @throw a SoundException if fails to initialize audio card.
-DSOEXPORT sound_handler* create_sound_handler_aos4(const std::string&
wave_file);
+DSOEXPORT sound_handler* create_sound_handler_aos4(media::MediaHandler* m
+ const std::string& wave_file);
#elif defined(SOUND_MKIT)
/// @throw a SoundException if fails to create node.
-DSOEXPORT sound_handler* create_sound_handler_mkit();
+DSOEXPORT sound_handler* create_sound_handler_mkit(media::MediaHandler* m);
/// @throw a SoundException if fails to create node.
-DSOEXPORT sound_handler* create_sound_handler_mkit(const std::string&
wave_file);
+DSOEXPORT sound_handler* create_sound_handler_mkit(media::MediaHandler* m,
+ const std::string& wave_file);
#endif
} // gnash.sound namespace
=== modified file 'testsuite/MovieTester.cpp'
--- a/testsuite/MovieTester.cpp 2010-07-12 07:48:07 +0000
+++ b/testsuite/MovieTester.cpp 2010-07-14 13:43:06 +0000
@@ -36,6 +36,9 @@
#include "StreamProvider.h" // for passing to RunResources
#include "swf/TagLoadersTable.h"
#include "swf/DefaultTagLoaders.h"
+
+#include "MediaHandler.h"
+
#ifdef RENDERER_CAIRO
# include "Renderer_cairo.h"
#endif
@@ -47,11 +50,6 @@
#endif
#include "MediaHandler.h"
-#ifdef USE_FFMPEG
-# include "ffmpeg/MediaHandlerFfmpeg.h"
-#elif defined(USE_GST)
-# include "gst/MediaHandlerGst.h"
-#endif
#include <cstdio>
#include <string>
@@ -88,6 +86,7 @@
_runResources.reset(new RunResources(url));
_runResources->setSoundHandler(_sound_handler);
+ _runResources->setMediaHandler(_mediaHandler);
boost::shared_ptr<SWF::TagLoadersTable> loaders(new
SWF::TagLoadersTable());
addDefaultLoaders(*loaders);
@@ -569,29 +568,17 @@
// Currently, SoundHandler can't be constructed
// w/out a registered MediaHandler .
// Should be fixed though...
- //
- if ( gnash::media::MediaHandler::get() ) {
- log_error("MediaHandler::get returns: %s",
- gnash::media::MediaHandler::get());
- _sound_handler.reset( new sound::NullSoundHandler() );
+ if (_mediaHandler.get()) {
+ log_error("MediaHandler::get returns: %s", _mediaHandler.get());
+ _sound_handler.reset(new sound::NullSoundHandler(_mediaHandler.get()));
}
}
void
MovieTester::initTestingMediaHandlers()
{
- std::auto_ptr<media::MediaHandler> handler;
-
-#ifdef USE_FFMPEG
- handler.reset( new gnash::media::ffmpeg::MediaHandlerFfmpeg() );
-#elif defined(USE_GST)
- handler.reset( new gnash::media::gst::MediaHandlerGst() );
-#else
- std::cerr << "Neigther SOUND_SDL nor SOUND_GST defined" << std::endl;
- return;
-#endif
-
- gnash::media::MediaHandler::set(handler);
+ // TODO: allow selection.
+ _mediaHandler.reset(media::MediaFactory::instance().get(""));
}
void
=== modified file 'testsuite/MovieTester.h'
--- a/testsuite/MovieTester.h 2010-07-10 09:23:03 +0000
+++ b/testsuite/MovieTester.h 2010-07-14 10:47:13 +0000
@@ -332,6 +332,8 @@
boost::shared_ptr<sound::sound_handler> _sound_handler;
+ boost::shared_ptr<media::MediaHandler> _mediaHandler;
+
std::auto_ptr<RunResources> _runResources;
/// Current pointer position - X ordinate
int _x;
=== modified file 'utilities/processor.cpp'
--- a/utilities/processor.cpp 2010-07-11 06:43:23 +0000
+++ b/utilities/processor.cpp 2010-07-14 13:43:06 +0000
@@ -23,11 +23,6 @@
#endif
#include "NullSoundHandler.h"
-#ifdef USE_FFMPEG
-# include "ffmpeg/MediaHandlerFfmpeg.h"
-#elif defined(USE_GST)
-# include "gst/MediaHandlerGst.h"
-#endif
#include <ios>
#include <iostream>
@@ -355,20 +350,11 @@
}
- std::auto_ptr<gnash::media::MediaHandler> mediaHandler;
+ boost::shared_ptr<gnash::media::MediaHandler> mediaHandler;
boost::shared_ptr<sound::sound_handler> soundHandler;
-#ifdef USE_FFMPEG
- mediaHandler.reset( new gnash::media::ffmpeg::MediaHandlerFfmpeg() );
-#elif defined(USE_GST)
- mediaHandler.reset( new gnash::media::gst::MediaHandlerGst() );
-#endif
-
- if ( mediaHandler.get() )
- {
- gnash::media::MediaHandler::set(mediaHandler);
- soundHandler.reset( new sound::NullSoundHandler() );
- }
+ mediaHandler.reset(media::MediaFactory::instance().get(""));
+ soundHandler.reset(new sound::NullSoundHandler(mediaHandler.get()));
boost::shared_ptr<StreamProvider> sp(new StreamProvider);
@@ -383,6 +369,7 @@
RunResources runResources(*i);
runResources.setSoundHandler(soundHandler);
+ runResources.setMediaHandler(mediaHandler);
runResources.setStreamProvider(sp);
runResources.setTagLoaders(loaders);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r12302: Allow selection of media handlers at runtime. If none is selected, the,
Benjamin Wolsey <=