transcoder: Add pipeline list to details dialog

List current running transcode pipelines when the details dialog is displayed.
This will be allow the addition of cancel and debug options.
This commit is contained in:
Jim Broadus 2021-01-24 00:18:03 -08:00 committed by John Maguire
parent befaacebf9
commit 8c2ab8fa05
6 changed files with 79 additions and 21 deletions

View File

@ -69,7 +69,7 @@ void GstPipelineModel::RemovePipeline(int id) {
removeRow(row); removeRow(row);
} }
int GstPipelineModel::FindRowById(int id) { int GstPipelineModel::FindRowById(int id) const {
for (int i = 0; i < rowCount(); i++) { for (int i = 0; i < rowCount(); i++) {
if (item(i)->data(Role::Role_Id).toInt() == id) return i; if (item(i)->data(Role::Role_Id).toInt() == id) return i;
} }

View File

@ -49,8 +49,8 @@ static bool ComparePresetsByName(const TranscoderPreset& left,
TranscodeDialog::TranscodeDialog(QWidget* parent) TranscodeDialog::TranscodeDialog(QWidget* parent)
: QDialog(parent), : QDialog(parent),
ui_(new Ui_TranscodeDialog), ui_(new Ui_TranscodeDialog),
log_ui_(new Ui_TranscodeLogDialog), details_ui_(new Ui_TranscodeLogDialog),
log_dialog_(new QDialog(this)), details_dialog_(new QDialog(this)),
transcoder_(new Transcoder(this)), transcoder_(new Transcoder(this)),
queued_(0), queued_(0),
finished_success_(0), finished_success_(0),
@ -58,10 +58,11 @@ TranscodeDialog::TranscodeDialog(QWidget* parent)
ui_->setupUi(this); ui_->setupUi(this);
ui_->files->header()->setSectionResizeMode(QHeaderView::ResizeToContents); ui_->files->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
log_ui_->setupUi(log_dialog_); details_ui_->setupUi(details_dialog_);
QPushButton* clear_button = details_ui_->pipelines->setModel(transcoder_->model());
log_ui_->buttonBox->addButton(tr("Clear"), QDialogButtonBox::ResetRole); QPushButton* clear_button = details_ui_->buttonBox->addButton(
connect(clear_button, SIGNAL(clicked()), log_ui_->log, SLOT(clear())); tr("Clear"), QDialogButtonBox::ResetRole);
connect(clear_button, SIGNAL(clicked()), details_ui_->log, SLOT(clear()));
// Get presets // Get presets
QList<TranscoderPreset> presets = Transcoder::GetAllPresets(); QList<TranscoderPreset> presets = Transcoder::GetAllPresets();
@ -107,7 +108,7 @@ TranscodeDialog::TranscodeDialog(QWidget* parent)
connect(start_button_, SIGNAL(clicked()), SLOT(Start())); connect(start_button_, SIGNAL(clicked()), SLOT(Start()));
connect(cancel_button_, SIGNAL(clicked()), SLOT(Cancel())); connect(cancel_button_, SIGNAL(clicked()), SLOT(Cancel()));
connect(close_button_, SIGNAL(clicked()), SLOT(hide())); connect(close_button_, SIGNAL(clicked()), SLOT(hide()));
connect(ui_->details, SIGNAL(clicked()), log_dialog_, SLOT(show())); connect(ui_->details, SIGNAL(clicked()), details_dialog_, SLOT(show()));
connect(ui_->options, SIGNAL(clicked()), SLOT(Options())); connect(ui_->options, SIGNAL(clicked()), SLOT(Options()));
connect(ui_->select, SIGNAL(clicked()), SLOT(AddDestination())); connect(ui_->select, SIGNAL(clicked()), SLOT(AddDestination()));
@ -117,10 +118,7 @@ TranscodeDialog::TranscodeDialog(QWidget* parent)
connect(transcoder_, SIGNAL(AllJobsComplete()), SLOT(AllJobsComplete())); connect(transcoder_, SIGNAL(AllJobsComplete()), SLOT(AllJobsComplete()));
} }
TranscodeDialog::~TranscodeDialog() { TranscodeDialog::~TranscodeDialog() {}
delete log_ui_;
delete ui_;
}
void TranscodeDialog::SetWorking(bool working) { void TranscodeDialog::SetWorking(bool working) {
start_button_->setVisible(!working); start_button_->setVisible(!working);
@ -278,7 +276,7 @@ void TranscodeDialog::Remove() { qDeleteAll(ui_->files->selectedItems()); }
void TranscodeDialog::LogLine(const QString& message) { void TranscodeDialog::LogLine(const QString& message) {
QString date(QDateTime::currentDateTime().toString(Qt::TextDate)); QString date(QDateTime::currentDateTime().toString(Qt::TextDate));
log_ui_->log->appendPlainText(QString("%1: %2").arg(date, message)); details_ui_->log->appendPlainText(QString("%1: %2").arg(date, message));
} }
void TranscodeDialog::timerEvent(QTimerEvent* e) { void TranscodeDialog::timerEvent(QTimerEvent* e) {

View File

@ -21,6 +21,7 @@
#include <QBasicTimer> #include <QBasicTimer>
#include <QDialog> #include <QDialog>
#include <QFileInfo> #include <QFileInfo>
#include <memory>
class Transcoder; class Transcoder;
class Ui_TranscodeDialog; class Ui_TranscodeDialog;
@ -64,9 +65,9 @@ class TranscodeDialog : public QDialog {
const TranscoderPreset& preset) const; const TranscoderPreset& preset) const;
private: private:
Ui_TranscodeDialog* ui_; std::unique_ptr<Ui_TranscodeDialog> ui_;
Ui_TranscodeLogDialog* log_ui_; std::unique_ptr<Ui_TranscodeLogDialog> details_ui_;
QDialog* log_dialog_; QDialog* details_dialog_;
QBasicTimer progress_timer_; QBasicTimer progress_timer_;

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Transcoder Log</string> <string>Transcoder Details</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../../data/data.qrc"> <iconset resource="../../data/data.qrc">
@ -19,10 +19,56 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QPlainTextEdit" name="log"> <widget class="QGroupBox" name="pipelineBox">
<property name="readOnly"> <property name="sizePolicy">
<bool>true</bool> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="title">
<string>Pipelines</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QListView" name="pipelines">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="logBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Logs</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPlainTextEdit" name="log">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>

View File

@ -195,10 +195,16 @@ void Transcoder::JobState::PostFinished(bool success) {
new Transcoder::JobFinishedEvent(this, success)); new Transcoder::JobFinishedEvent(this, success));
} }
QString Transcoder::JobState::GetDisplayName() {
return QFileInfo(job_.input).fileName() + " => " +
QFileInfo(job_.output).fileName();
}
Transcoder::Transcoder(QObject* parent, const QString& settings_postfix) Transcoder::Transcoder(QObject* parent, const QString& settings_postfix)
: QObject(parent), : QObject(parent),
max_threads_(QThread::idealThreadCount()), max_threads_(QThread::idealThreadCount()),
settings_postfix_(settings_postfix) { settings_postfix_(settings_postfix),
model_(new GstPipelineModel(this)) {
if (JobFinishedEvent::sEventType == -1) if (JobFinishedEvent::sEventType == -1)
JobFinishedEvent::sEventType = QEvent::registerEventType(); JobFinishedEvent::sEventType = QEvent::registerEventType();
@ -459,6 +465,7 @@ bool Transcoder::StartJob(const Job& job) {
// something else. Keep the JobState object around. It'll post an event // something else. Keep the JobState object around. It'll post an event
// to our event loop when it finishes. // to our event loop when it finishes.
current_jobs_ << state; current_jobs_ << state;
model_->AddPipeline(state->id(), state->GetDisplayName());
return true; return true;
} }
@ -489,6 +496,7 @@ bool Transcoder::event(QEvent* e) {
nullptr, nullptr, nullptr); nullptr, nullptr, nullptr);
// Remove it from the list - this will also destroy the GStreamer pipeline // Remove it from the list - this will also destroy the GStreamer pipeline
model_->RemovePipeline((*it)->id());
current_jobs_.erase(it); current_jobs_.erase(it);
// Emit the finished signal // Emit the finished signal
@ -527,6 +535,7 @@ void Transcoder::Cancel() {
} }
// Remove the job, this destroys the GStreamer pipeline too // Remove the job, this destroys the GStreamer pipeline too
model_->RemovePipeline((*it)->id());
it = current_jobs_.erase(it); it = current_jobs_.erase(it);
} }
} }

View File

@ -63,6 +63,8 @@ class Transcoder : public QObject {
QMap<QString, float> GetProgress() const; QMap<QString, float> GetProgress() const;
int QueuedJobsCount() const { return queued_jobs_.count(); } int QueuedJobsCount() const { return queued_jobs_.count(); }
GstPipelineModel* model() { return model_; }
public slots: public slots:
void Start(); void Start();
void Cancel(); void Cancel();
@ -97,6 +99,7 @@ class Transcoder : public QObject {
void ReportError(GstMessage* msg); void ReportError(GstMessage* msg);
GstElement* Pipeline() { return pipeline_; } GstElement* Pipeline() { return pipeline_; }
QString GetDisplayName();
Job job_; Job job_;
Transcoder* parent_; Transcoder* parent_;
@ -143,6 +146,7 @@ class Transcoder : public QObject {
QList<Job> queued_jobs_; QList<Job> queued_jobs_;
JobStateList current_jobs_; JobStateList current_jobs_;
QString settings_postfix_; QString settings_postfix_;
GstPipelineModel* model_;
}; };
#endif // TRANSCODER_H #endif // TRANSCODER_H