Create a static constructor for libav initialization.

This commit is contained in:
codestation
2013-08-19 23:23:19 -04:30
parent 45a8366f9e
commit 0704cfa80a
4 changed files with 17 additions and 14 deletions

View File

@@ -12,16 +12,15 @@ official CMA and also offer some features missing in the original one.
#### Implemented features missing in OpenCMA (Yifan Lu CLI application) #### Implemented features missing in OpenCMA (Yifan Lu CLI application)
* Metadata for PSP savedatas. * Metadata for PSP savedatas.
* Basic metadata for single songs (album, artist, title). * Basic metadata for single songs (album, artist, title, cover art).
* Basic metadata for videos (duration, dimensions). * Basic metadata for videos (duration, dimensions, thumbnail).
* Basic metadata for photos (dimensions). * Basic metadata for photos (dimensions, thumbnails).
* Easy wireless pairing (show PIN to the user when a Vita is detected). * Easy wireless pairing (show PIN to the user when a Vita is detected).
* Ability to restart the connection if the Vita is reconnected (on test). * Ability to restart the connection if the Vita is reconnected (on test).
* Ability to change the connection mode (usb/wireless) on the fly (on test).
#### TODO: #### TODO:
* Fix remaining bugs with thread synchronizations. * Fix remaining bugs with thread synchronizations.
* Implement thumbnails for videos and album art for music. * Remove wireless/usb switch and allow both to run.
* Folder categories for music/videos. * Folder categories for music/videos.
* SQLite backend for database. * SQLite backend for database.
* Fix wireless streaming for music/videos. * Fix wireless streaming for music/videos.
@@ -40,7 +39,7 @@ using the wireless streaming feature.
* [VitaMTP](https://github.com/yifanlu/VitaMTP) * [VitaMTP](https://github.com/yifanlu/VitaMTP)
* [MediaInfo](http://mediaarea.net/en/MediaInfo) * [Libav](http://www.libav.org/)
#### Where do I get the source code? #### Where do I get the source code?

View File

@@ -4,6 +4,8 @@
#include <QFile> #include <QFile>
#include <QSettings> #include <QSettings>
AVDecoder::AvInit init;
AVDecoder::AVDecoder() : AVDecoder::AVDecoder() :
pFormatCtx(NULL) pFormatCtx(NULL)
{ {
@@ -16,14 +18,8 @@ AVDecoder::~AVDecoder()
} }
} }
void AVDecoder::init()
{
av_register_all();
}
bool AVDecoder::open(const QString filename) bool AVDecoder::open(const QString filename)
{ {
if(avformat_open_input(&pFormatCtx, QFile::encodeName(filename).constData(), NULL, NULL) != 0) { if(avformat_open_input(&pFormatCtx, QFile::encodeName(filename).constData(), NULL, NULL) != 0) {
return false; return false;
} }

View File

@@ -24,7 +24,16 @@ public:
void getVideoMetadata(metadata_t &metadata); void getVideoMetadata(metadata_t &metadata);
void close(); void close();
static void init(); class AvInit
{
public:
AvInit()
{
av_register_all();
}
};
static AvInit init;
private: private:
void AVFrameToQImage(AVFrame &frame, QImage &image, int width, int height); void AVFrameToQImage(AVFrame &frame, QImage &image, int width, int height);

View File

@@ -40,7 +40,6 @@ CmaClient::CmaClient(QObject *parent) :
BaseWorker(parent) BaseWorker(parent)
{ {
this_object = this; this_object = this;
AVDecoder::init();
} }
int CmaClient::deviceRegistered(const char *deviceid) int CmaClient::deviceRegistered(const char *deviceid)