/// @brief Get provider /// @param video /// @return /// VideoProvider *VideoProviderFactory::GetProvider(std::string video) { //XXX std::vector<std::string> list = GetClasses(OPT_GET("Video/Provider")->GetString()); std::vector<std::string> list = GetClasses("ffmpegsource"); if (video.find("?dummy") == 0) list.insert(list.begin(), "Dummy"); list.insert(list.begin(), "YUV4MPEG"); bool fileFound = false; bool fileSupported = false; std::string errors; errors.reserve(1024); for (int i = 0; i < (signed)list.size(); ++i) { std::string err; try { VideoProvider *provider = Create(list[i], video); LOG_I("manager/video/provider") << list[i] << ": opened " << video; if (provider->WantsCaching()) { return new VideoProviderCache(provider); } return provider; } catch (agi::FileNotFoundError const&) { err = list[i] + ": file not found."; // Keep trying other providers as this one may just not be able to // open a valid path } catch (VideoNotSupported const&) { fileFound = true; err = list[i] + ": video is not in a supported format."; } catch (VideoOpenError const& ex) { fileSupported = true; err = list[i] + ": " + ex.GetMessage(); } catch (agi::vfr::Error const& ex) { fileSupported = true; err = list[i] + ": " + ex.GetMessage(); } errors += err; errors += "\n"; LOG_D("manager/video/provider") << err; } // No provider could open the file LOG_E("manager/video/provider") << "Could not open " << video; std::string msg = "Could not open " + video + ":\n" + errors; if (!fileFound) throw agi::FileNotFoundError(video); if (!fileSupported) throw VideoNotSupported(msg); throw VideoOpenError(msg); }
/// @brief Get provider /// @param video /// @return /// VideoProvider *VideoProviderFactory::GetProvider(wxString video) { std::vector<std::string> list = GetClasses(OPT_GET("Video/Provider")->GetString()); if (video.StartsWith("?dummy")) list.insert(list.begin(), "Dummy"); list.insert(list.begin(), "YUV4MPEG"); bool fileFound = false; bool fileSupported = false; std::string errors; errors.reserve(1024); for (auto const& factory : list) { std::string err; try { VideoProvider *provider = Create(factory, video); LOG_I("manager/video/provider") << factory << ": opened " << from_wx(video); if (provider->WantsCaching()) { return new VideoProviderCache(provider); } return provider; } catch (agi::FileNotFoundError const&) { err = factory + ": file not found."; // Keep trying other providers as this one may just not be able to // open a valid path } catch (VideoNotSupported const&) { fileFound = true; err = factory + ": video is not in a supported format."; } catch (VideoOpenError const& ex) { fileSupported = true; err = factory + ": " + ex.GetMessage(); } catch (agi::vfr::Error const& ex) { fileSupported = true; err = factory + ": " + ex.GetMessage(); } errors += err; errors += "\n"; LOG_D("manager/video/provider") << err; } // No provider could open the file LOG_E("manager/video/provider") << "Could not open " << from_wx(video); std::string msg = "Could not open " + from_wx(video) + ":\n" + errors; if (!fileFound) throw agi::FileNotFoundError(from_wx(video)); if (!fileSupported) throw VideoNotSupported(msg); throw VideoOpenError(msg); }