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:06:58 +01:00
|
|
|
// Rips selected tracks from an audio CD, transcodes them to a chosen
|
|
|
|
// format, and finally tags the files with the supplied metadata.
|
|
|
|
//
|
|
|
|
// Usage: Add tracks with AddTrack() and album metadata with
|
|
|
|
// SetAlbumInformation(). Then start the ripper with Start(). The ripper
|
|
|
|
// emits the Finished() signal when it's done or the Cancelled()
|
|
|
|
// signal if the ripping has been cancelled.
|
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();
|
2015-02-18 20:06:58 +01:00
|
|
|
|
|
|
|
// Adds a track to the rip list if the track number corresponds to a
|
|
|
|
// track on the audio cd. The track will transcoded according to the
|
|
|
|
// chosen TranscoderPreset.
|
2015-02-18 20:05:35 +01:00
|
|
|
void AddTrack(int track_number, const QString& title,
|
|
|
|
const QString& transcoded_filename,
|
|
|
|
const TranscoderPreset& preset);
|
2015-02-18 20:06:58 +01:00
|
|
|
// Sets album metadata. This information is used when tagging the
|
|
|
|
// final files.
|
2015-02-18 20:05:35 +01:00
|
|
|
void SetAlbumInformation(const QString& album, const QString& artist,
|
|
|
|
const QString& genre, int year, int disc,
|
|
|
|
Song::FileType type);
|
2015-02-18 20:06:58 +01:00
|
|
|
// Returns the number of audio tracks on the disc.
|
2015-02-18 20:05:35 +01:00
|
|
|
int TracksOnDisc() const;
|
2015-02-18 20:06:58 +01:00
|
|
|
// Returns the number of tracks added to the rip list.
|
2015-02-18 20:05:35 +01:00
|
|
|
int AddedTracks() const;
|
2015-02-18 20:06:58 +01:00
|
|
|
// Clears the rip list.
|
2015-02-18 20:05:35 +01:00
|
|
|
void ClearTracks();
|
2015-02-18 20:06:58 +01:00
|
|
|
// Returns true if a cd device was successfully opened.
|
2014-02-04 01:40:56 +01:00
|
|
|
bool CheckCDIOIsValid();
|
2015-02-18 20:06:58 +01:00
|
|
|
// Returns true if the cd media has changed.
|
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;
|
2015-02-18 22:58:45 +01:00
|
|
|
QString temporary_filename;
|
2014-05-12 23:57:11 +02:00
|
|
|
};
|
|
|
|
|
2014-05-13 15:18:42 +02:00
|
|
|
struct AlbumInformation {
|
2015-02-18 20:06:58 +01:00
|
|
|
AlbumInformation() : year(0), disc(0), type(Song::Type_Unknown) {}
|
2014-05-13 15:18:42 +02:00
|
|
|
|
|
|
|
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_
|