Merge pull request #5039 from CEikermann/patch-1
[vuplus_xbmc] / xbmc / cdrip / CDDARipJob.h
1 #pragma once
2 /*
3 *      Copyright (C) 2012-2013 Team XBMC
4 *      http://xbmc.org
5 *
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)
9 *  any later version.
10 *
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.
15 *
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/>.
19 *
20 */
21
22 #include "utils/Job.h"
23 #include "utils/StdString.h"
24 #include "music/tags/MusicInfoTag.h"
25
26 class CEncoder;
27
28 namespace XFILE
29 {
30 class CFile;
31 }
32
33 class CCDDARipJob : public CJob
34 {
35 public:
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);
49
50   virtual ~CCDDARipJob();
51
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; }
56 protected:
57   //! \brief Setup the audio encoder
58   CEncoder* SetupEncoder(XFILE::CFile& reader);
59
60   //! \brief Helper used if output is a remote url
61   CStdString SetupTempFile();
62
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);
72
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
81 };
82