Switching to Av libs to handle cover pictures
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
||||
namespace Av
|
||||
{
|
||||
|
||||
std::string
|
||||
AvError::to_str(void) const
|
||||
{
|
||||
@@ -27,3 +30,5 @@ void AvInit()
|
||||
av_register_all();
|
||||
std::cout << "AVCDOEC VERSION = " << avcodec_version() << std::endl;
|
||||
}
|
||||
|
||||
} // namespace Av
|
||||
|
||||
@@ -17,6 +17,9 @@ extern "C" {
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Av
|
||||
{
|
||||
|
||||
|
||||
void AvInit();
|
||||
|
||||
@@ -40,5 +43,6 @@ class AvError
|
||||
int _errnum;
|
||||
};
|
||||
|
||||
} // namespace Av
|
||||
|
||||
#endif
|
||||
|
||||
@@ -96,4 +96,22 @@ InputFormatContext::getMetadata(void)
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
InputFormatContext::getPictures(std::vector< std::vector<unsigned char> >& pictures) const
|
||||
{
|
||||
for (std::size_t i = 0; i < native()->nb_streams; ++i)
|
||||
{
|
||||
if (native()->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC)
|
||||
{
|
||||
std::cout << "Found album art..." << std::endl;
|
||||
AVPacket pkt = native()->streams[i]->attached_pic;
|
||||
|
||||
std::vector<unsigned char> data;
|
||||
std::copy(pkt.data, pkt.data + pkt.size, std::back_inserter(data));
|
||||
|
||||
pictures.push_back( data );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace Av
|
||||
|
||||
@@ -25,11 +25,15 @@ class InputFormatContext : public FormatContext
|
||||
// Scan file
|
||||
void findStreamInfo();
|
||||
|
||||
std::vector<Stream> getStreams(void);
|
||||
|
||||
bool getBestStreamIdx(enum AVMediaType type, Stream::Idx& idx);
|
||||
// Get attached pictures
|
||||
void getPictures(std::vector< std::vector<unsigned char> >& pictures) const;
|
||||
|
||||
std::size_t getDurationSecs() const;
|
||||
// Get the streams
|
||||
std::vector<Stream> getStreams(void);
|
||||
|
||||
bool getBestStreamIdx(enum AVMediaType type, Stream::Idx& idx);
|
||||
std::size_t getDurationSecs() const;
|
||||
|
||||
private:
|
||||
boost::filesystem::path _path;
|
||||
|
||||
@@ -23,4 +23,10 @@ Stream::getMetadata(void)
|
||||
return Dictionary(_stream->metadata);
|
||||
}
|
||||
|
||||
bool
|
||||
Stream::hasAttachedPic(void) const
|
||||
{
|
||||
return (_stream->disposition & AV_DISPOSITION_ATTACHED_PIC);
|
||||
}
|
||||
|
||||
} // namespace Av
|
||||
|
||||
@@ -21,6 +21,7 @@ class Stream
|
||||
|
||||
// Idx getIdx() const { return _stream->index; }
|
||||
|
||||
bool hasAttachedPic(void) const;
|
||||
Dictionary getMetadata(void);
|
||||
CodecContext getCodecContext(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user