update copyright date
[gnash.git] / libcore / RunResources.h
blobf9fa96c664d950963e3c19d8ada394000efa1912
1 // RunResources.h Hold external and per-run resources for Gnash core.
2 //
3 // Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef GNASH_RUN_INFO_H
21 #define GNASH_RUN_INFO_H
23 #include <string>
24 #include <boost/shared_ptr.hpp>
25 #include "StreamProvider.h"
26 #include "Renderer.h"
27 #include "sound_handler.h"
28 #include "MediaHandler.h"
29 #include "TagLoadersTable.h"
31 namespace gnash {
33 /// Class to group together per-run and external resources for Gnash
35 /// This holds the following resources:
36 /// - sound::sound_handler
37 /// - StreamProvider
38 /// In addition, it stores the constant base URL for the run.
39 /// This must be kept alive for the entire duration of a run (presently
40 /// until the last SWFMovieDefinition has been destroyed).
41 /// @todo Check the lifetime and update documentation if it changes.
42 class RunResources
44 public:
46 /// Constructs a RunResources instance with an immutable base URL.
48 /// @param baseURL The base URL for the run. This cannot be changed after
49 /// construction.
50 RunResources() {}
52 /// Set the StreamProvider.
54 /// This can probably be changed during a run without ill effects.
55 void setStreamProvider(boost::shared_ptr<StreamProvider> sp) {
56 _streamProvider = sp;
59 /// Get a StreamProvider instance.
61 /// This isn't optional. It must always be available, or nothing
62 /// can be loaded.
64 /// @return A StreamProvider
65 const StreamProvider& streamProvider() const {
66 assert (_streamProvider.get());
67 return *_streamProvider;
70 /// Set the sound::sound_handler.
72 /// @param s A pointer to the sound::sound_handler for use
73 /// by Gnash core. This may also be NULL.
75 /// This is cached in various places, so changing it during a run will
76 /// lead to unexpected behaviour.
77 void setSoundHandler(boost::shared_ptr<sound::sound_handler> s) {
78 _soundHandler = s;
81 /// Get a pointer to a sound::sound_handler set by a hosting application.
83 /// @return A pointer to a sound::sound_handler, or NULL if none
84 /// has yet been set.
85 sound::sound_handler* soundHandler() const {
86 return _soundHandler.get();
89 void setMediaHandler(boost::shared_ptr<media::MediaHandler> s) {
90 _mediaHandler = s;
93 media::MediaHandler* mediaHandler() const {
94 return _mediaHandler.get();
97 void setRenderer(boost::shared_ptr<Renderer> r) {
98 _renderer = r;
101 Renderer* renderer() const {
102 return _renderer.get();
105 /// Set the loader functions for SWF parsing.
107 /// This must be present before parsing.
108 /// It is a pointer to const so that the same table can be shared between
109 /// simultaneous runs if desired.
110 void setTagLoaders(boost::shared_ptr<const SWF::TagLoadersTable> loaders) {
111 _tagLoaders = loaders;
114 /// Get the loader function table for parsing a SWF.
115 const SWF::TagLoadersTable& tagLoaders() const {
116 assert(_tagLoaders.get());
117 return *_tagLoaders;
120 #if 1
121 /// Set the renderer backend, agg, opengl, or cairo. This is set
122 /// in the users gnashrc file, or can be overridden with the
123 /// --hwaccel option to gnash.
124 void setRenderBackend(const std::string& x) { _renderer_backend = x; }
125 std::string& getRenderBackend() { return _renderer_backend; }
127 /// Set the hardware video accleration backend, none, vaapi, xv,
128 /// or cairo. This is set in the users gnashrc file, or can be
129 /// overridden with the --render-mode option to gnash.
130 std::string& getHWAccelBackend() { return _hwaccel_backend; }
131 void setHWAccelBackend(const std::string& x) { _hwaccel_backend = x; }
132 #endif
134 private:
136 boost::shared_ptr<StreamProvider> _streamProvider;
138 boost::shared_ptr<sound::sound_handler> _soundHandler;
140 boost::shared_ptr<media::MediaHandler> _mediaHandler;
142 boost::shared_ptr<Renderer> _renderer;
144 boost::shared_ptr<const SWF::TagLoadersTable> _tagLoaders;
146 #if 1
147 /// Whether to ue HW video decoding support, no value means disabled.
148 /// The only currently supported values are: none, vaapi, or xv (omap)
149 /// support coming. The default is none,
150 std::string _hwaccel_backend;
152 /// Which renderer backend to use, no value means use the default.
153 /// The currently supported values are agg, opengl, or cairo. AGG
154 /// being the default.
155 std::string _renderer_backend;
156 #endif
159 } // end of gnash namespace
161 #endif
163 // local Variables:
164 // mode: C++
165 // indent-tabs-mode: t
166 // End: