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";
93 }
else if (movies_cat->is_debug()) {
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) {
126 std::string error = load_dso_error();
129 <<
": " << error << endl;
130 }
else if (movies_cat.is_debug()) {
132 <<
"done loading audio type module: " << name << endl;
135 }
else if (words.size() > 1) {
139 size_t num_extensions = words.size() - 1;
140 string library_name = words[num_extensions];
142 for (
size_t i = 0; i < num_extensions; i++) {
143 string extension =
downcase(words[i]);
144 if (extension[0] ==
'.') {
145 extension = extension.substr(1);
148 _deferred_audio_types[extension] = library_name;
153 audio_types_loaded =
true;
165 if (ext ==
"pz" || ext ==
"gz") {
176 if (_deferred_video_types.count(ext)) {
178 _deferred_video_types.erase(ext);
182 if (_video_type_registry.count(ext)) {
183 MakeVideoFunc func = _video_type_registry[ext];
185 return (*func)(name);
190 if (_deferred_video_types.count(
"*")) {
192 _deferred_video_types.erase(
"*");
195 if (_video_type_registry.count(
"*")) {
196 MakeVideoFunc func = _video_type_registry[
"*"];
198 return (*func)(name);
202 <<
"Support for video files with extension ." << ext <<
" was not enabled.\n";
218 vector_string::const_iterator wi;
219 for (wi = words.begin(); wi != words.end(); ++wi) {
220 if (_video_type_registry.count(*wi)) {
221 movies_cat->warning()
222 <<
"Attempt to register multiple video types with extension " << (*wi) <<
"\n";
223 }
else if (movies_cat->is_debug()) {
225 <<
"Registered video type with extension " << (*wi) <<
"\n";
227 _video_type_registry[*wi] = func;
237 static bool video_types_loaded =
false;
239 if (!video_types_loaded) {
242 for (
int i = 0; i < num_unique_values; i++) {
248 if (words.size() == 1) {
250 string name = words[0];
251 Filename dlname = Filename::dso_filename(
"lib" + name +
".so");
253 <<
"loading video type module: " << name << endl;
254 void *tmp = load_dso(get_plugin_path().get_value(), dlname);
255 if (tmp ==
nullptr) {
256 std::string error = load_dso_error();
259 <<
": " << error << endl;
260 }
else if (movies_cat.is_debug()) {
262 <<
"done loading video type module: " << name << endl;
265 }
else if (words.size() > 1) {
269 size_t num_extensions = words.size() - 1;
270 string library_name = words[num_extensions];
272 for (
size_t i = 0; i < num_extensions; i++) {
273 string extension =
downcase(words[i]);
274 if (extension[0] ==
'.') {
275 extension = extension.substr(1);
278 _deferred_video_types[extension] = library_name;
283 video_types_loaded =
true;
293 Filename dlname = Filename::dso_filename(
"lib" + name +
".so");
295 <<
"loading video type module: " << name << endl;
296 void *tmp = load_dso(get_plugin_path().get_value(), dlname);
298 if (tmp ==
nullptr) {
299 std::string error = load_dso_error();
302 <<
": " << error << endl;
303 }
else if (movies_cat.is_debug()) {
305 <<
"done loading video type module: " << name << endl;
std::string get_unique_value(size_t n) const
Returns the nth unique value of the variable.
size_t get_num_unique_values() const
Returns the number of unique values in the variable.
The name of a file, such as a texture file or an Egg file.
std::string to_os_specific() const
Converts the filename from our generic Unix-like convention (forward slashes starting with the root a...
std::string get_extension() const
Returns the file extension.
std::string get_basename_wo_extension() const
Returns the basename part of the filename, without the file extension.
A MovieAudio is actually any source that provides a sequence of audio samples.
This class records the different types of MovieAudio and MovieVideo that are available for loading.
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...
void load_audio_types()
Loads the list with audio types, if we haven't already.
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...
void load_video_types()
Loads the list with video types, if we haven't already.
void load_movie_library(const std::string &name)
Loads the module.
A MovieVideo is actually any source that provides a sequence of video frames.
void unlock()
Alias for release() to match C++11 semantics.
void lock()
Alias for acquire() to match C++11 semantics.
Similar to MutexHolder, but for a reentrant mutex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
int extract_words(const string &str, vector_string &words)
Divides the string into a number of words according to whitespace.
string downcase(const string &s)
Returns the input string with all uppercase letters converted to lowercase.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.