35 if (ext ==
"pz" || ext ==
"gz") {
46 if (_deferred_audio_types.count(ext)) {
48 _deferred_audio_types.erase(ext);
52 if (_audio_type_registry.count(ext)) {
53 MakeAudioFunc func = _audio_type_registry[ext];
60 if (_deferred_audio_types.count(
"*")) {
62 _deferred_audio_types.erase(
"*");
65 if (_audio_type_registry.count(
"*")) {
66 MakeAudioFunc func = _audio_type_registry[
"*"];
72 <<
"Support for audio files with extension ." << ext <<
" was not enabled.\n";
88 vector_string::const_iterator wi;
89 for (wi = words.begin(); wi != words.end(); ++wi) {
90 if (_audio_type_registry.count(*wi)) {
92 <<
"Attempt to register multiple audio types with extension " << (*wi) <<
"\n";
95 <<
"Registered audio type with extension " << (*wi) <<
"\n";
97 _audio_type_registry[*wi] = func;
107 static bool audio_types_loaded =
false;
109 if (!audio_types_loaded) {
112 for (
int i = 0; i < num_unique_values; i++) {
118 if (words.size() == 1) {
120 string name = words[0];
121 Filename dlname = Filename::dso_filename(
"lib" + name +
".so");
123 <<
"loading audio type module: " << name << endl;
124 void *tmp = load_dso(get_plugin_path().get_value(), dlname);
125 if (tmp ==
nullptr) {
128 <<
": " << load_dso_error() << endl;
129 }
else if (movies_cat.is_debug()) {
131 <<
"done loading audio type module: " << name << endl;
134 }
else if (words.size() > 1) {
138 size_t num_extensions = words.size() - 1;
139 string library_name = words[num_extensions];
141 for (
size_t i = 0; i < num_extensions; i++) {
142 string extension =
downcase(words[i]);
143 if (extension[0] ==
'.') {
144 extension = extension.substr(1);
147 _deferred_audio_types[extension] = library_name;
152 audio_types_loaded =
true;
164 if (ext ==
"pz" || ext ==
"gz") {
175 if (_deferred_video_types.count(ext)) {
177 _deferred_video_types.erase(ext);
181 if (_video_type_registry.count(ext)) {
182 MakeVideoFunc func = _video_type_registry[ext];
184 return (*func)(name);
189 if (_deferred_video_types.count(
"*")) {
191 _deferred_video_types.erase(
"*");
194 if (_video_type_registry.count(
"*")) {
195 MakeVideoFunc func = _video_type_registry[
"*"];
197 return (*func)(name);
201 <<
"Support for video files with extension ." << ext <<
" was not enabled.\n";
217 vector_string::const_iterator wi;
218 for (wi = words.begin(); wi != words.end(); ++wi) {
219 if (_video_type_registry.count(*wi)) {
220 movies_cat->warning()
221 <<
"Attempt to register multiple video types with extension " << (*wi) <<
"\n";
224 <<
"Registered video type with extension " << (*wi) <<
"\n";
226 _video_type_registry[*wi] = func;
236 static bool video_types_loaded =
false;
238 if (!video_types_loaded) {
241 for (
int i = 0; i < num_unique_values; i++) {
247 if (words.size() == 1) {
249 string name = words[0];
250 Filename dlname = Filename::dso_filename(
"lib" + name +
".so");
252 <<
"loading video type module: " << name << endl;
253 void *tmp = load_dso(get_plugin_path().get_value(), dlname);
254 if (tmp ==
nullptr) {
257 <<
": " << load_dso_error() << endl;
258 }
else if (movies_cat.is_debug()) {
260 <<
"done loading video type module: " << name << endl;
263 }
else if (words.size() > 1) {
267 size_t num_extensions = words.size() - 1;
268 string library_name = words[num_extensions];
270 for (
size_t i = 0; i < num_extensions; i++) {
271 string extension =
downcase(words[i]);
272 if (extension[0] ==
'.') {
273 extension = extension.substr(1);
276 _deferred_video_types[extension] = library_name;
281 video_types_loaded =
true;
291 Filename dlname = Filename::dso_filename(
"lib" + name +
".so");
293 <<
"loading video type module: " << name << endl;
294 void *tmp = load_dso(get_plugin_path().get_value(), dlname);
296 if (tmp ==
nullptr) {
299 <<
": " << load_dso_error() << endl;
300 }
else if (movies_cat.is_debug()) {
302 <<
"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.
std::string get_basename_wo_extension() const
Returns the basename part of the filename, without the file extension.
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.