Ivan Andrianov avatar Ivan Andrianov committed a66b05f

Refined FFmpeg decoder plugin.

Comments (0)

Files changed (5)

src/codecs/plugins/ffmpegdecoder/ffmpegdecoder.cpp

  */
 
 #include "ffmpegdecoder.h"
-#include "ffmpegdecoder_p.h"
 
-bool FFmpegDecoderPrivate::isFirstObject = true;
+extern "C"
+{
+#include <libavformat/avformat.h>
+#include <libavcodec/avcodec.h>
+}
+
+#include <codecs/frame.h>
+
+class FFmpegDecoder::Private
+{
+    Q_DISABLE_COPY(FFmpegDecoder::Private)
+
+public:
+    Private();
+    ~Private();
+
+    void initValues();
+
+    bool openFile();
+    bool findStreamIndex();
+    bool openCodec();
+
+    void setMetaData();
+
+    void setCodecName();
+    void setBitRate();
+
+    void setBytesPerSample();
+    void setSampleRate();
+    void setChannelCount();
+
+    QString getTag(const char * tagName);
+    void setArtistName();
+    void setAlbumName();
+    void setYear();
+    void setTrackName();
+    void setTrackNumber();
+
+    Frame * processFrame();
+
+    static bool isFirstObject;
+
+    QString fileName;
+    AVFormatContext * formatContext;
+    AVCodecContext * codecContext;
+    AVCodec * codec;
+    int streamIndex;
+
+    QString codecName;
+    uint bitRate;
+
+    StreamInfo streamInfo;
+
+    TagBlock tagBlock;
+
+    AVPacket packet;
+    int currentPacketSize;
+    AVFrame frame;
+
+    bool readMetaData;
+    bool readMetaDataSuccessful;
+};
+
+bool FFmpegDecoder::Private::isFirstObject = true;
 
 FFmpegDecoder::FFmpegDecoder(const QString & fileName) :
-        d(new FFmpegDecoderPrivate())
+        d(new FFmpegDecoder::Private())
 {
-    if(FFmpegDecoderPrivate::isFirstObject)
+    if(FFmpegDecoder::Private::isFirstObject)
     {
-        FFmpegDecoderPrivate::isFirstObject = false;
+        FFmpegDecoder::Private::isFirstObject = false;
         av_register_all();
         avformat_network_init();
     }
     return d->processFrame();
 }
 
-FFmpegDecoderPrivate::FFmpegDecoderPrivate()
+FFmpegDecoder::Private::Private()
 {
 }
 
-FFmpegDecoderPrivate::~FFmpegDecoderPrivate()
+FFmpegDecoder::Private::~Private()
 {
 }
 
-void FFmpegDecoderPrivate::initValues()
+void FFmpegDecoder::Private::initValues()
 {
     formatContext = 0;
     codecContext = 0;
     readMetaDataSuccessful = false;
 }
 
-bool FFmpegDecoderPrivate::openFile()
+bool FFmpegDecoder::Private::openFile()
 {
     return avformat_open_input(&formatContext, fileName.toUtf8().data(), 0, 0)
             >= 0 && avformat_find_stream_info(formatContext, 0) >= 0;
 }
 
-bool FFmpegDecoderPrivate::findStreamIndex()
+bool FFmpegDecoder::Private::findStreamIndex()
 {
     for(unsigned int i = 0; i < formatContext->nb_streams; i++)
     {
     return streamIndex >= 0;
 }
 
-bool FFmpegDecoderPrivate::openCodec()
+bool FFmpegDecoder::Private::openCodec()
 {
     AVCodec * codec = avcodec_find_decoder(codecContext->codec_id);
 
     return true;
 }
 
-void FFmpegDecoderPrivate::setMetaData()
+void FFmpegDecoder::Private::setMetaData()
 {
     setCodecName();
     setBitRate();
     readMetaDataSuccessful = true;
 }
 
-void FFmpegDecoderPrivate::setCodecName()
+void FFmpegDecoder::Private::setCodecName()
 {
     if(codec->id == CODEC_ID_AAC)
     {
     }
 }
 
-void FFmpegDecoderPrivate::setBitRate()
+void FFmpegDecoder::Private::setBitRate()
 {
     if(~codec->capabilities & CODEC_CAP_LOSSLESS)
     {
     }
 }
 
-void FFmpegDecoderPrivate::setBytesPerSample()
+void FFmpegDecoder::Private::setBytesPerSample()
 {
     if(codecContext->sample_fmt == AV_SAMPLE_FMT_U8)
     {
     }
 }
 
-void FFmpegDecoderPrivate::setSampleRate()
+void FFmpegDecoder::Private::setSampleRate()
 {
     streamInfo.setSampleRate(codecContext->sample_rate);
 }
 
-void FFmpegDecoderPrivate::setChannelCount()
+void FFmpegDecoder::Private::setChannelCount()
 {
     streamInfo.setChannelCount(codecContext->channels);
 }
 
-QString FFmpegDecoderPrivate::getTag(const char * tagName)
+QString FFmpegDecoder::Private::getTag(const char * tagName)
 {
     AVDictionaryEntry * tag = av_dict_get(formatContext->metadata, tagName, 0,
             AV_DICT_IGNORE_SUFFIX);
     return "";
 }
 
-void FFmpegDecoderPrivate::setArtistName()
+void FFmpegDecoder::Private::setArtistName()
 {
     QString tag = getTag("Artist");
     if(!tag.isEmpty())
     }
 }
 
-void FFmpegDecoderPrivate::setAlbumName()
+void FFmpegDecoder::Private::setAlbumName()
 {
     QString tag = getTag("Album");
     if(!tag.isEmpty())
     }
 }
 
-void FFmpegDecoderPrivate::setYear()
+void FFmpegDecoder::Private::setYear()
 {
     QString tag = getTag("Date");
     if(!tag.isEmpty())
     }
 }
 
-void FFmpegDecoderPrivate::setTrackName()
+void FFmpegDecoder::Private::setTrackName()
 {
     QString tag = getTag("Title");
     if(!tag.isEmpty())
     }
 }
 
-void FFmpegDecoderPrivate::setTrackNumber()
+void FFmpegDecoder::Private::setTrackNumber()
 {
     QString tag = getTag("Track");
     if(!tag.isEmpty())
     }
 }
 
-Frame * FFmpegDecoderPrivate::processFrame()
+Frame * FFmpegDecoder::Private::processFrame()
 {
     int sampleCount = frame.nb_samples;
     int channelCount = codecContext->channels;

src/codecs/plugins/ffmpegdecoder/ffmpegdecoder.h

 #ifndef FFMPEGDECODER_H
 #define FFMPEGDECODER_H
 
-#include <QString>
-#include <QScopedPointer>
+#include <QtCore/QString>
+#include <QtCore/QScopedPointer>
 
 #include <codecs/decoder.h>
 #include <codecs/streaminfo.h>
 }
 }
 
-class FFmpegDecoderPrivate;
-
 using FFTranscoder::Codecs::Decoder;
 using FFTranscoder::Codecs::Frame;
 using FFTranscoder::Codecs::StreamInfo;
     virtual Frame * readFrame();
 
 private:
-    QScopedPointer<FFmpegDecoderPrivate> d;
+    class Private;
+    QScopedPointer<Private> d;
 };
 
 #endif // FFMPEGDECODER_H

src/codecs/plugins/ffmpegdecoder/ffmpegdecoder_p.h

-/*
- * Copyright (C) 2012 by Ivan Andrianov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#ifndef FFMPEGDECODER_P_H
-#define FFMPEGDECODER_P_H
-
-#include <QString>
-
-extern "C"
-{
-#include <libavformat/avformat.h>
-#include <libavcodec/avcodec.h>
-}
-
-#include <codecs/frame.h>
-#include <codecs/streaminfo.h>
-#include <codecs/tagblock.h>
-
-class FFmpegDecoder;
-
-using FFTranscoder::Codecs::Frame;
-using FFTranscoder::Codecs::TagBlock;
-
-class FFmpegDecoderPrivate
-{
-    Q_DISABLE_COPY(FFmpegDecoderPrivate)
-
-public:
-    FFmpegDecoderPrivate();
-    ~FFmpegDecoderPrivate();
-
-    void initValues();
-
-    bool openFile();
-    bool findStreamIndex();
-    bool openCodec();
-
-    void setMetaData();
-
-    void setCodecName();
-    void setBitRate();
-
-    void setBytesPerSample();
-    void setSampleRate();
-    void setChannelCount();
-
-    QString getTag(const char * tagName);
-    void setArtistName();
-    void setAlbumName();
-    void setYear();
-    void setTrackName();
-    void setTrackNumber();
-
-    Frame * processFrame();
-
-    static bool isFirstObject;
-
-    QString fileName;
-    AVFormatContext * formatContext;
-    AVCodecContext * codecContext;
-    AVCodec * codec;
-    int streamIndex;
-
-    QString codecName;
-    uint bitRate;
-
-    StreamInfo streamInfo;
-
-    TagBlock tagBlock;
-
-    AVPacket packet;
-    int currentPacketSize;
-    AVFrame frame;
-
-    bool readMetaData;
-    bool readMetaDataSuccessful;
-};
-
-#endif // FFMPEGDECODER_P_H

src/codecs/plugins/ffmpegdecoder/ffmpegdecoderplugin.cpp

 
 #include "ffmpegdecoderplugin.h"
 
-#include <QtPlugin>
+#include <QtCore/QtPlugin>
 
 #include "ffmpegdecoder.h"
 #include "global.h"

src/codecs/plugins/ffmpegdecoder/ffmpegdecoderplugin.h

 #ifndef FFMPEGDECODERPLUGIN_H
 #define FFMPEGDECODERPLUGIN_H
 
-#include <QString>
-#include <QObject>
+#include <QtCore/QString>
+#include <QtCore/QObject>
 
 #include <codecs/decoderplugin.h>
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.