40 if (_deferred_audio_types.count(ext)) {
42 _deferred_audio_types.erase(ext);
46 if (_audio_type_registry.count(ext)) {
47 MakeAudioFunc func = _audio_type_registry[ext];
54 if (_deferred_audio_types.count(
"*")) {
56 _deferred_audio_types.erase(
"*");
59 if (_audio_type_registry.count(
"*")) {
60 MakeAudioFunc func = _audio_type_registry[
"*"];
66 <<
"Support for audio files with extension ." << ext <<
" was not enabled.\n";
82 vector_string::const_iterator wi;
83 for (wi = words.begin(); wi != words.end(); ++wi) {
84 if (_audio_type_registry.count(*wi)) {
86 <<
"Attempt to register multiple audio types with extension " << (*wi) <<
"\n";
89 <<
"Registered audio type with extension " << (*wi) <<
"\n";
91 _audio_type_registry[*wi] = func;
101 static bool audio_types_loaded =
false;
103 if (!audio_types_loaded) {
106 for (
int i = 0; i < num_unique_values; i++) {
112 if (words.size() == 1) {
114 string name = words[0];
115 Filename dlname = Filename::dso_filename(
"lib" + name +
".so");
117 <<
"loading audio type module: " << name << endl;
118 void *tmp = load_dso(get_plugin_path().get_value(), dlname);
119 if (tmp ==
nullptr) {
122 <<
": " << load_dso_error() << endl;
123 }
else if (movies_cat.is_debug()) {
125 <<
"done loading audio type module: " << name << endl;
128 }
else if (words.size() > 1) {
132 size_t num_extensions = words.size() - 1;
133 string library_name = words[num_extensions];
135 for (
size_t i = 0; i < num_extensions; i++) {
136 string extension =
downcase(words[i]);
137 if (extension[0] ==
'.') {
138 extension = extension.substr(1);
141 _deferred_audio_types[extension] = library_name;
146 audio_types_loaded =
true;
163 if (_deferred_video_types.count(ext)) {
165 _deferred_video_types.erase(ext);
169 if (_video_type_registry.count(ext)) {
170 MakeVideoFunc func = _video_type_registry[ext];
172 return (*func)(name);
177 if (_deferred_video_types.count(
"*")) {
179 _deferred_video_types.erase(
"*");
182 if (_video_type_registry.count(
"*")) {
183 MakeVideoFunc func = _video_type_registry[
"*"];
185 return (*func)(name);
189 <<
"Support for video files with extension ." << ext <<
" was not enabled.\n";
205 vector_string::const_iterator wi;
206 for (wi = words.begin(); wi != words.end(); ++wi) {
207 if (_video_type_registry.count(*wi)) {
208 movies_cat->warning()
209 <<
"Attempt to register multiple video types with extension " << (*wi) <<
"\n";
212 <<
"Registered video type with extension " << (*wi) <<
"\n";
214 _video_type_registry[*wi] = func;
224 static bool video_types_loaded =
false;
226 if (!video_types_loaded) {
229 for (
int i = 0; i < num_unique_values; i++) {
235 if (words.size() == 1) {
237 string name = words[0];
238 Filename dlname = Filename::dso_filename(
"lib" + name +
".so");
240 <<
"loading video type module: " << name << endl;
241 void *tmp = load_dso(get_plugin_path().get_value(), dlname);
242 if (tmp ==
nullptr) {
245 <<
": " << load_dso_error() << endl;
246 }
else if (movies_cat.is_debug()) {
248 <<
"done loading video type module: " << name << endl;
251 }
else if (words.size() > 1) {
255 size_t num_extensions = words.size() - 1;
256 string library_name = words[num_extensions];
258 for (
size_t i = 0; i < num_extensions; i++) {
259 string extension =
downcase(words[i]);
260 if (extension[0] ==
'.') {
261 extension = extension.substr(1);
264 _deferred_video_types[extension] = library_name;
269 video_types_loaded =
true;
279 Filename dlname = Filename::dso_filename(
"lib" + name +
".so");
281 <<
"loading video type module: " << name << endl;
282 void *tmp = load_dso(get_plugin_path().get_value(), dlname);
284 if (tmp ==
nullptr) {
287 <<
": " << load_dso_error() << endl;
288 }
else if (movies_cat.is_debug()) {
290 <<
"done loading video type module: " << name << endl;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
size_t get_num_unique_values() const
Returns the number of unique values in the variable.
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.
string downcase(const string &s)
Returns the input string with all uppercase letters converted to lowercase.
void lock()
Alias for acquire() to match C++11 semantics.
PT(MovieAudio) MovieTypeRegistry
Obtains a MovieVideo that references a file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int extract_words(const string &str, vector_string &words)
Divides the string into a number of words according to whitespace.
The name of a file, such as a texture file or an Egg file.
void load_movie_library(const std::string &name)
Loads the module.
void unlock()
Alias for release() to match C++11 semantics.
Similar to MutexHolder, but for a reentrant mutex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::string get_unique_value(size_t n) const
Returns the nth unique value of the variable.
std::string get_extension() const
Returns the file extension.
A MovieVideo is actually any source that provides a sequence of video frames.
void load_video_types()
Loads the list with video types, if we haven't already.
void register_video_type(MakeVideoFunc func, const std::string &extensions)
Registers a MovieVideo type, so that files with any of the given extensions will be loaded as this ty...
A MovieAudio is actually any source that provides a sequence of audio samples.
void register_audio_type(MakeAudioFunc func, const std::string &extensions)
Registers a MovieAudio type, so that files with any of the given extensions will be loaded as this ty...
std::string to_os_specific() const
Converts the filename from our generic Unix-like convention (forward slashes starting with the root a...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.