3 * Copyright (C) 2012-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
22 #include "utils/Job.h"
23 #include "utils/StdString.h"
24 #include "music/tags/MusicInfoTag.h"
33 class CCDDARipJob : public CJob
36 //! \brief Construct a ripper job
37 //! \param input The input file url
38 //! \param output The output file url
39 //! \param tag The music tag to attach to track
40 //! \param encoder The encoder to use. See Encoder.h
41 //! \param eject Should we eject tray on finish?
42 //! \param rate The sample rate of the input
43 //! \param channels Number of audio channels in input
44 //! \param bps The bits per sample for input
45 CCDDARipJob(const CStdString& input, const CStdString& output,
46 const MUSIC_INFO::CMusicInfoTag& tag, int encoder,
47 bool eject=false, unsigned int rate=44100,
48 unsigned int channels=2, unsigned int bps=16);
50 virtual ~CCDDARipJob();
52 virtual const char* GetType() const { return "cdrip"; };
53 virtual bool operator==(const CJob *job) const;
54 virtual bool DoWork();
55 CStdString GetOutput() const { return m_output; }
57 //! \brief Setup the audio encoder
58 CEncoder* SetupEncoder(XFILE::CFile& reader);
60 //! \brief Helper used if output is a remote url
61 CStdString SetupTempFile();
63 //! \brief Rip a chunk of audio
64 //! \param reader The input reader
65 //! \param encoder The audio encoder
66 //! \param percent The percentage completed on return
67 //! \return 0 (CDDARIP_OK) if everything went okay, or
68 //! a positive error code from the reader, or
69 //! -1 if the encoder failed
70 //! \sa CCDDARipper::GetData, CEncoder::Encode
71 int RipChunk(XFILE::CFile& reader, CEncoder* encoder, int& percent);
73 unsigned int m_rate; //< The sample rate of the input file
74 unsigned int m_channels; //< The number of channels in input file
75 unsigned int m_bps; //< The bits per sample of input
76 MUSIC_INFO::CMusicInfoTag m_tag; //< Music tag to attach to output file
77 CStdString m_input; //< The input url
78 CStdString m_output; //< The output url
79 bool m_eject; //< Should we eject tray when we are finished?
80 int m_encoder; //< The audio encoder