status_t AddOnManager::GetDecoderForFormat(xfer_entry_ref* _decoderRef, const media_format& format) { if ((format.type == B_MEDIA_ENCODED_VIDEO || format.type == B_MEDIA_ENCODED_AUDIO || format.type == B_MEDIA_MULTISTREAM) && format.Encoding() == 0) { return B_MEDIA_BAD_FORMAT; } if (format.type == B_MEDIA_NO_TYPE || format.type == B_MEDIA_UNKNOWN_TYPE) return B_MEDIA_BAD_FORMAT; BAutolock locker(fLock); printf("AddOnManager::GetDecoderForFormat: searching decoder for encoding " "%" B_PRIu32 "\n", format.Encoding()); // Since the list of decoders is unsorted, we need to search for // a decoder by add-on directory, in order to maintain the shadowing // of system add-ons by user add-ons, in case they offer decoders // for the same format. BPath path; for (uint i = 0; i < sizeof(sDirectories) / sizeof(directory_which); i++) { if (find_directory(sDirectories[i], &path) != B_OK || path.Append("media/plugins") != B_OK) { printf("AddOnManager::GetDecoderForFormat: failed to construct " "path for directory %u\n", i); continue; } if (_FindDecoder(format, path, _decoderRef)) return B_OK; } return B_ENTRY_NOT_FOUND; }
status_t AddOnManager::GetDecoderForFormat(entry_ref* _decoderRef, const media_format& format) { if ((format.type == B_MEDIA_ENCODED_VIDEO || format.type == B_MEDIA_ENCODED_AUDIO || format.type == B_MEDIA_MULTISTREAM) && format.Encoding() == 0) { return B_MEDIA_BAD_FORMAT; } if (format.type == B_MEDIA_NO_TYPE || format.type == B_MEDIA_UNKNOWN_TYPE) return B_MEDIA_BAD_FORMAT; BAutolock locker(fLock); RegisterAddOns(); // Since the list of decoders is unsorted, we need to search for // a decoder by add-on directory, in order to maintain the shadowing // of system add-ons by user add-ons, in case they offer decoders // for the same format. char** directories = NULL; size_t directoryCount = 0; if (find_paths_etc(get_architecture(), B_FIND_PATH_ADD_ONS_DIRECTORY, "media/plugins", B_FIND_PATH_EXISTING_ONLY, &directories, &directoryCount) != B_OK) { printf("AddOnManager::GetDecoderForFormat: failed to locate plugins\n"); return B_ENTRY_NOT_FOUND; } MemoryDeleter directoriesDeleter(directories); BPath path; for (uint i = 0; i < directoryCount; i++) { path.SetTo(directories[i]); if (_FindDecoder(format, path, _decoderRef)) return B_OK; } return B_ENTRY_NOT_FOUND; }