Reworked the project layout

This commit is contained in:
emeric
2014-10-10 20:41:34 +02:00
parent 92a176c899
commit 49ff050539
146 changed files with 156 additions and 162 deletions
+237
View File
@@ -0,0 +1,237 @@
/*
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
#include <sstream>
#include <boost/iostreams/stream.hpp>
#include <boost/process.hpp>
#include <boost/foreach.hpp>
#include "logger/Logger.hpp"
#include "AvConvTranscoder.hpp"
namespace Transcode
{
// TODO, parametrize?
const std::vector<std::string> execNames =
{
"avconv",
"ffmpeg",
};
boost::mutex AvConvTranscoder::_mutex;
boost::filesystem::path AvConvTranscoder::_avConvPath = boost::filesystem::path();
void
AvConvTranscoder::init()
{
BOOST_FOREACH(std::string execName, execNames)
{
const boost::filesystem::path p = boost::process::search_path(execName);
if (!p.empty())
{
_avConvPath = p;
break;
}
}
if (!_avConvPath.empty())
LMS_LOG(MOD_TRANSCODE, SEV_INFO) << "Using transcoder " << _avConvPath;
else
LMS_LOG(MOD_TRANSCODE, SEV_ERROR) << "Cannot find any transcoder binary!";
}
//boost::filesystem::path AvConvTranscoder::_avConvPath = "";
AvConvTranscoder::AvConvTranscoder(const Parameters& parameters)
: _parameters(parameters),
_outputPipe(boost::process::create_pipe()),
_source(_outputPipe.source, boost::iostreams::close_handle),
_is(_source),
_in(&_is),
_isComplete(false)
{
if (!boost::filesystem::exists(_parameters.getInputMediaFile().getPath())) {
throw std::runtime_error("File " + _parameters.getInputMediaFile().getPath().string() + " does not exists!");
}
else if (!boost::filesystem::is_regular( _parameters.getInputMediaFile().getPath())) {
throw std::runtime_error("File " + _parameters.getInputMediaFile().getPath().string() + " is not regular!");
}
LMS_LOG(MOD_TRANSCODE, SEV_INFO) << "Transcoding file '" << _parameters.getInputMediaFile().getPath() << "'";
// Launch a process to handle the conversion
boost::iostreams::file_descriptor_sink sink(_outputPipe.sink, boost::iostreams::close_handle);
std::ostringstream oss;
oss << _avConvPath;
// input Offset
if (_parameters.getOffset().total_seconds() > 0)
oss << " -ss " << _parameters.getOffset().total_seconds(); // to be placed before '-i' to speed up seeking
// Input file
oss << " -i \"" << _parameters.getInputMediaFile().getPath().string() << "\"";
// Output bitrates
oss << " -b:a " << _parameters.getOutputBitrate(Stream::Audio) ;
if (_parameters.getOutputFormat().getType() == Format::Video)
oss << " -b:v " << _parameters.getOutputBitrate(Stream::Video);
// Stream mapping
{
typedef std::map<Stream::Type, Stream::Id> StreamMap;
const StreamMap& streamMap = _parameters.getInputStreams();
BOOST_FOREACH(const StreamMap::value_type& inputStream, streamMap)
{
// HACK (no subtitle support yet)
if (inputStream.first != Stream::Subtitle)
oss << " -map 0:" << inputStream.second; // 0 means input file index
}
}
// Codecs and formats
switch( _parameters.getOutputFormat().getEncoding())
{
case Format::MP3:
oss << " -f mp3";
break;
case Format::OGA:
oss << " -acodec libvorbis -f ogg";
break;
case Format::OGV:
oss << " -acodec libvorbis -ac 2 -ar 44100 -vcodec libtheora -threads 4 -f ogg";
break;
case Format::WEBMA:
oss << " -codec:a libvorbis -f webm";
break;
case Format::WEBMV:
oss << " -acodec libvorbis -ac 2 -ar 44100 -vcodec libvpx -threads 4 -f webm";
break;
case Format::M4A:
oss << " -acodec aac -f mp4";
break;
case Format::M4V:
oss << " -acodec aac -strict experimental -ac 2 -ar 44100 -vcodec libx264 -f m4v";
break;
case Format::FLV:
oss << " -acodec libmp3lame -ac 2 -ar 44100 -vcodec libx264 -f flv";
break;
default:
assert(0);
}
oss << " -"; // output to stdout
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Executing '" << oss.str() << "'";
// make sure only one thread is executing this part of code
// See boost process FAQ
{
boost::lock_guard<boost::mutex> lock(_mutex);
std::vector<int> ranges = { 3, 1024 }; // fd range to be closed
_child = std::make_shared<boost::process::child>( boost::process::execute(
boost::process::initializers::run_exe(_avConvPath),
boost::process::initializers::set_cmd_line(oss.str()),
boost::process::initializers::bind_stdout(sink),
boost::process::initializers::close_fd(STDIN_FILENO),
boost::process::initializers::close_fds(ranges)
)
);
}
}
void
AvConvTranscoder::process(void)
{
std::size_t readDatasSize = 1024; // TODO parametrize elsewhere?
char ch;
while(readDatasSize != 0 && _in && _in.get(ch)) {
_data.push_back(ch);
--readDatasSize;
}
if (!_in || _in.fail() || _in.eof()) {
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Transcode complete!";
waitChild();
_isComplete = true;
}
}
AvConvTranscoder::~AvConvTranscoder()
{
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "~AvConvTranscoder called!";
if (_in.eof())
waitChild();
else
killChild();
}
void
AvConvTranscoder::waitChild()
{
if (_child)
{
boost::system::error_code ec;
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Waiting for child...";
boost::process::wait_for_exit(*_child, ec);
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Waiting for child: OK";
if (ec)
LMS_LOG(MOD_TRANSCODE, SEV_ERROR) << "AvConvTranscoder::waitChild: error: " << ec.message();
_child.reset();
}
}
void
AvConvTranscoder::killChild()
{
if (_child)
{
boost::system::error_code ec;
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Killing child! pid = " << _child->pid;
boost::process::terminate(*_child, ec);
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Killing child DONE";
// If an error occured, force kill the child
if (ec)
LMS_LOG(MOD_TRANSCODE, SEV_ERROR) << "AvConvTranscoder::killChild: error: " << ec.message();
_child.reset();
}
}
} // namespace Transcode
+84
View File
@@ -0,0 +1,84 @@
/*
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
#ifndef AVCONV_TRANSCODER_HPP
#define AVCONV_TRANSCODER_HPP
#include <memory>
#include <iostream>
#include <deque>
#include <boost/iostreams/stream.hpp>
#include <boost/process.hpp>
#include <boost/filesystem.hpp>
#include <boost/thread.hpp>
#include "Parameters.hpp"
namespace Transcode
{
class AvConvTranscoder
{
public:
typedef std::deque<unsigned char> data_type;
static void init();
~AvConvTranscoder();
AvConvTranscoder(const Parameters& parameters);
data_type& getOutputData() { return _data; }
const Parameters& getParameters(void) const { return _parameters; }
// Process a bunch of input data
void process(void);
bool isComplete(void) const { return _isComplete;};
private:
typedef std::shared_ptr<boost::process::child> ChildPtr;
void waitChild();
void killChild();
const Parameters _parameters;
static boost::mutex _mutex;
boost::process::pipe _outputPipe;
boost::iostreams::file_descriptor_source _source;
boost::iostreams::stream_buffer<boost::iostreams::file_descriptor_source> _is;
std::istream _in;
std::shared_ptr<boost::process::child> _child;
static boost::filesystem::path _avConvPath;
data_type _data;
bool _isComplete;
};
} // naspace Transcode
#endif
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
#include <boost/foreach.hpp>
#include <stdexcept>
#include <cassert>
#include "Format.hpp"
namespace Transcode
{
const std::vector<Format> Format::_supportedFormats
{
{Format::OGA, Format::Audio, "audio/ogg", "Ogg"},
{Format::OGV, Format::Video, "video/ogg", "Ogg"},
{Format::MP3, Format::Audio, "audio/mp3", "MP3"},
{Format::WEBMA, Format::Audio, "audio/webm", "WebM"},
{Format::WEBMV, Format::Video, "video/webm", "WebM"},
{Format::FLV, Format::Video, "video/x-flv", "Flash Video"},
{Format::M4A, Format::Audio, "audio/mp4", "MP4"},
{Format::M4V, Format::Video, "video/mp4", "MP4"},
};
Format::Format(Encoding encoding, Type type, std::string mimeType, std::string desc)
:
_encoding(encoding),
_type(type),
_mineType(mimeType),
_desc(desc)
{}
const Format&
Format::get(Encoding encoding)
{
BOOST_FOREACH(const Format& format, _supportedFormats)
{
if (format.getEncoding() == encoding)
return format;
}
throw std::runtime_error("Cannot find format");
}
std::vector<Format>
Format::get(Type type)
{
std::vector<Format> res;
BOOST_FOREACH(const Format& format, _supportedFormats)
{
if (format.getType() == type)
res.push_back( format );
}
return res;
}
bool
Format::operator==(const Format& other) const
{
return getEncoding() == other.getEncoding();
}
} // namespace Transcode
+76
View File
@@ -0,0 +1,76 @@
/*
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
#ifndef TRANSCODE_FORMAT_HPP
#define TRANSCODE_FORMAT_HPP
#include <vector>
#include <string>
namespace Transcode
{
class Format
{
public:
// Output format
enum Encoding {
OGA,
OGV,
MP3,
WEBMA,
WEBMV,
FLV,
M4A,
M4V,
};
enum Type {
Video,
Audio,
};
// Utility
static const Format& get(Encoding encoding);
static std::vector<Format> get(Type type);
Format(Encoding format, Type type, std::string mimeType, std::string desc);
Encoding getEncoding(void) const { return _encoding;}
Type getType(void) const { return _type;}
const std::string& getMimeType(void) const { return _mineType;}
const std::string& getDesc(void) const { return _desc;}
bool operator==(const Format& other) const;
private:
Encoding _encoding;
Type _type;
std::string _mineType;
std::string _desc;
static const std::vector<Format> _supportedFormats;
};
} // namespace Transcode
#endif
+129
View File
@@ -0,0 +1,129 @@
/*
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
#include <list>
#include <boost/foreach.hpp>
#include "logger/Logger.hpp"
#include "av/InputFormatContext.hpp"
#include "cover/CoverArtGrabber.hpp"
#include "InputMediaFile.hpp"
namespace Transcode
{
bool getStreamType(enum AVMediaType type, Transcode::Stream::Type& streamType)
{
switch (type) {
case AVMEDIA_TYPE_VIDEO: streamType = Transcode::Stream::Video; return true;
case AVMEDIA_TYPE_AUDIO: streamType = Transcode::Stream::Audio; return true;
case AVMEDIA_TYPE_SUBTITLE: streamType = Transcode::Stream::Subtitle; return true;
default:
return false;
}
}
InputMediaFile::InputMediaFile(const boost::filesystem::path& p)
: _path(p)
{
Av::InputFormatContext input(_path);
input.findStreamInfo();
// Calculate estimated duration
if (input.getDurationSecs())
_duration = boost::posix_time::seconds(input.getDurationSecs() + 1);
// Get input streams
std::vector<Av::Stream> avStreams = input.getStreams();
std::list<enum AVMediaType> avMediaTypes; // List of encountered streams
for (std::size_t avStreamId = 0; avStreamId < avStreams.size(); ++avStreamId)
{
Av::Stream& avStream(avStreams[avStreamId]);
Stream::Type type;
if (getStreamType(avStream.getCodecContext().getType(), type))
{
// Reject Video stream hat are in fact cover arts
if (avStream.hasAttachedPic())
continue;
avMediaTypes.push_back(avStream.getCodecContext().getType());
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Stream idx " << avStreamId << ", type = " << type << ", bitrate = " << avStream.getCodecContext().getBitRate() << ", codec desc = " << avStream.getCodecContext().getCodecDesc();
_streams.push_back( Stream(avStreamId,
type,
avStream.getCodecContext().getBitRate(),
avStream.getMetadata().get("language"), // TODO define somewhere else?
avStream.getCodecContext().getCodecDesc()
));
}
}
avMediaTypes.unique();
// Scan for best streams
BOOST_FOREACH(enum AVMediaType type, avMediaTypes)
{
Av::Stream::Idx index;
if (input.getBestStreamIdx(type, index))
{
Stream::Type streamType;
if (getStreamType(type, streamType))
_bestStreams.insert(std::make_pair( streamType, index) );
}
else
LMS_LOG(MOD_TRANSCODE, SEV_WARNING) << "Cannot find best stream for type " << type;
}
_covers = CoverArt::Grabber::getFromInputFormatContext(input);
}
std::vector<Stream>
InputMediaFile::getStreams(Stream::Type type) const
{
std::vector<Stream> res;
BOOST_FOREACH(const Stream& stream, _streams)
{
if (stream.getType() == type)
res.push_back(stream);
}
return res;
}
const Stream&
InputMediaFile::getStream(Stream::Id index) const
{
BOOST_FOREACH(const Stream& stream, _streams)
{
if (stream.getId() == index)
return stream;
}
LMS_LOG(MOD_TRANSCODE, SEV_CRIT) << "Cannot find stream index " << index << " in stream map!";
throw std::runtime_error("InputMediaFile::getStream, cannot find stream idx");
}
} // namespace Transcode
+79
View File
@@ -0,0 +1,79 @@
/*
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
#ifndef TRANSCODE_INPUT_MEDIA_FILE
#define TRANSCODE_INPUT_MEDIA_FILE
#include <map>
#include <string>
#include <boost/filesystem.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "cover/CoverArt.hpp"
#include "Stream.hpp"
namespace Transcode
{
class InputMediaFile
{
public:
enum StreamType
{
StreamAudio,
StreamVideo,
StreamSubtitle,
};
InputMediaFile(const boost::filesystem::path& p);
// Accessors
boost::filesystem::path getPath(void) const {return _path;}
boost::posix_time::time_duration getDuration(void) const {return _duration;}
// Pictures
const std::vector< CoverArt::CoverArt >& getCovers(void) const { return _covers; }
// Stream handling
const Stream& getStream(Stream::Id id) const;
std::vector<Stream> getStreams(Stream::Type type) const;
const std::map<Stream::Type, Stream::Id>& getBestStreams(void) const {return _bestStreams;}
private:
boost::filesystem::path _path;
boost::posix_time::time_duration _duration;
std::vector<Stream> _streams;
std::map<Stream::Type, Stream::Id> _bestStreams;
std::vector< CoverArt::CoverArt > _covers;
};
} // namespace Transcode
#endif // TRANSCODE_INPUT_MEDIA_FILE
+94
View File
@@ -0,0 +1,94 @@
/*
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
#include "logger/Logger.hpp"
#include "av/InputFormatContext.hpp"
#include "Parameters.hpp"
namespace Transcode
{
std::string
getMimeType(Format format)
{
//TODO
return "";
}
Parameters::Parameters(const InputMediaFile& inputMediaFile,
const Format& outputFormat)
:
_mediaFile(inputMediaFile),
_outputFormat(outputFormat)
{
// By default, select the best stream indexes
_inputStreams = _mediaFile.getBestStreams();
}
std::size_t
Parameters::setBitrate(Stream::Type type, std::size_t bitrate)
{
// Limit the output bitrate to the input bitrate
if (_inputStreams.find(type) != _inputStreams.end())
{
const Transcode::Stream& stream = _mediaFile.getStream( _inputStreams[type] );
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Stream bitrate = " << stream.getBitrate();
if (bitrate > stream.getBitrate())
{
LMS_LOG(MOD_TRANSCODE, SEV_INFO) << "Setting bitrate for stream idx " << _inputStreams[type] << " to input bitrate (" << stream.getBitrate() << ")";
_outputBitrate[type] = stream.getBitrate();
}
else
{
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Setting bitrate for stream idx " << _inputStreams[type] << " to " << bitrate;
_outputBitrate[type] = bitrate;
}
return _outputBitrate[type];
}
else
{
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Cannot find stream type " << type;
return 0;
}
}
std::size_t
Parameters::getOutputBitrate(Stream::Type type) const
{
std::map<Stream::Type, std::size_t>::const_iterator it = _outputBitrate.find(type);
if (it != _inputStreams.end())
{
return it->second;
}
else
{
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "output bitrate not set for type " << type;
return 0;
}
}
} // namespace Transcode
+77
View File
@@ -0,0 +1,77 @@
/*
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
#ifndef TRANSCODE_PARAMETERS_HPP
#define TRANSCODE_PARAMETERS_HPP
#include <string>
#include <boost/filesystem.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "Format.hpp"
#include "InputMediaFile.hpp"
namespace Transcode
{
class Parameters {
public:
Parameters(const InputMediaFile& InputFile, const Format& outputFormat);
// Modifiers
void setOffset(boost::posix_time::time_duration offset) { _offset = offset; } // Set input offset
void setOutputFormat(const Format& format) { _outputFormat = format; }
std::size_t setBitrate(Stream::Type type, std::size_t bitrate);
// Manually select an input stream to output
// There can be only one stream per each type (video, audio, subtitle)
typedef std::map<Stream::Type, Stream::Id> StreamMap;
void selectInputStream(Stream::Type type, Stream::Id id) { _inputStreams[type] = id; }
const StreamMap& getInputStreams(void) const {return _inputStreams;}
//Accessors
boost::posix_time::time_duration getOffset(void) const {return _offset;}
const Format& getOutputFormat(void) const { return _outputFormat; }
std::size_t getOutputBitrate(Stream::Type type) const;
const InputMediaFile& getInputMediaFile(void) const { return _mediaFile;}
InputMediaFile& getInputMediaFile(void) { return _mediaFile;}
private:
InputMediaFile _mediaFile;
boost::posix_time::time_duration _offset; // start input offset
Format _outputFormat; // OGA, OGV, etc.
std::map<Stream::Type, std::size_t> _outputBitrate;
StreamMap _inputStreams;
};
} // namespace Transcode
#endif
+66
View File
@@ -0,0 +1,66 @@
/*
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
#ifndef TRANSCODE_STREAM_HPP
#define TRANSCODE_STREAM_HPP
#include <string>
namespace Transcode
{
class Stream
{
public:
enum Type
{
Audio,
Video,
Subtitle,
};
typedef std::size_t Id;
Stream(Id id, Type type, std::size_t bitrate, const std::string& lang, const std::string& desc)
: _id(id), _type(type), _bitrate(bitrate), _language(lang), _desc(desc) {}
// Accessors
Id getId() const { return _id;}
Type getType() const { return _type;}
std::size_t getBitrate() const { return _bitrate;}
const std::string& getLanguage() const { return _language;}
const std::string& getDesc() const { return _desc;}
private:
Id _id;
Type _type;
std::size_t _bitrate;
std::string _language;
std::string _desc;
};
} // namespace Transcode
#endif