From 6232d13f5321b87ddf12a1aa36b4545da45f173d Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 17 Nov 2021 22:34:57 +0100 Subject: Travel3: Simple image and video display site Reads the images and videos from filesystem and builds a site in memroy. --- src/video.cc | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 src/video.cc (limited to 'src/video.cc') diff --git a/src/video.cc b/src/video.cc new file mode 100644 index 0000000..110bd4a --- /dev/null +++ b/src/video.cc @@ -0,0 +1,171 @@ +#include "common.hh" + +#include "strutil.hh" +#include "timezone.hh" +#include "video.hh" + +#if HAVE_MEDIAINFO +#include +#endif + +namespace { + +class VideoImpl : public Video { +public: + VideoImpl(uint64_t width, uint64_t height) + : width_(width), height_(height) {} + + uint64_t width() const override { + return width_; + } + + uint64_t height() const override { + return height_; + } + + double length() const override { + return length_; + } + + Location location() const override { + return location_; + } + + Date date() const override { + return date_; + } + + void set_length(double length) { + length_ = length; + } + + void set_location(Location location) { + location_ = location; + } + + void set_date(Date date) { + date_ = date; + } + +private: + uint64_t width_; + uint64_t height_; + double length_{0.0}; + Location location_; + Date date_; +}; + +#if HAVE_MEDIAINFO +bool parse_location(std::string const& str, Location* location) { + auto end = str.find('/'); + if (end == std::string::npos) + return false; + char* latend = nullptr; + location->lat = strtod(str.c_str(), &latend); + if (!latend) + return false; + char* lngend = nullptr; + location->lng = strtod(latend, &lngend); + if (!lngend) + return false; + if (lngend != str.c_str() + end) + return false; + return true; +} +#endif + +} // namespace + +std::unique_ptr