1 // RunResources.h Hold external and per-run resources for Gnash core.
3 // Copyright (C) 2007, 2008, 2009, 2010, 2011. 2012
4 // Free Software Foundation, Inc.
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef GNASH_RUN_INFO_H
22 #define GNASH_RUN_INFO_H
25 #include <boost/shared_ptr.hpp>
26 #include "StreamProvider.h"
28 #include "sound_handler.h"
29 #include "MediaHandler.h"
30 #include "TagLoadersTable.h"
34 /// Class to group together per-run and external resources for Gnash
36 /// This holds the following resources:
37 /// - sound::sound_handler
39 /// In addition, it stores the constant base URL for the run.
40 /// This must be kept alive for the entire duration of a run (presently
41 /// until the last SWFMovieDefinition has been destroyed).
42 /// @todo Check the lifetime and update documentation if it changes.
47 /// Constructs a RunResources instance with an immutable base URL.
49 /// @param baseURL The base URL for the run. This cannot be changed after
53 /// Set the StreamProvider.
55 /// This can probably be changed during a run without ill effects.
56 void setStreamProvider(boost::shared_ptr
<StreamProvider
> sp
) {
60 /// Get a StreamProvider instance.
62 /// This isn't optional. It must always be available, or nothing
65 /// @return A StreamProvider
66 const StreamProvider
& streamProvider() const {
67 assert (_streamProvider
.get());
68 return *_streamProvider
;
71 /// Set the sound::sound_handler.
73 /// @param s A pointer to the sound::sound_handler for use
74 /// by Gnash core. This may also be NULL.
76 /// This is cached in various places, so changing it during a run will
77 /// lead to unexpected behaviour.
78 void setSoundHandler(boost::shared_ptr
<sound::sound_handler
> s
) {
82 /// Get a pointer to a sound::sound_handler set by a hosting application.
84 /// @return A pointer to a sound::sound_handler, or NULL if none
86 sound::sound_handler
* soundHandler() const {
87 return _soundHandler
.get();
90 void setMediaHandler(boost::shared_ptr
<media::MediaHandler
> s
) {
94 media::MediaHandler
* mediaHandler() const {
95 return _mediaHandler
.get();
98 void setRenderer(boost::shared_ptr
<Renderer
> r
) {
102 Renderer
* renderer() const {
103 return _renderer
.get();
106 /// Set the loader functions for SWF parsing.
108 /// This must be present before parsing.
109 /// It is a pointer to const so that the same table can be shared between
110 /// simultaneous runs if desired.
111 void setTagLoaders(boost::shared_ptr
<const SWF::TagLoadersTable
> loaders
) {
112 _tagLoaders
= loaders
;
115 /// Get the loader function table for parsing a SWF.
116 const SWF::TagLoadersTable
& tagLoaders() const {
117 assert(_tagLoaders
.get());
122 /// Set the renderer backend, agg, opengl, or cairo. This is set
123 /// in the users gnashrc file, or can be overridden with the
124 /// --hwaccel option to gnash.
125 void setRenderBackend(const std::string
& x
) { _renderer_backend
= x
; }
126 std::string
& getRenderBackend() { return _renderer_backend
; }
128 /// Set the hardware video accleration backend, none, vaapi, xv,
129 /// or cairo. This is set in the users gnashrc file, or can be
130 /// overridden with the --render-mode option to gnash.
131 std::string
& getHWAccelBackend() { return _hwaccel_backend
; }
132 void setHWAccelBackend(const std::string
& x
) { _hwaccel_backend
= x
; }
137 boost::shared_ptr
<StreamProvider
> _streamProvider
;
139 boost::shared_ptr
<sound::sound_handler
> _soundHandler
;
141 boost::shared_ptr
<media::MediaHandler
> _mediaHandler
;
143 boost::shared_ptr
<Renderer
> _renderer
;
145 boost::shared_ptr
<const SWF::TagLoadersTable
> _tagLoaders
;
148 /// Whether to ue HW video decoding support, no value means disabled.
149 /// The only currently supported values are: none, vaapi, or xv (omap)
150 /// support coming. The default is none,
151 std::string _hwaccel_backend
;
153 /// Which renderer backend to use, no value means use the default.
154 /// The currently supported values are agg, opengl, or cairo. AGG
155 /// being the default.
156 std::string _renderer_backend
;
160 } // end of gnash namespace
166 // indent-tabs-mode: t