1 //
2 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 //   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
18 
19 
20 #ifndef GNASH_MOVIE_FACTORY_H
21 #define GNASH_MOVIE_FACTORY_H
22 
23 #include "dsodefs.h"
24 
25 #include <boost/intrusive_ptr.hpp>
26 #include <string>
27 #include <memory>
28 
29 namespace gnash {
30     class IOChannel;
31     class RunResources;
32     class movie_definition;
33     class URL;
34     class MovieLibrary;
35 }
36 
37 namespace gnash {
38 
39 class MovieFactory
40 {
41 public:
42 
43     /// Create a gnash::movie_definition from the given URL
44     //
45     /// The URL can correspond to either a JPEG or SWF file.
46     ///
47     /// This is just like create_movie(), except that it checks the
48     /// "library" to see if a movie of this name has already been
49     /// created, and returns that movie if so.  Also, if it creates
50     /// a new movie, it adds it back into the library.
51     ///
52     /// The "library" is used when importing symbols from external
53     /// movies, so this call might be useful if you want to
54     /// explicitly load a movie that you know exports symbols
55     /// (e.g. fonts) to other movies as well.
56     ///
57     /// @@ this explanation/functionality could be clearer!
58     ///
59     /// If real_url is given, the movie's url will be set to that value.
60     ///
61     /// @param url
62     /// The URL to load the movie from.
63     ///
64     /// @param runResources
65     /// A RunResources containing resources needed for parsing, such as the
66     /// base URL for the run, the sound::sound_handler, and a StreamProvider.
67     ///
68     /// @param real_url
69     /// The url to encode as the _url member of the resulting
70     /// movie definition. Use NULL if it is not different from
71     /// the actual url (default). This is used to simulate a run from
72     /// the official publication url.
73     ///
74     /// @param startLoaderThread
75     /// If false only the header will be read, and you'll need to call
76     /// completeLoad on the returned movie_definition to actually start it.
77     /// This is typically used to postpone parsing until a VirtualMachine
78     /// is initialized. Initializing the VirtualMachine requires a target
79     /// SWF version, which can be found in the SWF header.
80     ///
81     /// @param postdata
82     /// If not NULL, use POST method (only valid for HTTP).
83     /// NOTE: when POSTing, the movies library won't be used.
84     static DSOEXPORT boost::intrusive_ptr<movie_definition> makeMovie(
85         const URL& url, const RunResources& runResources,
86         const char* real_url = nullptr, bool startLoaderThread = true,
87         const std::string* postdata = nullptr);
88 
89     /// Load a movie from an already opened stream.
90     //
91     /// The movie can be both an SWF or JPEG, the url parameter
92     /// will be used to set the _url member of the resulting object.
93     ///
94     /// @param in
95     /// The stream to load the movie from. Ownership is transferred
96     /// to the returned object.
97     ///
98     /// @param url
99     /// The url to use as the _url member of the resulting
100     /// movie definition. This is required as it can not be
101     /// derived from the IOChannel.
102     ///
103     /// @param runResources
104     /// A RunResources containing resources needed for parsing, such as the
105     /// base URL for the run, the sound::sound_handler, and a StreamProvider.
106     ///
107     /// @param startLoaderThread
108     /// If false only the header will be read, and you'll need to call
109     /// completeLoad on the returned movie_definition to actually start it.
110     /// This is typically used to postpone parsing until a VirtualMachine
111     /// is initialized. Initializing the VirtualMachine requires a target
112     /// SWF version, which can be found in the SWF header.
113     static DSOEXPORT boost::intrusive_ptr<movie_definition> makeMovie(
114             std::unique_ptr<IOChannel> in, const std::string& url,
115             const RunResources& runResources, bool startLoaderThread);
116 
117     /// Clear the MovieFactory resources
118     //
119     /// This should be in the dtor.
120     static DSOEXPORT void clear();
121 
122     static MovieLibrary movieLibrary;
123 };
124 
125 } // namespace gnash
126 
127 
128 #endif // GNASH_IMPL_H
129 
130 
131 // Local Variables:
132 // mode: C++
133 // indent-tabs-mode: t
134 // End:
135