WIP, Remote Client/Server, Reworking cover art retreival. To be tested

This commit is contained in:
emeric
2014-06-10 00:16:07 +02:00
parent d6ad178bdb
commit ca88d82677
17 changed files with 1799 additions and 933 deletions
+36
View File
@@ -0,0 +1,36 @@
#ifndef COVER_ART_HPP
#define COVER_ART_HPP
#include <vector>
#include <string>
#include "database/AudioTypes.hpp"
namespace CoverArt
{
class CoverArt
{
public:
typedef std::vector<unsigned char> data_type;
CoverArt();
CoverArt(const std::string& mime, const data_type& data) : _mimeType(mime), _data(data) {}
const std::string& getMimeType() const { return _mimeType; }
const data_type& getData() const { return _data; }
void setMimeType(const std::string& mimeType) { _mimeType = mimeType;}
void setData(const data_type& data) { _data = data; }
private:
std::string _mimeType;
data_type _data;
};
} // namespace CoverArt
#endif
+49
View File
@@ -0,0 +1,49 @@
#include <boost/foreach.hpp>
#include "CoverArtGrabber.hpp"
#include "av/InputFormatContext.hpp"
namespace CoverArt {
std::vector<CoverArt>
Grabber::getFromRelease(Release::pointer release)
{
std::vector<CoverArt> res;
// TODO
// Check if there is an image file in the directory of the release
// For now, just get the cover art from the first track of the release
Wt::Dbo::collection<Track::pointer> tracks (release->getTracks());
Track::pointer firstTrack;
if (tracks.begin() != tracks.end())
firstTrack = *tracks.begin();
if (firstTrack)
{
try
{
Av::InputFormatContext input(firstTrack->getPath());
std::vector< std::vector<unsigned char> > pictures;
input.getPictures(pictures);
BOOST_FOREACH(const std::vector<unsigned char>& picture, pictures)
res.push_back( CoverArt("application/octet-stream", picture) );
}
catch(std::exception& e)
{
std::cerr << "Cannot get pictures: " << e.what();
}
}
return res;
}
} // namespace CoverArt
+20
View File
@@ -0,0 +1,20 @@
#ifndef COVER_ART_GRABBER_HPP
#define COVER_ART_GRABBER_HPP
#include "CoverArt.hpp"
namespace CoverArt {
class Grabber
{
public:
static std::vector<CoverArt> getFromTrack(Track::pointer track);
static std::vector<CoverArt> getFromRelease(Release::pointer release);
};
} // namespace CoverArt
#endif