/* * 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 . */ #pragma once #include #include #include #include #include "AvTypes.hpp" namespace Av { struct TranscodeParameters { boost::optional encoding; // If not set, no transcoding is performed std::size_t bitrate {128000}; boost::optional stream; // Id of the stream to be transcoded (auto detect by default) boost::optional offset {}; bool stripMetadata {true}; }; class Transcoder { public: static void init(); Transcoder(boost::filesystem::path file, TranscodeParameters parameters); ~Transcoder(); // non copyable Transcoder(const Transcoder&) = delete; Transcoder& operator=(const Transcoder&) = delete; bool start(); const std::string& getOutputMimeType() const { return _outputMimeType; } void process(std::vector& output, std::size_t maxSize); bool isComplete(void) const { return _isComplete; } const TranscodeParameters& getParameters() const { return _parameters; } private: Transcoder(); boost::filesystem::path _filePath; TranscodeParameters _parameters; std::shared_ptr _child; bool _isComplete = false; std::size_t _total = 0; std::size_t _id; std::string _outputMimeType; }; } // namespace Av