Commits

Ivan Andrianov committed 87607dc

Refined FLAC encoder plugin.

Comments (0)

Files changed (5)

src/codecs/plugins/flacencoder/flacencoder.cpp

  */
 
 #include "flacencoder.h"
-#include "flacencoder_p.h"
 
 #include <codecs/frame.h>
 
+#include <FLAC/stream_encoder.h>
+#include <FLAC/metadata.h>
+
+class FLACEncoder::Private
+{
+    Q_DISABLE_COPY(FLACEncoder::Private)
+
+public:
+    Private();
+    ~Private();
+
+    void initValues();
+
+    bool createEncoder();
+    bool createMetaData();
+    bool initEncoder();
+
+    bool writeTag(const char * tagName, const char * tagValue);
+    bool writeStringTag(const char * tagName, const QString & tagValue);
+    bool writeIntTag(const char * tagName, uint tagValue);
+    bool writeArtistName();
+    bool writeAlbumName();
+    bool writeYear();
+    bool writeTrackName();
+    bool writeTrackNumber();
+
+    QString fileName;
+
+    StreamInfo streamInfo;
+
+    TagBlock tagBlock;
+
+    FLAC__StreamEncoder * encoder;
+    FLAC__StreamMetadata * metaData;
+
+    bool isMetaDataWritten;
+    bool isMetaDataWrittenSuccessfully;
+};
+
 FLACEncoder::FLACEncoder(const QString & fileName) :
-        d(new FLACEncoderPrivate())
+        d(new FLACEncoder::Private())
 {
     d->fileName = fileName;
     d->initValues();
     return false;
 }
 
-FLACEncoderPrivate::FLACEncoderPrivate()
+FLACEncoder::Private::Private()
 {
 }
 
-FLACEncoderPrivate::~FLACEncoderPrivate()
+FLACEncoder::Private::~Private()
 {
 }
 
-void FLACEncoderPrivate::initValues()
+void FLACEncoder::Private::initValues()
 {
     streamInfo = StreamInfo(2, 44100, 2);
 
     isMetaDataWrittenSuccessfully = false;
 }
 
-bool FLACEncoderPrivate::createEncoder()
+bool FLACEncoder::Private::createEncoder()
 {
     encoder = FLAC__stream_encoder_new();
     return encoder
             && FLAC__stream_encoder_set_compression_level(encoder, 8);
 }
 
-bool FLACEncoderPrivate::createMetaData()
+bool FLACEncoder::Private::createMetaData()
 {
     metaData = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
     return metaData && writeArtistName() && writeAlbumName() && writeYear()
             && FLAC__stream_encoder_set_metadata(encoder, &metaData, 1);
 }
 
-bool FLACEncoderPrivate::initEncoder()
+bool FLACEncoder::Private::initEncoder()
 {
     return FLAC__stream_encoder_init_file(encoder, fileName.toUtf8().data(), 0,
             0) == FLAC__STREAM_ENCODER_INIT_STATUS_OK;
 }
 
-bool FLACEncoderPrivate::writeTag(const char * tagName, const char * tagValue)
+bool FLACEncoder::Private::writeTag(const char * tagName, const char * tagValue)
 {
     FLAC__StreamMetadata_VorbisComment_Entry entry;
     return FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(
                     entry, false);
 }
 
-bool FLACEncoderPrivate::writeStringTag(const char * tagName,
+bool FLACEncoder::Private::writeStringTag(const char * tagName,
         const QString & tagValue)
 {
     if(!tagValue.isEmpty())
     return true;
 }
 
-bool FLACEncoderPrivate::writeIntTag(const char * tagName, uint tagValue)
+bool FLACEncoder::Private::writeIntTag(const char * tagName, uint tagValue)
 {
     if(tagValue > 0)
     {
     return true;
 }
 
-bool FLACEncoderPrivate::writeArtistName()
+bool FLACEncoder::Private::writeArtistName()
 {
     return writeStringTag("ARTIST", tagBlock.artistName());
 }
 
-bool FLACEncoderPrivate::writeAlbumName()
+bool FLACEncoder::Private::writeAlbumName()
 {
     return writeStringTag("ALBUM", tagBlock.albumName());
 }
 
-bool FLACEncoderPrivate::writeYear()
+bool FLACEncoder::Private::writeYear()
 {
     return writeIntTag("DATE", tagBlock.year());
 }
 
-bool FLACEncoderPrivate::writeTrackName()
+bool FLACEncoder::Private::writeTrackName()
 {
     return writeStringTag("TITLE", tagBlock.trackName());
 }
 
-bool FLACEncoderPrivate::writeTrackNumber()
+bool FLACEncoder::Private::writeTrackNumber()
 {
     return writeIntTag("TRACKNUMBER", tagBlock.trackNumber());
 }

src/codecs/plugins/flacencoder/flacencoder.h

 #ifndef FLACENCODER_H
 #define FLACENCODER_H
 
-#include <QString>
-#include <QScopedPointer>
+#include <QtCore/QString>
+#include <QtCore/QScopedPointer>
 
 #include <codecs/encoder.h>
 #include <codecs/streaminfo.h>
 }
 }
 
-class FLACEncoderPrivate;
-
 using FFTranscoder::Codecs::Encoder;
 using FFTranscoder::Codecs::Frame;
 using FFTranscoder::Codecs::StreamInfo;
     virtual bool flush();
 
 private:
-    QScopedPointer<FLACEncoderPrivate> d;
+    class Private;
+    QScopedPointer<Private> d;
 };
 
 #endif // FLACENCODER_H

src/codecs/plugins/flacencoder/flacencoder_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 FLACENCODER_P_H
-#define FLACENCODER_P_H
-
-#include <QString>
-
-#include <FLAC/stream_encoder.h>
-#include <FLAC/metadata.h>
-
-#include <codecs/tagblock.h>
-
-using FFTranscoder::Codecs::TagBlock;
-
-class FLACEncoder;
-
-class FLACEncoderPrivate
-{
-    Q_DISABLE_COPY(FLACEncoderPrivate)
-
-public:
-    FLACEncoderPrivate();
-    ~FLACEncoderPrivate();
-
-    void initValues();
-
-    bool createEncoder();
-    bool createMetaData();
-    bool initEncoder();
-
-    bool writeTag(const char * tagName, const char * tagValue);
-    bool writeStringTag(const char * tagName, const QString & tagValue);
-    bool writeIntTag(const char * tagName, uint tagValue);
-    bool writeArtistName();
-    bool writeAlbumName();
-    bool writeYear();
-    bool writeTrackName();
-    bool writeTrackNumber();
-
-    QString fileName;
-
-    StreamInfo streamInfo;
-
-    TagBlock tagBlock;
-
-    FLAC__StreamEncoder * encoder;
-    FLAC__StreamMetadata * metaData;
-
-    bool isMetaDataWritten;
-    bool isMetaDataWrittenSuccessfully;
-};
-
-#endif // FLACENCODER_P_H

src/codecs/plugins/flacencoder/flacencoderplugin.cpp

 
 #include "flacencoderplugin.h"
 
-#include <QtPlugin>
+#include <QtCore/QtPlugin>
 
 #include "flacencoder.h"
 #include "global.h"

src/codecs/plugins/flacencoder/flacencoderplugin.h

 #ifndef FLACENCODERPLUGIN_H
 #define FLACENCODERPLUGIN_H
 
-#include <QString>
-#include <QObject>
+#include <QtCore/QString>
+#include <QtCore/QObject>
 
 #include <codecs/encoderplugin.h>