/* * Copyright (C) 2015 Emeric Poupon * * This file is part of LMS. * * LMS is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * LMS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with LMS. If not, see . */ /* This file contains some classes in order to get info from file using the libavconv */ #pragma once extern "C" { #define __STDC_CONSTANT_MACROS #include #include #include } #include #include #include #include #include #include #include #include "utils/Exception.hpp" namespace Av { void AvInit(); struct Picture { std::string mimeType; std::vector data; }; struct StreamInfo { size_t id; std::size_t bitrate; }; class AvException : public LmsException { public: AvException(const std::string& msg) : LmsException(msg) {} }; class MediaFileException : public AvException { public: MediaFileException(int avError); }; class MediaFile { public: MediaFile(const boost::filesystem::path& p); ~MediaFile(); // non copyable MediaFile(const MediaFile&) = delete; MediaFile& operator=(const MediaFile&) = delete; const boost::filesystem::path& getPath() const {return _p;}; std::chrono::milliseconds getDuration() const; std::map getMetaData(void); std::vector getStreamInfo() const; boost::optional getBestStream() const; // none if failure/unknown bool hasAttachedPictures(void) const; std::vector getAttachedPictures(std::size_t nbMaxPictures) const; private: MediaFile(); boost::filesystem::path _p; AVFormatContext* _context; }; } // namespace Av