2014-01-11 04:32:08 +01:00
|
|
|
/* This file is part of Clementine.
|
2014-01-13 06:32:25 +01:00
|
|
|
Copyright 2014, Andre Siviero <altsiviero@gmail.com>
|
2014-01-11 04:32:08 +01:00
|
|
|
|
2014-01-13 06:32:25 +01:00
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2014-01-11 04:32:08 +01:00
|
|
|
|
2014-01-13 06:32:25 +01:00
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2014-01-11 04:32:08 +01:00
|
|
|
|
2014-01-13 06:32:25 +01:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2013-12-27 06:38:43 +01:00
|
|
|
|
2015-02-18 20:05:35 +01:00
|
|
|
#ifndef SRC_RIPPER_RIPPER_H_
|
|
|
|
#define SRC_RIPPER_RIPPER_H_
|
2013-12-27 06:38:43 +01:00
|
|
|
|
2014-01-08 04:39:28 +01:00
|
|
|
#include <cdio/cdio.h>
|
2015-02-18 20:05:35 +01:00
|
|
|
#include <QMutex>
|
|
|
|
#include <QObject>
|
|
|
|
|
2014-05-13 15:18:42 +02:00
|
|
|
#include "core/song.h"
|
2014-05-21 16:36:46 +02:00
|
|
|
#include "core/tagreaderclient.h"
|
2015-02-18 20:05:35 +01:00
|
|
|
#include "transcoder/transcoder.h"
|
2014-05-21 16:36:46 +02:00
|
|
|
|
2015-02-18 20:05:35 +01:00
|
|
|
class QFile;
|
2013-12-27 06:38:43 +01:00
|
|
|
|
2015-02-18 20:05:35 +01:00
|
|
|
class Ripper : public QObject {
|
2014-01-14 02:41:41 +01:00
|
|
|
Q_OBJECT
|
2013-12-27 06:38:43 +01:00
|
|
|
|
2014-01-13 06:32:25 +01:00
|
|
|
public:
|
2015-02-18 20:05:35 +01:00
|
|
|
explicit Ripper(QObject* parent = nullptr);
|
|
|
|
~Ripper();
|
|
|
|
void AddTrack(int track_number, const QString& title,
|
|
|
|
const QString& transcoded_filename,
|
|
|
|
const TranscoderPreset& preset);
|
|
|
|
void SetAlbumInformation(const QString& album, const QString& artist,
|
|
|
|
const QString& genre, int year, int disc,
|
|
|
|
Song::FileType type);
|
|
|
|
int TracksOnDisc() const;
|
|
|
|
int AddedTracks() const;
|
|
|
|
void ClearTracks();
|
2014-02-04 01:40:56 +01:00
|
|
|
bool CheckCDIOIsValid();
|
2015-02-18 20:05:35 +01:00
|
|
|
bool MediaChanged() const;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void Finished();
|
|
|
|
void Cancelled();
|
|
|
|
void ProgressInterval(int min, int max);
|
|
|
|
void Progress(int progress);
|
|
|
|
void RippingComplete();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void Start();
|
|
|
|
void Cancel();
|
2014-04-12 09:20:25 +02:00
|
|
|
|
2015-02-18 20:05:35 +01:00
|
|
|
private slots:
|
|
|
|
void TranscodingJobComplete(const QString& input, const QString& output,
|
|
|
|
bool success);
|
|
|
|
void AllTranscodingJobsComplete();
|
|
|
|
void LogLine(const QString& message);
|
|
|
|
void FileTagged(TagReaderReply* reply);
|
2014-01-15 06:00:41 +01:00
|
|
|
|
|
|
|
private:
|
2014-05-12 23:57:11 +02:00
|
|
|
struct TrackInformation {
|
|
|
|
TrackInformation(int track_number, const QString& title,
|
2015-02-18 20:05:35 +01:00
|
|
|
const QString& transcoded_filename,
|
|
|
|
const TranscoderPreset& preset)
|
2014-05-12 23:57:11 +02:00
|
|
|
: track_number(track_number),
|
|
|
|
title(title),
|
2015-02-18 20:05:35 +01:00
|
|
|
transcoded_filename(transcoded_filename),
|
|
|
|
preset(preset) {}
|
2014-05-12 23:57:11 +02:00
|
|
|
|
|
|
|
int track_number;
|
|
|
|
QString title;
|
|
|
|
QString transcoded_filename;
|
2015-02-18 20:05:35 +01:00
|
|
|
TranscoderPreset preset;
|
2014-05-12 23:57:11 +02:00
|
|
|
};
|
|
|
|
|
2014-05-13 15:18:42 +02:00
|
|
|
struct AlbumInformation {
|
2015-02-18 20:05:35 +01:00
|
|
|
AlbumInformation(const QString& album = QString(),
|
|
|
|
const QString& artist = QString(),
|
|
|
|
const QString& genre = QString(), int year = 0,
|
|
|
|
int disc = 0, Song::FileType type = Song::Type_Unknown)
|
2014-05-13 15:18:42 +02:00
|
|
|
: album(album),
|
|
|
|
artist(artist),
|
|
|
|
genre(genre),
|
|
|
|
year(year),
|
|
|
|
disc(disc),
|
|
|
|
type(type) {}
|
|
|
|
|
|
|
|
QString album;
|
|
|
|
QString artist;
|
|
|
|
QString genre;
|
|
|
|
int year;
|
|
|
|
int disc;
|
|
|
|
Song::FileType type;
|
|
|
|
};
|
|
|
|
|
2015-02-18 20:05:35 +01:00
|
|
|
void WriteWAVHeader(QFile* stream, int32_t i_bytecount);
|
|
|
|
void Rip();
|
|
|
|
void SetupProgressInterval();
|
|
|
|
void UpdateProgress();
|
|
|
|
void RemoveTemporaryDirectory();
|
|
|
|
void TagFiles();
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
CdIo_t* cdio_;
|
2015-02-18 20:05:35 +01:00
|
|
|
Transcoder* transcoder_;
|
2014-02-03 13:22:02 +01:00
|
|
|
QString temporary_directory_;
|
2014-02-02 18:17:33 +01:00
|
|
|
bool cancel_requested_;
|
2014-05-12 16:14:33 +02:00
|
|
|
QMutex mutex_;
|
2015-02-18 20:05:35 +01:00
|
|
|
int finished_success_;
|
|
|
|
int finished_failed_;
|
2014-05-21 16:36:46 +02:00
|
|
|
int files_tagged_;
|
2015-02-18 20:05:35 +01:00
|
|
|
QList<TrackInformation> tracks_;
|
|
|
|
AlbumInformation album_;
|
2013-12-27 06:38:43 +01:00
|
|
|
};
|
|
|
|
|
2015-02-18 20:05:35 +01:00
|
|
|
#endif // SRC_RIPPER_RIPPER_H_
|