Refactorized avdecoder class.

Disable warnings from ffmpeg.
This commit is contained in:
codestation
2014-01-20 22:55:20 -04:30
parent ca2e0a4b0c
commit 7234356319
2 changed files with 75 additions and 65 deletions

View File

@@ -38,13 +38,33 @@ public:
AVDecoder();
~AVDecoder();
enum codec_type {CODEC_VIDEO = AVMEDIA_TYPE_VIDEO, CODEC_AUDIO = AVMEDIA_TYPE_AUDIO};
bool open(const QString filename);
void close();
bool loadCodec(codec_type codec);
QByteArray getAudioThumbnail(int width, int height);
QByteArray getVideoThumbnail(int width, int height);
void getAudioMetadata(metadata_t &metadata);
void getVideoMetadata(metadata_t &metadata);
const char *getMetadataEntry(const char *key, const char *default_value = NULL);
inline int getWidth() {
return pCodecCtx->width;
}
inline int getHeight() {
return pCodecCtx->height;
}
inline int getDuration() {
return pFormatCtx->duration / 1000;
}
inline int getBitrate() {
return pCodecCtx->bit_rate;
}
// simulate a static constructor to initialize libav only once
class AvInit
@@ -52,6 +72,8 @@ public:
public:
AvInit() {
av_register_all();
// hide warning logs
av_log_set_level(AV_LOG_ERROR);
}
};
@@ -61,6 +83,10 @@ private:
AVFrame *getDecodedFrame(AVCodecContext *pCodecCtx, int stream_index);
AVFormatContext *pFormatCtx;
AVCodecContext *pCodecCtx;
AVStream *av_stream;
AVCodec *av_codec;
int stream_index;
};
#endif // AVDECODER_H