15 #include "movieTypeRegistry.h" 16 #include "string_utils.h" 17 #include "config_movies.h" 18 #include "config_util.h" 36 if (_deferred_audio_types.count(ext)) {
38 _deferred_audio_types.erase(ext);
42 if (_audio_type_registry.count(ext)) {
43 MakeAudioFunc func = _audio_type_registry[ext];
49 if (_deferred_audio_types.count(
"*")) {
51 _deferred_audio_types.erase(
"*");
54 if (_audio_type_registry.count(
"*")) {
55 MakeAudioFunc func = _audio_type_registry[
"*"];
60 <<
"Support for audio files with extension ." << ext <<
" was not enabled.\n";
75 extract_words(downcase(extensions), words);
77 vector_string::const_iterator wi;
78 for (wi = words.begin(); wi != words.end(); ++wi) {
79 if (_audio_type_registry.count(*wi)) {
81 <<
"Attempt to register multiple audio types with extension " << (*wi) <<
"\n";
84 <<
"Registered audio type with extension " << (*wi) <<
"\n";
86 _audio_type_registry[*wi] = func;
98 static bool audio_types_loaded =
false;
100 if (!audio_types_loaded) {
103 for (
int i = 0; i < num_unique_values; i++) {
107 extract_words(param, words);
109 if (words.size() == 1) {
111 string name = words[0];
112 Filename dlname = Filename::dso_filename(
"lib" + name +
".so");
114 <<
"loading audio type module: " << name << endl;
115 void *tmp = load_dso(get_plugin_path().get_value(), dlname);
116 if (tmp == (
void *)NULL) {
119 <<
": " << load_dso_error() << endl;
120 }
else if (movies_cat.is_debug()) {
122 <<
"done loading audio type module: " << name << endl;
125 }
else if (words.size() > 1) {
129 size_t num_extensions = words.size() - 1;
130 string library_name = words[num_extensions];
132 for (
size_t i = 0; i < num_extensions; i++) {
133 string extension = downcase(words[i]);
134 if (extension[0] ==
'.') {
135 extension = extension.substr(1);
138 _deferred_audio_types[extension] = library_name;
143 audio_types_loaded =
true;
160 if (_deferred_video_types.count(ext)) {
162 _deferred_video_types.erase(ext);
166 if (_video_type_registry.count(ext)) {
167 MakeVideoFunc func = _video_type_registry[ext];
168 return (*func)(name);
173 if (_deferred_video_types.count(
"*")) {
175 _deferred_video_types.erase(
"*");
178 if (_video_type_registry.count(
"*")) {
179 MakeVideoFunc func = _video_type_registry[
"*"];
180 return (*func)(name);
184 <<
"Support for video files with extension ." << ext <<
" was not enabled.\n";
199 extract_words(downcase(extensions), words);
201 vector_string::const_iterator wi;
202 for (wi = words.begin(); wi != words.end(); ++wi) {
203 if (_video_type_registry.count(*wi)) {
204 movies_cat->warning()
205 <<
"Attempt to register multiple video types with extension " << (*wi) <<
"\n";
208 <<
"Registered video type with extension " << (*wi) <<
"\n";
210 _video_type_registry[*wi] = func;
222 static bool video_types_loaded =
false;
224 if (!video_types_loaded) {
227 for (
int i = 0; i < num_unique_values; i++) {
231 extract_words(param, words);
233 if (words.size() == 1) {
235 string name = words[0];
236 Filename dlname = Filename::dso_filename(
"lib" + name +
".so");
238 <<
"loading video type module: " << name << endl;
239 void *tmp = load_dso(get_plugin_path().get_value(), dlname);
240 if (tmp == (
void *)NULL) {
243 <<
": " << load_dso_error() << endl;
244 }
else if (movies_cat.is_debug()) {
246 <<
"done loading video type module: " << name << endl;
249 }
else if (words.size() > 1) {
253 size_t num_extensions = words.size() - 1;
254 string library_name = words[num_extensions];
256 for (
size_t i = 0; i < num_extensions; i++) {
257 string extension = downcase(words[i]);
258 if (extension[0] ==
'.') {
259 extension = extension.substr(1);
262 _deferred_video_types[extension] = library_name;
267 video_types_loaded =
true;
278 Filename dlname = Filename::dso_filename(
"lib" + name +
".so");
280 <<
"loading video type module: " << name << endl;
281 void *tmp = load_dso(get_plugin_path().get_value(), dlname);
283 if (tmp == (
void *)NULL) {
286 <<
": " << load_dso_error() << endl;
287 }
else if (movies_cat.is_debug()) {
289 <<
"done loading video type module: " << name << endl;
void register_audio_type(MakeAudioFunc func, const string &extensions)
Registers a MovieAudio type, so that files with any of the given extensions will be loaded as this ty...
void register_video_type(MakeVideoFunc func, const string &extensions)
Registers a MovieVideo type, so that files with any of the given extensions will be loaded as this ty...
void load_audio_types()
Loads the list with audio types, if we haven't already.
This class records the different types of MovieAudio and MovieVideo that are available for loading...
void load_movie_library(const string &name)
Loads the module.
string get_extension() const
Returns the file extension.
The name of a file, such as a texture file or an Egg file.
string get_unique_value(int n) const
Returns the nth unique value of the variable.
A MovieVideo is actually any source that provides a sequence of video frames.
int get_num_unique_values() const
Returns the number of unique values in the variable.
void load_video_types()
Loads the list with video types, if we haven't already.
A MovieAudio is actually any source that provides a sequence of audio samples.
string to_os_specific() const
Converts the filename from our generic Unix-like convention (forward slashes starting with the root a...