From 4994091f868159cb0bdfdefa1e54fe83b62b6ae7 Mon Sep 17 00:00:00 2001 From: Jim Broadus Date: Sat, 6 Feb 2021 15:08:37 -0800 Subject: [PATCH] transcoder: Add options widget for fdkaacenc As with the other cases, the base GstAudioEncoder class properties are not included. Reference: https://gstreamer.freedesktop.org/documentation/fdkaac/fdkaacenc.html --- src/CMakeLists.txt | 3 + src/transcoder/transcoderoptionsdialog.cpp | 3 + src/transcoder/transcoderoptionsfdkaac.cpp | 69 ++++++++++++ src/transcoder/transcoderoptionsfdkaac.h | 44 ++++++++ src/transcoder/transcoderoptionsfdkaac.ui | 121 +++++++++++++++++++++ 5 files changed, 240 insertions(+) create mode 100644 src/transcoder/transcoderoptionsfdkaac.cpp create mode 100644 src/transcoder/transcoderoptionsfdkaac.h create mode 100644 src/transcoder/transcoderoptionsfdkaac.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ec90425f5..d4c0ddad9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -320,6 +320,7 @@ set(SOURCES transcoder/transcoderoptionsaac.cpp transcoder/transcoderoptionsdialog.cpp transcoder/transcoderoptionserror.cpp + transcoder/transcoderoptionsfdkaac.cpp transcoder/transcoderoptionsflac.cpp transcoder/transcoderoptionsmp3.cpp transcoder/transcoderoptionsopus.cpp @@ -618,6 +619,7 @@ set(HEADERS transcoder/transcoder.h transcoder/transcoderoptionsdialog.h transcoder/transcoderoptionsmp3.h + transcoder/transcoderoptionsfdkaac.h transcoder/transcoderoptionsflac.h transcoder/transcodersettingspage.h @@ -747,6 +749,7 @@ set(UI transcoder/transcoderoptionsaac.ui transcoder/transcoderoptionsdialog.ui transcoder/transcoderoptionserror.ui + transcoder/transcoderoptionsfdkaac.ui transcoder/transcoderoptionsflac.ui transcoder/transcoderoptionsmp3.ui transcoder/transcoderoptionsopus.ui diff --git a/src/transcoder/transcoderoptionsdialog.cpp b/src/transcoder/transcoderoptionsdialog.cpp index fcde413b7..a861f9037 100644 --- a/src/transcoder/transcoderoptionsdialog.cpp +++ b/src/transcoder/transcoderoptionsdialog.cpp @@ -22,6 +22,7 @@ #include "transcoder.h" #include "transcoderoptionsaac.h" #include "transcoderoptionserror.h" +#include "transcoderoptionsfdkaac.h" #include "transcoderoptionsflac.h" #include "transcoderoptionsmp3.h" #include "transcoderoptionsopus.h" @@ -78,6 +79,8 @@ TranscoderOptionsInterface* TranscoderOptionsDialog::MakeOptionsPage( return new TranscoderOptionsFlac(parent); } else if (element == "faac") { return new TranscoderOptionsAAC(parent); + } else if (element == "fdkaacenc") { + return new TranscoderOptionsFDKAAC(parent); } else if (element == "lamemp3enc") { return new TranscoderOptionsMP3(parent); } else if (element == "vorbisenc") { diff --git a/src/transcoder/transcoderoptionsfdkaac.cpp b/src/transcoder/transcoderoptionsfdkaac.cpp new file mode 100644 index 000000000..da9c0c6f4 --- /dev/null +++ b/src/transcoder/transcoderoptionsfdkaac.cpp @@ -0,0 +1,69 @@ +/* This file is part of Clementine. + Copyright 2021, Jim Broadus + + 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. + + 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. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +/* + Settings for the fdkaacenc gstreamer element. + https://gstreamer.freedesktop.org/documentation/fdkaac/fdkaacenc.html +*/ + +#include "transcoderoptionsfdkaac.h" + +#include + +#include "ui_transcoderoptionsfdkaac.h" + +const char* TranscoderOptionsFDKAAC::kSettingsGroup = "Transcoder/fdkaacenc"; + +TranscoderOptionsFDKAAC::TranscoderOptionsFDKAAC(QWidget* parent) + : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsFDKAAC) { + ui_->setupUi(this); + connect(ui_->target_radio, SIGNAL(toggled(bool)), + SLOT(TargetBitrateToggle(bool))); +} + +TranscoderOptionsFDKAAC::~TranscoderOptionsFDKAAC() { delete ui_; } + +void TranscoderOptionsFDKAAC::Load() { + QSettings s; + s.beginGroup(kSettingsGroup + settings_postfix_); + + // If bitrate is set to 0 (default), then bitrate is detemined by sample rate + // and channel count. + int bitrate = s.value("bitrate", 0).toInt(); + if (bitrate == 0) { + ui_->auto_radio->setChecked(true); + ui_->bitrate_group->setEnabled(false); + } else { + ui_->target_radio->setChecked(true); + ui_->bitrate_slider->setValue(bitrate / 1000); + } +} + +void TranscoderOptionsFDKAAC::Save() { + QSettings s; + s.beginGroup(kSettingsGroup + settings_postfix_); + + if (ui_->target_radio->isChecked()) { + s.setValue("bitrate", ui_->bitrate_slider->value() * 1000); + } else { + s.setValue("bitrate", 0); + } +} + +void TranscoderOptionsFDKAAC::TargetBitrateToggle(bool checked) { + ui_->bitrate_group->setEnabled(checked); +} diff --git a/src/transcoder/transcoderoptionsfdkaac.h b/src/transcoder/transcoderoptionsfdkaac.h new file mode 100644 index 000000000..9c87c2801 --- /dev/null +++ b/src/transcoder/transcoderoptionsfdkaac.h @@ -0,0 +1,44 @@ +/* This file is part of Clementine. + Copyright 2021, Jim Broadus + + 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. + + 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. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#ifndef TRANSCODEROPTIONSFDKAAC_H +#define TRANSCODEROPTIONSFDKAAC_H + +#include "transcoderoptionsinterface.h" + +class Ui_TranscoderOptionsFDKAAC; + +class TranscoderOptionsFDKAAC : public TranscoderOptionsInterface { + Q_OBJECT + + public: + TranscoderOptionsFDKAAC(QWidget* parent = nullptr); + ~TranscoderOptionsFDKAAC(); + + void Load(); + void Save(); + + private slots: + void TargetBitrateToggle(bool checked); + + private: + static const char* kSettingsGroup; + + Ui_TranscoderOptionsFDKAAC* ui_; +}; + +#endif // TRANSCODEROPTIONSFDKAAC_H diff --git a/src/transcoder/transcoderoptionsfdkaac.ui b/src/transcoder/transcoderoptionsfdkaac.ui new file mode 100644 index 000000000..c24223c36 --- /dev/null +++ b/src/transcoder/transcoderoptionsfdkaac.ui @@ -0,0 +1,121 @@ + + + TranscoderOptionsFDKAAC + + + + 0 + 0 + 480 + 344 + + + + Form + + + + + + Bitrate + + + + + + Automatically determine based on sample rate. + + + + + + + Set target rate + + + + + + + + + + + + + kbps + + + 8 + + + 320 + + + 8 + + + 128 + + + + + + + 8 + + + 320 + + + 128 + + + Qt::Horizontal + + + + + + + + + + + + + + + bitrate_slider + valueChanged(int) + bitrate_spinbox + setValue(int) + + + 170 + 29 + + + 445 + 24 + + + + + bitrate_spinbox + valueChanged(int) + bitrate_slider + setValue(int) + + + 407 + 18 + + + 191 + 29 + + + + +