diff --git a/src/QtAV/AVDecoder.h b/src/QtAV/AVDecoder.h index d67c1da1f..e645ceaf3 100644 --- a/src/QtAV/AVDecoder.h +++ b/src/QtAV/AVDecoder.h @@ -83,13 +83,13 @@ class Q_AV_EXPORT AVDecoder : public QObject Q_SIGNALS: void error(const QtAV::AVError& e); //explictly use QtAV::AVError in connection for Qt4 syntax void descriptionChanged(); + virtual void codecNameChanged(); protected: AVDecoder(AVDecoderPrivate& d); DPTR_DECLARE(AVDecoder) // force a codec. only used by avcodec sw decoders void setCodecName(const QString& name); QString codecName() const; - virtual void codecNameChanged() {} private: Q_DISABLE_COPY(AVDecoder) AVDecoder(); // base class, not direct create. only final class has is enough diff --git a/src/QtAV/VideoCapture.h b/src/QtAV/VideoCapture.h index 8af591945..a6e53602b 100644 --- a/src/QtAV/VideoCapture.h +++ b/src/QtAV/VideoCapture.h @@ -85,7 +85,8 @@ class Q_AV_EXPORT VideoCapture : public QObject void setCaptureDir(const QString& value); QString captureDir() const; public Q_SLOTS: - void request(); + void capture(); + QTAV_DEPRECATED void request(); Q_SIGNALS: void requested(); /*use it to popup a dialog for selecting dir, name etc. TODO: block avthread if not async*/ diff --git a/src/QtAV/VideoDecoder.h b/src/QtAV/VideoDecoder.h index 93d774779..24bf86e89 100644 --- a/src/QtAV/VideoDecoder.h +++ b/src/QtAV/VideoDecoder.h @@ -27,7 +27,6 @@ #include class QSize; -struct SwsContext; namespace QtAV { typedef int VideoDecoderId; diff --git a/src/QtAV/private/AVDecoder_p.h b/src/QtAV/private/AVDecoder_p.h index bde0f104c..49558abc2 100644 --- a/src/QtAV/private/AVDecoder_p.h +++ b/src/QtAV/private/AVDecoder_p.h @@ -24,8 +24,6 @@ #include #include -#include -#include #include "QtAV/private/AVCompat.h" namespace QtAV { @@ -55,7 +53,6 @@ class Q_AV_PRIVATE_EXPORT AVDecoderPrivate : public DPtrPrivate bool available; //TODO: true only when context(and hw ctx) is ready bool is_open; int undecoded_size; - QMutex mutex; QString codec_name; QVariantHash options; AVDictionary *dict; diff --git a/src/codec/AVDecoder.cpp b/src/codec/AVDecoder.cpp index 347b73b36..f1f0aed28 100644 --- a/src/codec/AVDecoder.cpp +++ b/src/codec/AVDecoder.cpp @@ -29,15 +29,7 @@ namespace QtAV { AVDecoder::AVDecoder(AVDecoderPrivate &d) :DPTR_INIT(&d) { - class AVInitializer { - public: - AVInitializer() { - qDebug("avcodec_register_all"); - avcodec_register_all(); - } - }; - static AVInitializer sAVInit; - Q_UNUSED(sAVInit); + avcodec_register_all(); // avcodec_find_decoder will always be used } AVDecoder::~AVDecoder() @@ -165,7 +157,11 @@ AVCodecContext* AVDecoder::codecContext() const void AVDecoder::setCodecName(const QString &name) { - d_func().codec_name = name; + DPTR_D(AVDecoder); + if (d.codec_name == name) + return; + d.codec_name = name; + Q_EMIT codecNameChanged(); } QString AVDecoder::codecName() const @@ -224,7 +220,7 @@ void AVDecoder::setOptions(const QVariantHash &dict) else if (dict.contains(name().toLower())) opt = dict.value(name().toLower()); else - return; + return; // TODO: set property if no name() key found? if (opt.type() == QVariant::Hash) { QVariantHash property_dict(opt.toHash()); if (property_dict.isEmpty()) diff --git a/src/codec/audio/AudioDecoderFFmpeg.cpp b/src/codec/audio/AudioDecoderFFmpeg.cpp index a9ec0a529..f06261fd7 100644 --- a/src/codec/audio/AudioDecoderFFmpeg.cpp +++ b/src/codec/audio/AudioDecoderFFmpeg.cpp @@ -66,7 +66,9 @@ class AudioDecoderFFmpegPrivate : public AudioDecoderPrivate AudioDecoderFFmpegPrivate() : AudioDecoderPrivate() , frame(av_frame_alloc()) - {} + { + avcodec_register_all(); + } ~AudioDecoderFFmpegPrivate() { if (frame) { av_frame_free(&frame); diff --git a/src/codec/video/VideoDecoderFFmpegBase.h b/src/codec/video/VideoDecoderFFmpegBase.h index 99c746893..8694af63b 100644 --- a/src/codec/video/VideoDecoderFFmpegBase.h +++ b/src/codec/video/VideoDecoderFFmpegBase.h @@ -49,6 +49,7 @@ class VideoDecoderFFmpegBasePrivate : public VideoDecoderPrivate : VideoDecoderPrivate() , frame(0) { + avcodec_register_all(); frame = av_frame_alloc(); } virtual ~VideoDecoderFFmpegBasePrivate() {