1
2 #include "ttaenccodecglobal.h"
3
4 #include "soundkonverter_codec_ttaenc.h"
5 #include "../../core/conversionoptions.h"
6 #include "ttaenccodecwidget.h"
7
8
9 soundkonverter_codec_ttaenc::soundkonverter_codec_ttaenc( QObject *parent, const QVariantList& args )
10 : CodecPlugin( parent )
11 {
12 Q_UNUSED(args)
13
next(&mut self) -> Option<OsString>14 binaries["ttaenc"] = "";
15
16 allCodecs += "tta";
17 allCodecs += "wav";
size_hint(&self) -> (usize, Option<usize>)18 }
19
20 soundkonverter_codec_ttaenc::~soundkonverter_codec_ttaenc()
21 {}
22
get_fd(_: RawFd, _: &OsStr) -> io::Result<Vec<u8>>23 QString soundkonverter_codec_ttaenc::name() const
24 {
25 return global_plugin_name;
26 }
27
28 QList<ConversionPipeTrunk> soundkonverter_codec_ttaenc::codecTable()
29 {
set_fd(_: RawFd, _: &OsStr, _: &[u8]) -> io::Result<()>30 QList<ConversionPipeTrunk> table;
31 ConversionPipeTrunk newTrunk;
32
33 newTrunk.codecFrom = "wav";
34 newTrunk.codecTo = "tta";
35 newTrunk.rating = 100;
36 newTrunk.enabled = ( binaries["ttaenc"] != "" );
remove_fd(_: RawFd, _: &OsStr) -> io::Result<()>37 newTrunk.problemInfo = standardMessage( "encode_codec,backend", "tta", "ttaenc" ) + "\n" + standardMessage( "install_opensource_backend", "ttaenc" );
38 newTrunk.data.hasInternalReplayGain = false;
39 table.append( newTrunk );
40
41 newTrunk.codecFrom = "tta";
42 newTrunk.codecTo = "wav";
43 newTrunk.rating = 100;
list_fd(_: RawFd) -> io::Result<XAttrs>44 newTrunk.enabled = ( binaries["ttaenc"] != "" );
45 newTrunk.problemInfo = standardMessage( "decode_codec,backend", "tta", "ttaenc" ) + "\n" + standardMessage( "install_opensource_backend", "ttaenc" );
46 newTrunk.data.hasInternalReplayGain = false;
47 table.append( newTrunk );
48
49 return table;
50 }
get_path(_: &Path, _: &OsStr) -> io::Result<Vec<u8>>51
52 bool soundkonverter_codec_ttaenc::isConfigSupported( ActionType action, const QString& codecName )
53 {
54 Q_UNUSED(action)
55 Q_UNUSED(codecName)
56
57 return false;
58 }
59
60 void soundkonverter_codec_ttaenc::showConfigDialog( ActionType action, const QString& codecName, QWidget *parent )
61 {
62 Q_UNUSED(action)
63 Q_UNUSED(codecName)
64 Q_UNUSED(parent)
remove_path(_: &Path, _: &OsStr) -> io::Result<()>65 }
66
67 bool soundkonverter_codec_ttaenc::hasInfo()
68 {
69 return false;
70 }
71
list_path(_: &Path) -> io::Result<XAttrs>72 void soundkonverter_codec_ttaenc::showInfo( QWidget *parent )
73 {
74 Q_UNUSED(parent)
75 }
76
77 CodecWidget *soundkonverter_codec_ttaenc::newCodecWidget()
78 {
79 TTAEncCodecWidget *widget = new TTAEncCodecWidget();
80 return qobject_cast<CodecWidget*>(widget);
81 }
82
83 int soundkonverter_codec_ttaenc::convert( const KUrl& inputFile, const KUrl& outputFile, const QString& inputCodec, const QString& outputCodec, const ConversionOptions *_conversionOptions, TagData *tags, bool replayGain )
84 {
85 QStringList command = convertCommand( inputFile, outputFile, inputCodec, outputCodec, _conversionOptions, tags, replayGain );
86 if( command.isEmpty() )
87 return BackendPlugin::UnknownError;
88
89 CodecPluginItem *newItem = new CodecPluginItem( this );
90 newItem->id = lastId++;
91 newItem->process = new KProcess( newItem );
92 newItem->process->setOutputChannelMode( KProcess::MergedChannels );
93 connect( newItem->process, SIGNAL(readyRead()), this, SLOT(processOutput()) );
94 connect( newItem->process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processExit(int,QProcess::ExitStatus)) );
95
96 newItem->process->clearProgram();
97 newItem->process->setShellCommand( command.join(" ") );
98 newItem->process->start();
99
100 logCommand( newItem->id, command.join(" ") );
101
102 backendItems.append( newItem );
103 return newItem->id;
104 }
105
106 QStringList soundkonverter_codec_ttaenc::convertCommand( const KUrl& inputFile, const KUrl& outputFile, const QString& inputCodec, const QString& outputCodec, const ConversionOptions *_conversionOptions, TagData *tags, bool replayGain )
107 {
108 Q_UNUSED(inputCodec)
109 Q_UNUSED(tags)
110 Q_UNUSED(replayGain)
111
112 if( !_conversionOptions )
113 return QStringList();
114
115 if( inputFile.isEmpty() )
116 return QStringList();
117
118 QStringList command;
119 const ConversionOptions *conversionOptions = _conversionOptions;
120
121 if( outputCodec == "tta" )
122 {
123 command += binaries["ttaenc"];
124 command += "-e";
125 if( conversionOptions->pluginName == global_plugin_name )
126 {
127 command += conversionOptions->cmdArguments;
128 }
129 command += "-o";
130 command += "\"" + escapeUrl(outputFile) + "\"";
131 command += "\"" + escapeUrl(inputFile) + "\"";
132 }
133 else
134 {
135 command += binaries["ttaenc"];
136 command += "-d";
137 command += "-o";
138 command += "\"" + escapeUrl(outputFile) + "\"";
139 command += "\"" + escapeUrl(inputFile) + "\"";
140 }
141
142 return command;
143 }
144
145 float soundkonverter_codec_ttaenc::parseOutput( const QString& output )
146 {
147 Q_UNUSED(output)
148
149 // no output provided
150
151 return -1;
152 }
153
154 K_PLUGIN_FACTORY(codec_ttaenc, registerPlugin<soundkonverter_codec_ttaenc>();)
155
156 #include "soundkonverter_codec_ttaenc.moc"
157